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

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

Issue 10822026: Implement "Key Presence" step in "Encrypted Block Encounted" algorithm in EME. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unit test. Created 8 years, 4 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/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include <algorithm>
8 #include <deque>
scherkus (not reviewing) 2012/07/28 23:07:19 were these changes needed due to including m_l_p i
xhwang 2012/07/30 19:58:10 No, it's because of the "include-what-you-use" rul
9
7 #include "base/bind.h" 10 #include "base/bind.h"
8 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
12 #include "base/location.h"
9 #include "base/logging.h" 13 #include "base/logging.h"
10 #include "base/message_loop.h" 14 #include "base/message_loop_proxy.h"
11 #include "base/string_util.h" 15 #include "base/string_util.h"
12 #include "media/base/audio_decoder_config.h" 16 #include "media/base/audio_decoder_config.h"
13 #include "media/base/stream_parser_buffer.h" 17 #include "media/base/stream_parser_buffer.h"
14 #include "media/base/video_decoder_config.h" 18 #include "media/base/video_decoder_config.h"
15 #include "media/filters/chunk_demuxer_client.h" 19 #include "media/filters/chunk_demuxer_client.h"
16 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) 20 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
17 #include "media/mp4/mp4_stream_parser.h" 21 #include "media/mp4/mp4_stream_parser.h"
18 #endif 22 #endif
19 #include "media/webm/webm_stream_parser.h" 23 #include "media/webm/webm_stream_parser.h"
20 24
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 ChangeState_Locked(SHUTDOWN); 398 ChangeState_Locked(SHUTDOWN);
395 std::swap(read_cbs_, read_cbs); 399 std::swap(read_cbs_, read_cbs);
396 } 400 }
397 401
398 // Pass end of stream buffers to all callbacks to signal that no more data 402 // Pass end of stream buffers to all callbacks to signal that no more data
399 // will be sent. 403 // will be sent.
400 for (ReadCBQueue::iterator it = read_cbs.begin(); it != read_cbs.end(); ++it) 404 for (ReadCBQueue::iterator it = read_cbs.begin(); it != read_cbs.end(); ++it)
401 it->Run(DemuxerStream::kOk, StreamParserBuffer::CreateEOSBuffer()); 405 it->Run(DemuxerStream::kOk, StreamParserBuffer::CreateEOSBuffer());
402 } 406 }
403 407
404 // Helper function that makes sure |read_cb| runs on |message_loop|. 408 // Helper function that makes sure |read_cb| runs on |message_loop_proxy|.
405 static void RunOnMessageLoop(const DemuxerStream::ReadCB& read_cb, 409 static void RunOnMessageLoop(
406 MessageLoop* message_loop, 410 const DemuxerStream::ReadCB& read_cb,
407 DemuxerStream::Status status, 411 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy,
408 const scoped_refptr<DecoderBuffer>& buffer) { 412 DemuxerStream::Status status,
409 if (MessageLoop::current() != message_loop) { 413 const scoped_refptr<DecoderBuffer>& buffer) {
410 message_loop->PostTask(FROM_HERE, base::Bind( 414 if (!message_loop_proxy->BelongsToCurrentThread()) {
411 &RunOnMessageLoop, read_cb, message_loop, status, buffer)); 415 message_loop_proxy->PostTask(FROM_HERE, base::Bind(
416 &RunOnMessageLoop, read_cb, message_loop_proxy, status, buffer));
412 return; 417 return;
413 } 418 }
414 419
415 read_cb.Run(status, buffer); 420 read_cb.Run(status, buffer);
416 } 421 }
417 422
418 // DemuxerStream methods. 423 // DemuxerStream methods.
419 void ChunkDemuxerStream::Read(const ReadCB& read_cb) { 424 void ChunkDemuxerStream::Read(const ReadCB& read_cb) {
420 DemuxerStream::Status status = kOk; 425 DemuxerStream::Status status = kOk;
421 scoped_refptr<StreamParserBuffer> buffer; 426 scoped_refptr<StreamParserBuffer> buffer;
(...skipping 29 matching lines...) Expand all
451 state_ = state; 456 state_ = state;
452 } 457 }
453 458
454 ChunkDemuxerStream::~ChunkDemuxerStream() {} 459 ChunkDemuxerStream::~ChunkDemuxerStream() {}
455 460
456 void ChunkDemuxerStream::DeferRead_Locked(const ReadCB& read_cb) { 461 void ChunkDemuxerStream::DeferRead_Locked(const ReadCB& read_cb) {
457 lock_.AssertAcquired(); 462 lock_.AssertAcquired();
458 // Wrap & store |read_cb| so that it will 463 // Wrap & store |read_cb| so that it will
459 // get called on the current MessageLoop. 464 // get called on the current MessageLoop.
460 read_cbs_.push_back(base::Bind(&RunOnMessageLoop, read_cb, 465 read_cbs_.push_back(base::Bind(&RunOnMessageLoop, read_cb,
461 MessageLoop::current())); 466 base::MessageLoopProxy::current()));
462 } 467 }
463 468
464 void ChunkDemuxerStream::CreateReadDoneClosures_Locked(ClosureQueue* closures) { 469 void ChunkDemuxerStream::CreateReadDoneClosures_Locked(ClosureQueue* closures) {
465 lock_.AssertAcquired(); 470 lock_.AssertAcquired();
466 471
467 if (state_ != RETURNING_DATA_FOR_READS) 472 if (state_ != RETURNING_DATA_FOR_READS)
468 return; 473 return;
469 474
470 DemuxerStream::Status status; 475 DemuxerStream::Status status;
471 scoped_refptr<StreamParserBuffer> buffer; 476 scoped_refptr<StreamParserBuffer> buffer;
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 video_->SetStartTime(start_time_); 1066 video_->SetStartTime(start_time_);
1062 video_->Seek(start_time_); 1067 video_->Seek(start_time_);
1063 } 1068 }
1064 1069
1065 // The demuxer is now initialized after the |start_timestamp_| was set. 1070 // The demuxer is now initialized after the |start_timestamp_| was set.
1066 ChangeState_Locked(INITIALIZED); 1071 ChangeState_Locked(INITIALIZED);
1067 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); 1072 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK);
1068 } 1073 }
1069 1074
1070 } // namespace media 1075 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698