146e78a3dcffc981a9d81e3b610a7fa1f83c9a10
[platform/framework/web/crosswalk.git] / src / media / base / stream_parser_buffer.h
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.
4
5 #ifndef MEDIA_BASE_STREAM_PARSER_BUFFER_H_
6 #define MEDIA_BASE_STREAM_PARSER_BUFFER_H_
7
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"
12
13 namespace media {
14
15 class MEDIA_EXPORT StreamParserBuffer : public DecoderBuffer {
16  public:
17   // Value used to signal an invalid decoder config ID.
18   enum { kInvalidConfigId = -1 };
19
20   typedef DemuxerStream::Type Type;
21   typedef StreamParser::TrackId TrackId;
22
23   static scoped_refptr<StreamParserBuffer> CreateEOSBuffer();
24   static scoped_refptr<StreamParserBuffer> CopyFrom(
25       const uint8* data, int data_size, bool is_keyframe, Type type,
26       TrackId track_id);
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,
30       TrackId track_id);
31   bool IsKeyframe() const { return is_keyframe_; }
32
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);
37
38   // Gets/sets the ID of the decoder config associated with this buffer.
39   int GetConfigId() const;
40   void SetConfigId(int config_id);
41
42   // Gets the parser's media type associated with this buffer. Value is
43   // meaningless for EOS buffers.
44   Type type() const { return type_; }
45
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_; }
49
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()
53       const;
54   void SetFadeOutPreroll(
55       const std::vector<scoped_refptr<StreamParserBuffer> >& fade_out_preroll);
56
57  private:
58   StreamParserBuffer(const uint8* data, int data_size,
59                      const uint8* side_data, int side_data_size,
60                      bool is_keyframe, Type type,
61                      TrackId track_id);
62   virtual ~StreamParserBuffer();
63
64   bool is_keyframe_;
65   base::TimeDelta decode_timestamp_;
66   int config_id_;
67   Type type_;
68   TrackId track_id_;
69
70   std::vector<scoped_refptr<StreamParserBuffer> > fade_out_preroll_;
71
72   DISALLOW_COPY_AND_ASSIGN(StreamParserBuffer);
73 };
74
75 }  // namespace media
76
77 #endif  // MEDIA_BASE_STREAM_PARSER_BUFFER_H_