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

Unified Diff: media/filters/media_source_state.cc

Issue 2050043002: Generate and assign media track ids in demuxers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-streamparser-trackid
Patch Set: rebase to ToT Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/media_source_state.h ('k') | media/formats/mp4/mp4_stream_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/media_source_state.cc
diff --git a/media/filters/media_source_state.cc b/media/filters/media_source_state.cc
index 6a1d95f6190f3369ab66db489c948abcafade5d1..d5132eb3e2ea381df42da6dc52cae0ef791aa90b 100644
--- a/media/filters/media_source_state.cc
+++ b/media/filters/media_source_state.cc
@@ -151,8 +151,8 @@ void MediaSourceState::SetGroupStartTimestampIfInSequenceMode(
void MediaSourceState::SetTracksWatcher(
const Demuxer::MediaTracksUpdatedCB& tracks_updated_cb) {
DCHECK(init_segment_received_cb_.is_null());
+ DCHECK(!tracks_updated_cb.is_null());
init_segment_received_cb_ = tracks_updated_cb;
- DCHECK(!init_segment_received_cb_.is_null());
}
bool MediaSourceState::Append(const uint8_t* data,
@@ -481,9 +481,37 @@ bool MediaSourceState::OnNewConfigs(
DCHECK_GE(state_, PENDING_PARSER_CONFIG);
DCHECK(tracks.get());
- media_tracks_ = std::move(tracks);
- const AudioDecoderConfig& audio_config = media_tracks_->getFirstAudioConfig();
- const VideoDecoderConfig& video_config = media_tracks_->getFirstVideoConfig();
+ MediaTrack* audio_track = nullptr;
+ MediaTrack* video_track = nullptr;
+ AudioDecoderConfig audio_config;
+ VideoDecoderConfig video_config;
+ for (const auto& track : tracks->tracks()) {
+ const auto& track_id = track->bytestream_track_id();
+
+ if (track->type() == MediaTrack::Audio) {
+ if (audio_track) {
+ MEDIA_LOG(ERROR, media_log_)
+ << "Error: more than one audio track is currently not supported.";
+ return false;
+ }
+ audio_track = track.get();
+ audio_config = tracks->getAudioConfig(track_id);
+ DCHECK(audio_config.IsValidConfig());
+ } else if (track->type() == MediaTrack::Video) {
+ if (video_track) {
+ MEDIA_LOG(ERROR, media_log_)
+ << "Error: more than one video track is currently not supported.";
+ return false;
+ }
+ video_track = track.get();
+ video_config = tracks->getVideoConfig(track_id);
+ DCHECK(video_config.IsValidConfig());
+ } else {
+ MEDIA_LOG(ERROR, media_log_) << "Error: unsupported media track type "
+ << track->type();
+ return false;
+ }
+ }
DVLOG(1) << "OnNewConfigs(" << allow_audio << ", " << allow_video << ", "
<< audio_config.IsValidConfig() << ", "
@@ -652,12 +680,21 @@ bool MediaSourceState::OnNewConfigs(
frame_processor_->SetAllTrackBuffersNeedRandomAccessPoint();
+ if (audio_track) {
+ DCHECK(audio_);
+ audio_track->set_id(audio_->media_track_id());
+ }
+ if (video_track) {
+ DCHECK(video_);
+ video_track->set_id(video_->media_track_id());
+ }
+
DVLOG(1) << "OnNewConfigs() : " << (success ? "success" : "failed");
if (success) {
if (state_ == PENDING_PARSER_CONFIG)
state_ = PENDING_PARSER_INIT;
DCHECK(!init_segment_received_cb_.is_null());
- init_segment_received_cb_.Run(std::move(media_tracks_));
+ init_segment_received_cb_.Run(std::move(tracks));
}
return success;
« no previous file with comments | « media/filters/media_source_state.h ('k') | media/formats/mp4/mp4_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698