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