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
63
64
65
66
67
68
|
// 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.
#include "media/base/media_tracks.h"
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/video_decoder_config.h"
namespace media {
MediaTracks::MediaTracks() {}
MediaTracks::~MediaTracks() {}
MediaTrack* MediaTracks::AddAudioTrack(
const AudioDecoderConfig& config,
StreamParser::TrackId bytestream_track_id,
const std::string& kind,
const std::string& label,
const std::string& language) {
DCHECK(config.IsValidConfig());
CHECK(audio_configs_.find(bytestream_track_id) == audio_configs_.end());
std::unique_ptr<MediaTrack> track = base::MakeUnique<MediaTrack>(
MediaTrack::Audio, bytestream_track_id, kind, label, language);
MediaTrack* track_ptr = track.get();
tracks_.push_back(std::move(track));
audio_configs_[bytestream_track_id] = config;
return track_ptr;
}
MediaTrack* MediaTracks::AddVideoTrack(
const VideoDecoderConfig& config,
StreamParser::TrackId bytestream_track_id,
const std::string& kind,
const std::string& label,
const std::string& language) {
DCHECK(config.IsValidConfig());
CHECK(video_configs_.find(bytestream_track_id) == video_configs_.end());
std::unique_ptr<MediaTrack> track = base::MakeUnique<MediaTrack>(
MediaTrack::Video, bytestream_track_id, kind, label, language);
MediaTrack* track_ptr = track.get();
tracks_.push_back(std::move(track));
video_configs_[bytestream_track_id] = config;
return track_ptr;
}
const AudioDecoderConfig& MediaTracks::getAudioConfig(
StreamParser::TrackId bytestream_track_id) const {
auto it = audio_configs_.find(bytestream_track_id);
if (it != audio_configs_.end())
return it->second;
static AudioDecoderConfig invalidConfig;
return invalidConfig;
}
const VideoDecoderConfig& MediaTracks::getVideoConfig(
StreamParser::TrackId bytestream_track_id) const {
auto it = video_configs_.find(bytestream_track_id);
if (it != video_configs_.end())
return it->second;
static VideoDecoderConfig invalidConfig;
return invalidConfig;
}
} // namespace media
|