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_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 | |
|
wolenetz
2016/06/13 23:23:58
nit: s/multiple\//multiple/
servolk
2016/06/14 00:01:22
Done.
| |
| 50 // segments bytestream ids might be redefined in subsequent init segments. | |
|
wolenetz
2016/06/13 23:23:57
nit: s/{whole line}/ // segments' may redefine th
servolk
2016/06/14 00:01:22
Done.
| |
| 51 // Thus bytestream track ids are not guaranteed to be unique at the Demuxer | |
| 52 // and HTMLMediaElement level. So we generate truly unique media track |id_| | |
| 53 // on the Demuxer level. | |
| 36 StreamParser::TrackId bytestream_track_id_; | 54 StreamParser::TrackId bytestream_track_id_; |
| 55 Id id_; | |
| 56 | |
| 57 // These properties are read from input streams by stream parsers as specified | |
| 58 // in https://dev.w3.org/html5/html-sourcing-inband-tracks/. | |
| 37 std::string kind_; | 59 std::string kind_; |
| 38 std::string label_; | 60 std::string label_; |
| 39 std::string language_; | 61 std::string language_; |
| 40 }; | 62 }; |
| 41 | 63 |
| 42 } // namespace media | 64 } // namespace media |
| 43 | 65 |
| 44 #endif // MEDIA_BASE_MEDIA_TRACK_H_ | 66 #endif // MEDIA_BASE_MEDIA_TRACK_H_ |
| OLD | NEW |