Fix for browser_plugin_host_browsertest when embedder is not yet available.
[chromium-blink-merge.git] / media / base / demuxer_stream.h
blobbb4534475ed14099c92a2cfec0ffb75e2f18584a
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"
12 namespace media {
14 class AudioDecoderConfig;
15 class DecoderBuffer;
16 class VideoDecoderConfig;
18 class MEDIA_EXPORT DemuxerStream {
19 public:
20 enum Type {
21 UNKNOWN,
22 AUDIO,
23 VIDEO,
24 NUM_TYPES, // Always keep this entry as the last one!
27 // Status returned in the Read() callback.
28 // kOk : Indicates the second parameter is Non-NULL and contains media data
29 // or the end of the stream.
30 // kAborted : Indicates an aborted Read(). This can happen if the
31 // DemuxerStream gets flushed and doesn't have any more data to
32 // return. The second parameter MUST be NULL when this status is
33 // returned.
34 // kConfigChange : Indicates that the AudioDecoderConfig or
35 // VideoDecoderConfig for the stream has changed.
36 // The DemuxerStream expects an audio_decoder_config() or
37 // video_decoder_config() call before Read() will start
38 // returning DecoderBuffers again. The decoder will need this
39 // new configuration to properly decode the buffers read
40 // from this point forward. The second parameter MUST be NULL
41 // when this status is returned.
42 enum Status {
43 kOk,
44 kAborted,
45 kConfigChanged,
48 // Request a buffer to returned via the provided callback.
50 // The first parameter indicates the status of the read.
51 // The second parameter is non-NULL and contains media data
52 // or the end of the stream if the first parameter is kOk. NULL otherwise.
53 typedef base::Callback<void(Status,
54 const scoped_refptr<DecoderBuffer>&)>ReadCB;
55 virtual void Read(const ReadCB& read_cb) = 0;
57 // Returns the audio decoder configuration. It is an error to call this method
58 // if type() != AUDIO.
59 virtual AudioDecoderConfig audio_decoder_config() = 0;
61 // Returns the video decoder configuration. It is an error to call this method
62 // if type() != VIDEO.
63 virtual VideoDecoderConfig video_decoder_config() = 0;
65 // Returns the type of stream.
66 virtual Type type() = 0;
68 virtual void EnableBitstreamConverter() = 0;
70 protected:
71 // Only allow concrete implementations to get deleted.
72 virtual ~DemuxerStream();
75 } // namespace media
77 #endif // MEDIA_BASE_DEMUXER_STREAM_H_