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

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

Issue 391703002: Implement ConstraintNotSatisfiedError for getusermedia (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 // An implementation must start capture frames using the resolution in 105 // An implementation must start capture frames using the resolution in
106 // |params|. When the source has started or the source failed to start 106 // |params|. When the source has started or the source failed to start
107 // OnStartDone must be called. An implementation must call 107 // OnStartDone must be called. An implementation must call
108 // invoke |frame_callback| on the IO thread with the captured frames. 108 // invoke |frame_callback| on the IO thread with the captured frames.
109 // TODO(perkj): pass a VideoCaptureFormats instead of VideoCaptureParams for 109 // TODO(perkj): pass a VideoCaptureFormats instead of VideoCaptureParams for
110 // subclasses to customize. 110 // subclasses to customize.
111 virtual void StartSourceImpl( 111 virtual void StartSourceImpl(
112 const media::VideoCaptureParams& params, 112 const media::VideoCaptureParams& params,
113 const VideoCaptureDeliverFrameCB& frame_callback) = 0; 113 const VideoCaptureDeliverFrameCB& frame_callback) = 0;
114 void OnStartDone(bool success); 114 void OnStartDone(MediaStreamRequestResult result);
115 115
116 // An implementation must immediately stop capture video frames and must not 116 // An implementation must immediately stop capture video frames and must not
117 // call OnSupportedFormats after this method has been called. After this 117 // call OnSupportedFormats after this method has been called. After this
118 // method has been called, MediaStreamVideoSource may be deleted. 118 // method has been called, MediaStreamVideoSource may be deleted.
119 virtual void StopSourceImpl() = 0; 119 virtual void StopSourceImpl() = 0;
120 120
121 enum State { 121 enum State {
122 NEW, 122 NEW,
123 RETRIEVING_CAPABILITIES, 123 RETRIEVING_CAPABILITIES,
124 STARTING, 124 STARTING,
125 STARTED, 125 STARTED,
126 ENDED 126 ENDED
127 }; 127 };
128 State state() const { return state_; } 128 State state() const { return state_; }
129 129
130 private: 130 private:
131 void OnSupportedFormats(const media::VideoCaptureFormats& formats); 131 void OnSupportedFormats(const media::VideoCaptureFormats& formats);
132 132
133 // Finds the first constraints in |requested_constraints_| that can be 133 // Finds the first constraints in |requested_constraints_| that can be
134 // fulfilled. |best_format| is set to the video resolution that can be 134 // fulfilled. |best_format| is set to the video resolution that can be
135 // fulfilled. 135 // fulfilled.
136 bool FindBestFormatWithConstraints( 136 bool FindBestFormatWithConstraints(
137 const media::VideoCaptureFormats& formats, 137 const media::VideoCaptureFormats& formats,
138 media::VideoCaptureFormat* best_format); 138 media::VideoCaptureFormat* best_format,
139 blink::WebString* unsatisfied_constraint);
139 140
140 // Trigger all cached callbacks from AddTrack. AddTrack is successful 141 // Trigger all cached callbacks from AddTrack. AddTrack is successful
141 // if the capture delegate has started and the constraints provided in 142 // if the capture delegate has started and the constraints provided in
142 // AddTrack match the format that was used to start the device. 143 // AddTrack match the format that was used to start the device.
143 // Note that it must be ok to delete the MediaStreamVideoSource object 144 // Note that it must be ok to delete the MediaStreamVideoSource object
144 // in the context of the callback. If gUM fail, the implementation will 145 // in the context of the callback. If gUM fail, the implementation will
145 // simply drop the references to the blink source and track which will lead 146 // simply drop the references to the blink source and track which will lead
146 // to that this object is deleted. 147 // to that this object is deleted.
147 void FinalizeAddTrack(); 148 void FinalizeAddTrack(MediaStreamRequestResult result,
149 const blink::WebString& result_name);
148 150
149 State state_; 151 State state_;
150 bool muted_state_; 152 bool muted_state_;
151 153
152 media::VideoCaptureFormat current_format_; 154 media::VideoCaptureFormat current_format_;
153 155
154 struct RequestedConstraints { 156 struct RequestedConstraints {
155 RequestedConstraints(MediaStreamVideoTrack* track, 157 RequestedConstraints(MediaStreamVideoTrack* track,
156 const VideoCaptureDeliverFrameCB& frame_callback, 158 const VideoCaptureDeliverFrameCB& frame_callback,
157 const blink::WebMediaConstraints& constraints, 159 const blink::WebMediaConstraints& constraints,
(...skipping 17 matching lines...) Expand all
175 177
176 // NOTE: Weak pointers must be invalidated before all other member variables. 178 // NOTE: Weak pointers must be invalidated before all other member variables.
177 base::WeakPtrFactory<MediaStreamVideoSource> weak_factory_; 179 base::WeakPtrFactory<MediaStreamVideoSource> weak_factory_;
178 180
179 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); 181 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource);
180 }; 182 };
181 183
182 } // namespace content 184 } // namespace content
183 185
184 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ 186 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698