OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_STREAM_PARSER_BUFFER_H_ | 5 #ifndef MEDIA_BASE_STREAM_PARSER_BUFFER_H_ |
6 #define MEDIA_BASE_STREAM_PARSER_BUFFER_H_ | 6 #define MEDIA_BASE_STREAM_PARSER_BUFFER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // by hacks where a decode time is being used as a presentation time. | 92 // by hacks where a decode time is being used as a presentation time. |
93 base::TimeDelta ToPresentationTime() const { return ts_; } | 93 base::TimeDelta ToPresentationTime() const { return ts_; } |
94 | 94 |
95 private: | 95 private: |
96 explicit DecodeTimestamp(base::TimeDelta timestamp) : ts_(timestamp) { } | 96 explicit DecodeTimestamp(base::TimeDelta timestamp) : ts_(timestamp) { } |
97 | 97 |
98 base::TimeDelta ts_; | 98 base::TimeDelta ts_; |
99 }; | 99 }; |
100 | 100 |
101 MEDIA_EXPORT extern inline DecodeTimestamp kNoDecodeTimestamp() { | 101 MEDIA_EXPORT extern inline DecodeTimestamp kNoDecodeTimestamp() { |
102 return DecodeTimestamp::FromPresentationTime(kNoTimestamp()); | 102 return DecodeTimestamp::FromPresentationTime(kNoTimestamp); |
103 } | 103 } |
104 | 104 |
105 class MEDIA_EXPORT StreamParserBuffer : public DecoderBuffer { | 105 class MEDIA_EXPORT StreamParserBuffer : public DecoderBuffer { |
106 public: | 106 public: |
107 // Value used to signal an invalid decoder config ID. | 107 // Value used to signal an invalid decoder config ID. |
108 enum { kInvalidConfigId = -1 }; | 108 enum { kInvalidConfigId = -1 }; |
109 | 109 |
110 typedef DemuxerStream::Type Type; | 110 typedef DemuxerStream::Type Type; |
111 typedef StreamParser::TrackId TrackId; | 111 typedef StreamParser::TrackId TrackId; |
112 | 112 |
113 static scoped_refptr<StreamParserBuffer> CreateEOSBuffer(); | 113 static scoped_refptr<StreamParserBuffer> CreateEOSBuffer(); |
114 | 114 |
115 static scoped_refptr<StreamParserBuffer> CopyFrom(const uint8_t* data, | 115 static scoped_refptr<StreamParserBuffer> CopyFrom(const uint8_t* data, |
116 int data_size, | 116 int data_size, |
117 bool is_key_frame, | 117 bool is_key_frame, |
118 Type type, | 118 Type type, |
119 TrackId track_id); | 119 TrackId track_id); |
120 static scoped_refptr<StreamParserBuffer> CopyFrom(const uint8_t* data, | 120 static scoped_refptr<StreamParserBuffer> CopyFrom(const uint8_t* data, |
121 int data_size, | 121 int data_size, |
122 const uint8_t* side_data, | 122 const uint8_t* side_data, |
123 int side_data_size, | 123 int side_data_size, |
124 bool is_key_frame, | 124 bool is_key_frame, |
125 Type type, | 125 Type type, |
126 TrackId track_id); | 126 TrackId track_id); |
127 | 127 |
128 // Decode timestamp. If not explicitly set, or set to kNoTimestamp(), the | 128 // Decode timestamp. If not explicitly set, or set to kNoTimestamp, the |
129 // value will be taken from the normal timestamp. | 129 // value will be taken from the normal timestamp. |
130 DecodeTimestamp GetDecodeTimestamp() const; | 130 DecodeTimestamp GetDecodeTimestamp() const; |
131 void SetDecodeTimestamp(DecodeTimestamp timestamp); | 131 void SetDecodeTimestamp(DecodeTimestamp timestamp); |
132 | 132 |
133 // Gets/sets the ID of the decoder config associated with this buffer. | 133 // Gets/sets the ID of the decoder config associated with this buffer. |
134 int GetConfigId() const; | 134 int GetConfigId() const; |
135 void SetConfigId(int config_id); | 135 void SetConfigId(int config_id); |
136 | 136 |
137 // Returns the config ID of this buffer if it has no splice buffers or | 137 // Returns the config ID of this buffer if it has no splice buffers or |
138 // |index| is out of range. Otherwise returns the config ID for the | 138 // |index| is out of range. Otherwise returns the config ID for the |
139 // buffer in |splice_buffers_| at position |index|. | 139 // buffer in |splice_buffers_| at position |index|. |
140 int GetSpliceBufferConfigId(size_t index) const; | 140 int GetSpliceBufferConfigId(size_t index) const; |
141 | 141 |
142 // Gets the parser's media type associated with this buffer. Value is | 142 // Gets the parser's media type associated with this buffer. Value is |
143 // meaningless for EOS buffers. | 143 // meaningless for EOS buffers. |
144 Type type() const { return type_; } | 144 Type type() const { return type_; } |
145 const char* GetTypeName() const; | 145 const char* GetTypeName() const; |
146 | 146 |
147 // Gets the parser's track ID associated with this buffer. Value is | 147 // Gets the parser's track ID associated with this buffer. Value is |
148 // meaningless for EOS buffers. | 148 // meaningless for EOS buffers. |
149 TrackId track_id() const { return track_id_; } | 149 TrackId track_id() const { return track_id_; } |
150 | 150 |
151 // Converts this buffer to a splice buffer. |pre_splice_buffers| must not | 151 // Converts this buffer to a splice buffer. |pre_splice_buffers| must not |
152 // have any EOS buffers, must not have any splice buffers, nor must have any | 152 // have any EOS buffers, must not have any splice buffers, nor must have any |
153 // buffer with preroll. | 153 // buffer with preroll. |
154 // | 154 // |
155 // |pre_splice_buffers| will be deep copied and each copy's splice_timestamp() | 155 // |pre_splice_buffers| will be deep copied and each copy's splice_timestamp() |
156 // will be set to this buffer's splice_timestamp(). A copy of |this|, with a | 156 // will be set to this buffer's splice_timestamp(). A copy of |this|, with a |
157 // splice_timestamp() of kNoTimestamp(), will be added to the end of | 157 // splice_timestamp() of kNoTimestamp, will be added to the end of |
158 // |splice_buffers_|. | 158 // |splice_buffers_|. |
159 // | 159 // |
160 // See the Audio Splice Frame Algorithm in the MSE specification for details. | 160 // See the Audio Splice Frame Algorithm in the MSE specification for details. |
161 typedef StreamParser::BufferQueue BufferQueue; | 161 typedef StreamParser::BufferQueue BufferQueue; |
162 void ConvertToSpliceBuffer(const BufferQueue& pre_splice_buffers); | 162 void ConvertToSpliceBuffer(const BufferQueue& pre_splice_buffers); |
163 const BufferQueue& splice_buffers() const { return splice_buffers_; } | 163 const BufferQueue& splice_buffers() const { return splice_buffers_; } |
164 | 164 |
165 // Specifies a buffer which must be decoded prior to this one to ensure this | 165 // Specifies a buffer which must be decoded prior to this one to ensure this |
166 // buffer can be accurately decoded. The given buffer must be of the same | 166 // buffer can be accurately decoded. The given buffer must be of the same |
167 // type, must not be a splice buffer, must not have any discard padding, and | 167 // type, must not be a splice buffer, must not have any discard padding, and |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 BufferQueue splice_buffers_; | 202 BufferQueue splice_buffers_; |
203 scoped_refptr<StreamParserBuffer> preroll_buffer_; | 203 scoped_refptr<StreamParserBuffer> preroll_buffer_; |
204 bool is_duration_estimated_; | 204 bool is_duration_estimated_; |
205 | 205 |
206 DISALLOW_COPY_AND_ASSIGN(StreamParserBuffer); | 206 DISALLOW_COPY_AND_ASSIGN(StreamParserBuffer); |
207 }; | 207 }; |
208 | 208 |
209 } // namespace media | 209 } // namespace media |
210 | 210 |
211 #endif // MEDIA_BASE_STREAM_PARSER_BUFFER_H_ | 211 #endif // MEDIA_BASE_STREAM_PARSER_BUFFER_H_ |
OLD | NEW |