Chromium Code Reviews| OLD | NEW |
|---|---|
| 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<const MediaTrack*, const DemuxerStream*> | |
| 27 TrackToDemuxStreamMap; | |
| 25 | 28 |
| 26 MediaTracks(); | 29 MediaTracks(); |
| 27 ~MediaTracks(); | 30 ~MediaTracks(); |
| 28 | 31 |
| 29 // Callers need to ensure that track id is unique. | 32 // Callers need to ensure that track id is unique. |
| 30 void AddAudioTrack(const AudioDecoderConfig& config, | 33 const MediaTrack* AddAudioTrack(const AudioDecoderConfig& config, |
| 31 const std::string& id, | 34 const std::string& id, |
| 32 const std::string& kind, | 35 const std::string& kind, |
| 33 const std::string& label, | 36 const std::string& label, |
| 34 const std::string& language); | 37 const std::string& language); |
| 35 // Callers need to ensure that track id is unique. | 38 // Callers need to ensure that track id is unique. |
| 36 void AddVideoTrack(const VideoDecoderConfig& config, | 39 const MediaTrack* AddVideoTrack(const VideoDecoderConfig& config, |
| 37 const std::string& id, | 40 const std::string& id, |
| 38 const std::string& kind, | 41 const std::string& kind, |
| 39 const std::string& label, | 42 const std::string& label, |
| 40 const std::string& language); | 43 const std::string& language); |
| 41 | 44 |
| 42 const MediaTracksCollection& tracks() const { return tracks_; } | 45 const MediaTracksCollection& tracks() const { return tracks_; } |
| 43 | 46 |
| 47 const TrackToDemuxStreamMap& track_to_demux_stream_map() const { | |
| 48 return track_to_demux_stream_map_; | |
| 49 } | |
| 50 void set_track_to_demux_stream_map(const TrackToDemuxStreamMap& m); | |
|
wolenetz
2016/04/08 23:32:31
Hmm. Is this for testing only? It seems a bit extr
servolk
2016/04/08 23:47:20
No. This needs to be called before reporting media
wolenetz
2016/04/14 20:43:39
I see. Since MediaTracks effectively owns the map,
servolk
2016/04/15 02:23:24
Ok, I've refactored this code a bit, to make it si
servolk
2016/04/15 02:32:59
To expand a bit on this: I think we probably don't
| |
| 51 | |
| 44 const AudioDecoderConfig& getAudioConfig(const std::string& id) const; | 52 const AudioDecoderConfig& getAudioConfig(const std::string& id) const; |
| 45 const VideoDecoderConfig& getVideoConfig(const std::string& id) const; | 53 const VideoDecoderConfig& getVideoConfig(const std::string& id) const; |
| 46 | 54 |
| 47 // TODO(servolk): These are temporary helpers useful until all code paths are | 55 // TODO(servolk): These are temporary helpers useful until all code paths are |
| 48 // converted to properly handle multiple media tracks. | 56 // converted to properly handle multiple media tracks. |
| 49 const AudioDecoderConfig& getFirstAudioConfig() const; | 57 const AudioDecoderConfig& getFirstAudioConfig() const; |
| 50 const VideoDecoderConfig& getFirstVideoConfig() const; | 58 const VideoDecoderConfig& getFirstVideoConfig() const; |
| 51 | 59 |
| 52 private: | 60 private: |
| 53 MediaTracksCollection tracks_; | 61 MediaTracksCollection tracks_; |
| 62 TrackToDemuxStreamMap track_to_demux_stream_map_; | |
| 54 std::map<std::string, AudioDecoderConfig> audio_configs_; | 63 std::map<std::string, AudioDecoderConfig> audio_configs_; |
| 55 std::map<std::string, VideoDecoderConfig> video_configs_; | 64 std::map<std::string, VideoDecoderConfig> video_configs_; |
| 56 | 65 |
| 57 DISALLOW_COPY_AND_ASSIGN(MediaTracks); | 66 DISALLOW_COPY_AND_ASSIGN(MediaTracks); |
| 58 }; | 67 }; |
| 59 | 68 |
| 60 } // namespace media | 69 } // namespace media |
| 61 | 70 |
| 62 #endif // MEDIA_BASE_MEDIA_TRACKS_H_ | 71 #endif // MEDIA_BASE_MEDIA_TRACKS_H_ |
| OLD | NEW |