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

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

Issue 14256013: Make more VideoDecoders reinitializable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/filters/decrypting_video_decoder_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/decrypting_video_decoder.h" 5 #include "media/filters/decrypting_video_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 21 matching lines...) Expand all
32 key_added_while_decode_pending_(false), 32 key_added_while_decode_pending_(false),
33 trace_id_(0) { 33 trace_id_(0) {
34 } 34 }
35 35
36 void DecryptingVideoDecoder::Initialize( 36 void DecryptingVideoDecoder::Initialize(
37 DemuxerStream* stream, 37 DemuxerStream* stream,
38 const PipelineStatusCB& status_cb, 38 const PipelineStatusCB& status_cb,
39 const StatisticsCB& statistics_cb) { 39 const StatisticsCB& statistics_cb) {
40 DVLOG(2) << "Initialize()"; 40 DVLOG(2) << "Initialize()";
41 DCHECK(message_loop_->BelongsToCurrentThread()); 41 DCHECK(message_loop_->BelongsToCurrentThread());
42 DCHECK_EQ(state_, kUninitialized) << state_; 42 DCHECK(state_ == kUninitialized ||
43 state_ == kIdle ||
44 state_ == kDecodeFinished) << state_;
45 DCHECK(read_cb_.is_null());
46 DCHECK(reset_cb_.is_null());
43 DCHECK(stream); 47 DCHECK(stream);
48
44 init_cb_ = BindToCurrentLoop(status_cb); 49 init_cb_ = BindToCurrentLoop(status_cb);
45 weak_this_ = weak_factory_.GetWeakPtr(); 50 weak_this_ = weak_factory_.GetWeakPtr();
51 demuxer_stream_ = stream;
52 statistics_cb_ = statistics_cb;
46 53
47 const VideoDecoderConfig& config = stream->video_decoder_config(); 54 const VideoDecoderConfig& config = demuxer_stream_->video_decoder_config();
48 if (!config.IsValidConfig()) { 55 DCHECK(config.IsValidConfig());
49 DLOG(ERROR) << "Invalid video stream config: " 56 DCHECK(config.is_encrypted());
50 << config.AsHumanReadableString(); 57
51 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_DECODE); 58 if (state_ == kUninitialized) {
59 state_ = kDecryptorRequested;
60 set_decryptor_ready_cb_.Run(BindToCurrentLoop(base::Bind(
61 &DecryptingVideoDecoder::SetDecryptor, weak_this_)));
52 return; 62 return;
53 } 63 }
54 64
55 // DecryptingVideoDecoder only accepts potentially encrypted stream. 65 // Reinitialization.
56 if (!config.is_encrypted()) { 66 decryptor_->DeinitializeDecoder(Decryptor::kVideo);
57 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); 67 state_ = kPendingDecoderInit;
58 return; 68 decryptor_->InitializeVideoDecoder(config, BindToCurrentLoop(base::Bind(
59 } 69 &DecryptingVideoDecoder::FinishInitialization, weak_this_)));
60
61 DCHECK(!demuxer_stream_);
62 demuxer_stream_ = stream;
63 statistics_cb_ = statistics_cb;
64
65 state_ = kDecryptorRequested;
66 set_decryptor_ready_cb_.Run(BindToCurrentLoop(base::Bind(
67 &DecryptingVideoDecoder::SetDecryptor, weak_this_)));
68 } 70 }
69 71
70 void DecryptingVideoDecoder::Read(const ReadCB& read_cb) { 72 void DecryptingVideoDecoder::Read(const ReadCB& read_cb) {
71 DVLOG(3) << "Read()"; 73 DVLOG(3) << "Read()";
72 DCHECK(message_loop_->BelongsToCurrentThread()); 74 DCHECK(message_loop_->BelongsToCurrentThread());
73 DCHECK(state_ == kIdle || 75 DCHECK(state_ == kIdle ||
74 state_ == kDecodeFinished || 76 state_ == kDecodeFinished ||
75 state_ == kError) << state_; 77 state_ == kError) << state_;
76 DCHECK(!read_cb.is_null()); 78 DCHECK(!read_cb.is_null());
77 CHECK(read_cb_.is_null()) << "Overlapping decodes are not supported."; 79 CHECK(read_cb_.is_null()) << "Overlapping decodes are not supported.";
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 403 }
402 404
403 void DecryptingVideoDecoder::DoReset() { 405 void DecryptingVideoDecoder::DoReset() {
404 DCHECK(init_cb_.is_null()); 406 DCHECK(init_cb_.is_null());
405 DCHECK(read_cb_.is_null()); 407 DCHECK(read_cb_.is_null());
406 state_ = kIdle; 408 state_ = kIdle;
407 base::ResetAndReturn(&reset_cb_).Run(); 409 base::ResetAndReturn(&reset_cb_).Run();
408 } 410 }
409 411
410 } // namespace media 412 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/filters/decrypting_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698