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

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

Issue 712593003: Move key frame flag from StreamParserBuffer to DecoderBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 6 years, 1 month 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/chunk_demuxer_unittest.cc ('k') | media/filters/ffmpeg_demuxer.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_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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 237 }
238 238
239 DCHECK(buffer->decrypt_config()); 239 DCHECK(buffer->decrypt_config());
240 // An empty iv string signals that the frame is unencrypted. 240 // An empty iv string signals that the frame is unencrypted.
241 if (buffer->decrypt_config()->iv().empty()) { 241 if (buffer->decrypt_config()->iv().empty()) {
242 DVLOG(2) << "DoDecryptBuffer() - clear buffer."; 242 DVLOG(2) << "DoDecryptBuffer() - clear buffer.";
243 scoped_refptr<DecoderBuffer> decrypted = DecoderBuffer::CopyFrom( 243 scoped_refptr<DecoderBuffer> decrypted = DecoderBuffer::CopyFrom(
244 buffer->data(), buffer->data_size()); 244 buffer->data(), buffer->data_size());
245 decrypted->set_timestamp(buffer->timestamp()); 245 decrypted->set_timestamp(buffer->timestamp());
246 decrypted->set_duration(buffer->duration()); 246 decrypted->set_duration(buffer->duration());
247 if (buffer->is_key_frame())
248 decrypted->set_is_key_frame(true);
249
247 state_ = kIdle; 250 state_ = kIdle;
248 base::ResetAndReturn(&read_cb_).Run(kOk, decrypted); 251 base::ResetAndReturn(&read_cb_).Run(kOk, decrypted);
249 return; 252 return;
250 } 253 }
251 254
252 pending_buffer_to_decrypt_ = buffer; 255 pending_buffer_to_decrypt_ = buffer;
253 state_ = kPendingDecrypt; 256 state_ = kPendingDecrypt;
254 DecryptPendingBuffer(); 257 DecryptPendingBuffer();
255 } 258 }
256 259
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // The |state_| is still kPendingDecrypt. 303 // The |state_| is still kPendingDecrypt.
301 DecryptPendingBuffer(); 304 DecryptPendingBuffer();
302 return; 305 return;
303 } 306 }
304 307
305 state_ = kWaitingForKey; 308 state_ = kWaitingForKey;
306 return; 309 return;
307 } 310 }
308 311
309 DCHECK_EQ(status, Decryptor::kSuccess); 312 DCHECK_EQ(status, Decryptor::kSuccess);
313
314 // Copy the key frame flag from the encrypted to decrypted buffer, assuming
315 // that the decryptor initialized the flag to false.
316 if (pending_buffer_to_decrypt_->is_key_frame())
317 decrypted_buffer->set_is_key_frame(true);
318
310 pending_buffer_to_decrypt_ = NULL; 319 pending_buffer_to_decrypt_ = NULL;
311 state_ = kIdle; 320 state_ = kIdle;
312 base::ResetAndReturn(&read_cb_).Run(kOk, decrypted_buffer); 321 base::ResetAndReturn(&read_cb_).Run(kOk, decrypted_buffer);
313 } 322 }
314 323
315 void DecryptingDemuxerStream::OnKeyAdded() { 324 void DecryptingDemuxerStream::OnKeyAdded() {
316 DCHECK(task_runner_->BelongsToCurrentThread()); 325 DCHECK(task_runner_->BelongsToCurrentThread());
317 326
318 if (state_ == kPendingDecrypt) { 327 if (state_ == kPendingDecrypt) {
319 key_added_while_decrypt_pending_ = true; 328 key_added_while_decrypt_pending_ = true;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 break; 394 break;
386 } 395 }
387 396
388 default: 397 default:
389 NOTREACHED(); 398 NOTREACHED();
390 return; 399 return;
391 } 400 }
392 } 401 }
393 402
394 } // namespace media 403 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer_unittest.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698