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 <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 TRACE_EVENT1("webrtc", "RemoteVideoSourceDelegate::RenderFrame", | 82 TRACE_EVENT1("webrtc", "RemoteVideoSourceDelegate::RenderFrame", |
83 "Ideal Render Instant", render_time.ToInternalValue()); | 83 "Ideal Render Instant", render_time.ToInternalValue()); |
84 | 84 |
85 CHECK_NE(media::kNoTimestamp(), incoming_timestamp); | 85 CHECK_NE(media::kNoTimestamp(), incoming_timestamp); |
86 if (start_timestamp_ == media::kNoTimestamp()) | 86 if (start_timestamp_ == media::kNoTimestamp()) |
87 start_timestamp_ = incoming_timestamp; | 87 start_timestamp_ = incoming_timestamp; |
88 const base::TimeDelta elapsed_timestamp = | 88 const base::TimeDelta elapsed_timestamp = |
89 incoming_timestamp - start_timestamp_; | 89 incoming_timestamp - start_timestamp_; |
90 | 90 |
91 scoped_refptr<media::VideoFrame> video_frame; | 91 scoped_refptr<media::VideoFrame> video_frame; |
92 if (incoming_frame.video_frame_buffer()->native_handle() != NULL) { | 92 scoped_refptr<webrtc::VideoFrameBuffer> buffer( |
93 incoming_frame.video_frame_buffer()); | |
94 | |
95 if (buffer->native_handle() != NULL) { | |
93 video_frame = | 96 video_frame = |
94 static_cast<media::VideoFrame*>( | 97 static_cast<media::VideoFrame*>(buffer->native_handle()); |
95 incoming_frame.video_frame_buffer()->native_handle()); | |
96 video_frame->set_timestamp(elapsed_timestamp); | 98 video_frame->set_timestamp(elapsed_timestamp); |
97 } else { | 99 } else { |
98 const cricket::VideoFrame* frame = | 100 buffer = |
99 incoming_frame.GetCopyWithRotationApplied(); | 101 incoming_frame.GetCopyWithRotationApplied()->video_frame_buffer(); |
nisse-chromium (ooo August 14)
2016/06/14 13:06:58
This looks a bit silly. Should there be a rotate m
| |
100 | 102 gfx::Size size(buffer->width(), buffer->height()); |
101 gfx::Size size(frame->width(), frame->height()); | |
102 | 103 |
103 // Make a shallow copy. Both |frame| and |video_frame| will share a single | 104 // Make a shallow copy. Both |frame| and |video_frame| will share a single |
104 // reference counted frame buffer. Const cast and hope no one will overwrite | 105 // reference counted frame buffer. Const cast and hope no one will overwrite |
105 // the data. | 106 // the data. |
106 // TODO(magjed): Update media::VideoFrame to support const data so we don't | 107 // TODO(magjed): Update media::VideoFrame to support const data so we don't |
107 // need to const cast here. | 108 // need to const cast here. |
108 video_frame = media::VideoFrame::WrapExternalYuvData( | 109 video_frame = media::VideoFrame::WrapExternalYuvData( |
109 media::PIXEL_FORMAT_YV12, size, gfx::Rect(size), size, | 110 media::PIXEL_FORMAT_YV12, size, gfx::Rect(size), size, |
110 frame->video_frame_buffer()->StrideY(), | 111 buffer->StrideY(), |
111 frame->video_frame_buffer()->StrideU(), | 112 buffer->StrideU(), |
112 frame->video_frame_buffer()->StrideV(), | 113 buffer->StrideV(), |
113 const_cast<uint8_t*>(frame->video_frame_buffer()->DataY()), | 114 const_cast<uint8_t*>(buffer->DataY()), |
114 const_cast<uint8_t*>(frame->video_frame_buffer()->DataU()), | 115 const_cast<uint8_t*>(buffer->DataU()), |
115 const_cast<uint8_t*>(frame->video_frame_buffer()->DataV()), | 116 const_cast<uint8_t*>(buffer->DataV()), |
116 elapsed_timestamp); | 117 elapsed_timestamp); |
117 if (!video_frame) | 118 if (!video_frame) |
118 return; | 119 return; |
119 video_frame->AddDestructionObserver( | 120 video_frame->AddDestructionObserver( |
120 base::Bind(&base::DeletePointer<cricket::VideoFrame>, frame->Copy())); | 121 base::Bind( |
122 &base::DeletePointer<scoped_refptr<webrtc::VideoFrameBuffer>>, | |
123 new scoped_refptr<webrtc::VideoFrameBuffer>(buffer))); | |
nisse-chromium (ooo August 14)
2016/06/14 13:06:58
There ought to be some better way to do this, with
perkj_chrome
2016/06/14 13:59:28
video_frame->AddDestructionObserver(
base:
nisse-chromium (ooo August 14)
2016/06/15 06:45:46
The compiler didn't like a lambda here, but bindin
| |
121 } | 124 } |
122 | 125 |
123 video_frame->metadata()->SetTimeTicks( | 126 video_frame->metadata()->SetTimeTicks( |
124 media::VideoFrameMetadata::REFERENCE_TIME, render_time); | 127 media::VideoFrameMetadata::REFERENCE_TIME, render_time); |
125 | 128 |
126 io_task_runner_->PostTask( | 129 io_task_runner_->PostTask( |
127 FROM_HERE, base::Bind(&RemoteVideoSourceDelegate::DoRenderFrameOnIOThread, | 130 FROM_HERE, base::Bind(&RemoteVideoSourceDelegate::DoRenderFrameOnIOThread, |
128 this, video_frame)); | 131 this, video_frame)); |
129 } | 132 } |
130 | 133 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 case webrtc::MediaStreamTrackInterface::kEnded: | 215 case webrtc::MediaStreamTrackInterface::kEnded: |
213 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); | 216 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); |
214 break; | 217 break; |
215 default: | 218 default: |
216 NOTREACHED(); | 219 NOTREACHED(); |
217 break; | 220 break; |
218 } | 221 } |
219 } | 222 } |
220 | 223 |
221 } // namespace content | 224 } // namespace content |
OLD | NEW |