| // Copyright 2013 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "media/cast/video_receiver/video_decoder.h" |
| |
| #include "base/bind.h" |
| #include "base/logging.h" |
| #include "base/message_loop/message_loop.h" |
| #include "media/cast/video_receiver/codecs/vp8/vp8_decoder.h" |
| |
| namespace media { |
| namespace cast { |
| |
| VideoDecoder::VideoDecoder(const VideoReceiverConfig& video_config) |
| : codec_(video_config.codec), |
| vp8_decoder_() { |
| switch (video_config.codec) { |
| case kVp8: |
| // Initializing to use one core. |
| vp8_decoder_.reset(new Vp8Decoder(1)); |
| break; |
| case kH264: |
| NOTIMPLEMENTED(); |
| break; |
| case kExternalVideo: |
| DCHECK(false) << "Invalid codec"; |
| break; |
| } |
| } |
| |
| VideoDecoder::~VideoDecoder() {} |
| |
| bool VideoDecoder::DecodeVideoFrame( |
| const EncodedVideoFrame* encoded_frame, |
| const base::TimeTicks render_time, |
| I420VideoFrame* video_frame) { |
| DCHECK(encoded_frame->codec == codec_) << "Invalid codec"; |
| DCHECK_GT(encoded_frame->data.size(), GG_UINT64_C(0)) << "Empty video frame"; |
| return vp8_decoder_->Decode(*encoded_frame, video_frame); |
| } |
| |
| } // namespace cast |
| } // namespace media |