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 "media/base/decoder_buffer.h" | 8 #include "media/base/decoder_buffer.h" |
| 9 #include "media/base/demuxer_stream.h" |
9 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
10 | 11 |
11 namespace media { | 12 namespace media { |
12 | 13 |
13 class MEDIA_EXPORT StreamParserBuffer : public DecoderBuffer { | 14 class MEDIA_EXPORT StreamParserBuffer : public DecoderBuffer { |
14 public: | 15 public: |
15 // Value used to signal an invalid decoder config ID. | 16 // Value used to signal an invalid decoder config ID. |
16 enum { kInvalidConfigId = -1 }; | 17 enum { kInvalidConfigId = -1 }; |
17 | 18 |
| 19 typedef DemuxerStream::Type Type; |
| 20 |
18 static scoped_refptr<StreamParserBuffer> CreateEOSBuffer(); | 21 static scoped_refptr<StreamParserBuffer> CreateEOSBuffer(); |
19 static scoped_refptr<StreamParserBuffer> CopyFrom( | 22 static scoped_refptr<StreamParserBuffer> CopyFrom( |
20 const uint8* data, int data_size, bool is_keyframe); | 23 const uint8* data, int data_size, bool is_keyframe, Type type); |
21 static scoped_refptr<StreamParserBuffer> CopyFrom( | 24 static scoped_refptr<StreamParserBuffer> CopyFrom( |
22 const uint8* data, int data_size, | 25 const uint8* data, int data_size, |
23 const uint8* side_data, int side_data_size, bool is_keyframe); | 26 const uint8* side_data, int side_data_size, bool is_keyframe, Type type); |
24 bool IsKeyframe() const { return is_keyframe_; } | 27 bool IsKeyframe() const { return is_keyframe_; } |
25 | 28 |
26 // Decode timestamp. If not explicitly set, or set to kNoTimestamp(), the | 29 // Decode timestamp. If not explicitly set, or set to kNoTimestamp(), the |
27 // value will be taken from the normal timestamp. | 30 // value will be taken from the normal timestamp. |
28 base::TimeDelta GetDecodeTimestamp() const; | 31 base::TimeDelta GetDecodeTimestamp() const; |
29 void SetDecodeTimestamp(const base::TimeDelta& timestamp); | 32 void SetDecodeTimestamp(const base::TimeDelta& timestamp); |
30 | 33 |
31 // Gets/sets the ID of the decoder config associated with this | 34 // Gets/sets the ID of the decoder config associated with this buffer. |
32 // buffer. | |
33 int GetConfigId() const; | 35 int GetConfigId() const; |
34 void SetConfigId(int config_id); | 36 void SetConfigId(int config_id); |
35 | 37 |
| 38 // Gets the parser's media type associated with this buffer. Value is |
| 39 // meaningless for EOS buffers. |
| 40 Type type() const { return type_; } |
| 41 |
| 42 // Gets/sets the parser's text track number associated with this buffer. Value |
| 43 // is meaningless for EOS buffers or buffers whose type() is not |kText|. |
| 44 int text_track_number() const { return text_track_number_; } |
| 45 void set_text_track_number(int track_num) { text_track_number_ = track_num; } |
| 46 |
36 // Buffers to be exhausted before using the data in this DecoderBuffer. Used | 47 // Buffers to be exhausted before using the data in this DecoderBuffer. Used |
37 // to implement the Audio Splice Frame Algorithm per the MSE specification. | 48 // to implement the Audio Splice Frame Algorithm per the MSE specification. |
38 const std::vector<scoped_refptr<StreamParserBuffer> >& GetFadeOutPreroll() | 49 const std::vector<scoped_refptr<StreamParserBuffer> >& GetFadeOutPreroll() |
39 const; | 50 const; |
40 void SetFadeOutPreroll( | 51 void SetFadeOutPreroll( |
41 const std::vector<scoped_refptr<StreamParserBuffer> >& fade_out_preroll); | 52 const std::vector<scoped_refptr<StreamParserBuffer> >& fade_out_preroll); |
42 | 53 |
43 private: | 54 private: |
44 StreamParserBuffer(const uint8* data, int data_size, | 55 StreamParserBuffer(const uint8* data, int data_size, |
45 const uint8* side_data, int side_data_size, | 56 const uint8* side_data, int side_data_size, |
46 bool is_keyframe); | 57 bool is_keyframe, Type type); |
47 virtual ~StreamParserBuffer(); | 58 virtual ~StreamParserBuffer(); |
48 | 59 |
49 bool is_keyframe_; | 60 bool is_keyframe_; |
50 base::TimeDelta decode_timestamp_; | 61 base::TimeDelta decode_timestamp_; |
51 int config_id_; | 62 int config_id_; |
| 63 Type type_; |
| 64 |
| 65 // Range of |text_track_number_| is dependent upon each stream parser. It is |
| 66 // the key for the buffer's text track config in the applicable |
| 67 // TextTrackConfigMap (which is passed in StreamParser::NewConfigCB). |
| 68 // WebMTracksParser uses -1 as an invalid text track number. |
| 69 // TODO(wolenetz/acolwell): Update valid/invalid range once more text track |
| 70 // parsers are implemented. See http://crbug.com/336926. |
| 71 int text_track_number_; |
| 72 |
52 std::vector<scoped_refptr<StreamParserBuffer> > fade_out_preroll_; | 73 std::vector<scoped_refptr<StreamParserBuffer> > fade_out_preroll_; |
53 | 74 |
54 DISALLOW_COPY_AND_ASSIGN(StreamParserBuffer); | 75 DISALLOW_COPY_AND_ASSIGN(StreamParserBuffer); |
55 }; | 76 }; |
56 | 77 |
57 } // namespace media | 78 } // namespace media |
58 | 79 |
59 #endif // MEDIA_BASE_STREAM_PARSER_BUFFER_H_ | 80 #endif // MEDIA_BASE_STREAM_PARSER_BUFFER_H_ |
OLD | NEW |