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

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

Issue 10969028: Add video decoding methods in Decryptor and add DecryptingVideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reorder methods in the unittest Created 8 years, 2 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 | « media/filters/decrypting_video_decoder_unittest.cc ('k') | media/media.gyp » ('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/ffmpeg_video_decoder.h" 5 #include "media/filters/ffmpeg_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 &FFmpegVideoDecoder::DoRead, this, read_cb)); 172 &FFmpegVideoDecoder::DoRead, this, read_cb));
173 } 173 }
174 174
175 void FFmpegVideoDecoder::Reset(const base::Closure& closure) { 175 void FFmpegVideoDecoder::Reset(const base::Closure& closure) {
176 if (!message_loop_->BelongsToCurrentThread()) { 176 if (!message_loop_->BelongsToCurrentThread()) {
177 message_loop_->PostTask(FROM_HERE, base::Bind( 177 message_loop_->PostTask(FROM_HERE, base::Bind(
178 &FFmpegVideoDecoder::Reset, this, closure)); 178 &FFmpegVideoDecoder::Reset, this, closure));
179 return; 179 return;
180 } 180 }
181 181
182 DCHECK(reset_cb_.is_null());
183 reset_cb_ = closure;
184
182 if (decryptor_) 185 if (decryptor_)
183 decryptor_->CancelDecrypt(); 186 decryptor_->CancelDecrypt();
184 187
185 reset_cb_ = closure;
186
187 // Defer the reset if a read is pending. 188 // Defer the reset if a read is pending.
188 if (!read_cb_.is_null()) 189 if (!read_cb_.is_null())
189 return; 190 return;
190 191
191 DoReset(); 192 DoReset();
192 } 193 }
193 194
194 void FFmpegVideoDecoder::DoReset() { 195 void FFmpegVideoDecoder::DoReset() {
195 DCHECK(read_cb_.is_null()); 196 DCHECK(read_cb_.is_null());
196 197
197 avcodec_flush_buffers(codec_context_); 198 avcodec_flush_buffers(codec_context_);
198 state_ = kNormal; 199 state_ = kNormal;
199 reset_cb_.Run(); 200 reset_cb_.Run();
200 reset_cb_.Reset(); 201 reset_cb_.Reset();
201 } 202 }
202 203
203 void FFmpegVideoDecoder::Stop(const base::Closure& closure) { 204 void FFmpegVideoDecoder::Stop(const base::Closure& closure) {
204 if (!message_loop_->BelongsToCurrentThread()) { 205 if (!message_loop_->BelongsToCurrentThread()) {
205 message_loop_->PostTask(FROM_HERE, base::Bind( 206 message_loop_->PostTask(FROM_HERE, base::Bind(
206 &FFmpegVideoDecoder::Stop, this, closure)); 207 &FFmpegVideoDecoder::Stop, this, closure));
207 return; 208 return;
208 } 209 }
209 210
211 DCHECK(stop_cb_.is_null());
212
210 if (state_ == kUninitialized) { 213 if (state_ == kUninitialized) {
211 closure.Run(); 214 closure.Run();
212 return; 215 return;
213 } 216 }
214 217
218 stop_cb_ = closure;
219
215 if (decryptor_) 220 if (decryptor_)
216 decryptor_->CancelDecrypt(); 221 decryptor_->CancelDecrypt();
217 222
218 stop_cb_ = closure;
219
220 // Defer stopping if a read is pending. 223 // Defer stopping if a read is pending.
221 if (!read_cb_.is_null()) 224 if (!read_cb_.is_null())
222 return; 225 return;
223 226
224 DoStop(); 227 DoStop();
225 } 228 }
226 229
227 void FFmpegVideoDecoder::DoStop() { 230 void FFmpegVideoDecoder::DoStop() {
228 ReleaseFFmpegResources(); 231 ReleaseFFmpegResources();
229 state_ = kUninitialized; 232 state_ = kUninitialized;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) { 541 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) {
539 ReleaseFFmpegResources(); 542 ReleaseFFmpegResources();
540 return false; 543 return false;
541 } 544 }
542 545
543 av_frame_ = avcodec_alloc_frame(); 546 av_frame_ = avcodec_alloc_frame();
544 return true; 547 return true;
545 } 548 }
546 549
547 } // namespace media 550 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decrypting_video_decoder_unittest.cc ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698