[App banners] Add RAPPOR support
[chromium-blink-merge.git] / media / base / demuxer_stream.h
blob596ab67e83692aba287f11e6c1488a623ffee8e6
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_DEMUXER_STREAM_H_
6 #define MEDIA_BASE_DEMUXER_STREAM_H_
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "media/base/media_export.h"
11 #include "media/base/video_rotation.h"
13 namespace media {
15 class AudioDecoderConfig;
16 class DecoderBuffer;
17 class VideoDecoderConfig;
19 class MEDIA_EXPORT DemuxerStream {
20 public:
21 enum Type {
22 UNKNOWN,
23 AUDIO,
24 VIDEO,
25 TEXT,
26 NUM_TYPES, // Always keep this entry as the last one!
29 enum Liveness {
30 LIVENESS_UNKNOWN,
31 LIVENESS_RECORDED,
32 LIVENESS_LIVE,
35 // Status returned in the Read() callback.
36 // kOk : Indicates the second parameter is Non-NULL and contains media data
37 // or the end of the stream.
38 // kAborted : Indicates an aborted Read(). This can happen if the
39 // DemuxerStream gets flushed and doesn't have any more data to
40 // return. The second parameter MUST be NULL when this status is
41 // returned.
42 // kConfigChange : Indicates that the AudioDecoderConfig or
43 // VideoDecoderConfig for the stream has changed.
44 // The DemuxerStream expects an audio_decoder_config() or
45 // video_decoder_config() call before Read() will start
46 // returning DecoderBuffers again. The decoder will need this
47 // new configuration to properly decode the buffers read
48 // from this point forward. The second parameter MUST be NULL
49 // when this status is returned.
50 // This will only be returned if SupportsConfigChanges()
51 // returns 'true' for this DemuxerStream.
52 enum Status {
53 kOk,
54 kAborted,
55 kConfigChanged,
58 // Request a buffer to returned via the provided callback.
60 // The first parameter indicates the status of the read.
61 // The second parameter is non-NULL and contains media data
62 // or the end of the stream if the first parameter is kOk. NULL otherwise.
63 typedef base::Callback<void(Status,
64 const scoped_refptr<DecoderBuffer>&)>ReadCB;
65 virtual void Read(const ReadCB& read_cb) = 0;
67 // Returns the audio/video decoder configuration. It is an error to call the
68 // audio method on a video stream and vice versa. After |kConfigChanged| is
69 // returned in a Read(), the caller should call this method again to retrieve
70 // the new config.
71 virtual AudioDecoderConfig audio_decoder_config() = 0;
72 virtual VideoDecoderConfig video_decoder_config() = 0;
74 // Returns the type of stream.
75 virtual Type type() const = 0;
77 // Returns liveness of the streams provided, i.e. whether recorded or live.
78 virtual Liveness liveness() const;
80 virtual void EnableBitstreamConverter();
82 // Whether or not this DemuxerStream allows midstream configuration changes.
84 // A DemuxerStream that returns 'true' to this may return the 'kConfigChange'
85 // status from a Read() call. In this case the client is expected to be
86 // capable of taking appropriate action to handle config changes. Otherwise
87 // audio_decoder_config() and video_decoder_config()'s return values are
88 // guaranteed to remain constant, and the client may make optimizations based
89 // on this.
90 virtual bool SupportsConfigChanges() = 0;
92 virtual VideoRotation video_rotation() = 0;
94 protected:
95 // Only allow concrete implementations to get deleted.
96 virtual ~DemuxerStream();
99 } // namespace media
101 #endif // MEDIA_BASE_DEMUXER_STREAM_H_