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_
11 #include "content/common/content_export.h"
12 #include "content/public/common/media_stream_request.h"
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
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 // StreamOptions is a Chromium representation of constraints
35 // used in WebUserMediaRequest.
36 // It describes properties requested by JS in a request for a new
38 class CONTENT_EXPORT StreamOptions
{
41 StreamOptions(bool request_audio
, bool request_video
);
44 struct CONTENT_EXPORT Constraint
{
46 Constraint(const std::string
& name
,
47 const std::string
& value
);
52 typedef std::vector
<Constraint
> Constraints
;
55 Constraints mandatory_audio
;
56 Constraints optional_audio
;
59 Constraints mandatory_video
;
60 Constraints optional_video
;
62 // Fetches |value| from the first audio constraint with a name that matches
63 // |name| from |mandatory_audio| and |optional_audio|. First mandatory
64 // constraints are searched, then optional.
65 // |is_mandatory| may be NULL but if it is provided, it is set
66 // to true if the found constraint is mandatory.
67 // Returns false if no constraint is found.
68 bool GetFirstAudioConstraintByName(const std::string
& name
,
70 bool* is_mandatory
) const;
72 // Fetches |value| from the first video constraint with a name that matches
73 // |name| from |mandatory_video| and |optional_video|. First mandatory
74 // constraints are searched, then optional.
75 // |is_mandatory| may be NULL but if it is provided, it is set
76 // to true if the found constraint is mandatory.
77 // Returns false if no constraint is found.
78 bool GetFirstVideoConstraintByName(const std::string
& name
,
80 bool* is_mandatory
) const;
82 // Fetches |values| from all constraint with a name that matches |name|
83 // from |constraints|.
84 static void GetConstraintsByName(
85 const StreamOptions::Constraints
& constraints
,
86 const std::string
& name
,
87 std::vector
<std::string
>* values
);
90 // StreamDeviceInfo describes information about a device.
91 struct CONTENT_EXPORT StreamDeviceInfo
{
92 static const int kNoId
;
95 StreamDeviceInfo(MediaStreamType service_param
,
96 const std::string
& name_param
,
97 const std::string
& device_param
);
98 StreamDeviceInfo(MediaStreamType service_param
,
99 const std::string
& name_param
,
100 const std::string
& device_param
,
103 int frames_per_buffer
);
104 static bool IsEqual(const StreamDeviceInfo
& first
,
105 const StreamDeviceInfo
& second
);
107 MediaStreamDevice device
;
109 // Id for this capture session. Unique for all sessions of the same type.
113 typedef std::vector
<StreamDeviceInfo
> StreamDeviceInfoArray
;
115 } // namespace content
117 #endif // CONTENT_COMMON_MEDIA_MEDIA_STREAM_OPTIONS_H_