blob: 18ff7f55a03cf5740c16d639502ff8f88eaccaac [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 Sorenson1320dfb2018-12-04 18:09:15 -050022using SerializedPipelineState = std::vector<uint8_t>;
Luke Sorenson16e89022019-03-13 16:12:15 -040023using SerializedGlobalPipelineState = std::vector<uint8_t>;
Luke Sorenson1b3dedc2018-12-12 11:00:47 -050024using SerializedDeviceTemplate = std::vector<uint8_t>;
25using SerializedVideoDevice = std::vector<uint8_t>;
26using SerializedAudioDevice = std::vector<uint8_t>;
27using SerializedVirtualVideoDevice = std::vector<uint8_t>;
Luke Sorensona918ec32019-01-02 14:41:21 -050028using PipelineOutputHandler = std::function<void(const std::vector<uint8_t>&)>;
Luke Sorenson13e28272018-11-09 14:43:16 -050029
30class Rtanalytics {
31 public:
32 virtual ~Rtanalytics() = default;
33
Luke Sorensona918ec32019-01-02 14:41:21 -050034 // ------------------ Start of Media Perception Mojo API ---------------------
35
Luke Sorenson13e28272018-11-09 14:43:16 -050036 // Asks the library to setup a particular configuration. Success status is
Luke Sorensona918ec32019-01-02 14:41:21 -050037 // 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 Sorenson13e28272018-11-09 14:43:16 -050044 const std::string& configuration_name,
45 SerializedSuccessStatus* success_status) = 0;
Luke Sorenson1320dfb2018-12-04 18:09:15 -050046
Luke Sorenson1b3dedc2018-12-12 11:00:47 -050047 // 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 Sorenson1320dfb2018-12-04 18:09:15 -050071 // 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 Sorenson1b3dedc2018-12-12 11:00:47 -050078 const SerializedPipelineState& desired_state) = 0;
Luke Sorensona918ec32019-01-02 14:41:21 -050079
Luke Sorenson16e89022019-03-13 16:12:15 -040080 // Returns states of all existing pipelines.
81 virtual SerializedGlobalPipelineState GetGlobalPipelineState() const = 0;
82
Luke Sorensona918ec32019-01-02 14:41:21 -050083 // ------------------- 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 Sorenson13e28272018-11-09 14:43:16 -050089};
90
91} // namespace mri
92
93#endif // MEDIA_PERCEPTION_RTANALYTICS_H_