blob: f2653accf2dfc95c4b4cb21694a3cf9add6bd163 [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 Sorenson1b3dedc2018-12-12 11:00:47 -050023using SerializedDeviceTemplate = std::vector<uint8_t>;
24using SerializedVideoDevice = std::vector<uint8_t>;
25using SerializedAudioDevice = std::vector<uint8_t>;
26using SerializedVirtualVideoDevice = std::vector<uint8_t>;
Luke Sorensona918ec32019-01-02 14:41:21 -050027using PipelineOutputHandler = std::function<void(const std::vector<uint8_t>&)>;
Luke Sorenson13e28272018-11-09 14:43:16 -050028
29class Rtanalytics {
30 public:
31 virtual ~Rtanalytics() = default;
32
Luke Sorensona918ec32019-01-02 14:41:21 -050033 // ------------------ Start of Media Perception Mojo API ---------------------
34
Luke Sorenson13e28272018-11-09 14:43:16 -050035 // Asks the library to setup a particular configuration. Success status is
Luke Sorensona918ec32019-01-02 14:41:21 -050036 // filled in by the library side. The return value is the list of perception
37 // interfaces that are fulfilled by the current configuration. This function
38 // can be called multiple times to setup multiple configurations.
39 // |success_status| cannot be null. Each PerceptionInterface contains output
40 // stream types so that the CrOS side can register appropriate output
41 // handlers.
42 virtual SerializedPerceptionInterfaces SetupConfiguration(
Luke Sorenson13e28272018-11-09 14:43:16 -050043 const std::string& configuration_name,
44 SerializedSuccessStatus* success_status) = 0;
Luke Sorenson1320dfb2018-12-04 18:09:15 -050045
Luke Sorenson1b3dedc2018-12-12 11:00:47 -050046 // Returns the list of template names for devices that can be filled in for a
47 // particular configuration that has been setup. If the configuration has not
48 // been setup via |SetupConfiguration| the returned list will always be empty.
49 virtual std::vector<SerializedDeviceTemplate> GetTemplateDevices(
50 const std::string& configuration_name) const = 0;
51
52 // Enables a client of rtanalytics to set the parameters for a video device
53 // for a specified device template.
54 virtual SerializedSuccessStatus SetVideoDeviceForTemplateName(
55 const std::string& configuration_name, const std::string& template_name,
56 const SerializedVideoDevice& video_device) = 0;
57
58 // Enables a client of rtanalytics to set the parameters for an audio device
59 // for a specified device template.
60 virtual SerializedSuccessStatus SetAudioDeviceForTemplateName(
61 const std::string& configuration_name, const std::string& template_name,
62 const SerializedAudioDevice& audio_device) = 0;
63
64 // Enables a client of rtanalytics to set the parameters for a virtual video
65 // device for a specified device template.
66 virtual SerializedSuccessStatus SetVirtualVideoDeviceForTemplateName(
67 const std::string& configuration_name, const std::string& template_name,
68 const SerializedVirtualVideoDevice& virtual_device) = 0;
69
Luke Sorenson1320dfb2018-12-04 18:09:15 -050070 // Returns the pipeline state of the given configuation.
71 virtual SerializedPipelineState GetPipelineState(
72 const std::string& configuration_name) const = 0;
73
74 // Sets the pipeline to the desired state and returns the new state.
75 virtual SerializedPipelineState SetPipelineState(
76 const std::string& configuration_name,
Luke Sorenson1b3dedc2018-12-12 11:00:47 -050077 const SerializedPipelineState& desired_state) = 0;
Luke Sorensona918ec32019-01-02 14:41:21 -050078
79 // ------------------- End of Media Perception Mojo API ----------------------
80
81 // Sets a callback for an output stream of the given configuration.
82 virtual SerializedSuccessStatus SetPipelineOutputHandler(
83 const std::string& configuration_name, const std::string& output_stream,
84 PipelineOutputHandler output_handler) = 0;
Luke Sorenson13e28272018-11-09 14:43:16 -050085};
86
87} // namespace mri
88
89#endif // MEDIA_PERCEPTION_RTANALYTICS_H_