We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / content / common / media / media_stream_options.h
blob9f208da80e3cc442a890cf06186c6339046cd249
1 // Copyright (c) 2012 The Chromium 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.
5 #ifndef CONTENT_COMMON_MEDIA_MEDIA_STREAM_OPTIONS_H_
6 #define CONTENT_COMMON_MEDIA_MEDIA_STREAM_OPTIONS_H_
8 #include <string>
9 #include <vector>
11 #include "content/common/content_export.h"
12 #include "content/public/common/media_stream_request.h"
14 namespace content {
16 // MediaStreamConstraint keys for constraints that are passed to getUserMedia.
17 CONTENT_EXPORT extern const char kMediaStreamSource[];
18 CONTENT_EXPORT extern const char kMediaStreamSourceId[];
19 CONTENT_EXPORT extern const char kMediaStreamSourceInfoId[];
20 CONTENT_EXPORT extern const char kMediaStreamSourceTab[];
21 CONTENT_EXPORT extern const char kMediaStreamSourceScreen[];
22 CONTENT_EXPORT extern const char kMediaStreamSourceDesktop[];
23 CONTENT_EXPORT extern const char kMediaStreamSourceSystem[];
25 // Experimental constraint to do device matching. When this optional constraint
26 // is set, WebRTC audio renderer will render audio from media streams to an
27 // output device that belongs to the same hardware as the requested source
28 // device belongs to.
29 CONTENT_EXPORT extern const char kMediaStreamRenderToAssociatedSink[];
31 // Controls whether ducking of audio is enabled on platforms that support it.
32 CONTENT_EXPORT extern const char kMediaStreamAudioDucking[];
34 // Controls whether the hotword audio stream is used on platforms that support
35 // it.
36 CONTENT_EXPORT extern const char kMediaStreamAudioHotword[];
38 // StreamOptions is a Chromium representation of constraints
39 // used in WebUserMediaRequest.
40 // It describes properties requested by JS in a request for a new
41 // media stream.
42 class CONTENT_EXPORT StreamOptions {
43 public:
44 StreamOptions();
45 StreamOptions(bool request_audio, bool request_video);
46 ~StreamOptions();
48 struct CONTENT_EXPORT Constraint {
49 Constraint();
50 Constraint(const std::string& name,
51 const std::string& value);
53 std::string name;
54 std::string value;
56 typedef std::vector<Constraint> Constraints;
58 bool audio_requested;
59 Constraints mandatory_audio;
60 Constraints optional_audio;
62 bool video_requested;
63 Constraints mandatory_video;
64 Constraints optional_video;
66 // Fetches |value| from the first audio constraint with a name that matches
67 // |name| from |mandatory_audio| and |optional_audio|. First mandatory
68 // constraints are searched, then optional.
69 // |is_mandatory| may be NULL but if it is provided, it is set
70 // to true if the found constraint is mandatory.
71 // Returns false if no constraint is found.
72 bool GetFirstAudioConstraintByName(const std::string& name,
73 std::string* value,
74 bool* is_mandatory) const;
76 // Fetches |value| from the first video constraint with a name that matches
77 // |name| from |mandatory_video| and |optional_video|. First mandatory
78 // constraints are searched, then optional.
79 // |is_mandatory| may be NULL but if it is provided, it is set
80 // to true if the found constraint is mandatory.
81 // Returns false if no constraint is found.
82 bool GetFirstVideoConstraintByName(const std::string& name,
83 std::string* value,
84 bool* is_mandatory) const;
86 // Fetches |values| from all constraint with a name that matches |name|
87 // from |constraints|.
88 static void GetConstraintsByName(
89 const StreamOptions::Constraints& constraints,
90 const std::string& name,
91 std::vector<std::string>* values);
94 // StreamDeviceInfo describes information about a device.
95 struct CONTENT_EXPORT StreamDeviceInfo {
96 static const int kNoId;
98 StreamDeviceInfo();
99 StreamDeviceInfo(MediaStreamType service_param,
100 const std::string& name_param,
101 const std::string& device_param);
102 StreamDeviceInfo(MediaStreamType service_param,
103 const std::string& name_param,
104 const std::string& device_param,
105 int sample_rate,
106 int channel_layout,
107 int frames_per_buffer);
108 static bool IsEqual(const StreamDeviceInfo& first,
109 const StreamDeviceInfo& second);
111 MediaStreamDevice device;
113 // Id for this capture session. Unique for all sessions of the same type.
114 int session_id;
117 typedef std::vector<StreamDeviceInfo> StreamDeviceInfoArray;
119 } // namespace content
121 #endif // CONTENT_COMMON_MEDIA_MEDIA_STREAM_OPTIONS_H_