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

Side by Side Diff: media/filters/fake_video_decoder.cc

Issue 2650823006: media: Pass CdmContext in decoder reinitialization (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « media/filters/fake_video_decoder.h ('k') | media/filters/video_frame_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/filters/fake_video_decoder.h" 5 #include "media/filters/fake_video_decoder.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "media/base/bind_to_current_loop.h" 8 #include "media/base/bind_to_current_loop.h"
9 #include "media/base/test_helpers.h" 9 #include "media/base/test_helpers.h"
10 10
11 namespace media { 11 namespace media {
12 12
13 FakeVideoDecoder::FakeVideoDecoder(int decoding_delay, 13 FakeVideoDecoder::FakeVideoDecoder(int decoding_delay,
14 int max_parallel_decoding_requests, 14 int max_parallel_decoding_requests,
15 const BytesDecodedCB& bytes_decoded_cb) 15 const BytesDecodedCB& bytes_decoded_cb)
16 : decoding_delay_(decoding_delay), 16 : decoding_delay_(decoding_delay),
17 max_parallel_decoding_requests_(max_parallel_decoding_requests), 17 max_parallel_decoding_requests_(max_parallel_decoding_requests),
18 bytes_decoded_cb_(bytes_decoded_cb), 18 bytes_decoded_cb_(bytes_decoded_cb),
19 state_(STATE_UNINITIALIZED), 19 state_(STATE_UNINITIALIZED),
20 hold_decode_(false), 20 hold_decode_(false),
21 total_bytes_decoded_(0), 21 total_bytes_decoded_(0),
22 fail_to_initialize_(false), 22 fail_to_initialize_(false),
23 weak_factory_(this) { 23 weak_factory_(this) {
24 DVLOG(1) << __func__;
24 DCHECK_GE(decoding_delay, 0); 25 DCHECK_GE(decoding_delay, 0);
25 } 26 }
26 27
27 FakeVideoDecoder::~FakeVideoDecoder() { 28 FakeVideoDecoder::~FakeVideoDecoder() {
29 DVLOG(1) << __func__;
28 DCHECK(thread_checker_.CalledOnValidThread()); 30 DCHECK(thread_checker_.CalledOnValidThread());
29 31
30 if (state_ == STATE_UNINITIALIZED) 32 if (state_ == STATE_UNINITIALIZED)
31 return; 33 return;
32 34
33 if (!init_cb_.IsNull()) 35 if (!init_cb_.IsNull())
34 SatisfyInit(); 36 SatisfyInit();
35 if (!held_decode_callbacks_.empty()) 37 if (!held_decode_callbacks_.empty())
36 SatisfyDecode(); 38 SatisfyDecode();
37 if (!reset_cb_.IsNull()) 39 if (!reset_cb_.IsNull())
38 SatisfyReset(); 40 SatisfyReset();
39 41
40 decoded_frames_.clear(); 42 decoded_frames_.clear();
41 } 43 }
42 44
45 void FakeVideoDecoder::EnableEncryptedConfigSupport() {
46 supports_encrypted_config_ = true;
47 }
48
43 std::string FakeVideoDecoder::GetDisplayName() const { 49 std::string FakeVideoDecoder::GetDisplayName() const {
44 return "FakeVideoDecoder"; 50 return "FakeVideoDecoder";
45 } 51 }
46 52
47 void FakeVideoDecoder::Initialize(const VideoDecoderConfig& config, 53 void FakeVideoDecoder::Initialize(const VideoDecoderConfig& config,
48 bool low_delay, 54 bool low_delay,
49 CdmContext* /* cdm_context */, 55 CdmContext* cdm_context,
50 const InitCB& init_cb, 56 const InitCB& init_cb,
51 const OutputCB& output_cb) { 57 const OutputCB& output_cb) {
58 DVLOG(1) << __func__;
52 DCHECK(thread_checker_.CalledOnValidThread()); 59 DCHECK(thread_checker_.CalledOnValidThread());
53 DCHECK(config.IsValidConfig()); 60 DCHECK(config.IsValidConfig());
54 DCHECK(held_decode_callbacks_.empty()) 61 DCHECK(held_decode_callbacks_.empty())
55 << "No reinitialization during pending decode."; 62 << "No reinitialization during pending decode.";
56 DCHECK(reset_cb_.IsNull()) << "No reinitialization during pending reset."; 63 DCHECK(reset_cb_.IsNull()) << "No reinitialization during pending reset.";
57 64
58 current_config_ = config; 65 current_config_ = config;
59 init_cb_.SetCallback(BindToCurrentLoop(init_cb)); 66 init_cb_.SetCallback(BindToCurrentLoop(init_cb));
60 67
61 // Don't need BindToCurrentLoop() because |output_cb_| is only called from 68 // Don't need BindToCurrentLoop() because |output_cb_| is only called from
62 // RunDecodeCallback() which is posted from Decode(). 69 // RunDecodeCallback() which is posted from Decode().
63 output_cb_ = output_cb; 70 output_cb_ = output_cb;
64 71
65 if (!decoded_frames_.empty()) { 72 if (!decoded_frames_.empty()) {
66 DVLOG(1) << "Decoded frames dropped during reinitialization."; 73 DVLOG(1) << "Decoded frames dropped during reinitialization.";
67 decoded_frames_.clear(); 74 decoded_frames_.clear();
68 } 75 }
69 76
77 if (config.is_encrypted() && (!supports_encrypted_config_ || !cdm_context)) {
78 DVLOG(1) << "Encrypted config not supported.";
79 fail_to_initialize_ = true;
80 }
81
70 if (fail_to_initialize_) { 82 if (fail_to_initialize_) {
71 state_ = STATE_ERROR; 83 state_ = STATE_ERROR;
72 init_cb_.RunOrHold(false); 84 init_cb_.RunOrHold(false);
73 } else { 85 } else {
74 state_ = STATE_NORMAL; 86 state_ = STATE_NORMAL;
75 init_cb_.RunOrHold(true); 87 init_cb_.RunOrHold(true);
76 } 88 }
77 } 89 }
78 90
79 void FakeVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, 91 void FakeVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 264
253 void FakeVideoDecoder::DoReset() { 265 void FakeVideoDecoder::DoReset() {
254 DCHECK(thread_checker_.CalledOnValidThread()); 266 DCHECK(thread_checker_.CalledOnValidThread());
255 DCHECK(held_decode_callbacks_.empty()); 267 DCHECK(held_decode_callbacks_.empty());
256 DCHECK(!reset_cb_.IsNull()); 268 DCHECK(!reset_cb_.IsNull());
257 269
258 reset_cb_.RunOrHold(); 270 reset_cb_.RunOrHold();
259 } 271 }
260 272
261 } // namespace media 273 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/fake_video_decoder.h ('k') | media/filters/video_frame_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698