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

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

Issue 397953007: Fold DecryptingDemuxerStream::Stop() into the dtor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed 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 | Annotate | Revision Log
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_demuxer_stream.h" 5 #include "media/filters/decrypting_demuxer_stream.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/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 read_cb_ = BindToCurrentLoop(read_cb); 67 read_cb_ = BindToCurrentLoop(read_cb);
68 state_ = kPendingDemuxerRead; 68 state_ = kPendingDemuxerRead;
69 demuxer_stream_->Read( 69 demuxer_stream_->Read(
70 base::Bind(&DecryptingDemuxerStream::DecryptBuffer, weak_this_)); 70 base::Bind(&DecryptingDemuxerStream::DecryptBuffer, weak_this_));
71 } 71 }
72 72
73 void DecryptingDemuxerStream::Reset(const base::Closure& closure) { 73 void DecryptingDemuxerStream::Reset(const base::Closure& closure) {
74 DVLOG(2) << __FUNCTION__ << " - state: " << state_; 74 DVLOG(2) << __FUNCTION__ << " - state: " << state_;
75 DCHECK(task_runner_->BelongsToCurrentThread()); 75 DCHECK(task_runner_->BelongsToCurrentThread());
76 DCHECK(state_ != kUninitialized) << state_; 76 DCHECK(state_ != kUninitialized) << state_;
77 DCHECK(state_ != kStopped) << state_;
78 DCHECK(reset_cb_.is_null()); 77 DCHECK(reset_cb_.is_null());
79 78
80 reset_cb_ = BindToCurrentLoop(closure); 79 reset_cb_ = BindToCurrentLoop(closure);
81 80
82 // TODO(xhwang): This should not happen. Remove it, DCHECK against the 81 // TODO(xhwang): This should not happen. Remove it, DCHECK against the
83 // condition and clean up related tests. 82 // condition and clean up related tests.
84 if (state_ == kDecryptorRequested) { 83 if (state_ == kDecryptorRequested) {
85 DCHECK(!init_cb_.is_null()); 84 DCHECK(!init_cb_.is_null());
86 set_decryptor_ready_cb_.Run(DecryptorReadyCB()); 85 set_decryptor_ready_cb_.Run(DecryptorReadyCB());
87 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT); 86 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT);
(...skipping 15 matching lines...) Expand all
103 if (state_ == kWaitingForKey) { 102 if (state_ == kWaitingForKey) {
104 DCHECK(!read_cb_.is_null()); 103 DCHECK(!read_cb_.is_null());
105 pending_buffer_to_decrypt_ = NULL; 104 pending_buffer_to_decrypt_ = NULL;
106 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); 105 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL);
107 } 106 }
108 107
109 DCHECK(read_cb_.is_null()); 108 DCHECK(read_cb_.is_null());
110 DoReset(); 109 DoReset();
111 } 110 }
112 111
113 void DecryptingDemuxerStream::Stop() {
114 DVLOG(2) << __FUNCTION__ << " - state: " << state_;
115 DCHECK(task_runner_->BelongsToCurrentThread());
116 DCHECK(state_ != kUninitialized) << state_;
117
118 // Invalidate all weak pointers so that pending callbacks won't be fired into
119 // this object.
120 weak_factory_.InvalidateWeakPtrs();
121
122 // At this point the render thread is likely paused (in WebMediaPlayerImpl's
123 // Destroy()), so running |closure| can't wait for anything that requires the
124 // render thread to process messages to complete (such as PPAPI methods).
125 if (decryptor_) {
126 decryptor_->CancelDecrypt(GetDecryptorStreamType());
127 decryptor_ = NULL;
128 }
129 if (!set_decryptor_ready_cb_.is_null())
130 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB());
131 if (!init_cb_.is_null())
132 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT);
133 if (!read_cb_.is_null())
134 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL);
135 if (!reset_cb_.is_null())
136 base::ResetAndReturn(&reset_cb_).Run();
137 pending_buffer_to_decrypt_ = NULL;
138
139 state_ = kStopped;
140 }
141
142 AudioDecoderConfig DecryptingDemuxerStream::audio_decoder_config() { 112 AudioDecoderConfig DecryptingDemuxerStream::audio_decoder_config() {
143 DCHECK(state_ != kUninitialized && state_ != kDecryptorRequested) << state_; 113 DCHECK(state_ != kUninitialized && state_ != kDecryptorRequested) << state_;
144 CHECK_EQ(demuxer_stream_->type(), AUDIO); 114 CHECK_EQ(demuxer_stream_->type(), AUDIO);
145 return audio_config_; 115 return audio_config_;
146 } 116 }
147 117
148 VideoDecoderConfig DecryptingDemuxerStream::video_decoder_config() { 118 VideoDecoderConfig DecryptingDemuxerStream::video_decoder_config() {
149 DCHECK(state_ != kUninitialized && state_ != kDecryptorRequested) << state_; 119 DCHECK(state_ != kUninitialized && state_ != kDecryptorRequested) << state_;
150 CHECK_EQ(demuxer_stream_->type(), VIDEO); 120 CHECK_EQ(demuxer_stream_->type(), VIDEO);
151 return video_config_; 121 return video_config_;
(...skipping 11 matching lines...) Expand all
163 bool DecryptingDemuxerStream::SupportsConfigChanges() { 133 bool DecryptingDemuxerStream::SupportsConfigChanges() {
164 return demuxer_stream_->SupportsConfigChanges(); 134 return demuxer_stream_->SupportsConfigChanges();
165 } 135 }
166 136
167 VideoRotation DecryptingDemuxerStream::video_rotation() { 137 VideoRotation DecryptingDemuxerStream::video_rotation() {
168 return VIDEO_ROTATION_0; 138 return VIDEO_ROTATION_0;
169 } 139 }
170 140
171 DecryptingDemuxerStream::~DecryptingDemuxerStream() { 141 DecryptingDemuxerStream::~DecryptingDemuxerStream() {
172 DVLOG(2) << __FUNCTION__ << " : state_ = " << state_; 142 DVLOG(2) << __FUNCTION__ << " : state_ = " << state_;
143 DCHECK(task_runner_->BelongsToCurrentThread());
144
145 if (state_ == kUninitialized)
146 return;
147
148 if (decryptor_) {
149 decryptor_->CancelDecrypt(GetDecryptorStreamType());
150 decryptor_ = NULL;
151 }
152 if (!set_decryptor_ready_cb_.is_null())
153 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB());
154 if (!init_cb_.is_null())
155 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT);
156 if (!read_cb_.is_null())
157 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL);
158 if (!reset_cb_.is_null())
159 base::ResetAndReturn(&reset_cb_).Run();
160 pending_buffer_to_decrypt_ = NULL;
173 } 161 }
174 162
175 void DecryptingDemuxerStream::SetDecryptor(Decryptor* decryptor) { 163 void DecryptingDemuxerStream::SetDecryptor(Decryptor* decryptor) {
176 DVLOG(2) << __FUNCTION__; 164 DVLOG(2) << __FUNCTION__;
177 DCHECK(task_runner_->BelongsToCurrentThread()); 165 DCHECK(task_runner_->BelongsToCurrentThread());
178 DCHECK_EQ(state_, kDecryptorRequested) << state_; 166 DCHECK_EQ(state_, kDecryptorRequested) << state_;
179 DCHECK(!init_cb_.is_null()); 167 DCHECK(!init_cb_.is_null());
180 DCHECK(!set_decryptor_ready_cb_.is_null()); 168 DCHECK(!set_decryptor_ready_cb_.is_null());
181 169
182 set_decryptor_ready_cb_.Reset(); 170 set_decryptor_ready_cb_.Reset();
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 break; 381 break;
394 } 382 }
395 383
396 default: 384 default:
397 NOTREACHED(); 385 NOTREACHED();
398 return; 386 return;
399 } 387 }
400 } 388 }
401 389
402 } // namespace media 390 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decrypting_demuxer_stream.h ('k') | media/filters/decrypting_demuxer_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698