| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/video_track_recorder.h" | 5 #include "content/renderer/media/video_track_recorder.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // Cache the thread sending frames on first frame arrival. | 198 // Cache the thread sending frames on first frame arrival. |
| 199 if (!origin_task_runner_.get()) | 199 if (!origin_task_runner_.get()) |
| 200 origin_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 200 origin_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 201 DCHECK(origin_task_runner_->BelongsToCurrentThread()); | 201 DCHECK(origin_task_runner_->BelongsToCurrentThread()); |
| 202 if (paused_) | 202 if (paused_) |
| 203 return; | 203 return; |
| 204 | 204 |
| 205 if (!(video_frame->format() == media::PIXEL_FORMAT_I420 || | 205 if (!(video_frame->format() == media::PIXEL_FORMAT_I420 || |
| 206 video_frame->format() == media::PIXEL_FORMAT_YV12 || | 206 video_frame->format() == media::PIXEL_FORMAT_YV12 || |
| 207 video_frame->format() == media::PIXEL_FORMAT_ARGB || | 207 video_frame->format() == media::PIXEL_FORMAT_ARGB || |
| 208 video_frame->format() == media::PIXEL_FORMAT_YV12A)) { | 208 video_frame->format() == media::PIXEL_FORMAT_YV12A || |
| 209 video_frame->format() == media::PIXEL_FORMAT_Y16)) { |
| 209 NOTREACHED() << media::VideoPixelFormatToString(video_frame->format()); | 210 NOTREACHED() << media::VideoPixelFormatToString(video_frame->format()); |
| 210 return; | 211 return; |
| 211 } | 212 } |
| 212 | 213 |
| 213 if (video_frame->HasTextures()) { | 214 if (video_frame->HasTextures() || |
| 215 video_frame->format() == media::PIXEL_FORMAT_Y16) { |
| 214 main_task_runner_->PostTask( | 216 main_task_runner_->PostTask( |
| 215 FROM_HERE, base::Bind(&Encoder::RetrieveFrameOnMainThread, this, | 217 FROM_HERE, base::Bind(&Encoder::RetrieveFrameOnMainThread, this, |
| 216 video_frame, capture_timestamp)); | 218 video_frame, capture_timestamp)); |
| 217 return; | 219 return; |
| 218 } | 220 } |
| 219 | 221 |
| 220 scoped_refptr<media::VideoFrame> frame = video_frame; | 222 scoped_refptr<media::VideoFrame> frame = video_frame; |
| 221 // Drop alpha channel since we do not support it yet. | 223 // Drop alpha channel since we do not support it yet. |
| 222 if (frame->format() == media::PIXEL_FORMAT_YV12A) | 224 if (frame->format() == media::PIXEL_FORMAT_YV12A) |
| 223 frame = media::WrapAsI420VideoFrame(video_frame); | 225 frame = media::WrapAsI420VideoFrame(video_frame); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 238 ContextProviderCommandBuffer* const context_provider = | 240 ContextProviderCommandBuffer* const context_provider = |
| 239 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 241 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
| 240 if (!context_provider) { | 242 if (!context_provider) { |
| 241 // Send black frames (yuv = {0, 127, 127}). | 243 // Send black frames (yuv = {0, 127, 127}). |
| 242 frame = media::VideoFrame::CreateColorFrame( | 244 frame = media::VideoFrame::CreateColorFrame( |
| 243 video_frame->visible_rect().size(), 0u, 0x80, 0x80, | 245 video_frame->visible_rect().size(), 0u, 0x80, 0x80, |
| 244 video_frame->timestamp()); | 246 video_frame->timestamp()); |
| 245 } else { | 247 } else { |
| 246 // Accelerated decoders produce ARGB/ABGR texture-backed frames (see | 248 // Accelerated decoders produce ARGB/ABGR texture-backed frames (see |
| 247 // https://crbug.com/585242), fetch them using a SkCanvasVideoRenderer. | 249 // https://crbug.com/585242), fetch them using a SkCanvasVideoRenderer. |
| 248 DCHECK(video_frame->HasTextures()); | 250 // Y16 CPU and GPU frames are using the same path for copying to RGBA. |
| 249 DCHECK_EQ(media::PIXEL_FORMAT_ARGB, video_frame->format()); | 251 DCHECK((video_frame->HasTextures() && |
| 252 video_frame->format() == media::PIXEL_FORMAT_ARGB) || |
| 253 video_frame->format() == media::PIXEL_FORMAT_Y16); |
| 250 | 254 |
| 251 frame = media::VideoFrame::CreateFrame( | 255 frame = media::VideoFrame::CreateFrame( |
| 252 media::PIXEL_FORMAT_I420, video_frame->coded_size(), | 256 media::PIXEL_FORMAT_I420, video_frame->coded_size(), |
| 253 video_frame->visible_rect(), video_frame->natural_size(), | 257 video_frame->visible_rect(), video_frame->natural_size(), |
| 254 video_frame->timestamp()); | 258 video_frame->timestamp()); |
| 255 | 259 |
| 256 const SkImageInfo info = SkImageInfo::MakeN32( | 260 const SkImageInfo info = SkImageInfo::MakeN32( |
| 257 frame->visible_rect().width(), frame->visible_rect().height(), | 261 frame->visible_rect().width(), frame->visible_rect().height(), |
| 258 kOpaque_SkAlphaType); | 262 kOpaque_SkAlphaType); |
| 259 | 263 |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 encoder_->SetPaused(paused_before_init_); | 1144 encoder_->SetPaused(paused_before_init_); |
| 1141 | 1145 |
| 1142 // StartFrameEncode() will be called on Render IO thread. | 1146 // StartFrameEncode() will be called on Render IO thread. |
| 1143 MediaStreamVideoSink::ConnectToTrack( | 1147 MediaStreamVideoSink::ConnectToTrack( |
| 1144 track_, | 1148 track_, |
| 1145 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_), | 1149 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_), |
| 1146 false); | 1150 false); |
| 1147 } | 1151 } |
| 1148 | 1152 |
| 1149 } // namespace content | 1153 } // namespace content |
| OLD | NEW |