| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |