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