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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BASE_STREAM_PARSER_BUFFER_H_
6 #define MEDIA_BASE_STREAM_PARSER_BUFFER_H_
8 #include "media/base/decoder_buffer.h"
9 #include "media/base/demuxer_stream.h"
10 #include "media/base/media_export.h"
11 #include "media/base/stream_parser.h"
15 class MEDIA_EXPORT StreamParserBuffer : public DecoderBuffer {
17 // Value used to signal an invalid decoder config ID.
18 enum { kInvalidConfigId = -1 };
20 typedef DemuxerStream::Type Type;
21 typedef StreamParser::TrackId TrackId;
23 static scoped_refptr<StreamParserBuffer> CreateEOSBuffer();
24 static scoped_refptr<StreamParserBuffer> CopyFrom(
25 const uint8* data, int data_size, bool is_keyframe, Type type,
27 static scoped_refptr<StreamParserBuffer> CopyFrom(
28 const uint8* data, int data_size,
29 const uint8* side_data, int side_data_size, bool is_keyframe, Type type,
31 bool IsKeyframe() const { return is_keyframe_; }
33 // Decode timestamp. If not explicitly set, or set to kNoTimestamp(), the
34 // value will be taken from the normal timestamp.
35 base::TimeDelta GetDecodeTimestamp() const;
36 void SetDecodeTimestamp(const base::TimeDelta& timestamp);
38 // Gets/sets the ID of the decoder config associated with this buffer.
39 int GetConfigId() const;
40 void SetConfigId(int config_id);
42 // Gets the parser's media type associated with this buffer. Value is
43 // meaningless for EOS buffers.
44 Type type() const { return type_; }
46 // Gets the parser's track ID associated with this buffer. Value is
47 // meaningless for EOS buffers.
48 TrackId track_id() const { return track_id_; }
50 // Buffers to be exhausted before using the data in this DecoderBuffer. Used
51 // to implement the Audio Splice Frame Algorithm per the MSE specification.
52 const std::vector<scoped_refptr<StreamParserBuffer> >& GetFadeOutPreroll()
54 void SetFadeOutPreroll(
55 const std::vector<scoped_refptr<StreamParserBuffer> >& fade_out_preroll);
58 StreamParserBuffer(const uint8* data, int data_size,
59 const uint8* side_data, int side_data_size,
60 bool is_keyframe, Type type,
62 virtual ~StreamParserBuffer();
65 base::TimeDelta decode_timestamp_;
70 std::vector<scoped_refptr<StreamParserBuffer> > fade_out_preroll_;
72 DISALLOW_COPY_AND_ASSIGN(StreamParserBuffer);
77 #endif // MEDIA_BASE_STREAM_PARSER_BUFFER_H_