Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: media/cast/receiver/video_decoder.cc

Issue 362123005: Cast: Update simulator tool with more inputs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Diff Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.
188 if (!len || data[0] != '{')
189 return NULL;
187 base::JSONReader reader; 190 base::JSONReader reader;
188 scoped_ptr<base::Value> values( 191 scoped_ptr<base::Value> values(
189 reader.Read(base::StringPiece(reinterpret_cast<char*>(data)))); 192 reader.Read(base::StringPiece(reinterpret_cast<char*>(data), len)));
193 if (!values)
194 return NULL;
190 base::DictionaryValue* dict = NULL; 195 base::DictionaryValue* dict = NULL;
191 values->GetAsDictionary(&dict); 196 values->GetAsDictionary(&dict);
192 197
193 bool key = false; 198 bool key = false;
194 int id = 0; 199 int id = 0;
195 int ref = 0; 200 int ref = 0;
196 dict->GetBoolean("key", &key); 201 dict->GetBoolean("key", &key);
197 dict->GetInteger("id", &id); 202 dict->GetInteger("id", &id);
198 dict->GetInteger("ref", &ref); 203 dict->GetInteger("ref", &ref);
199 DCHECK(id == last_decoded_id_ + 1); 204 DCHECK(id == last_decoded_id_ + 1);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 cast_environment_->PostTask(CastEnvironment::VIDEO, 255 cast_environment_->PostTask(CastEnvironment::VIDEO,
251 FROM_HERE, 256 FROM_HERE,
252 base::Bind(&VideoDecoder::ImplBase::DecodeFrame, 257 base::Bind(&VideoDecoder::ImplBase::DecodeFrame,
253 impl_, 258 impl_,
254 base::Passed(&encoded_frame), 259 base::Passed(&encoded_frame),
255 callback)); 260 callback));
256 } 261 }
257 262
258 } // namespace cast 263 } // namespace cast
259 } // namespace media 264 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698