| 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 "media/cast/receiver/video_decoder.h" | 5 #include "media/cast/receiver/video_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // Note: Timestamp for the VideoFrame will be set in VideoReceiver. | 143 // Note: Timestamp for the VideoFrame will be set in VideoReceiver. |
| 144 const scoped_refptr<VideoFrame> decoded_frame = | 144 const scoped_refptr<VideoFrame> decoded_frame = |
| 145 VideoFrame::CreateFrame(VideoFrame::YV12, | 145 VideoFrame::CreateFrame(VideoFrame::YV12, |
| 146 frame_size, | 146 frame_size, |
| 147 gfx::Rect(frame_size), | 147 gfx::Rect(frame_size), |
| 148 frame_size, | 148 frame_size, |
| 149 base::TimeDelta()); | 149 base::TimeDelta()); |
| 150 CopyYPlane(image->planes[VPX_PLANE_Y], | 150 CopyYPlane(image->planes[VPX_PLANE_Y], |
| 151 image->stride[VPX_PLANE_Y], | 151 image->stride[VPX_PLANE_Y], |
| 152 image->d_h, | 152 image->d_h, |
| 153 decoded_frame); | 153 decoded_frame.get()); |
| 154 CopyUPlane(image->planes[VPX_PLANE_U], | 154 CopyUPlane(image->planes[VPX_PLANE_U], |
| 155 image->stride[VPX_PLANE_U], | 155 image->stride[VPX_PLANE_U], |
| 156 (image->d_h + 1) / 2, | 156 (image->d_h + 1) / 2, |
| 157 decoded_frame); | 157 decoded_frame.get()); |
| 158 CopyVPlane(image->planes[VPX_PLANE_V], | 158 CopyVPlane(image->planes[VPX_PLANE_V], |
| 159 image->stride[VPX_PLANE_V], | 159 image->stride[VPX_PLANE_V], |
| 160 (image->d_h + 1) / 2, | 160 (image->d_h + 1) / 2, |
| 161 decoded_frame); | 161 decoded_frame.get()); |
| 162 return decoded_frame; | 162 return decoded_frame; |
| 163 } | 163 } |
| 164 | 164 |
| 165 // VPX decoder context (i.e., an instantiation). | 165 // VPX decoder context (i.e., an instantiation). |
| 166 vpx_codec_ctx_t context_; | 166 vpx_codec_ctx_t context_; |
| 167 | 167 |
| 168 DISALLOW_COPY_AND_ASSIGN(Vp8Impl); | 168 DISALLOW_COPY_AND_ASSIGN(Vp8Impl); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 #ifndef OFFICIAL_BUILD | 171 #ifndef OFFICIAL_BUILD |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 break; | 231 break; |
| 232 default: | 232 default: |
| 233 NOTREACHED() << "Unknown or unspecified codec."; | 233 NOTREACHED() << "Unknown or unspecified codec."; |
| 234 break; | 234 break; |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 | 237 |
| 238 VideoDecoder::~VideoDecoder() {} | 238 VideoDecoder::~VideoDecoder() {} |
| 239 | 239 |
| 240 CastInitializationStatus VideoDecoder::InitializationResult() const { | 240 CastInitializationStatus VideoDecoder::InitializationResult() const { |
| 241 if (impl_) | 241 if (impl_.get()) |
| 242 return impl_->InitializationResult(); | 242 return impl_->InitializationResult(); |
| 243 return STATUS_UNSUPPORTED_VIDEO_CODEC; | 243 return STATUS_UNSUPPORTED_VIDEO_CODEC; |
| 244 } | 244 } |
| 245 | 245 |
| 246 void VideoDecoder::DecodeFrame( | 246 void VideoDecoder::DecodeFrame( |
| 247 scoped_ptr<EncodedFrame> encoded_frame, | 247 scoped_ptr<EncodedFrame> encoded_frame, |
| 248 const DecodeFrameCallback& callback) { | 248 const DecodeFrameCallback& callback) { |
| 249 DCHECK(encoded_frame.get()); | 249 DCHECK(encoded_frame.get()); |
| 250 DCHECK(!callback.is_null()); | 250 DCHECK(!callback.is_null()); |
| 251 if (!impl_ || impl_->InitializationResult() != STATUS_VIDEO_INITIALIZED) { | 251 if (!impl_.get() || |
| 252 impl_->InitializationResult() != STATUS_VIDEO_INITIALIZED) { |
| 252 callback.Run(make_scoped_refptr<VideoFrame>(NULL), false); | 253 callback.Run(make_scoped_refptr<VideoFrame>(NULL), false); |
| 253 return; | 254 return; |
| 254 } | 255 } |
| 255 cast_environment_->PostTask(CastEnvironment::VIDEO, | 256 cast_environment_->PostTask(CastEnvironment::VIDEO, |
| 256 FROM_HERE, | 257 FROM_HERE, |
| 257 base::Bind(&VideoDecoder::ImplBase::DecodeFrame, | 258 base::Bind(&VideoDecoder::ImplBase::DecodeFrame, |
| 258 impl_, | 259 impl_, |
| 259 base::Passed(&encoded_frame), | 260 base::Passed(&encoded_frame), |
| 260 callback)); | 261 callback)); |
| 261 } | 262 } |
| 262 | 263 |
| 263 } // namespace cast | 264 } // namespace cast |
| 264 } // namespace media | 265 } // namespace media |
| OLD | NEW |