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_
10 #include "media/base/decoder_buffer.h"
11 #include "media/base/demuxer_stream.h"
12 #include "media/base/media_export.h"
13 #include "media/base/stream_parser.h"
17 class MEDIA_EXPORT StreamParserBuffer : public DecoderBuffer {
19 // Value used to signal an invalid decoder config ID.
20 enum { kInvalidConfigId = -1 };
22 typedef DemuxerStream::Type Type;
23 typedef StreamParser::TrackId TrackId;
25 static scoped_refptr<StreamParserBuffer> CreateEOSBuffer();
27 static scoped_refptr<StreamParserBuffer> CopyFrom(
28 const uint8* data, int data_size, bool is_keyframe, Type type,
30 static scoped_refptr<StreamParserBuffer> CopyFrom(
31 const uint8* data, int data_size,
32 const uint8* side_data, int side_data_size, bool is_keyframe, Type type,
34 bool IsKeyframe() const { return is_keyframe_; }
36 // Decode timestamp. If not explicitly set, or set to kNoTimestamp(), the
37 // value will be taken from the normal timestamp.
38 base::TimeDelta GetDecodeTimestamp() const;
39 void SetDecodeTimestamp(const base::TimeDelta& timestamp);
41 // Gets/sets the ID of the decoder config associated with this buffer.
42 int GetConfigId() const;
43 void SetConfigId(int config_id);
45 // Gets the parser's media type associated with this buffer. Value is
46 // meaningless for EOS buffers.
47 Type type() const { return type_; }
49 // Gets the parser's track ID associated with this buffer. Value is
50 // meaningless for EOS buffers.
51 TrackId track_id() const { return track_id_; }
53 // Converts this buffer to a splice buffer. |pre_splice_buffers| must not
54 // have any EOS buffers and must not have any nested splice buffers.
56 // |pre_splice_buffers| will be deep copied and each copy's splice_timestamp()
57 // will be set to this buffer's splice_timestamp(). A copy of |this|, with a
58 // splice_timestamp() of kNoTimestamp(), will be added to the end of
61 // See the Audio Splice Frame Algorithm in the MSE specification for details.
62 typedef StreamParser::BufferQueue BufferQueue;
63 void ConvertToSpliceBuffer(const BufferQueue& pre_splice_buffers);
64 const BufferQueue& get_splice_buffers() const { return splice_buffers_; }
67 StreamParserBuffer(const uint8* data, int data_size,
68 const uint8* side_data, int side_data_size,
69 bool is_keyframe, Type type,
71 virtual ~StreamParserBuffer();
74 base::TimeDelta decode_timestamp_;
79 BufferQueue splice_buffers_;
81 DISALLOW_COPY_AND_ASSIGN(StreamParserBuffer);
86 #endif // MEDIA_BASE_STREAM_PARSER_BUFFER_H_