blob: f4739fa2db497bc0e59cfe1f7ae800dc6b2f23a6 [file] [log] [blame]
Luke Sorenson13e28272018-11-09 14:43:16 -05001// 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 Sorensona918ec32019-01-02 14:41:21 -050011#include <functional>
Luke Sorenson13e28272018-11-09 14:43:16 -050012#include <string>
13#include <vector>
14
15namespace mri {
16
17// Typdefs for readability. Serialized protos are passed back and forth across
18// the boundary between platform2 code and librtanalytics.so.
Luke Sorenson1b3dedc2018-12-12 11:00:47 -050019// Note that these aliases are guaranteed to always have this type.
Luke Sorensona918ec32019-01-02 14:41:21 -050020using SerializedPerceptionInterfaces = std::vector<uint8_t>;
Luke Sorenson13e28272018-11-09 14:43:16 -050021using SerializedSuccessStatus = std::vector<uint8_t>;
Luke Sorenson171f4732019-05-29 11:12:07 -040022using SerializedTemplateArguments = std::vector<uint8_t>;
Luke Sorenson1320dfb2018-12-04 18:09:15 -050023using SerializedPipelineState = std::vector<uint8_t>;
Luke Sorenson16e89022019-03-13 16:12:15 -040024using SerializedGlobalPipelineState = std::vector<uint8_t>;
Luke Sorenson1b3dedc2018-12-12 11:00:47 -050025using SerializedDeviceTemplate = std::vector<uint8_t>;
26using SerializedVideoDevice = std::vector<uint8_t>;
27using SerializedAudioDevice = std::vector<uint8_t>;
28using SerializedVirtualVideoDevice = std::vector<uint8_t>;
Luke Sorensona918ec32019-01-02 14:41:21 -050029using PipelineOutputHandler = std::function<void(const std::vector<uint8_t>&)>;
Luke Sorenson46dfd502020-07-22 01:23:45 -040030using SerializedIndexedTransitionsResponse = std::vector<uint8_t>;
Luke Sorenson13e28272018-11-09 14:43:16 -050031
32class Rtanalytics {
33 public:
34 virtual ~Rtanalytics() = default;
35
Luke Sorensona918ec32019-01-02 14:41:21 -050036 // ------------------ Start of Media Perception Mojo API ---------------------
37
Luke Sorenson13e28272018-11-09 14:43:16 -050038 // Asks the library to setup a particular configuration. Success status is
Luke Sorensona918ec32019-01-02 14:41:21 -050039 // 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 Sorenson13e28272018-11-09 14:43:16 -050046 const std::string& configuration_name,
47 SerializedSuccessStatus* success_status) = 0;
Luke Sorenson1320dfb2018-12-04 18:09:15 -050048
Luke Sorenson171f4732019-05-29 11:12:07 -040049 // 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 Sorenson1b3dedc2018-12-12 11:00:47 -050056 // 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 Hughes1ef93742020-09-08 11:36:30 -070065 const std::string& configuration_name,
66 const std::string& template_name,
Luke Sorenson1b3dedc2018-12-12 11:00:47 -050067 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 Hughes1ef93742020-09-08 11:36:30 -070072 const std::string& configuration_name,
73 const std::string& template_name,
Luke Sorenson1b3dedc2018-12-12 11:00:47 -050074 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 Hughes1ef93742020-09-08 11:36:30 -070079 const std::string& configuration_name,
80 const std::string& template_name,
Luke Sorenson1b3dedc2018-12-12 11:00:47 -050081 const SerializedVirtualVideoDevice& virtual_device) = 0;
82
Luke Sorenson1320dfb2018-12-04 18:09:15 -050083 // 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 Sorenson1b3dedc2018-12-12 11:00:47 -050090 const SerializedPipelineState& desired_state) = 0;
Luke Sorensona918ec32019-01-02 14:41:21 -050091
Luke Sorenson16e89022019-03-13 16:12:15 -040092 // Returns states of all existing pipelines.
93 virtual SerializedGlobalPipelineState GetGlobalPipelineState() const = 0;
94
Luke Sorensona918ec32019-01-02 14:41:21 -050095 // ------------------- End of Media Perception Mojo API ----------------------
96
97 // Sets a callback for an output stream of the given configuration.
98 virtual SerializedSuccessStatus SetPipelineOutputHandler(
Tom Hughes1ef93742020-09-08 11:36:30 -070099 const std::string& configuration_name,
100 const std::string& output_stream,
Luke Sorensona918ec32019-01-02 14:41:21 -0500101 PipelineOutputHandler output_handler) = 0;
Luke Sorenson46dfd502020-07-22 01:23:45 -0400102
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 Sorenson13e28272018-11-09 14:43:16 -0500111};
112
113} // namespace mri
114
115#endif // MEDIA_PERCEPTION_RTANALYTICS_H_