| 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_FILTERS_SOURCE_BUFFER_RANGE_H_ | 5 #ifndef MEDIA_FILTERS_SOURCE_BUFFER_RANGE_H_ |
| 6 #define MEDIA_FILTERS_SOURCE_BUFFER_RANGE_H_ | 6 #define MEDIA_FILTERS_SOURCE_BUFFER_RANGE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 // Policy for handling large gaps between buffers. Continuous media like | 31 // Policy for handling large gaps between buffers. Continuous media like |
| 32 // audio & video should use NO_GAPS_ALLOWED. Discontinuous media like | 32 // audio & video should use NO_GAPS_ALLOWED. Discontinuous media like |
| 33 // timed text should use ALLOW_GAPS because large differences in timestamps | 33 // timed text should use ALLOW_GAPS because large differences in timestamps |
| 34 // are common and acceptable. | 34 // are common and acceptable. |
| 35 enum GapPolicy { | 35 enum GapPolicy { |
| 36 NO_GAPS_ALLOWED, | 36 NO_GAPS_ALLOWED, |
| 37 ALLOW_GAPS | 37 ALLOW_GAPS |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 // Buffers with the same timestamp are only allowed under certain conditions. | 40 // Sequential buffers with the same decode timestamp make sense under certain |
| 41 // More precisely, it is allowed in all situations except when the previous | 41 // conditions, typically when the first buffer is a keyframe. Due to some |
| 42 // frame is not a key frame and the current is a key frame. | 42 // atypical media append behaviors where a new keyframe might have the same |
| 43 // Examples of situations where DTS of two consecutive frames can be equal: | 43 // timestamp as a previous non-keyframe, the playback of the sequence might |
| 44 // involve some throwaway decode work. This method supports detecting this |
| 45 // situation so that callers can log warnings (it returns true in this case |
| 46 // only). |
| 47 // For all other cases, including more typical same-DTS sequences, this method |
| 48 // returns false. Examples of typical situations where DTS of two consecutive |
| 49 // frames can be equal: |
| 44 // - Video: VP8 Alt-Ref frames. | 50 // - Video: VP8 Alt-Ref frames. |
| 45 // - Video: IPBPBP...: DTS for I frame and for P frame can be equal. | 51 // - Video: IPBPBP...: DTS for I frame and for P frame can be equal. |
| 46 // - Text track cues that start at same time. | 52 // - Text track cues that start at same time. |
| 47 // Returns true if |prev_is_keyframe| and |current_is_keyframe| indicate a | 53 // Returns true if |prev_is_keyframe| and |current_is_keyframe| indicate a |
| 48 // same timestamp situation that is allowed. False is returned otherwise. | 54 // same timestamp situation that is atypical. False is returned otherwise. |
| 49 static bool AllowSameTimestamp(bool prev_is_keyframe, | 55 static bool IsUncommonSameTimestampSequence(bool prev_is_keyframe, |
| 50 bool current_is_keyframe); | 56 bool current_is_keyframe); |
| 51 | 57 |
| 52 // Creates a source buffer range with |new_buffers|. |new_buffers| cannot be | 58 // Creates a source buffer range with |new_buffers|. |new_buffers| cannot be |
| 53 // empty and the front of |new_buffers| must be a keyframe. | 59 // empty and the front of |new_buffers| must be a keyframe. |
| 54 // |media_segment_start_time| refers to the starting timestamp for the media | 60 // |media_segment_start_time| refers to the starting timestamp for the media |
| 55 // segment to which these buffers belong. | 61 // segment to which these buffers belong. |
| 56 SourceBufferRange(GapPolicy gap_policy, | 62 SourceBufferRange(GapPolicy gap_policy, |
| 57 const BufferQueue& new_buffers, | 63 const BufferQueue& new_buffers, |
| 58 DecodeTimestamp media_segment_start_time, | 64 DecodeTimestamp media_segment_start_time, |
| 59 const InterbufferDistanceCB& interbuffer_distance_cb); | 65 const InterbufferDistanceCB& interbuffer_distance_cb); |
| 60 | 66 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 197 |
| 192 // Returns true if this range's buffered timespan completely overlaps the | 198 // Returns true if this range's buffered timespan completely overlaps the |
| 193 // buffered timespan of |range|. | 199 // buffered timespan of |range|. |
| 194 bool CompletelyOverlaps(const SourceBufferRange& range) const; | 200 bool CompletelyOverlaps(const SourceBufferRange& range) const; |
| 195 | 201 |
| 196 // Returns true if the end of this range contains buffers that overlaps with | 202 // Returns true if the end of this range contains buffers that overlaps with |
| 197 // the beginning of |range|. | 203 // the beginning of |range|. |
| 198 bool EndOverlaps(const SourceBufferRange& range) const; | 204 bool EndOverlaps(const SourceBufferRange& range) const; |
| 199 | 205 |
| 200 // Returns true if |timestamp| is the timestamp of the next buffer in | 206 // Returns true if |timestamp| is the timestamp of the next buffer in |
| 201 // sequence after |buffers_.back()|, false otherwise. | 207 // sequence after |buffers_.back()|, false othewise. |
| 202 bool IsNextInSequence(DecodeTimestamp timestamp, bool is_key_frame) const; | 208 bool IsNextInSequence(DecodeTimestamp timestamp) const; |
| 203 | 209 |
| 204 // Adds all buffers which overlap [start, end) to the end of |buffers|. If | 210 // Adds all buffers which overlap [start, end) to the end of |buffers|. If |
| 205 // no buffers exist in the range returns false, true otherwise. | 211 // no buffers exist in the range returns false, true otherwise. |
| 206 bool GetBuffersInRange(DecodeTimestamp start, DecodeTimestamp end, | 212 bool GetBuffersInRange(DecodeTimestamp start, DecodeTimestamp end, |
| 207 BufferQueue* buffers); | 213 BufferQueue* buffers); |
| 208 | 214 |
| 209 size_t size_in_bytes() const { return size_in_bytes_; } | 215 size_t size_in_bytes() const { return size_in_bytes_; } |
| 210 | 216 |
| 211 private: | 217 private: |
| 212 typedef std::map<DecodeTimestamp, int> KeyframeMap; | 218 typedef std::map<DecodeTimestamp, int> KeyframeMap; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 296 |
| 291 // Stores the amount of memory taken up by the data in |buffers_|. | 297 // Stores the amount of memory taken up by the data in |buffers_|. |
| 292 size_t size_in_bytes_; | 298 size_t size_in_bytes_; |
| 293 | 299 |
| 294 DISALLOW_COPY_AND_ASSIGN(SourceBufferRange); | 300 DISALLOW_COPY_AND_ASSIGN(SourceBufferRange); |
| 295 }; | 301 }; |
| 296 | 302 |
| 297 } // namespace media | 303 } // namespace media |
| 298 | 304 |
| 299 #endif // MEDIA_FILTERS_SOURCE_BUFFER_RANGE_H_ | 305 #endif // MEDIA_FILTERS_SOURCE_BUFFER_RANGE_H_ |
| OLD | NEW |