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"
14 class AudioDecoderConfig
;
16 class VideoDecoderConfig
;
18 class MEDIA_EXPORT DemuxerStream
{
25 NUM_TYPES
, // Always keep this entry as the last one!
28 // Status returned in the Read() callback.
29 // kOk : Indicates the second parameter is Non-NULL and contains media data
30 // or the end of the stream.
31 // kAborted : Indicates an aborted Read(). This can happen if the
32 // DemuxerStream gets flushed and doesn't have any more data to
33 // return. The second parameter MUST be NULL when this status is
35 // kConfigChange : Indicates that the AudioDecoderConfig or
36 // VideoDecoderConfig for the stream has changed.
37 // The DemuxerStream expects an audio_decoder_config() or
38 // video_decoder_config() call before Read() will start
39 // returning DecoderBuffers again. The decoder will need this
40 // new configuration to properly decode the buffers read
41 // from this point forward. The second parameter MUST be NULL
42 // when this status is returned.
43 // This will only be returned if SupportsConfigChanges()
44 // returns 'true' for this DemuxerStream.
51 // Request a buffer to returned via the provided callback.
53 // The first parameter indicates the status of the read.
54 // The second parameter is non-NULL and contains media data
55 // or the end of the stream if the first parameter is kOk. NULL otherwise.
56 typedef base::Callback
<void(Status
,
57 const scoped_refptr
<DecoderBuffer
>&)>ReadCB
;
58 virtual void Read(const ReadCB
& read_cb
) = 0;
60 // Returns the audio decoder configuration. It is an error to call this method
61 // if type() != AUDIO.
62 virtual AudioDecoderConfig
audio_decoder_config() = 0;
64 // Returns the video decoder configuration. It is an error to call this method
65 // if type() != VIDEO.
66 virtual VideoDecoderConfig
video_decoder_config() = 0;
68 // Returns the type of stream.
69 virtual Type
type() = 0;
71 virtual void EnableBitstreamConverter() = 0;
73 // Whether or not this DemuxerStream allows midstream configuration changes.
75 // A DemuxerStream that returns 'true' to this may return the 'kConfigChange'
76 // status from a Read() call. In this case the client is expected to be
77 // capable of taking appropriate action to handle config changes. Otherwise
78 // audio_decoder_config() and video_decoder_config()'s return values are
79 // guaranteed to remain constant, and the client may make optimizations based
81 virtual bool SupportsConfigChanges() = 0;
84 // Only allow concrete implementations to get deleted.
85 virtual ~DemuxerStream();
90 #endif // MEDIA_BASE_DEMUXER_STREAM_H_