Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Side by Side Diff: content/renderer/media/media_stream_video_source.h

Issue 212973002: Refactor VideoDestinationHandler to implement MediaStreamVideoSource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 const blink::WebMediaConstraints& constraints, 59 const blink::WebMediaConstraints& constraints,
60 const ConstraintsCallback& callback); 60 const ConstraintsCallback& callback);
61 void RemoveTrack(MediaStreamVideoTrack* track); 61 void RemoveTrack(MediaStreamVideoTrack* track);
62 62
63 // TODO(ronghuawu): Remove webrtc::VideoSourceInterface from the public 63 // TODO(ronghuawu): Remove webrtc::VideoSourceInterface from the public
64 // interface of this class. 64 // interface of this class.
65 // This creates a VideoSourceInterface implementation if it does not already 65 // This creates a VideoSourceInterface implementation if it does not already
66 // exist. 66 // exist.
67 webrtc::VideoSourceInterface* GetAdapter(); 67 webrtc::VideoSourceInterface* GetAdapter();
68 68
69 // Return true if |name| is a constraint supported by MediaStreamVideoSource.
70 static bool IsConstraintSupported(const std::string& name);
71
69 // Constraint keys used by a video source. 72 // Constraint keys used by a video source.
70 // Specified by draft-alvestrand-constraints-resolution-00b 73 // Specified by draft-alvestrand-constraints-resolution-00b
71 static const char kMinAspectRatio[]; // minAspectRatio 74 static const char kMinAspectRatio[]; // minAspectRatio
72 static const char kMaxAspectRatio[]; // maxAspectRatio 75 static const char kMaxAspectRatio[]; // maxAspectRatio
73 static const char kMaxWidth[]; // maxWidth 76 static const char kMaxWidth[]; // maxWidth
74 static const char kMinWidth[]; // minWidthOnCaptureFormats 77 static const char kMinWidth[]; // minWidthOnCaptureFormats
75 static const char kMaxHeight[]; // maxHeight 78 static const char kMaxHeight[]; // maxHeight
76 static const char kMinHeight[]; // minHeight 79 static const char kMinHeight[]; // minHeight
77 static const char kMaxFrameRate[]; // maxFrameRate 80 static const char kMaxFrameRate[]; // maxFrameRate
78 static const char kMinFrameRate[]; // minFrameRate 81 static const char kMinFrameRate[]; // minFrameRate
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // TODO(perkj): pass a VideoCaptureFormats instead of VideoCaptureParams for 116 // TODO(perkj): pass a VideoCaptureFormats instead of VideoCaptureParams for
114 // subclasses to customize. 117 // subclasses to customize.
115 virtual void StartSourceImpl(const media::VideoCaptureParams& params) = 0; 118 virtual void StartSourceImpl(const media::VideoCaptureParams& params) = 0;
116 void OnStartDone(bool success); 119 void OnStartDone(bool success);
117 120
118 // An implementation must immediately stop capture video frames and must not 121 // An implementation must immediately stop capture video frames and must not
119 // call OnSupportedFormats after this method has been called. After this 122 // call OnSupportedFormats after this method has been called. After this
120 // method has been called, MediaStreamVideoSource may be deleted. 123 // method has been called, MediaStreamVideoSource may be deleted.
121 virtual void StopSourceImpl() = 0; 124 virtual void StopSourceImpl() = 0;
122 125
126 enum State {
127 NEW,
128 RETRIEVING_CAPABILITIES,
129 STARTING,
130 STARTED,
131 ENDED
132 };
133 State state() { return state_; }
134
123 private: 135 private:
124 // Creates a webrtc::VideoSourceInterface used by libjingle. 136 // Creates a webrtc::VideoSourceInterface used by libjingle.
125 void InitAdapter(); 137 void InitAdapter();
126 138
127 // Finds the first constraints in |requested_constraints_| that can be 139 // Finds the first constraints in |requested_constraints_| that can be
128 // fulfilled. |best_format| is set to the video resolution that can be 140 // fulfilled. |best_format| is set to the video resolution that can be
129 // fulfilled. |frame_output_size| is the requested frame size after cropping. 141 // fulfilled. |frame_output_size| is the requested frame size after cropping.
130 // |resulting_constraints| is set to the found constraints in 142 // |resulting_constraints| is set to the found constraints in
131 // |requested_constraints_|. 143 // |requested_constraints_|.
132 bool FindBestFormatWithConstraints( 144 bool FindBestFormatWithConstraints(
133 const media::VideoCaptureFormats& formats, 145 const media::VideoCaptureFormats& formats,
134 media::VideoCaptureFormat* best_format, 146 media::VideoCaptureFormat* best_format,
135 gfx::Size* frame_output_size, 147 gfx::Size* frame_output_size,
136 blink::WebMediaConstraints* resulting_constraints); 148 blink::WebMediaConstraints* resulting_constraints);
137 149
138 // Trigger all cached callbacks from AddTrack. AddTrack is successful 150 // Trigger all cached callbacks from AddTrack. AddTrack is successful
139 // if the capture delegate has started and the constraints provided in 151 // if the capture delegate has started and the constraints provided in
140 // AddTrack match the format that was used to start the device. 152 // AddTrack match the format that was used to start the device.
141 void FinalizeAddTrack(); 153 void FinalizeAddTrack();
142 154
143 enum State {
144 NEW,
145 RETRIEVING_CAPABILITIES,
146 STARTING,
147 STARTED,
148 ENDED
149 };
150 State state_; 155 State state_;
151 156
152 media::VideoCaptureFormat current_format_; 157 media::VideoCaptureFormat current_format_;
153 blink::WebMediaConstraints current_constraints_; 158 blink::WebMediaConstraints current_constraints_;
154 gfx::Size frame_output_size_; 159 gfx::Size frame_output_size_;
155 160
156 struct RequestedConstraints { 161 struct RequestedConstraints {
157 RequestedConstraints(const blink::WebMediaConstraints& constraints, 162 RequestedConstraints(const blink::WebMediaConstraints& constraints,
158 const ConstraintsCallback& callback); 163 const ConstraintsCallback& callback);
159 ~RequestedConstraints(); 164 ~RequestedConstraints();
(...skipping 13 matching lines...) Expand all
173 MediaStreamDependencyFactory* factory_; 178 MediaStreamDependencyFactory* factory_;
174 scoped_refptr<webrtc::VideoSourceInterface> adapter_; 179 scoped_refptr<webrtc::VideoSourceInterface> adapter_;
175 WebRtcVideoCapturerAdapter* capture_adapter_; 180 WebRtcVideoCapturerAdapter* capture_adapter_;
176 181
177 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); 182 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource);
178 }; 183 };
179 184
180 } // namespace content 185 } // namespace content
181 186
182 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ 187 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698