| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/video_receiver/video_decoder.h" | 5 #include "media/cast/video_receiver/video_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "media/cast/video_receiver/codecs/vp8/vp8_decoder.h" | 10 #include "media/cast/video_receiver/codecs/vp8/vp8_decoder.h" |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 namespace cast { | 13 namespace cast { |
| 14 | 14 |
| 15 VideoDecoder::VideoDecoder(const VideoReceiverConfig& video_config, | 15 VideoDecoder::VideoDecoder(const VideoReceiverConfig& video_config, |
| 16 scoped_refptr<CastEnvironment> cast_environment) | 16 scoped_refptr<CastEnvironment> cast_environment) |
| 17 : codec_(video_config.codec), | 17 : codec_(video_config.codec), |
| 18 vp8_decoder_() { | 18 vp8_decoder_() { |
| 19 switch (video_config.codec) { | 19 switch (video_config.codec) { |
| 20 case kVp8: | 20 case kVp8: |
| 21 // Initializing to use one core. | 21 vp8_decoder_.reset(new Vp8Decoder(cast_environment)); |
| 22 vp8_decoder_.reset(new Vp8Decoder(1, cast_environment)); | |
| 23 break; | 22 break; |
| 24 case kH264: | 23 case kH264: |
| 25 NOTIMPLEMENTED(); | 24 NOTIMPLEMENTED(); |
| 26 break; | 25 break; |
| 27 case kExternalVideo: | 26 case kExternalVideo: |
| 28 DCHECK(false) << "Invalid codec"; | 27 DCHECK(false) << "Invalid codec"; |
| 29 break; | 28 break; |
| 30 } | 29 } |
| 31 } | 30 } |
| 32 | 31 |
| 33 VideoDecoder::~VideoDecoder() {} | 32 VideoDecoder::~VideoDecoder() {} |
| 34 | 33 |
| 34 void VideoDecoder::InitDecoder() { |
| 35 // Initializing to use one core. |
| 36 vp8_decoder_->InitDecoder(); |
| 37 } |
| 38 |
| 35 bool VideoDecoder::DecodeVideoFrame(const EncodedVideoFrame* encoded_frame, | 39 bool VideoDecoder::DecodeVideoFrame(const EncodedVideoFrame* encoded_frame, |
| 36 const base::TimeTicks render_time, | 40 const base::TimeTicks render_time, |
| 37 const VideoFrameDecodedCallback& | 41 const VideoFrameDecodedCallback& |
| 38 frame_decoded_cb) { | 42 frame_decoded_cb) { |
| 39 DCHECK(encoded_frame->codec == codec_) << "Invalid codec"; | 43 DCHECK(encoded_frame->codec == codec_) << "Invalid codec"; |
| 40 DCHECK_GT(encoded_frame->data.size(), GG_UINT64_C(0)) << "Empty video frame"; | 44 DCHECK_GT(encoded_frame->data.size(), GG_UINT64_C(0)) << "Empty video frame"; |
| 41 return vp8_decoder_->Decode(encoded_frame, render_time, frame_decoded_cb); | 45 return vp8_decoder_->Decode(encoded_frame, render_time, frame_decoded_cb); |
| 42 } | 46 } |
| 43 | 47 |
| 44 } // namespace cast | 48 } // namespace cast |
| 45 } // namespace media | 49 } // namespace media |
| OLD | NEW |