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 | 171f473 | 2019-05-29 11:12:07 -0400 | [diff] [blame^] | 22 | using SerializedTemplateArguments = std::vector<uint8_t>; |
Luke Sorenson | 1320dfb | 2018-12-04 18:09:15 -0500 | [diff] [blame] | 23 | using SerializedPipelineState = std::vector<uint8_t>; |
Luke Sorenson | 16e8902 | 2019-03-13 16:12:15 -0400 | [diff] [blame] | 24 | using SerializedGlobalPipelineState = std::vector<uint8_t>; |
Luke Sorenson | 1b3dedc | 2018-12-12 11:00:47 -0500 | [diff] [blame] | 25 | using SerializedDeviceTemplate = std::vector<uint8_t>; |
| 26 | using SerializedVideoDevice = std::vector<uint8_t>; |
| 27 | using SerializedAudioDevice = std::vector<uint8_t>; |
| 28 | using SerializedVirtualVideoDevice = std::vector<uint8_t>; |
Luke Sorenson | a918ec3 | 2019-01-02 14:41:21 -0500 | [diff] [blame] | 29 | using PipelineOutputHandler = std::function<void(const std::vector<uint8_t>&)>; |
Luke Sorenson | 13e2827 | 2018-11-09 14:43:16 -0500 | [diff] [blame] | 30 | |
| 31 | class Rtanalytics { |
| 32 | public: |
| 33 | virtual ~Rtanalytics() = default; |
| 34 | |
Luke Sorenson | a918ec3 | 2019-01-02 14:41:21 -0500 | [diff] [blame] | 35 | // ------------------ Start of Media Perception Mojo API --------------------- |
| 36 | |
Luke Sorenson | 13e2827 | 2018-11-09 14:43:16 -0500 | [diff] [blame] | 37 | // Asks the library to setup a particular configuration. Success status is |
Luke Sorenson | a918ec3 | 2019-01-02 14:41:21 -0500 | [diff] [blame] | 38 | // filled in by the library side. The return value is the list of perception |
| 39 | // interfaces that are fulfilled by the current configuration. This function |
| 40 | // can be called multiple times to setup multiple configurations. |
| 41 | // |success_status| cannot be null. Each PerceptionInterface contains output |
| 42 | // stream types so that the CrOS side can register appropriate output |
| 43 | // handlers. |
| 44 | virtual SerializedPerceptionInterfaces SetupConfiguration( |
Luke Sorenson | 13e2827 | 2018-11-09 14:43:16 -0500 | [diff] [blame] | 45 | const std::string& configuration_name, |
| 46 | SerializedSuccessStatus* success_status) = 0; |
Luke Sorenson | 1320dfb | 2018-12-04 18:09:15 -0500 | [diff] [blame] | 47 | |
Luke Sorenson | 171f473 | 2019-05-29 11:12:07 -0400 | [diff] [blame^] | 48 | // Sets template arugments for a specified configuration. Arguments should be |
| 49 | // passed as a serialized proto that is kept in sync between the MPS and a |
| 50 | // client. |
| 51 | virtual SerializedSuccessStatus SetTemplateArguments( |
| 52 | const std::string& configuration_name, |
| 53 | const SerializedTemplateArguments& serialized_arguments) = 0; |
| 54 | |
Luke Sorenson | 1b3dedc | 2018-12-12 11:00:47 -0500 | [diff] [blame] | 55 | // Returns the list of template names for devices that can be filled in for a |
| 56 | // particular configuration that has been setup. If the configuration has not |
| 57 | // been setup via |SetupConfiguration| the returned list will always be empty. |
| 58 | virtual std::vector<SerializedDeviceTemplate> GetTemplateDevices( |
| 59 | const std::string& configuration_name) const = 0; |
| 60 | |
| 61 | // Enables a client of rtanalytics to set the parameters for a video device |
| 62 | // for a specified device template. |
| 63 | virtual SerializedSuccessStatus SetVideoDeviceForTemplateName( |
| 64 | const std::string& configuration_name, const std::string& template_name, |
| 65 | const SerializedVideoDevice& video_device) = 0; |
| 66 | |
| 67 | // Enables a client of rtanalytics to set the parameters for an audio device |
| 68 | // for a specified device template. |
| 69 | virtual SerializedSuccessStatus SetAudioDeviceForTemplateName( |
| 70 | const std::string& configuration_name, const std::string& template_name, |
| 71 | const SerializedAudioDevice& audio_device) = 0; |
| 72 | |
| 73 | // Enables a client of rtanalytics to set the parameters for a virtual video |
| 74 | // device for a specified device template. |
| 75 | virtual SerializedSuccessStatus SetVirtualVideoDeviceForTemplateName( |
| 76 | const std::string& configuration_name, const std::string& template_name, |
| 77 | const SerializedVirtualVideoDevice& virtual_device) = 0; |
| 78 | |
Luke Sorenson | 1320dfb | 2018-12-04 18:09:15 -0500 | [diff] [blame] | 79 | // Returns the pipeline state of the given configuation. |
| 80 | virtual SerializedPipelineState GetPipelineState( |
| 81 | const std::string& configuration_name) const = 0; |
| 82 | |
| 83 | // Sets the pipeline to the desired state and returns the new state. |
| 84 | virtual SerializedPipelineState SetPipelineState( |
| 85 | const std::string& configuration_name, |
Luke Sorenson | 1b3dedc | 2018-12-12 11:00:47 -0500 | [diff] [blame] | 86 | const SerializedPipelineState& desired_state) = 0; |
Luke Sorenson | a918ec3 | 2019-01-02 14:41:21 -0500 | [diff] [blame] | 87 | |
Luke Sorenson | 16e8902 | 2019-03-13 16:12:15 -0400 | [diff] [blame] | 88 | // Returns states of all existing pipelines. |
| 89 | virtual SerializedGlobalPipelineState GetGlobalPipelineState() const = 0; |
| 90 | |
Luke Sorenson | a918ec3 | 2019-01-02 14:41:21 -0500 | [diff] [blame] | 91 | // ------------------- End of Media Perception Mojo API ---------------------- |
| 92 | |
| 93 | // Sets a callback for an output stream of the given configuration. |
| 94 | virtual SerializedSuccessStatus SetPipelineOutputHandler( |
| 95 | const std::string& configuration_name, const std::string& output_stream, |
| 96 | PipelineOutputHandler output_handler) = 0; |
Luke Sorenson | 13e2827 | 2018-11-09 14:43:16 -0500 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | } // namespace mri |
| 100 | |
| 101 | #endif // MEDIA_PERCEPTION_RTANALYTICS_H_ |