| 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 <list> | 9 #include <list> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, | 358 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, |
| 359 const scoped_refptr<MediaLog>& media_log, | 359 const scoped_refptr<MediaLog>& media_log, |
| 360 bool splice_frames_enabled) | 360 bool splice_frames_enabled) |
| 361 : state_(WAITING_FOR_INIT), | 361 : state_(WAITING_FOR_INIT), |
| 362 cancel_next_seek_(false), | 362 cancel_next_seek_(false), |
| 363 host_(NULL), | 363 host_(NULL), |
| 364 open_cb_(open_cb), | 364 open_cb_(open_cb), |
| 365 encrypted_media_init_data_cb_(encrypted_media_init_data_cb), | 365 encrypted_media_init_data_cb_(encrypted_media_init_data_cb), |
| 366 enable_text_(false), | 366 enable_text_(false), |
| 367 media_log_(media_log), | 367 media_log_(media_log), |
| 368 pending_source_init_done_count_(0), |
| 368 duration_(kNoTimestamp()), | 369 duration_(kNoTimestamp()), |
| 369 user_specified_duration_(-1), | 370 user_specified_duration_(-1), |
| 370 liveness_(DemuxerStream::LIVENESS_UNKNOWN), | 371 liveness_(DemuxerStream::LIVENESS_UNKNOWN), |
| 371 splice_frames_enabled_(splice_frames_enabled), | 372 splice_frames_enabled_(splice_frames_enabled), |
| 372 detected_audio_track_count_(0), | 373 detected_audio_track_count_(0), |
| 373 detected_video_track_count_(0), | 374 detected_video_track_count_(0), |
| 374 detected_text_track_count_(0) { | 375 detected_text_track_count_(0) { |
| 375 DCHECK(!open_cb_.is_null()); | 376 DCHECK(!open_cb_.is_null()); |
| 376 DCHECK(!encrypted_media_init_data_cb_.is_null()); | 377 DCHECK(!encrypted_media_init_data_cb_.is_null()); |
| 377 } | 378 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 base::Bind(&ChunkDemuxer::CreateDemuxerStream, base::Unretained(this)), | 539 base::Bind(&ChunkDemuxer::CreateDemuxerStream, base::Unretained(this)), |
| 539 media_log_)); | 540 media_log_)); |
| 540 | 541 |
| 541 MediaSourceState::NewTextTrackCB new_text_track_cb; | 542 MediaSourceState::NewTextTrackCB new_text_track_cb; |
| 542 | 543 |
| 543 if (enable_text_) { | 544 if (enable_text_) { |
| 544 new_text_track_cb = base::Bind(&ChunkDemuxer::OnNewTextTrack, | 545 new_text_track_cb = base::Bind(&ChunkDemuxer::OnNewTextTrack, |
| 545 base::Unretained(this)); | 546 base::Unretained(this)); |
| 546 } | 547 } |
| 547 | 548 |
| 549 pending_source_init_done_count_++; |
| 550 |
| 548 source_state->Init( | 551 source_state->Init( |
| 549 base::Bind(&ChunkDemuxer::OnSourceInitDone, base::Unretained(this)), | 552 base::Bind(&ChunkDemuxer::OnSourceInitDone, base::Unretained(this)), |
| 550 has_audio, has_video, encrypted_media_init_data_cb_, new_text_track_cb); | 553 has_audio, has_video, encrypted_media_init_data_cb_, new_text_track_cb); |
| 551 | 554 |
| 552 source_state_map_[id] = source_state.release(); | 555 source_state_map_[id] = source_state.release(); |
| 553 return kOk; | 556 return kOk; |
| 554 } | 557 } |
| 555 | 558 |
| 556 void ChunkDemuxer::SetTracksWatcher( | 559 void ChunkDemuxer::SetTracksWatcher( |
| 557 const std::string& id, | 560 const std::string& id, |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 audio_->SetLiveness(params.liveness); | 966 audio_->SetLiveness(params.liveness); |
| 964 if (video_) | 967 if (video_) |
| 965 video_->SetLiveness(params.liveness); | 968 video_->SetLiveness(params.liveness); |
| 966 } | 969 } |
| 967 | 970 |
| 968 detected_audio_track_count_ += params.detected_audio_track_count; | 971 detected_audio_track_count_ += params.detected_audio_track_count; |
| 969 detected_video_track_count_ += params.detected_video_track_count; | 972 detected_video_track_count_ += params.detected_video_track_count; |
| 970 detected_text_track_count_ += params.detected_text_track_count; | 973 detected_text_track_count_ += params.detected_text_track_count; |
| 971 | 974 |
| 972 // Wait until all streams have initialized. | 975 // Wait until all streams have initialized. |
| 973 // TODO(wolenetz): Make this gate less fragile. See https://crbug.com/597447. | 976 pending_source_init_done_count_--; |
| 974 if ((!source_id_audio_.empty() && !audio_) || | 977 |
| 975 (!source_id_video_.empty() && !video_)) { | 978 if (pending_source_init_done_count_ > 0) |
| 976 return; | 979 return; |
| 977 } | 980 |
| 981 DCHECK_EQ(0, pending_source_init_done_count_); |
| 982 DCHECK((source_id_audio_.empty() == !audio_) && |
| 983 (source_id_video_.empty() == !video_)); |
| 978 | 984 |
| 979 // Record detected track counts by type corresponding to an MSE playback. | 985 // Record detected track counts by type corresponding to an MSE playback. |
| 980 // Counts are split into 50 buckets, capped into [0,100] range. | 986 // Counts are split into 50 buckets, capped into [0,100] range. |
| 981 UMA_HISTOGRAM_COUNTS_100("Media.MSE.DetectedTrackCount.Audio", | 987 UMA_HISTOGRAM_COUNTS_100("Media.MSE.DetectedTrackCount.Audio", |
| 982 detected_audio_track_count_); | 988 detected_audio_track_count_); |
| 983 UMA_HISTOGRAM_COUNTS_100("Media.MSE.DetectedTrackCount.Video", | 989 UMA_HISTOGRAM_COUNTS_100("Media.MSE.DetectedTrackCount.Video", |
| 984 detected_video_track_count_); | 990 detected_video_track_count_); |
| 985 UMA_HISTOGRAM_COUNTS_100("Media.MSE.DetectedTrackCount.Text", | 991 UMA_HISTOGRAM_COUNTS_100("Media.MSE.DetectedTrackCount.Text", |
| 986 detected_text_track_count_); | 992 detected_text_track_count_); |
| 987 | 993 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 } | 1139 } |
| 1134 | 1140 |
| 1135 void ChunkDemuxer::ShutdownAllStreams() { | 1141 void ChunkDemuxer::ShutdownAllStreams() { |
| 1136 for (MediaSourceStateMap::iterator itr = source_state_map_.begin(); | 1142 for (MediaSourceStateMap::iterator itr = source_state_map_.begin(); |
| 1137 itr != source_state_map_.end(); ++itr) { | 1143 itr != source_state_map_.end(); ++itr) { |
| 1138 itr->second->Shutdown(); | 1144 itr->second->Shutdown(); |
| 1139 } | 1145 } |
| 1140 } | 1146 } |
| 1141 | 1147 |
| 1142 } // namespace media | 1148 } // namespace media |
| OLD | NEW |