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

Side by Side Diff: content/renderer/media/media_stream_video_track.cc

Issue 1315993003: Reland: Change VideoCaptureDeliverFrameCB's signature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address new changes Created 5 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/renderer/media/media_stream_video_track.h" 5 #include "content/renderer/media/media_stream_video_track.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // Removes |callback| associated with |id| from receiving video frames if |id| 49 // Removes |callback| associated with |id| from receiving video frames if |id|
50 // has been added. It is ok to call RemoveCallback even if the |id| has not 50 // has been added. It is ok to call RemoveCallback even if the |id| has not
51 // been added. Note that the added callback will be reset on the main thread. 51 // been added. Note that the added callback will be reset on the main thread.
52 // Must be called on the main render thread. 52 // Must be called on the main render thread.
53 void RemoveCallback(VideoSinkId id); 53 void RemoveCallback(VideoSinkId id);
54 54
55 // Triggers all registered callbacks with |frame|, |format| and 55 // Triggers all registered callbacks with |frame|, |format| and
56 // |estimated_capture_time| as parameters. Must be called on the IO-thread. 56 // |estimated_capture_time| as parameters. Must be called on the IO-thread.
57 void DeliverFrameOnIO(const scoped_refptr<media::VideoFrame>& frame, 57 void DeliverFrameOnIO(const scoped_refptr<media::VideoFrame>& frame,
58 const base::TimeTicks& estimated_capture_time); 58 base::TimeTicks estimated_capture_time);
59 59
60 private: 60 private:
61 friend class base::RefCountedThreadSafe<FrameDeliverer>; 61 friend class base::RefCountedThreadSafe<FrameDeliverer>;
62 virtual ~FrameDeliverer(); 62 virtual ~FrameDeliverer();
63 void AddCallbackOnIO(VideoSinkId id, 63 void AddCallbackOnIO(VideoSinkId id,
64 const VideoCaptureDeliverFrameCB& callback); 64 const VideoCaptureDeliverFrameCB& callback);
65 void RemoveCallbackOnIO( 65 void RemoveCallbackOnIO(
66 VideoSinkId id, 66 VideoSinkId id,
67 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); 67 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
68 68
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 void MediaStreamVideoTrack::FrameDeliverer::SetEnabledOnIO(bool enabled) { 148 void MediaStreamVideoTrack::FrameDeliverer::SetEnabledOnIO(bool enabled) {
149 DCHECK(io_task_runner_->BelongsToCurrentThread()); 149 DCHECK(io_task_runner_->BelongsToCurrentThread());
150 enabled_ = enabled; 150 enabled_ = enabled;
151 if (enabled_) 151 if (enabled_)
152 black_frame_ = NULL; 152 black_frame_ = NULL;
153 } 153 }
154 154
155 void MediaStreamVideoTrack::FrameDeliverer::DeliverFrameOnIO( 155 void MediaStreamVideoTrack::FrameDeliverer::DeliverFrameOnIO(
156 const scoped_refptr<media::VideoFrame>& frame, 156 const scoped_refptr<media::VideoFrame>& frame,
157 const base::TimeTicks& estimated_capture_time) { 157 base::TimeTicks estimated_capture_time) {
158 DCHECK(io_task_runner_->BelongsToCurrentThread()); 158 DCHECK(io_task_runner_->BelongsToCurrentThread());
159 const scoped_refptr<media::VideoFrame>& video_frame = 159 const scoped_refptr<media::VideoFrame>& video_frame =
160 enabled_ ? frame : GetBlackFrame(frame); 160 enabled_ ? frame : GetBlackFrame(frame);
161 for (const auto& entry : callbacks_) 161 for (const auto& entry : callbacks_)
162 entry.second.Run(video_frame, estimated_capture_time); 162 entry.second.Run(video_frame, estimated_capture_time);
163 } 163 }
164 164
165 scoped_refptr<media::VideoFrame> 165 scoped_refptr<media::VideoFrame>
166 MediaStreamVideoTrack::FrameDeliverer::GetBlackFrame( 166 MediaStreamVideoTrack::FrameDeliverer::GetBlackFrame(
167 const scoped_refptr<media::VideoFrame>& reference_frame) { 167 const scoped_refptr<media::VideoFrame>& reference_frame) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 266 }
267 267
268 void MediaStreamVideoTrack::OnReadyStateChanged( 268 void MediaStreamVideoTrack::OnReadyStateChanged(
269 blink::WebMediaStreamSource::ReadyState state) { 269 blink::WebMediaStreamSource::ReadyState state) {
270 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 270 DCHECK(main_render_thread_checker_.CalledOnValidThread());
271 for (auto* sink : sinks_) 271 for (auto* sink : sinks_)
272 sink->OnReadyStateChanged(state); 272 sink->OnReadyStateChanged(state);
273 } 273 }
274 274
275 } // namespace content 275 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698