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

Side by Side Diff: chrome/renderer/media/cast_rtp_stream.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
« no previous file with comments | « no previous file | content/common/media/video_capture.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/renderer/media/cast_rtp_stream.h" 5 #include "chrome/renderer/media/cast_rtp_stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 225 }
226 226
227 // This static method is used to forward video frames to |frame_input|. 227 // This static method is used to forward video frames to |frame_input|.
228 static void OnVideoFrame( 228 static void OnVideoFrame(
229 // These parameters are already bound when callback is created. 229 // These parameters are already bound when callback is created.
230 const gfx::Size& expected_coded_size, 230 const gfx::Size& expected_coded_size,
231 const CastRtpStream::ErrorCallback& error_callback, 231 const CastRtpStream::ErrorCallback& error_callback,
232 const scoped_refptr<media::cast::VideoFrameInput> frame_input, 232 const scoped_refptr<media::cast::VideoFrameInput> frame_input,
233 // These parameters are passed for each frame. 233 // These parameters are passed for each frame.
234 const scoped_refptr<media::VideoFrame>& frame, 234 const scoped_refptr<media::VideoFrame>& frame,
235 const media::VideoCaptureFormat& format) { 235 const media::VideoCaptureFormat& format,
236 const base::TimeTicks& estimated_capture_time) {
236 if (frame->coded_size() != expected_coded_size) { 237 if (frame->coded_size() != expected_coded_size) {
237 error_callback.Run("Video frame resolution does not match config."); 238 error_callback.Run("Video frame resolution does not match config.");
238 return; 239 return;
239 } 240 }
240 241
241 const base::TimeTicks now = base::TimeTicks::Now(); 242 base::TimeTicks timestamp;
243 if (estimated_capture_time.is_null())
244 timestamp = base::TimeTicks::Now();
245 else
246 timestamp = estimated_capture_time;
242 247
243 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc 248 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc
244 TRACE_EVENT_INSTANT2( 249 TRACE_EVENT_INSTANT2(
245 "cast_perf_test", "MediaStreamVideoSink::OnVideoFrame", 250 "cast_perf_test", "MediaStreamVideoSink::OnVideoFrame",
246 TRACE_EVENT_SCOPE_THREAD, 251 TRACE_EVENT_SCOPE_THREAD,
247 "timestamp", now.ToInternalValue(), 252 "timestamp", timestamp.ToInternalValue(),
248 "time_delta", frame->timestamp().ToInternalValue()); 253 "time_delta", frame->timestamp().ToInternalValue());
249 frame_input->InsertRawVideoFrame(frame, now); 254 frame_input->InsertRawVideoFrame(frame, timestamp);
250 } 255 }
251 256
252 // Attach this sink to a video track represented by |track_|. 257 // Attach this sink to a video track represented by |track_|.
253 // Data received from the track will be submitted to |frame_input|. 258 // Data received from the track will be submitted to |frame_input|.
254 void AddToTrack( 259 void AddToTrack(
255 const scoped_refptr<media::cast::VideoFrameInput>& frame_input) { 260 const scoped_refptr<media::cast::VideoFrameInput>& frame_input) {
256 DCHECK(!sink_added_); 261 DCHECK(!sink_added_);
257 sink_added_ = true; 262 sink_added_ = true;
258 AddToVideoTrack( 263 AddToVideoTrack(
259 this, 264 this,
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 539 }
535 540
536 void CastRtpStream::DidEncounterError(const std::string& message) { 541 void CastRtpStream::DidEncounterError(const std::string& message) {
537 // Save the WeakPtr first because the error callback might delete this object. 542 // Save the WeakPtr first because the error callback might delete this object.
538 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); 543 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr();
539 error_callback_.Run(message); 544 error_callback_.Run(message);
540 content::RenderThread::Get()->GetMessageLoop()->PostTask( 545 content::RenderThread::Get()->GetMessageLoop()->PostTask(
541 FROM_HERE, 546 FROM_HERE,
542 base::Bind(&CastRtpStream::Stop, ptr)); 547 base::Bind(&CastRtpStream::Stop, ptr));
543 } 548 }
OLDNEW
« no previous file with comments | « no previous file | content/common/media/video_capture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698