OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ | 5 #ifndef MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ |
6 #define MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ | 6 #define MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // https://tools.ietf.org/html/rfc6716#page-14 | 47 // https://tools.ietf.org/html/rfc6716#page-14 |
48 static const uint16_t kOpusFrameDurationsMu[]; | 48 static const uint16_t kOpusFrameDurationsMu[]; |
49 | 49 |
50 private: | 50 private: |
51 // Helper class that manages per-track state. | 51 // Helper class that manages per-track state. |
52 class Track { | 52 class Track { |
53 public: | 53 public: |
54 Track(int track_num, | 54 Track(int track_num, |
55 bool is_video, | 55 bool is_video, |
56 base::TimeDelta default_duration, | 56 base::TimeDelta default_duration, |
57 const scoped_refptr<MediaLog>& media_log); | 57 MediaLog* media_log); |
58 Track(const Track& other); | 58 Track(const Track& other); |
59 ~Track(); | 59 ~Track(); |
60 | 60 |
61 int track_num() const { return track_num_; } | 61 int track_num() const { return track_num_; } |
62 | 62 |
63 // If a buffer is currently held aside pending duration calculation, returns | 63 // If a buffer is currently held aside pending duration calculation, returns |
64 // its decode timestamp. Otherwise, returns kInfiniteDuration. | 64 // its decode timestamp. Otherwise, returns kInfiniteDuration. |
65 DecodeTimestamp GetReadyUpperBound(); | 65 DecodeTimestamp GetReadyUpperBound(); |
66 | 66 |
67 // Prepares |ready_buffers_| for retrieval. Prior to calling, | 67 // Prepares |ready_buffers_| for retrieval. Prior to calling, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // If kNoTimestamp, then |estimated_next_frame_duration_| will be used. | 134 // If kNoTimestamp, then |estimated_next_frame_duration_| will be used. |
135 base::TimeDelta default_duration_; | 135 base::TimeDelta default_duration_; |
136 | 136 |
137 // If kNoTimestamp, then a default value will be used. This estimate is | 137 // If kNoTimestamp, then a default value will be used. This estimate is |
138 // the maximum (for video), or minimum (for audio) duration seen so far for | 138 // the maximum (for video), or minimum (for audio) duration seen so far for |
139 // this track, and is used only if |default_duration_| is kNoTimestamp. | 139 // this track, and is used only if |default_duration_| is kNoTimestamp. |
140 // TODO(chcunningham): Use maximum for audio too, adding checks to disable | 140 // TODO(chcunningham): Use maximum for audio too, adding checks to disable |
141 // splicing when these estimates are observed in SourceBufferStream. | 141 // splicing when these estimates are observed in SourceBufferStream. |
142 base::TimeDelta estimated_next_frame_duration_; | 142 base::TimeDelta estimated_next_frame_duration_; |
143 | 143 |
144 scoped_refptr<MediaLog> media_log_; | 144 MediaLog* media_log_; |
145 }; | 145 }; |
146 | 146 |
147 typedef std::map<int, Track> TextTrackMap; | 147 typedef std::map<int, Track> TextTrackMap; |
148 | 148 |
149 public: | 149 public: |
150 WebMClusterParser(int64_t timecode_scale, | 150 WebMClusterParser(int64_t timecode_scale, |
151 int audio_track_num, | 151 int audio_track_num, |
152 base::TimeDelta audio_default_duration, | 152 base::TimeDelta audio_default_duration, |
153 int video_track_num, | 153 int video_track_num, |
154 base::TimeDelta video_default_duration, | 154 base::TimeDelta video_default_duration, |
155 const WebMTracksParser::TextTracks& text_tracks, | 155 const WebMTracksParser::TextTracks& text_tracks, |
156 const std::set<int64_t>& ignored_tracks, | 156 const std::set<int64_t>& ignored_tracks, |
157 const std::string& audio_encryption_key_id, | 157 const std::string& audio_encryption_key_id, |
158 const std::string& video_encryption_key_id, | 158 const std::string& video_encryption_key_id, |
159 const AudioCodec audio_codec, | 159 const AudioCodec audio_codec, |
160 const scoped_refptr<MediaLog>& media_log); | 160 MediaLog* media_log); |
161 ~WebMClusterParser() override; | 161 ~WebMClusterParser() override; |
162 | 162 |
163 // Resets the parser state so it can accept a new cluster. | 163 // Resets the parser state so it can accept a new cluster. |
164 void Reset(); | 164 void Reset(); |
165 | 165 |
166 // Parses a WebM cluster element in |buf|. | 166 // Parses a WebM cluster element in |buf|. |
167 // | 167 // |
168 // Returns -1 if the parse fails. | 168 // Returns -1 if the parse fails. |
169 // Returns 0 if more data is needed. | 169 // Returns 0 if more data is needed. |
170 // Returns the number of bytes parsed on success. | 170 // Returns the number of bytes parsed on success. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 TextBufferQueueMap text_buffers_map_; | 308 TextBufferQueueMap text_buffers_map_; |
309 | 309 |
310 // Limits the range of buffers returned by Get{Audio,Video,Text}Buffers() to | 310 // Limits the range of buffers returned by Get{Audio,Video,Text}Buffers() to |
311 // this exclusive upper bound. Set to kNoDecodeTimestamp(), meaning not yet | 311 // this exclusive upper bound. Set to kNoDecodeTimestamp(), meaning not yet |
312 // calculated, by Reset() and Parse(). If kNoDecodeTimestamp(), then | 312 // calculated, by Reset() and Parse(). If kNoDecodeTimestamp(), then |
313 // Get{Audio,Video,Text}Buffers() will calculate it to be the minimum (decode) | 313 // Get{Audio,Video,Text}Buffers() will calculate it to be the minimum (decode) |
314 // timestamp across all tracks' |last_buffer_missing_duration_|, or | 314 // timestamp across all tracks' |last_buffer_missing_duration_|, or |
315 // kInfiniteDuration if no buffers are currently missing duration. | 315 // kInfiniteDuration if no buffers are currently missing duration. |
316 DecodeTimestamp ready_buffer_upper_bound_; | 316 DecodeTimestamp ready_buffer_upper_bound_; |
317 | 317 |
318 scoped_refptr<MediaLog> media_log_; | 318 MediaLog* media_log_; |
319 | 319 |
320 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); | 320 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); |
321 }; | 321 }; |
322 | 322 |
323 } // namespace media | 323 } // namespace media |
324 | 324 |
325 #endif // MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ | 325 #endif // MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ |
OLD | NEW |