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

Side by Side Diff: media/base/media_tracks.h

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: Avoid ChunkDemuxer/PipelineImpl deadlock 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 unified diff | Download patch
« no previous file with comments | « media/base/demuxer.h ('k') | media/base/media_tracks.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef MEDIA_BASE_MEDIA_TRACKS_H_ 5 #ifndef MEDIA_BASE_MEDIA_TRACKS_H_
6 #define MEDIA_BASE_MEDIA_TRACKS_H_ 6 #define MEDIA_BASE_MEDIA_TRACKS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "media/base/media_export.h" 14 #include "media/base/media_export.h"
15 #include "media/base/media_track.h" 15 #include "media/base/media_track.h"
16 16
17 namespace media { 17 namespace media {
18 18
19 class AudioDecoderConfig; 19 class AudioDecoderConfig;
20 class DemuxerStream;
20 class VideoDecoderConfig; 21 class VideoDecoderConfig;
21 22
22 class MEDIA_EXPORT MediaTracks { 23 class MEDIA_EXPORT MediaTracks {
23 public: 24 public:
24 typedef std::vector<scoped_ptr<MediaTrack>> MediaTracksCollection; 25 typedef std::vector<scoped_ptr<MediaTrack>> MediaTracksCollection;
26 typedef std::map<unsigned, const DemuxerStream*> TrackIdToDemuxStreamMap;
25 27
26 MediaTracks(); 28 MediaTracks();
27 ~MediaTracks(); 29 ~MediaTracks();
28 30
29 // Callers need to ensure that track id is unique. 31 // Callers need to ensure that track id is unique.
30 void AddAudioTrack(const AudioDecoderConfig& config, 32 const MediaTrack* AddAudioTrack(const AudioDecoderConfig& config,
31 const std::string& id, 33 const std::string& id,
32 const std::string& kind, 34 const std::string& kind,
33 const std::string& label, 35 const std::string& label,
34 const std::string& language); 36 const std::string& language);
35 // Callers need to ensure that track id is unique. 37 // Callers need to ensure that track id is unique.
36 void AddVideoTrack(const VideoDecoderConfig& config, 38 const MediaTrack* AddVideoTrack(const VideoDecoderConfig& config,
37 const std::string& id, 39 const std::string& id,
38 const std::string& kind, 40 const std::string& kind,
39 const std::string& label, 41 const std::string& label,
40 const std::string& language); 42 const std::string& language);
41 43
42 const MediaTracksCollection& tracks() const { return tracks_; } 44 const MediaTracksCollection& tracks() const { return tracks_; }
43 45
46 // TODO(servolk,wolenetz): Consider refactoring media track creation in MSE to
47 // simplify track id to DemuxerStream mapping. crbug.com/604088
48
49 // Notifies MediaTracks that a given media |track| object is backed by the
50 // given DemuxerStream |stream| object.
51 void SetDemuxerStreamForMediaTrack(const MediaTrack* track,
52 const DemuxerStream* stream);
53 // Notifies MediaTracks that external (blink) track ids have been assigned to
54 // the media |tracks_|. The size and ordering of |track_ids| must match the
55 // size and ordering of tracks in the |tracks_| collection, and
56 // |track_to_demux_stream_map_| must have an entry for each track in |tracks_|
57 // (set by SetDemuxerStreamForMediaTrack()).
58 TrackIdToDemuxStreamMap OnTrackIdsAssigned(
59 const std::vector<unsigned>& track_ids) const;
60
44 const AudioDecoderConfig& getAudioConfig(const std::string& id) const; 61 const AudioDecoderConfig& getAudioConfig(const std::string& id) const;
45 const VideoDecoderConfig& getVideoConfig(const std::string& id) const; 62 const VideoDecoderConfig& getVideoConfig(const std::string& id) const;
46 63
47 // TODO(servolk): These are temporary helpers useful until all code paths are 64 // TODO(servolk): These are temporary helpers useful until all code paths are
48 // converted to properly handle multiple media tracks. 65 // converted to properly handle multiple media tracks.
49 const AudioDecoderConfig& getFirstAudioConfig() const; 66 const AudioDecoderConfig& getFirstAudioConfig() const;
50 const VideoDecoderConfig& getFirstVideoConfig() const; 67 const VideoDecoderConfig& getFirstVideoConfig() const;
51 68
52 private: 69 private:
53 MediaTracksCollection tracks_; 70 MediaTracksCollection tracks_;
54 std::map<std::string, AudioDecoderConfig> audio_configs_; 71 std::map<std::string, AudioDecoderConfig> audio_configs_;
55 std::map<std::string, VideoDecoderConfig> video_configs_; 72 std::map<std::string, VideoDecoderConfig> video_configs_;
56 73
74 typedef std::map<const MediaTrack*, const DemuxerStream*>
75 TrackToDemuxStreamMap;
76 TrackToDemuxStreamMap track_to_demux_stream_map_;
77
57 DISALLOW_COPY_AND_ASSIGN(MediaTracks); 78 DISALLOW_COPY_AND_ASSIGN(MediaTracks);
58 }; 79 };
59 80
60 } // namespace media 81 } // namespace media
61 82
62 #endif // MEDIA_BASE_MEDIA_TRACKS_H_ 83 #endif // MEDIA_BASE_MEDIA_TRACKS_H_
OLDNEW
« no previous file with comments | « media/base/demuxer.h ('k') | media/base/media_tracks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698