Luke Sorenson | 13e2827 | 2018-11-09 14:43:16 -0500 | [diff] [blame] | 1 | // Copyright 2018 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef MEDIA_PERCEPTION_RTANALYTICS_H_ |
| 6 | #define MEDIA_PERCEPTION_RTANALYTICS_H_ |
| 7 | |
| 8 | // This header needs to be buildable from both Google3 and outside, so it cannot |
| 9 | // rely on Google3 dependencies. |
| 10 | |
Luke Sorenson | a918ec3 | 2019-01-02 14:41:21 -0500 | [diff] [blame] | 11 | #include <functional> |
Luke Sorenson | 13e2827 | 2018-11-09 14:43:16 -0500 | [diff] [blame] | 12 | #include <string> |
| 13 | #include <vector> |
| 14 | |
| 15 | namespace mri { |
| 16 | |
| 17 | // Typdefs for readability. Serialized protos are passed back and forth across |
| 18 | // the boundary between platform2 code and librtanalytics.so. |
Luke Sorenson | 1b3dedc | 2018-12-12 11:00:47 -0500 | [diff] [blame] | 19 | // Note that these aliases are guaranteed to always have this type. |
Luke Sorenson | a918ec3 | 2019-01-02 14:41:21 -0500 | [diff] [blame] | 20 | using SerializedPerceptionInterfaces = std::vector<uint8_t>; |
Luke Sorenson | 13e2827 | 2018-11-09 14:43:16 -0500 | [diff] [blame] | 21 | using SerializedSuccessStatus = std::vector<uint8_t>; |
Luke Sorenson | 1320dfb | 2018-12-04 18:09:15 -0500 | [diff] [blame] | 22 | using SerializedPipelineState = std::vector<uint8_t>; |
Luke Sorenson | 1b3dedc | 2018-12-12 11:00:47 -0500 | [diff] [blame] | 23 | using SerializedDeviceTemplate = std::vector<uint8_t>; |
| 24 | using SerializedVideoDevice = std::vector<uint8_t>; |
| 25 | using SerializedAudioDevice = std::vector<uint8_t>; |
| 26 | using SerializedVirtualVideoDevice = std::vector<uint8_t>; |
Luke Sorenson | a918ec3 | 2019-01-02 14:41:21 -0500 | [diff] [blame] | 27 | using PipelineOutputHandler = std::function<void(const std::vector<uint8_t>&)>; |
Luke Sorenson | 13e2827 | 2018-11-09 14:43:16 -0500 | [diff] [blame] | 28 | |
| 29 | class Rtanalytics { |
| 30 | public: |
| 31 | virtual ~Rtanalytics() = default; |
| 32 | |
Luke Sorenson | a918ec3 | 2019-01-02 14:41:21 -0500 | [diff] [blame] | 33 | // ------------------ Start of Media Perception Mojo API --------------------- |
| 34 | |
Luke Sorenson | 13e2827 | 2018-11-09 14:43:16 -0500 | [diff] [blame] | 35 | // Asks the library to setup a particular configuration. Success status is |
Luke Sorenson | a918ec3 | 2019-01-02 14:41:21 -0500 | [diff] [blame] | 36 | // filled in by the library side. The return value is the list of perception |
| 37 | // interfaces that are fulfilled by the current configuration. This function |
| 38 | // can be called multiple times to setup multiple configurations. |
| 39 | // |success_status| cannot be null. Each PerceptionInterface contains output |
| 40 | // stream types so that the CrOS side can register appropriate output |
| 41 | // handlers. |
| 42 | virtual SerializedPerceptionInterfaces SetupConfiguration( |
Luke Sorenson | 13e2827 | 2018-11-09 14:43:16 -0500 | [diff] [blame] | 43 | const std::string& configuration_name, |
| 44 | SerializedSuccessStatus* success_status) = 0; |
Luke Sorenson | 1320dfb | 2018-12-04 18:09:15 -0500 | [diff] [blame] | 45 | |
Luke Sorenson | 1b3dedc | 2018-12-12 11:00:47 -0500 | [diff] [blame] | 46 | // Returns the list of template names for devices that can be filled in for a |
| 47 | // particular configuration that has been setup. If the configuration has not |
| 48 | // been setup via |SetupConfiguration| the returned list will always be empty. |
| 49 | virtual std::vector<SerializedDeviceTemplate> GetTemplateDevices( |
| 50 | const std::string& configuration_name) const = 0; |
| 51 | |
| 52 | // Enables a client of rtanalytics to set the parameters for a video device |
| 53 | // for a specified device template. |
| 54 | virtual SerializedSuccessStatus SetVideoDeviceForTemplateName( |
| 55 | const std::string& configuration_name, const std::string& template_name, |
| 56 | const SerializedVideoDevice& video_device) = 0; |
| 57 | |
| 58 | // Enables a client of rtanalytics to set the parameters for an audio device |
| 59 | // for a specified device template. |
| 60 | virtual SerializedSuccessStatus SetAudioDeviceForTemplateName( |
| 61 | const std::string& configuration_name, const std::string& template_name, |
| 62 | const SerializedAudioDevice& audio_device) = 0; |
| 63 | |
| 64 | // Enables a client of rtanalytics to set the parameters for a virtual video |
| 65 | // device for a specified device template. |
| 66 | virtual SerializedSuccessStatus SetVirtualVideoDeviceForTemplateName( |
| 67 | const std::string& configuration_name, const std::string& template_name, |
| 68 | const SerializedVirtualVideoDevice& virtual_device) = 0; |
| 69 | |
Luke Sorenson | 1320dfb | 2018-12-04 18:09:15 -0500 | [diff] [blame] | 70 | // Returns the pipeline state of the given configuation. |
| 71 | virtual SerializedPipelineState GetPipelineState( |
| 72 | const std::string& configuration_name) const = 0; |
| 73 | |
| 74 | // Sets the pipeline to the desired state and returns the new state. |
| 75 | virtual SerializedPipelineState SetPipelineState( |
| 76 | const std::string& configuration_name, |
Luke Sorenson | 1b3dedc | 2018-12-12 11:00:47 -0500 | [diff] [blame] | 77 | const SerializedPipelineState& desired_state) = 0; |
Luke Sorenson | a918ec3 | 2019-01-02 14:41:21 -0500 | [diff] [blame] | 78 | |
| 79 | // ------------------- End of Media Perception Mojo API ---------------------- |
| 80 | |
| 81 | // Sets a callback for an output stream of the given configuration. |
| 82 | virtual SerializedSuccessStatus SetPipelineOutputHandler( |
| 83 | const std::string& configuration_name, const std::string& output_stream, |
| 84 | PipelineOutputHandler output_handler) = 0; |
Luke Sorenson | 13e2827 | 2018-11-09 14:43:16 -0500 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | } // namespace mri |
| 88 | |
| 89 | #endif // MEDIA_PERCEPTION_RTANALYTICS_H_ |