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

Unified Diff: media/filters/chunk_demuxer.h

Issue 2226443002: Support multiple media tracks in MSE / ChunkDemuxer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mp4 format is not supported on some trybots, so use webm Created 4 years, 3 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.h
diff --git a/media/filters/chunk_demuxer.h b/media/filters/chunk_demuxer.h
index 3d0409e90f74051a1852a25ca07df48d404f7dd4..1147d6898c67e35aba0842653d87ffffad6efbe6 100644
--- a/media/filters/chunk_demuxer.h
+++ b/media/filters/chunk_demuxer.h
@@ -10,6 +10,7 @@
#include <deque>
#include <map>
+#include <set>
#include <string>
#include <utility>
#include <vector>
@@ -217,8 +218,9 @@ class MEDIA_EXPORT ChunkDemuxer : public Demuxer {
// kNotSupported is returned if |type| is not a supported format.
// kReachedIdLimit is returned if the demuxer cannot handle another ID right
// now.
- Status AddId(const std::string& id, const std::string& type,
- std::vector<std::string>& codecs);
+ Status AddId(const std::string& id,
+ const std::string& type,
+ const std::string& codecs);
// Notifies a caller via |tracks_updated_cb| that the set of media tracks
// for a given |id| has changed.
@@ -344,12 +346,15 @@ class MEDIA_EXPORT ChunkDemuxer : public Demuxer {
bool CanEndOfStream_Locked() const;
// MediaSourceState callbacks.
- void OnSourceInitDone(const StreamParser::InitParameters& params);
+ void OnSourceInitDone(const std::string& source_id,
+ const StreamParser::InitParameters& params);
- // Creates a DemuxerStream for the specified |type|.
- // Returns a new ChunkDemuxerStream instance if a stream of this type
- // has not been created before. Returns NULL otherwise.
- ChunkDemuxerStream* CreateDemuxerStream(DemuxerStream::Type type);
+ // Creates a DemuxerStream of the specified |type| for the MediaSourceState
+ // with the given |source_id|.
+ // Returns a pointer to a new ChunkDemuxerStream instance, which is owned by
+ // ChunkDemuxer.
+ ChunkDemuxerStream* CreateDemuxerStream(const std::string& source_id,
+ DemuxerStream::Type type);
void OnNewTextTrack(ChunkDemuxerStream* text_stream,
const TextTrackConfig& config);
@@ -408,12 +413,12 @@ class MEDIA_EXPORT ChunkDemuxer : public Demuxer {
// http://crbug.com/308226
PipelineStatusCB seek_cb_;
- std::unique_ptr<ChunkDemuxerStream> audio_;
- std::unique_ptr<ChunkDemuxerStream> video_;
+ std::vector<std::unique_ptr<ChunkDemuxerStream>> audio_streams_;
+ std::vector<std::unique_ptr<ChunkDemuxerStream>> video_streams_;
- // Counter to ensure that we do not transition too early to INITIALIZED.
- // Incremented in AddId(), decremented in OnSourceInitDone().
- int pending_source_init_done_count_;
+ // Keep track of which ids still remain uninitialized so that we transition
+ // into the INITIALIZED only after all ids/SourceBuffers got init segment.
+ std::set<std::string> pending_source_init_ids_;
base::TimeDelta duration_;
@@ -430,11 +435,12 @@ class MEDIA_EXPORT ChunkDemuxer : public Demuxer {
typedef std::map<std::string, MediaSourceState*> MediaSourceStateMap;
MediaSourceStateMap source_state_map_;
- // Used to ensure that (1) config data matches the type and codec provided in
- // AddId(), (2) only 1 audio and 1 video sources are added, and (3) ids may be
- // removed with RemoveID() but can not be re-added (yet).
- std::string source_id_audio_;
- std::string source_id_video_;
+ std::map<std::string, std::vector<ChunkDemuxerStream*>> id_to_streams_map_;
+ // Used to hold alive the demuxer streams that were created for removed /
+ // released MediaSourceState objects. Demuxer clients might still have
+ // references to these streams, so we need to keep them alive. But they'll be
+ // in a shut down state, so reading from them will return EOS.
+ std::vector<std::unique_ptr<ChunkDemuxerStream>> removed_streams_;
// Indicates that splice frame generation is enabled.
const bool splice_frames_enabled_;
@@ -444,7 +450,7 @@ class MEDIA_EXPORT ChunkDemuxer : public Demuxer {
int detected_video_track_count_;
int detected_text_track_count_;
- std::map<MediaTrack::Id, const DemuxerStream*> track_id_to_demux_stream_map_;
+ std::map<MediaTrack::Id, DemuxerStream*> track_id_to_demux_stream_map_;
DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer);
};

Powered by Google App Engine
This is Rietveld 408576698