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

Unified Diff: media/filters/chunk_demuxer.cc

Issue 1812543003: Allow muting/unmuting audio through media track API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink-sb-tracks6
Patch Set: Don't call DemuxStream::type from the wrong thread Created 4 years, 8 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
Index: media/filters/chunk_demuxer.cc
diff --git a/media/filters/chunk_demuxer.cc b/media/filters/chunk_demuxer.cc
index 53ce1f3ec09c046598f5a0b9f5c9a2aa9254ecfa..ad42848bdd5fed4015bdb564beabde220716d719 100644
--- a/media/filters/chunk_demuxer.cc
+++ b/media/filters/chunk_demuxer.cc
@@ -17,6 +17,7 @@
#include "base/stl_util.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/bind_to_current_loop.h"
+#include "media/base/media_tracks.h"
#include "media/base/stream_parser_buffer.h"
#include "media/base/timestamp_constants.h"
#include "media/base/video_decoder_config.h"
@@ -1002,32 +1003,31 @@ void ChunkDemuxer::OnSourceInitDone(
base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK);
}
-ChunkDemuxerStream*
-ChunkDemuxer::CreateDemuxerStream(DemuxerStream::Type type) {
- switch (type) {
- case DemuxerStream::AUDIO:
+ChunkDemuxerStream* ChunkDemuxer::CreateDemuxerStream(
+ const MediaTrack& media_track) {
+ // Demuxer streams can only be created when ChunkDemuxer::AppendData is in
+ // progress.
+ lock_.AssertAcquired();
+ switch (media_track.type()) {
+ case MediaTrack::Audio:
if (audio_)
return NULL;
audio_.reset(
new ChunkDemuxerStream(DemuxerStream::AUDIO, splice_frames_enabled_));
return audio_.get();
break;
- case DemuxerStream::VIDEO:
+ case MediaTrack::Video:
if (video_)
return NULL;
video_.reset(
new ChunkDemuxerStream(DemuxerStream::VIDEO, splice_frames_enabled_));
return video_.get();
break;
- case DemuxerStream::TEXT: {
+ case MediaTrack::Text: {
return new ChunkDemuxerStream(DemuxerStream::TEXT,
splice_frames_enabled_);
break;
}
- case DemuxerStream::UNKNOWN:
- case DemuxerStream::NUM_TYPES:
- NOTREACHED();
- return NULL;
}
NOTREACHED();
return NULL;
@@ -1040,6 +1040,33 @@ void ChunkDemuxer::OnNewTextTrack(ChunkDemuxerStream* text_stream,
host_->AddTextStream(text_stream, config);
}
+void ChunkDemuxer::OnTrackIdsAssigned(const MediaTracks& tracks,
+ const std::vector<unsigned>& track_ids) {
+ // New tracks and therefore track id assignements can happen only during
+ // ChunkDemuxer::AppendData processing, which should be holding the lock.
+ lock_.AssertAcquired();
+ DCHECK_EQ(tracks.tracks().size(), track_ids.size());
wolenetz 2016/04/14 20:43:39 These two DCHECK_EQs need to be CHECKs, since if t
servolk 2016/04/15 02:23:24 Done.
+ const auto& track_to_demux_stream = tracks.track_to_demux_stream_map();
+ DCHECK_EQ(track_to_demux_stream.size(), tracks.tracks().size());
+ for (size_t i = 0; i < track_ids.size(); ++i) {
+ const MediaTrack* track = tracks.tracks()[i].get();
+ DCHECK(track);
+ const auto& it = track_to_demux_stream.find(track);
+ DCHECK(it != track_to_demux_stream.end());
+ DVLOG(3) << "OnTrackIdsAssigned track_id=" << track_ids[i]
+ << " DemuxerStream=" << it->second;
+ track_id_to_demux_stream_[track_ids[i]] = it->second;
+ }
+}
+
+const DemuxerStream* ChunkDemuxer::GetDemuxerStreamByTrackId(
+ unsigned track_id) const {
+ base::AutoLock auto_lock(lock_);
+ const auto& it = track_id_to_demux_stream_.find(track_id);
+ CHECK(it != track_id_to_demux_stream_.end());
+ return it->second;
+}
+
bool ChunkDemuxer::IsValidId(const std::string& source_id) const {
lock_.AssertAcquired();
return source_state_map_.count(source_id) > 0u;

Powered by Google App Engine
This is Rietveld 408576698