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 "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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 error_callback_.Run("Video frame resolution does not match config."); | 208 error_callback_.Run("Video frame resolution does not match config."); |
209 return; | 209 return; |
210 } | 210 } |
211 | 211 |
212 // Capture time is calculated using the time when the first frame | 212 // Capture time is calculated using the time when the first frame |
213 // is delivered. Doing so has less jitter because each frame has | 213 // is delivered. Doing so has less jitter because each frame has |
214 // a TimeDelta from the first frame. However there is a delay between | 214 // a TimeDelta from the first frame. However there is a delay between |
215 // capture and delivery here for the first frame. We do not account | 215 // capture and delivery here for the first frame. We do not account |
216 // for this delay. | 216 // for this delay. |
217 if (first_frame_timestamp_.is_null()) | 217 if (first_frame_timestamp_.is_null()) |
218 first_frame_timestamp_ = base::TimeTicks::Now() - frame->GetTimestamp();; | 218 first_frame_timestamp_ = base::TimeTicks::Now() - frame->timestamp(); |
219 | 219 |
220 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc | 220 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc |
221 TRACE_EVENT_INSTANT2( | 221 TRACE_EVENT_INSTANT2( |
222 "mirroring", "MediaStreamVideoSink::OnVideoFrame", | 222 "mirroring", "MediaStreamVideoSink::OnVideoFrame", |
223 TRACE_EVENT_SCOPE_THREAD, | 223 TRACE_EVENT_SCOPE_THREAD, |
224 "timestamp", | 224 "timestamp", |
225 (first_frame_timestamp_ + frame->GetTimestamp()).ToInternalValue(), | 225 (first_frame_timestamp_ + frame->timestamp()).ToInternalValue(), |
226 "time_delta", frame->GetTimestamp().ToInternalValue()); | 226 "time_delta", frame->timestamp().ToInternalValue()); |
227 | 227 |
228 frame_input_->InsertRawVideoFrame( | 228 frame_input_->InsertRawVideoFrame( |
229 frame, first_frame_timestamp_ + frame->GetTimestamp()); | 229 frame, first_frame_timestamp_ + frame->timestamp()); |
230 } | 230 } |
231 | 231 |
232 // Attach this sink to a video track represented by |track_|. | 232 // Attach this sink to a video track represented by |track_|. |
233 // Data received from the track will be submitted to |frame_input|. | 233 // Data received from the track will be submitted to |frame_input|. |
234 void AddToTrack( | 234 void AddToTrack( |
235 const scoped_refptr<media::cast::VideoFrameInput>& frame_input) { | 235 const scoped_refptr<media::cast::VideoFrameInput>& frame_input) { |
236 DCHECK(!sink_added_); | 236 DCHECK(!sink_added_); |
237 sink_added_ = true; | 237 sink_added_ = true; |
238 | 238 |
239 frame_input_ = frame_input; | 239 frame_input_ = frame_input; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 } | 507 } |
508 | 508 |
509 void CastRtpStream::DidEncounterError(const std::string& message) { | 509 void CastRtpStream::DidEncounterError(const std::string& message) { |
510 // Save the WeakPtr first because the error callback might delete this object. | 510 // Save the WeakPtr first because the error callback might delete this object. |
511 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); | 511 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); |
512 error_callback_.Run(message); | 512 error_callback_.Run(message); |
513 content::RenderThread::Get()->GetMessageLoop()->PostTask( | 513 content::RenderThread::Get()->GetMessageLoop()->PostTask( |
514 FROM_HERE, | 514 FROM_HERE, |
515 base::Bind(&CastRtpStream::Stop, ptr)); | 515 base::Bind(&CastRtpStream::Stop, ptr)); |
516 } | 516 } |
OLD | NEW |