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

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

Issue 2050043002: Generate and assign media track ids in demuxers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-streamparser-trackid
Patch Set: rebase to ToT Created 4 years, 6 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 | « content/renderer/media/webmediaplayer_ms_unittest.cc ('k') | media/base/media_tracks.h » ('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_TRACK_H_ 5 #ifndef MEDIA_BASE_MEDIA_TRACK_H_
6 #define MEDIA_BASE_MEDIA_TRACK_H_ 6 #define MEDIA_BASE_MEDIA_TRACK_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "media/base/media_export.h" 10 #include "media/base/media_export.h"
11 #include "media/base/stream_parser.h" 11 #include "media/base/stream_parser.h"
12 12
13 namespace media { 13 namespace media {
14 14
15 class MEDIA_EXPORT MediaTrack { 15 class MEDIA_EXPORT MediaTrack {
16 public: 16 public:
17 enum Type { Text, Audio, Video }; 17 enum Type { Text, Audio, Video };
18 using Id = std::string;
18 MediaTrack(Type type, 19 MediaTrack(Type type,
19 StreamParser::TrackId bytestream_track_id, 20 StreamParser::TrackId bytestream_track_id,
20 const std::string& kind, 21 const std::string& kind,
21 const std::string& label, 22 const std::string& label,
22 const std::string& lang); 23 const std::string& lang);
23 ~MediaTrack(); 24 ~MediaTrack();
24 25
25 Type type() const { return type_; } 26 Type type() const { return type_; }
26 27
27 StreamParser::TrackId bytestream_track_id() const { 28 StreamParser::TrackId bytestream_track_id() const {
28 return bytestream_track_id_; 29 return bytestream_track_id_;
29 } 30 }
30 const std::string& kind() const { return kind_; } 31 const std::string& kind() const { return kind_; }
31 const std::string& label() const { return label_; } 32 const std::string& label() const { return label_; }
32 const std::string& language() const { return language_; } 33 const std::string& language() const { return language_; }
33 34
35 Id id() const { return id_; }
36 void set_id(Id id) {
37 DCHECK(id_.empty());
38 DCHECK(!id.empty());
39 id_ = id;
40 }
41
34 private: 42 private:
35 Type type_; 43 Type type_;
44
45 // |bytestream_track_id_| is read from the bytestream and is guaranteed to be
46 // unique only within the scope of single bytestream's initialization segment.
47 // But we might have multiple bytestreams (MediaSource might have multiple
48 // SourceBuffers attached to it, which translates into ChunkDemuxer having
49 // multiple MediaSourceStates and multiple bytestreams) or subsequent init
50 // segments may redefine the bytestream ids. Thus bytestream track ids are not
51 // guaranteed to be unique at the Demuxer and HTMLMediaElement level. So we
52 // generate truly unique media track |id_| on the Demuxer level.
36 StreamParser::TrackId bytestream_track_id_; 53 StreamParser::TrackId bytestream_track_id_;
54 Id id_;
55
56 // These properties are read from input streams by stream parsers as specified
57 // in https://dev.w3.org/html5/html-sourcing-inband-tracks/.
37 std::string kind_; 58 std::string kind_;
38 std::string label_; 59 std::string label_;
39 std::string language_; 60 std::string language_;
40 }; 61 };
41 62
42 } // namespace media 63 } // namespace media
43 64
44 #endif // MEDIA_BASE_MEDIA_TRACK_H_ 65 #endif // MEDIA_BASE_MEDIA_TRACK_H_
OLDNEW
« no previous file with comments | « content/renderer/media/webmediaplayer_ms_unittest.cc ('k') | media/base/media_tracks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698