Remove ScrollbarLayerImplBase.
[chromium-blink-merge.git] / media / base / stream_parser.h
bloba4a8105a8b7d52c5f2965a3af97913e51e8a5d84
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_H_
6 #define MEDIA_BASE_STREAM_PARSER_H_
8 #include <deque>
9 #include <string>
11 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/time.h"
15 #include "media/base/media_export.h"
16 #include "media/base/media_log.h"
18 namespace media {
20 class AudioDecoderConfig;
21 class StreamParserBuffer;
22 class VideoDecoderConfig;
24 // Abstract interface for parsing media byte streams.
25 class MEDIA_EXPORT StreamParser {
26 public:
27 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue;
29 StreamParser();
30 virtual ~StreamParser();
32 // Indicates completion of parser initialization.
33 // First parameter - Indicates initialization success. Set to true if
34 // initialization was successful. False if an error
35 // occurred.
36 // Second parameter - Indicates the stream duration. Only contains a valid
37 // value if the first parameter is true.
38 typedef base::Callback<void(bool, base::TimeDelta)> InitCB;
40 // Indicates when new stream configurations have been parsed.
41 // First parameter - The new audio configuration. If the config is not valid
42 // then it means that there isn't an audio stream.
43 // Second parameter - The new video configuration. If the config is not valid
44 // then it means that there isn't an audio stream.
45 // Return value - True if the new configurations are accepted.
46 // False if the new configurations are not supported
47 // and indicates that a parsing error should be signalled.
48 typedef base::Callback<bool(const AudioDecoderConfig&,
49 const VideoDecoderConfig&)> NewConfigCB;
51 // New stream buffers have been parsed.
52 // First parameter - A queue of newly parsed buffers.
53 // Return value - True indicates that the buffers are accepted.
54 // False if something was wrong with the buffers and a parsing
55 // error should be signalled.
56 typedef base::Callback<bool(const BufferQueue&)> NewBuffersCB;
58 // Signals the beginning of a new media segment.
59 // First parameter - The earliest timestamp of all the streams in the segment.
60 typedef base::Callback<void(base::TimeDelta)> NewMediaSegmentCB;
62 // A new potentially encrypted stream has been parsed.
63 // First parameter - The type of the initialization data associated with the
64 // stream.
65 // Second parameter - The initialization data associated with the stream.
66 // Third parameter - Number of bytes of the initialization data.
67 // Return value - True indicates that the initialization data is accepted.
68 // False if something was wrong with the initialization data
69 // and a parsing error should be signalled.
70 typedef base::Callback<bool(const std::string&,
71 scoped_ptr<uint8[]>, int)> NeedKeyCB;
73 // Initialize the parser with necessary callbacks. Must be called before any
74 // data is passed to Parse(). |init_cb| will be called once enough data has
75 // been parsed to determine the initial stream configurations, presentation
76 // start time, and duration.
77 virtual void Init(const InitCB& init_cb,
78 const NewConfigCB& config_cb,
79 const NewBuffersCB& audio_cb,
80 const NewBuffersCB& video_cb,
81 const NeedKeyCB& need_key_cb,
82 const NewMediaSegmentCB& new_segment_cb,
83 const base::Closure& end_of_segment_cb,
84 const LogCB& log_cb) = 0;
86 // Called when a seek occurs. This flushes the current parser state
87 // and puts the parser in a state where it can receive data for the new seek
88 // point.
89 virtual void Flush() = 0;
91 // Called when there is new data to parse.
93 // Returns true if the parse succeeds.
94 virtual bool Parse(const uint8* buf, int size) = 0;
96 private:
97 DISALLOW_COPY_AND_ASSIGN(StreamParser);
100 } // namespace media
102 #endif // MEDIA_BASE_STREAM_PARSER_H_