blob: 89fca05a5cfd65cc7aae3cd303a852466bc2a025 [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 Sorenson13e28272018-11-09 14:43:16 -050030
31class Rtanalytics {
32 public:
33 virtual ~Rtanalytics() = default;
34
Luke Sorensona918ec32019-01-02 14:41:21 -050035 // ------------------ Start of Media Perception Mojo API ---------------------
36
Luke Sorenson13e28272018-11-09 14:43:16 -050037 // Asks the library to setup a particular configuration. Success status is
Luke Sorensona918ec32019-01-02 14:41:21 -050038 // 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 Sorenson13e28272018-11-09 14:43:16 -050045 const std::string& configuration_name,
46 SerializedSuccessStatus* success_status) = 0;
Luke Sorenson1320dfb2018-12-04 18:09:15 -050047
Luke Sorenson171f4732019-05-29 11:12:07 -040048 // 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 Sorenson1b3dedc2018-12-12 11:00:47 -050055 // 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 Sorenson1320dfb2018-12-04 18:09:15 -050079 // 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 Sorenson1b3dedc2018-12-12 11:00:47 -050086 const SerializedPipelineState& desired_state) = 0;
Luke Sorensona918ec32019-01-02 14:41:21 -050087
Luke Sorenson16e89022019-03-13 16:12:15 -040088 // Returns states of all existing pipelines.
89 virtual SerializedGlobalPipelineState GetGlobalPipelineState() const = 0;
90
Luke Sorensona918ec32019-01-02 14:41:21 -050091 // ------------------- 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 Sorenson13e28272018-11-09 14:43:16 -050097};
98
99} // namespace mri
100
101#endif // MEDIA_PERCEPTION_RTANALYTICS_H_