summaryrefslogtreecommitdiff
path: root/chromium/media/base/media_tracks.h
blob: 0df1b05bfd78f3ff6a01346e538b5dd512c1ef5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_BASE_MEDIA_TRACKS_H_
#define MEDIA_BASE_MEDIA_TRACKS_H_

#include <map>
#include <memory>
#include <vector>

#include "base/macros.h"
#include "media/base/media_export.h"
#include "media/base/media_track.h"

namespace media {

class AudioDecoderConfig;
class VideoDecoderConfig;

class MEDIA_EXPORT MediaTracks {
 public:
  using MediaTracksCollection = std::vector<std::unique_ptr<MediaTrack>>;

  MediaTracks();

  MediaTracks(const MediaTracks&) = delete;
  MediaTracks& operator=(const MediaTracks&) = delete;

  ~MediaTracks();

  // Adds a new audio track. The |bytestreamTrackId| must uniquely identify the
  // track within the bytestream.
  MediaTrack* AddAudioTrack(const AudioDecoderConfig& config,
                            StreamParser::TrackId bytestream_track_id,
                            const MediaTrack::Kind& kind,
                            const MediaTrack::Label& label,
                            const MediaTrack::Language& language);
  // Adds a new video track. The |bytestreamTrackId| must uniquely identify the
  // track within the bytestream.
  MediaTrack* AddVideoTrack(const VideoDecoderConfig& config,
                            StreamParser::TrackId bytestream_track_id,
                            const MediaTrack::Kind& kind,
                            const MediaTrack::Label& label,
                            const MediaTrack::Language& language);

  const MediaTracksCollection& tracks() const { return tracks_; }

  const AudioDecoderConfig& getAudioConfig(
      StreamParser::TrackId bytestream_track_id) const;
  const VideoDecoderConfig& getVideoConfig(
      StreamParser::TrackId bytestream_track_id) const;

 private:
  MediaTracksCollection tracks_;
  std::map<StreamParser::TrackId, AudioDecoderConfig> audio_configs_;
  std::map<StreamParser::TrackId, VideoDecoderConfig> video_configs_;
};

}  // namespace media

#endif  // MEDIA_BASE_MEDIA_TRACKS_H_