| OLD | NEW |
| 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> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 detected_video_track_count_(0), | 417 detected_video_track_count_(0), |
| 418 detected_text_track_count_(0) { | 418 detected_text_track_count_(0) { |
| 419 DCHECK(!open_cb_.is_null()); | 419 DCHECK(!open_cb_.is_null()); |
| 420 DCHECK(!encrypted_media_init_data_cb_.is_null()); | 420 DCHECK(!encrypted_media_init_data_cb_.is_null()); |
| 421 } | 421 } |
| 422 | 422 |
| 423 std::string ChunkDemuxer::GetDisplayName() const { | 423 std::string ChunkDemuxer::GetDisplayName() const { |
| 424 return "ChunkDemuxer"; | 424 return "ChunkDemuxer"; |
| 425 } | 425 } |
| 426 | 426 |
| 427 void ChunkDemuxer::Initialize( | 427 void ChunkDemuxer::Initialize(DemuxerHost* host, |
| 428 DemuxerHost* host, | 428 const PipelineStatusCB& init_cb, |
| 429 const PipelineStatusCB& cb, | 429 bool enable_text_tracks) { |
| 430 bool enable_text_tracks) { | |
| 431 DVLOG(1) << "Init()"; | 430 DVLOG(1) << "Init()"; |
| 432 | 431 |
| 433 base::AutoLock auto_lock(lock_); | 432 base::AutoLock auto_lock(lock_); |
| 434 | |
| 435 // The |init_cb_| must only be run after this method returns, so always post. | |
| 436 init_cb_ = BindToCurrentLoop(cb); | |
| 437 if (state_ == SHUTDOWN) { | 433 if (state_ == SHUTDOWN) { |
| 438 base::ResetAndReturn(&init_cb_).Run(DEMUXER_ERROR_COULD_NOT_OPEN); | 434 // Init cb must only be run after this method returns, so post. |
| 435 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 436 FROM_HERE, base::Bind(init_cb, DEMUXER_ERROR_COULD_NOT_OPEN)); |
| 439 return; | 437 return; |
| 440 } | 438 } |
| 439 |
| 441 DCHECK_EQ(state_, WAITING_FOR_INIT); | 440 DCHECK_EQ(state_, WAITING_FOR_INIT); |
| 442 host_ = host; | 441 host_ = host; |
| 442 // Do not post init_cb once this function returns because if there is an |
| 443 // error after initialization, the error might be reported before init_cb |
| 444 // has a chance to run. This is because ChunkDemuxer::ReportError_Locked |
| 445 // directly calls DemuxerHost::OnDemuxerError: crbug.com/633016. |
| 446 init_cb_ = init_cb; |
| 443 enable_text_ = enable_text_tracks; | 447 enable_text_ = enable_text_tracks; |
| 444 | 448 |
| 445 ChangeState_Locked(INITIALIZING); | 449 ChangeState_Locked(INITIALIZING); |
| 446 | 450 |
| 447 base::ResetAndReturn(&open_cb_).Run(); | 451 base::ResetAndReturn(&open_cb_).Run(); |
| 448 } | 452 } |
| 449 | 453 |
| 450 void ChunkDemuxer::Stop() { | 454 void ChunkDemuxer::Stop() { |
| 451 DVLOG(1) << "Stop()"; | 455 DVLOG(1) << "Stop()"; |
| 452 Shutdown(); | 456 Shutdown(); |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 } | 1313 } |
| 1310 | 1314 |
| 1311 void ChunkDemuxer::ShutdownAllStreams() { | 1315 void ChunkDemuxer::ShutdownAllStreams() { |
| 1312 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); | 1316 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); |
| 1313 ++itr) { | 1317 ++itr) { |
| 1314 itr->second->Shutdown(); | 1318 itr->second->Shutdown(); |
| 1315 } | 1319 } |
| 1316 } | 1320 } |
| 1317 | 1321 |
| 1318 } // namespace media | 1322 } // namespace media |
| OLD | NEW |