Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / common / media / media_stream_options.h
blobe795fdbdab5f6c8a5a1ca220221bc23548fc9719
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 the hotword audio stream is used on platforms that support
32 // it.
33 CONTENT_EXPORT extern const char kMediaStreamAudioHotword[];
35 // StreamOptions is a Chromium representation of constraints
36 // used in WebUserMediaRequest.
37 // It describes properties requested by JS in a request for a new
38 // media stream.
39 class CONTENT_EXPORT StreamOptions {
40 public:
41 StreamOptions();
42 StreamOptions(bool request_audio, bool request_video);
43 ~StreamOptions();
45 struct CONTENT_EXPORT Constraint {
46 Constraint();
47 Constraint(const std::string& name,
48 const std::string& value);
50 std::string name;
51 std::string value;
53 typedef std::vector<Constraint> Constraints;
55 bool audio_requested;
56 Constraints mandatory_audio;
57 Constraints optional_audio;
59 bool video_requested;
60 Constraints mandatory_video;
61 Constraints optional_video;
63 // Fetches |value| from the first audio constraint with a name that matches
64 // |name| from |mandatory_audio| and |optional_audio|. First mandatory
65 // constraints are searched, then optional.
66 // |is_mandatory| may be NULL but if it is provided, it is set
67 // to true if the found constraint is mandatory.
68 // Returns false if no constraint is found.
69 bool GetFirstAudioConstraintByName(const std::string& name,
70 std::string* value,
71 bool* is_mandatory) const;
73 // Fetches |value| from the first video constraint with a name that matches
74 // |name| from |mandatory_video| and |optional_video|. First mandatory
75 // constraints are searched, then optional.
76 // |is_mandatory| may be NULL but if it is provided, it is set
77 // to true if the found constraint is mandatory.
78 // Returns false if no constraint is found.
79 bool GetFirstVideoConstraintByName(const std::string& name,
80 std::string* value,
81 bool* is_mandatory) const;
83 // Fetches |values| from all constraint with a name that matches |name|
84 // from |constraints|.
85 static void GetConstraintsByName(
86 const StreamOptions::Constraints& constraints,
87 const std::string& name,
88 std::vector<std::string>* values);
91 // StreamDeviceInfo describes information about a device.
92 struct CONTENT_EXPORT StreamDeviceInfo {
93 static const int kNoId;
95 StreamDeviceInfo();
96 StreamDeviceInfo(MediaStreamType service_param,
97 const std::string& name_param,
98 const std::string& device_param);
99 StreamDeviceInfo(MediaStreamType service_param,
100 const std::string& name_param,
101 const std::string& device_param,
102 int sample_rate,
103 int channel_layout,
104 int frames_per_buffer);
105 static bool IsEqual(const StreamDeviceInfo& first,
106 const StreamDeviceInfo& second);
108 MediaStreamDevice device;
110 // Id for this capture session. Unique for all sessions of the same type.
111 int session_id;
114 typedef std::vector<StreamDeviceInfo> StreamDeviceInfoArray;
116 } // namespace content
118 #endif // CONTENT_COMMON_MEDIA_MEDIA_STREAM_OPTIONS_H_