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

Side by Side Diff: content/renderer/media/webrtc/webrtc_video_track_adapter.cc

Issue 287313002: Pass a TimeTicks along video capture pipeline to represent capture time (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged and land Created 6 years, 6 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 #include "content/renderer/media/webrtc/webrtc_video_track_adapter.h" 5 #include "content/renderer/media/webrtc/webrtc_video_track_adapter.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/synchronization/lock.h" 8 #include "base/synchronization/lock.h"
9 #include "content/common/media/media_stream_options.h" 9 #include "content/common/media/media_stream_options.h"
10 #include "content/renderer/media/media_stream_video_source.h" 10 #include "content/renderer/media/media_stream_video_source.h"
(...skipping 26 matching lines...) Expand all
37 37
38 // WebRtcVideoTrackAdapter can be destroyed on the main render thread or 38 // WebRtcVideoTrackAdapter can be destroyed on the main render thread or
39 // libjingles worker thread since it posts video frames on that thread. But 39 // libjingles worker thread since it posts video frames on that thread. But
40 // |video_source_| must be released on the main render thread before the 40 // |video_source_| must be released on the main render thread before the
41 // PeerConnectionFactory has been destroyed. The only way to ensure that is 41 // PeerConnectionFactory has been destroyed. The only way to ensure that is
42 // to make sure |video_source_| is released when WebRtcVideoTrackAdapter() is 42 // to make sure |video_source_| is released when WebRtcVideoTrackAdapter() is
43 // destroyed. 43 // destroyed.
44 void ReleaseSourceOnMainThread(); 44 void ReleaseSourceOnMainThread();
45 45
46 void OnVideoFrameOnIO(const scoped_refptr<media::VideoFrame>& frame, 46 void OnVideoFrameOnIO(const scoped_refptr<media::VideoFrame>& frame,
47 const media::VideoCaptureFormat& format); 47 const media::VideoCaptureFormat& format,
48 const base::TimeTicks& estimated_capture_time);
48 49
49 private: 50 private:
50 void OnVideoFrameOnWorkerThread(const scoped_refptr<media::VideoFrame>& frame, 51 void OnVideoFrameOnWorkerThread(
51 const media::VideoCaptureFormat& format); 52 const scoped_refptr<media::VideoFrame>& frame,
53 const media::VideoCaptureFormat& format,
54 const base::TimeTicks& estimated_capture_time);
52 friend class base::RefCountedThreadSafe<WebRtcVideoSourceAdapter>; 55 friend class base::RefCountedThreadSafe<WebRtcVideoSourceAdapter>;
53 virtual ~WebRtcVideoSourceAdapter(); 56 virtual ~WebRtcVideoSourceAdapter();
54 57
55 scoped_refptr<base::MessageLoopProxy> render_thread_message_loop_; 58 scoped_refptr<base::MessageLoopProxy> render_thread_message_loop_;
56 59
57 // |render_thread_checker_| is bound to the main render thread. 60 // |render_thread_checker_| is bound to the main render thread.
58 base::ThreadChecker render_thread_checker_; 61 base::ThreadChecker render_thread_checker_;
59 // Used to DCHECK that frames are called on the IO-thread. 62 // Used to DCHECK that frames are called on the IO-thread.
60 base::ThreadChecker io_thread_checker_; 63 base::ThreadChecker io_thread_checker_;
61 64
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // on that thread. However, since |video_source_| was created on the render 106 // on that thread. However, since |video_source_| was created on the render
104 // thread, it should be released on the render thread. 107 // thread, it should be released on the render thread.
105 base::AutoLock auto_lock(capture_adapter_stop_lock_); 108 base::AutoLock auto_lock(capture_adapter_stop_lock_);
106 // |video_source| owns |capture_adapter_|. 109 // |video_source| owns |capture_adapter_|.
107 capture_adapter_ = NULL; 110 capture_adapter_ = NULL;
108 video_source_ = NULL; 111 video_source_ = NULL;
109 } 112 }
110 113
111 void WebRtcVideoTrackAdapter::WebRtcVideoSourceAdapter::OnVideoFrameOnIO( 114 void WebRtcVideoTrackAdapter::WebRtcVideoSourceAdapter::OnVideoFrameOnIO(
112 const scoped_refptr<media::VideoFrame>& frame, 115 const scoped_refptr<media::VideoFrame>& frame,
113 const media::VideoCaptureFormat& format) { 116 const media::VideoCaptureFormat& format,
117 const base::TimeTicks& estimated_capture_time) {
114 DCHECK(io_thread_checker_.CalledOnValidThread()); 118 DCHECK(io_thread_checker_.CalledOnValidThread());
115 libjingle_worker_thread_->PostTask( 119 libjingle_worker_thread_->PostTask(
116 FROM_HERE, 120 FROM_HERE,
117 base::Bind(&WebRtcVideoSourceAdapter::OnVideoFrameOnWorkerThread, 121 base::Bind(&WebRtcVideoSourceAdapter::OnVideoFrameOnWorkerThread,
118 this, frame, format)); 122 this, frame, format, estimated_capture_time));
119 } 123 }
120 124
121 void 125 void
122 WebRtcVideoTrackAdapter::WebRtcVideoSourceAdapter::OnVideoFrameOnWorkerThread( 126 WebRtcVideoTrackAdapter::WebRtcVideoSourceAdapter::OnVideoFrameOnWorkerThread(
123 const scoped_refptr<media::VideoFrame>& frame, 127 const scoped_refptr<media::VideoFrame>& frame,
124 const media::VideoCaptureFormat& format) { 128 const media::VideoCaptureFormat& format,
129 const base::TimeTicks& estimated_capture_time) {
125 DCHECK(libjingle_worker_thread_->BelongsToCurrentThread()); 130 DCHECK(libjingle_worker_thread_->BelongsToCurrentThread());
126 base::AutoLock auto_lock(capture_adapter_stop_lock_); 131 base::AutoLock auto_lock(capture_adapter_stop_lock_);
127 if (capture_adapter_) 132 if (capture_adapter_)
128 capture_adapter_->OnFrameCaptured(frame); 133 capture_adapter_->OnFrameCaptured(frame);
129 } 134 }
130 135
131 WebRtcVideoTrackAdapter::WebRtcVideoTrackAdapter( 136 WebRtcVideoTrackAdapter::WebRtcVideoTrackAdapter(
132 const blink::WebMediaStreamTrack& track, 137 const blink::WebMediaStreamTrack& track,
133 PeerConnectionDependencyFactory* factory) 138 PeerConnectionDependencyFactory* factory)
134 : web_track_(track) { 139 : web_track_(track) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 RemoveFromVideoTrack(this, web_track_); 176 RemoveFromVideoTrack(this, web_track_);
172 source_adapter_->ReleaseSourceOnMainThread(); 177 source_adapter_->ReleaseSourceOnMainThread();
173 } 178 }
174 179
175 void WebRtcVideoTrackAdapter::OnEnabledChanged(bool enabled) { 180 void WebRtcVideoTrackAdapter::OnEnabledChanged(bool enabled) {
176 DCHECK(thread_checker_.CalledOnValidThread()); 181 DCHECK(thread_checker_.CalledOnValidThread());
177 video_track_->set_enabled(enabled); 182 video_track_->set_enabled(enabled);
178 } 183 }
179 184
180 } // namespace content 185 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698