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

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: Remove Demuxer::GetDemuxerStreamByTrackId 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
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 }
xhwang 2016/06/10 17:06:53 I wonder whether we can generate this ID when we c
servolk 2016/06/10 22:05:25 I don't think we can simplify this much further. I
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. But we might have
47 // multiple bytestreams (MediaSource might have multiple SourceBuffers
48 // attached to it, which translates into ChunkDemuxer having multiple
49 // MediaSourceStates and multiple bytestreams). Thus bytestream track ids
50 // are not guaranteed to be unique at the Demuxer and HTMLMediaElement level.
51 // So we generate truly unique media track |id_| on the Demuxer level.
xhwang 2016/06/10 17:06:54 I <3 this comment. Thanks!
servolk 2016/06/10 22:05:25 Acknowledged.
36 StreamParser::TrackId bytestream_track_id_; 52 StreamParser::TrackId bytestream_track_id_;
xhwang 2016/06/10 17:06:53 nit: I wonder whether StreamParser::TrackId should
servolk 2016/06/10 22:05:25 Yes, I think we could rename StreamParser::TrackId
53 Id id_;
54
55 // These properties are read from input streams by stream parsers as specified
56 // in https://dev.w3.org/html5/html-sourcing-inband-tracks/.
37 std::string kind_; 57 std::string kind_;
38 std::string label_; 58 std::string label_;
39 std::string language_; 59 std::string language_;
40 }; 60 };
41 61
42 } // namespace media 62 } // namespace media
43 63
44 #endif // MEDIA_BASE_MEDIA_TRACK_H_ 64 #endif // MEDIA_BASE_MEDIA_TRACK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698