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_DEMUXER_STREAM_H_ 6 #define MEDIA_BASE_DEMUXER_STREAM_H_ 7 8 #include "base/callback.h" 9 #include "base/memory/ref_counted.h" 10 #include "media/base/media_export.h" 11 12 namespace media { 13 14 class AudioDecoderConfig; 15 class DecoderBuffer; 16 class VideoDecoderConfig; 17 18 class MEDIA_EXPORT DemuxerStream { 19 public: 20 enum Type { 21 UNKNOWN, 22 AUDIO, 23 VIDEO, 24 TEXT, 25 NUM_TYPES, // Always keep this entry as the last one! 26 }; 27 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 34 // returned. 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 enum Status { 44 kOk, 45 kAborted, 46 kConfigChanged, 47 }; 48 49 // Request a buffer to returned via the provided callback. 50 // 51 // The first parameter indicates the status of the read. 52 // The second parameter is non-NULL and contains media data 53 // or the end of the stream if the first parameter is kOk. NULL otherwise. 54 typedef base::Callback<void(Status, 55 const scoped_refptr<DecoderBuffer>&)>ReadCB; 56 virtual void Read(const ReadCB& read_cb) = 0; 57 58 // Returns the audio decoder configuration. It is an error to call this method 59 // if type() != AUDIO. 60 virtual AudioDecoderConfig audio_decoder_config() = 0; 61 62 // Returns the video decoder configuration. It is an error to call this method 63 // if type() != VIDEO. 64 virtual VideoDecoderConfig video_decoder_config() = 0; 65 66 // Returns the type of stream. 67 virtual Type type() = 0; 68 69 virtual void EnableBitstreamConverter() = 0; 70 71 protected: 72 // Only allow concrete implementations to get deleted. 73 virtual ~DemuxerStream(); 74 }; 75 76 } // namespace media 77 78 #endif // MEDIA_BASE_DEMUXER_STREAM_H_ 79