| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 ImplBase::cast_initialization_status_ = STATUS_VIDEO_INITIALIZED; | 113 ImplBase::cast_initialization_status_ = STATUS_VIDEO_INITIALIZED; |
| 114 } | 114 } |
| 115 | 115 |
| 116 private: | 116 private: |
| 117 virtual ~Vp8Impl() { | 117 virtual ~Vp8Impl() { |
| 118 if (ImplBase::cast_initialization_status_ == STATUS_VIDEO_INITIALIZED) | 118 if (ImplBase::cast_initialization_status_ == STATUS_VIDEO_INITIALIZED) |
| 119 CHECK_EQ(VPX_CODEC_OK, vpx_codec_destroy(&context_)); | 119 CHECK_EQ(VPX_CODEC_OK, vpx_codec_destroy(&context_)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 virtual scoped_refptr<VideoFrame> Decode(uint8* data, int len) OVERRIDE { | 122 virtual scoped_refptr<VideoFrame> Decode(uint8* data, int len) override { |
| 123 if (len <= 0 || vpx_codec_decode(&context_, | 123 if (len <= 0 || vpx_codec_decode(&context_, |
| 124 data, | 124 data, |
| 125 static_cast<unsigned int>(len), | 125 static_cast<unsigned int>(len), |
| 126 NULL, | 126 NULL, |
| 127 0) != VPX_CODEC_OK) { | 127 0) != VPX_CODEC_OK) { |
| 128 return NULL; | 128 return NULL; |
| 129 } | 129 } |
| 130 | 130 |
| 131 vpx_codec_iter_t iter = NULL; | 131 vpx_codec_iter_t iter = NULL; |
| 132 vpx_image_t* const image = vpx_codec_get_frame(&context_, &iter); | 132 vpx_image_t* const image = vpx_codec_get_frame(&context_, &iter); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 : ImplBase(cast_environment, CODEC_VIDEO_FAKE), | 176 : ImplBase(cast_environment, CODEC_VIDEO_FAKE), |
| 177 last_decoded_id_(-1) { | 177 last_decoded_id_(-1) { |
| 178 if (ImplBase::cast_initialization_status_ != STATUS_VIDEO_UNINITIALIZED) | 178 if (ImplBase::cast_initialization_status_ != STATUS_VIDEO_UNINITIALIZED) |
| 179 return; | 179 return; |
| 180 ImplBase::cast_initialization_status_ = STATUS_VIDEO_INITIALIZED; | 180 ImplBase::cast_initialization_status_ = STATUS_VIDEO_INITIALIZED; |
| 181 } | 181 } |
| 182 | 182 |
| 183 private: | 183 private: |
| 184 virtual ~FakeImpl() {} | 184 virtual ~FakeImpl() {} |
| 185 | 185 |
| 186 virtual scoped_refptr<VideoFrame> Decode(uint8* data, int len) OVERRIDE { | 186 virtual scoped_refptr<VideoFrame> Decode(uint8* data, int len) override { |
| 187 // Make sure this is a JSON string. | 187 // Make sure this is a JSON string. |
| 188 if (!len || data[0] != '{') | 188 if (!len || data[0] != '{') |
| 189 return NULL; | 189 return NULL; |
| 190 base::JSONReader reader; | 190 base::JSONReader reader; |
| 191 scoped_ptr<base::Value> values( | 191 scoped_ptr<base::Value> values( |
| 192 reader.Read(base::StringPiece(reinterpret_cast<char*>(data), len))); | 192 reader.Read(base::StringPiece(reinterpret_cast<char*>(data), len))); |
| 193 if (!values) | 193 if (!values) |
| 194 return NULL; | 194 return NULL; |
| 195 base::DictionaryValue* dict = NULL; | 195 base::DictionaryValue* dict = NULL; |
| 196 values->GetAsDictionary(&dict); | 196 values->GetAsDictionary(&dict); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 cast_environment_->PostTask(CastEnvironment::VIDEO, | 256 cast_environment_->PostTask(CastEnvironment::VIDEO, |
| 257 FROM_HERE, | 257 FROM_HERE, |
| 258 base::Bind(&VideoDecoder::ImplBase::DecodeFrame, | 258 base::Bind(&VideoDecoder::ImplBase::DecodeFrame, |
| 259 impl_, | 259 impl_, |
| 260 base::Passed(&encoded_frame), | 260 base::Passed(&encoded_frame), |
| 261 callback)); | 261 callback)); |
| 262 } | 262 } |
| 263 | 263 |
| 264 } // namespace cast | 264 } // namespace cast |
| 265 } // namespace media | 265 } // namespace media |
| OLD | NEW |