Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_BASE_DEMUXER_STREAM_H_ | 5 #ifndef MEDIA_BASE_DEMUXER_STREAM_H_ |
| 6 #define MEDIA_BASE_DEMUXER_STREAM_H_ | 6 #define MEDIA_BASE_DEMUXER_STREAM_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
| 11 #include "media/base/video_rotation.h" | 11 #include "media/base/video_rotation.h" |
| 12 | 12 |
| 13 namespace media { | 13 namespace media { |
| 14 | 14 |
| 15 class AudioDecoderConfig; | 15 class AudioDecoderConfig; |
| 16 class DecoderBuffer; | 16 class DecoderBuffer; |
| 17 class VideoDecoderConfig; | 17 class VideoDecoderConfig; |
| 18 | 18 |
| 19 class MEDIA_EXPORT DemuxerStream { | 19 class MEDIA_EXPORT DemuxerStream { |
| 20 public: | 20 public: |
| 21 enum Type { | 21 enum Type { |
| 22 UNKNOWN, | 22 UNKNOWN, |
| 23 AUDIO, | 23 AUDIO, |
| 24 VIDEO, | 24 VIDEO, |
| 25 TEXT, | 25 TEXT, |
| 26 NUM_TYPES, // Always keep this entry as the last one! | 26 NUM_TYPES, // Always keep this entry as the last one! |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 enum Liveness { | |
| 30 LIVENESS_UNKNOWN, | |
| 31 LIVENESS_RECORDED, | |
| 32 LIVENESS_LIVE, | |
| 33 }; | |
| 34 | |
| 29 // Status returned in the Read() callback. | 35 // Status returned in the Read() callback. |
| 30 // kOk : Indicates the second parameter is Non-NULL and contains media data | 36 // kOk : Indicates the second parameter is Non-NULL and contains media data |
| 31 // or the end of the stream. | 37 // or the end of the stream. |
| 32 // kAborted : Indicates an aborted Read(). This can happen if the | 38 // kAborted : Indicates an aborted Read(). This can happen if the |
| 33 // DemuxerStream gets flushed and doesn't have any more data to | 39 // DemuxerStream gets flushed and doesn't have any more data to |
| 34 // return. The second parameter MUST be NULL when this status is | 40 // return. The second parameter MUST be NULL when this status is |
| 35 // returned. | 41 // returned. |
| 36 // kConfigChange : Indicates that the AudioDecoderConfig or | 42 // kConfigChange : Indicates that the AudioDecoderConfig or |
| 37 // VideoDecoderConfig for the stream has changed. | 43 // VideoDecoderConfig for the stream has changed. |
| 38 // The DemuxerStream expects an audio_decoder_config() or | 44 // The DemuxerStream expects an audio_decoder_config() or |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 51 | 57 |
| 52 // Request a buffer to returned via the provided callback. | 58 // Request a buffer to returned via the provided callback. |
| 53 // | 59 // |
| 54 // The first parameter indicates the status of the read. | 60 // The first parameter indicates the status of the read. |
| 55 // The second parameter is non-NULL and contains media data | 61 // The second parameter is non-NULL and contains media data |
| 56 // or the end of the stream if the first parameter is kOk. NULL otherwise. | 62 // or the end of the stream if the first parameter is kOk. NULL otherwise. |
| 57 typedef base::Callback<void(Status, | 63 typedef base::Callback<void(Status, |
| 58 const scoped_refptr<DecoderBuffer>&)>ReadCB; | 64 const scoped_refptr<DecoderBuffer>&)>ReadCB; |
| 59 virtual void Read(const ReadCB& read_cb) = 0; | 65 virtual void Read(const ReadCB& read_cb) = 0; |
| 60 | 66 |
| 61 // Returns the audio decoder configuration. It is an error to call this method | 67 // Returns the audio/video decoder configuration. It is an error to call the |
| 62 // if type() != AUDIO. | 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. | |
| 63 virtual AudioDecoderConfig audio_decoder_config() = 0; | 71 virtual AudioDecoderConfig audio_decoder_config() = 0; |
| 64 | |
| 65 // Returns the video decoder configuration. It is an error to call this method | |
| 66 // if type() != VIDEO. | |
| 67 virtual VideoDecoderConfig video_decoder_config() = 0; | 72 virtual VideoDecoderConfig video_decoder_config() = 0; |
| 68 | 73 |
| 69 // Returns the type of stream. | 74 // Returns the type of stream. |
| 70 virtual Type type() = 0; | 75 virtual Type type() = 0; |
|
wolenetz
2014/11/11 23:48:07
nit: adding const seems reasonable to me here (and
xhwang
2014/11/14 06:38:04
Done.
| |
| 71 | 76 |
| 77 // Returns liveness of the streams provided, i.e. whether recorded or live. | |
| 78 virtual Liveness liveness(); | |
|
wolenetz
2014/11/11 23:48:07
nit: ditto const
xhwang
2014/11/14 06:38:04
Done.
| |
| 79 | |
| 72 virtual void EnableBitstreamConverter(); | 80 virtual void EnableBitstreamConverter(); |
| 73 | 81 |
| 74 // Whether or not this DemuxerStream allows midstream configuration changes. | 82 // Whether or not this DemuxerStream allows midstream configuration changes. |
| 75 // | 83 // |
| 76 // A DemuxerStream that returns 'true' to this may return the 'kConfigChange' | 84 // A DemuxerStream that returns 'true' to this may return the 'kConfigChange' |
| 77 // status from a Read() call. In this case the client is expected to be | 85 // status from a Read() call. In this case the client is expected to be |
| 78 // capable of taking appropriate action to handle config changes. Otherwise | 86 // capable of taking appropriate action to handle config changes. Otherwise |
| 79 // audio_decoder_config() and video_decoder_config()'s return values are | 87 // audio_decoder_config() and video_decoder_config()'s return values are |
| 80 // guaranteed to remain constant, and the client may make optimizations based | 88 // guaranteed to remain constant, and the client may make optimizations based |
| 81 // on this. | 89 // on this. |
| 82 virtual bool SupportsConfigChanges() = 0; | 90 virtual bool SupportsConfigChanges() = 0; |
| 83 | 91 |
| 84 virtual VideoRotation video_rotation() = 0; | 92 virtual VideoRotation video_rotation() = 0; |
| 85 | 93 |
| 86 protected: | 94 protected: |
| 87 // Only allow concrete implementations to get deleted. | 95 // Only allow concrete implementations to get deleted. |
| 88 virtual ~DemuxerStream(); | 96 virtual ~DemuxerStream(); |
| 89 }; | 97 }; |
| 90 | 98 |
| 91 } // namespace media | 99 } // namespace media |
| 92 | 100 |
| 93 #endif // MEDIA_BASE_DEMUXER_STREAM_H_ | 101 #endif // MEDIA_BASE_DEMUXER_STREAM_H_ |
| OLD | NEW |