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

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: Rebase 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
« no previous file with comments | « media/crypto/aes_decryptor_unittest.cc ('k') | media/filters/chunk_demuxer_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/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include <algorithm>
8 #include <deque>
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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 ChangeState_Locked(SHUTDOWN); 378 ChangeState_Locked(SHUTDOWN);
375 std::swap(read_cbs_, read_cbs); 379 std::swap(read_cbs_, read_cbs);
376 } 380 }
377 381
378 // Pass end of stream buffers to all callbacks to signal that no more data 382 // Pass end of stream buffers to all callbacks to signal that no more data
379 // will be sent. 383 // will be sent.
380 for (ReadCBQueue::iterator it = read_cbs.begin(); it != read_cbs.end(); ++it) 384 for (ReadCBQueue::iterator it = read_cbs.begin(); it != read_cbs.end(); ++it)
381 it->Run(DemuxerStream::kOk, StreamParserBuffer::CreateEOSBuffer()); 385 it->Run(DemuxerStream::kOk, StreamParserBuffer::CreateEOSBuffer());
382 } 386 }
383 387
384 // Helper function that makes sure |read_cb| runs on |message_loop|. 388 // Helper function that makes sure |read_cb| runs on |message_loop_proxy|.
385 static void RunOnMessageLoop(const DemuxerStream::ReadCB& read_cb, 389 static void RunOnMessageLoop(
386 MessageLoop* message_loop, 390 const DemuxerStream::ReadCB& read_cb,
387 DemuxerStream::Status status, 391 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy,
388 const scoped_refptr<DecoderBuffer>& buffer) { 392 DemuxerStream::Status status,
389 if (MessageLoop::current() != message_loop) { 393 const scoped_refptr<DecoderBuffer>& buffer) {
390 message_loop->PostTask(FROM_HERE, base::Bind( 394 if (!message_loop_proxy->BelongsToCurrentThread()) {
391 &RunOnMessageLoop, read_cb, message_loop, status, buffer)); 395 message_loop_proxy->PostTask(FROM_HERE, base::Bind(
396 &RunOnMessageLoop, read_cb, message_loop_proxy, status, buffer));
392 return; 397 return;
393 } 398 }
394 399
395 read_cb.Run(status, buffer); 400 read_cb.Run(status, buffer);
396 } 401 }
397 402
398 // DemuxerStream methods. 403 // DemuxerStream methods.
399 void ChunkDemuxerStream::Read(const ReadCB& read_cb) { 404 void ChunkDemuxerStream::Read(const ReadCB& read_cb) {
400 DemuxerStream::Status status = kOk; 405 DemuxerStream::Status status = kOk;
401 scoped_refptr<StreamParserBuffer> buffer; 406 scoped_refptr<StreamParserBuffer> buffer;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 state_ = state; 439 state_ = state;
435 } 440 }
436 441
437 ChunkDemuxerStream::~ChunkDemuxerStream() {} 442 ChunkDemuxerStream::~ChunkDemuxerStream() {}
438 443
439 void ChunkDemuxerStream::DeferRead_Locked(const ReadCB& read_cb) { 444 void ChunkDemuxerStream::DeferRead_Locked(const ReadCB& read_cb) {
440 lock_.AssertAcquired(); 445 lock_.AssertAcquired();
441 // Wrap & store |read_cb| so that it will 446 // Wrap & store |read_cb| so that it will
442 // get called on the current MessageLoop. 447 // get called on the current MessageLoop.
443 read_cbs_.push_back(base::Bind(&RunOnMessageLoop, read_cb, 448 read_cbs_.push_back(base::Bind(&RunOnMessageLoop, read_cb,
444 MessageLoop::current())); 449 base::MessageLoopProxy::current()));
445 } 450 }
446 451
447 void ChunkDemuxerStream::CreateReadDoneClosures_Locked(ClosureQueue* closures) { 452 void ChunkDemuxerStream::CreateReadDoneClosures_Locked(ClosureQueue* closures) {
448 lock_.AssertAcquired(); 453 lock_.AssertAcquired();
449 454
450 if (state_ != RETURNING_DATA_FOR_READS) 455 if (state_ != RETURNING_DATA_FOR_READS)
451 return; 456 return;
452 457
453 DemuxerStream::Status status; 458 DemuxerStream::Status status;
454 scoped_refptr<StreamParserBuffer> buffer; 459 scoped_refptr<StreamParserBuffer> buffer;
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 1155
1151 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const { 1156 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const {
1152 if (audio_ && !video_) 1157 if (audio_ && !video_)
1153 return audio_->GetBufferedRanges(duration_); 1158 return audio_->GetBufferedRanges(duration_);
1154 else if (!audio_ && video_) 1159 else if (!audio_ && video_)
1155 return video_->GetBufferedRanges(duration_); 1160 return video_->GetBufferedRanges(duration_);
1156 return ComputeIntersection(); 1161 return ComputeIntersection();
1157 } 1162 }
1158 1163
1159 } // namespace media 1164 } // namespace media
OLDNEW
« no previous file with comments | « media/crypto/aes_decryptor_unittest.cc ('k') | media/filters/chunk_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698