OLD | NEW |
---|---|
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/media_stream_remote_video_source.h" | 5 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 const VideoCaptureDeliverFrameCB& new_frame_callback) | 55 const VideoCaptureDeliverFrameCB& new_frame_callback) |
56 : io_task_runner_(io_task_runner), frame_callback_(new_frame_callback) { | 56 : io_task_runner_(io_task_runner), frame_callback_(new_frame_callback) { |
57 } | 57 } |
58 | 58 |
59 MediaStreamRemoteVideoSource:: | 59 MediaStreamRemoteVideoSource:: |
60 RemoteVideoSourceDelegate::~RemoteVideoSourceDelegate() { | 60 RemoteVideoSourceDelegate::~RemoteVideoSourceDelegate() { |
61 } | 61 } |
62 | 62 |
63 void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::RenderFrame( | 63 void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::RenderFrame( |
64 const cricket::VideoFrame* incoming_frame) { | 64 const cricket::VideoFrame* incoming_frame) { |
65 TRACE_EVENT0("webrtc", "RemoteVideoSourceDelegate::RenderFrame"); | 65 TRACE_EVENT_BEGIN0("webrtc", "RemoteVideoSourceDelegate::RenderFrame"); |
DaleCurtis
2015/07/31 17:48:27
Ditto.
qiangchen
2015/07/31 20:06:07
Done.
| |
66 base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds( | 66 base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds( |
67 incoming_frame->GetElapsedTime() / rtc::kNumNanosecsPerMicrosec); | 67 incoming_frame->GetElapsedTime() / rtc::kNumNanosecsPerMicrosec); |
68 | 68 |
69 scoped_refptr<media::VideoFrame> video_frame; | 69 scoped_refptr<media::VideoFrame> video_frame; |
70 if (incoming_frame->GetNativeHandle() != NULL) { | 70 if (incoming_frame->GetNativeHandle() != NULL) { |
71 video_frame = | 71 video_frame = |
72 static_cast<media::VideoFrame*>(incoming_frame->GetNativeHandle()); | 72 static_cast<media::VideoFrame*>(incoming_frame->GetNativeHandle()); |
73 video_frame->set_timestamp(timestamp); | 73 video_frame->set_timestamp(timestamp); |
74 } else { | 74 } else { |
75 const cricket::VideoFrame* frame = | 75 const cricket::VideoFrame* frame = |
(...skipping 13 matching lines...) Expand all Loading... | |
89 video_frame = media::VideoFrame::WrapExternalYuvData( | 89 video_frame = media::VideoFrame::WrapExternalYuvData( |
90 media::PIXEL_FORMAT_YV12, size, gfx::Rect(size), size, | 90 media::PIXEL_FORMAT_YV12, size, gfx::Rect(size), size, |
91 frame->GetYPitch(), frame->GetUPitch(), frame->GetVPitch(), | 91 frame->GetYPitch(), frame->GetUPitch(), frame->GetVPitch(), |
92 const_cast<uint8_t*>(frame->GetYPlane()), | 92 const_cast<uint8_t*>(frame->GetYPlane()), |
93 const_cast<uint8_t*>(frame->GetUPlane()), | 93 const_cast<uint8_t*>(frame->GetUPlane()), |
94 const_cast<uint8_t*>(frame->GetVPlane()), timestamp); | 94 const_cast<uint8_t*>(frame->GetVPlane()), timestamp); |
95 video_frame->AddDestructionObserver( | 95 video_frame->AddDestructionObserver( |
96 base::Bind(&base::DeletePointer<cricket::VideoFrame>, frame->Copy())); | 96 base::Bind(&base::DeletePointer<cricket::VideoFrame>, frame->Copy())); |
97 } | 97 } |
98 | 98 |
99 base::TimeTicks render_time = | |
100 base::TimeTicks::FromInternalValue(incoming_frame->GetTimeStamp() / 1000); | |
DaleCurtis
2015/07/31 17:48:27
This still isn't correct unless the value returned
qiangchen
2015/07/31 20:06:07
This is a good point. The timestamp is from WebRTC
DaleCurtis
2015/08/03 21:08:04
If they're the same then using FromMicroseconds()
| |
101 video_frame->metadata()->SetTimeTicks( | |
102 media::VideoFrameMetadata::REFERENCE_TIME, | |
103 render_time); | |
104 | |
105 TRACE_EVENT_END1("webrtc", "RemoteVideoSourceDelegate::RenderFrame", | |
106 "Ideal Render Instant", render_time.ToInternalValue()); | |
107 | |
99 io_task_runner_->PostTask( | 108 io_task_runner_->PostTask( |
100 FROM_HERE, base::Bind(&RemoteVideoSourceDelegate::DoRenderFrameOnIOThread, | 109 FROM_HERE, base::Bind(&RemoteVideoSourceDelegate::DoRenderFrameOnIOThread, |
101 this, video_frame)); | 110 this, video_frame)); |
102 } | 111 } |
103 | 112 |
104 void MediaStreamRemoteVideoSource:: | 113 void MediaStreamRemoteVideoSource:: |
105 RemoteVideoSourceDelegate::DoRenderFrameOnIOThread( | 114 RemoteVideoSourceDelegate::DoRenderFrameOnIOThread( |
106 const scoped_refptr<media::VideoFrame>& video_frame) { | 115 const scoped_refptr<media::VideoFrame>& video_frame) { |
107 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 116 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
108 TRACE_EVENT0("webrtc", "RemoteVideoSourceDelegate::DoRenderFrameOnIOThread"); | 117 TRACE_EVENT0("webrtc", "RemoteVideoSourceDelegate::DoRenderFrameOnIOThread"); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 case webrtc::MediaStreamTrackInterface::kEnded: | 184 case webrtc::MediaStreamTrackInterface::kEnded: |
176 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); | 185 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); |
177 break; | 186 break; |
178 default: | 187 default: |
179 NOTREACHED(); | 188 NOTREACHED(); |
180 break; | 189 break; |
181 } | 190 } |
182 } | 191 } |
183 | 192 |
184 } // namespace content | 193 } // namespace content |
OLD | NEW |