Chromium Code Reviews| Index: media/base/android/media_codec_bridge.h |
| diff --git a/media/base/android/media_codec_bridge.h b/media/base/android/media_codec_bridge.h |
| index cdd883f03120aa8cb89a2cf823ba031416413b2c..5a28c93ff565e757ffa9115a4f08ccc400dcdc7d 100644 |
| --- a/media/base/android/media_codec_bridge.h |
| +++ b/media/base/android/media_codec_bridge.h |
| @@ -44,6 +44,9 @@ class MEDIA_EXPORT MediaCodecBridge { |
| // Returns true if MediaCodec is available on the device. |
| static bool IsAvailable(); |
| + // Returns true if MediaCodec.setParameters() is available on the device. |
| + static bool SupportsSetParameters(); |
| + |
| // Returns whether MediaCodecBridge has a decoder that |is_secure| and can |
| // decode |codec| type. |
| static bool CanDecode(const std::string& codec, bool is_secure); |
| @@ -52,12 +55,13 @@ class MEDIA_EXPORT MediaCodecBridge { |
| // TODO(qinmin): Curretly the codecs string only contains one codec, do we |
| // need more specific codecs separated by comma. (e.g. "vp8" -> "vp8, vp8.0") |
| struct CodecsInfo { |
| - std::string codecs; |
| - std::string name; |
| + std::string codecs; // E.g. "vp8" or "avc1". |
| + std::string name; // E.g. "OMX.google.vp8.decoder". |
| + bool is_encoder; |
| }; |
| // Get a list of supported codecs. |
| - static void GetCodecsInfo(std::vector<CodecsInfo>* codecs_info); |
| + static std::vector<CodecsInfo> GetCodecsInfo(); |
| virtual ~MediaCodecBridge(); |
| @@ -80,15 +84,21 @@ class MEDIA_EXPORT MediaCodecBridge { |
| // returns a format change by returning INFO_OUTPUT_FORMAT_CHANGED |
| void GetOutputFormat(int* width, int* height); |
| + // Returns the number of input buffers used by the codec. |
| + int GetInputBuffersCount(); |
| + |
| // Submits a byte array to the given input buffer. Call this after getting an |
| - // available buffer from DequeueInputBuffer(). |
| + // available buffer from DequeueInputBuffer(). If |data| is NULL, assume the |
| + // input buffer has already been populated (but still obey |size|). |
| MediaCodecStatus QueueInputBuffer(int index, |
| const uint8* data, |
| int size, |
| const base::TimeDelta& presentation_time); |
| // Similar to the above call, but submits a buffer that is encrypted. |
| - // Note: NULL |subsamples| indicates the whole buffer is encrypted. |
| + // Note: NULL |subsamples| indicates the whole buffer is encrypted. If |data| |
| + // is NULL, assume the input buffer has already been populated (but still obey |
| + // |data_size|). |
| MediaCodecStatus QueueSecureInputBuffer( |
| int index, |
| const uint8* data, int data_size, |
| @@ -112,35 +122,49 @@ class MEDIA_EXPORT MediaCodecBridge { |
| // Dequeues an output buffer, block at most timeout_us microseconds. |
| // Returns the status of this operation. If OK is returned, the output |
| // parameters should be populated. Otherwise, the values of output parameters |
| - // should not be used. |
| + // should not be used. Output parameters other than index/offset/size are |
| + // optional and only set if not NULL. |
| // Note: Never use infinite timeout as this would block the decoder thread and |
| // prevent the decoder job from being released. |
| // TODO(xhwang): Can we drop |end_of_stream| and return |
| // MEDIA_CODEC_OUTPUT_END_OF_STREAM? |
| MediaCodecStatus DequeueOutputBuffer(const base::TimeDelta& timeout, |
| - int* index, |
| - size_t* offset, |
| - size_t* size, |
| + int* index, size_t* offset, size_t* size, |
| base::TimeDelta* presentation_time, |
| - bool* end_of_stream); |
| + bool* end_of_stream, bool* key_frame); |
| - // Returns the buffer to the codec. If you previously specified a surface |
| - // when configuring this video decoder you can optionally render the buffer. |
| + // Returns the buffer to the codec. If you previously specified a surface when |
| + // configuring this video decoder you can |
| + // optionally render the buffer. |
|
xhwang
2013/11/19 00:11:25
nit: merge with the previous line?
Ami GONE FROM CHROMIUM
2013/11/21 22:59:07
Done.
|
| void ReleaseOutputBuffer(int index, bool render); |
| + // Returns the number of output buffers used by the codec. |
| + int GetOutputBuffersCount(); |
| + |
| + // Returns the capacity of each output buffer used by the codec. |
| + size_t GetOutputBuffersCapacity(); |
| + |
| // Gets output buffers from media codec and keeps them inside the java class. |
| // To access them, use DequeueOutputBuffer(). Returns whether output buffers |
| // were successfully obtained. |
| bool GetOutputBuffers() WARN_UNUSED_RESULT; |
| + // Returns an input buffers' base pointer and capacity. |
|
xhwang
2013/11/19 00:11:25
s/buffers'/buffer's
Ami GONE FROM CHROMIUM
2013/11/21 22:59:07
Done.
|
| + void GetInputBuffer(int input_buffer_index, uint8** data, size_t* capacity); |
| + |
| + // Copy |dst_size| bytes from output buffer |index|'s |offset| onwards into |
| + // |*dst|. |
| + bool CopyFromOutputBuffer(int index, size_t offset, void* dst, int dst_size); |
| + |
| static bool RegisterMediaCodecBridge(JNIEnv* env); |
| protected: |
| // Returns true if |mime_type| is known to be unaccelerated (i.e. backed by a |
| // software codec instead of a hardware one). |
| - static bool IsKnownUnaccelerated(const std::string& mime_type); |
| + static bool IsKnownUnaccelerated(const std::string& mime_type, |
| + bool is_encoder); |
| - MediaCodecBridge(const std::string& mime, bool is_secure); |
| + MediaCodecBridge(const std::string& mime, bool is_secure, bool is_encoder); |
| // Calls start() against the media codec instance. Used in StartXXX() after |
| // configuring media codec. Returns whether media codec was successfully |
| @@ -148,13 +172,13 @@ class MEDIA_EXPORT MediaCodecBridge { |
| bool StartInternal() WARN_UNUSED_RESULT; |
| jobject media_codec() { return j_media_codec_.obj(); } |
| + bool is_encoder_; |
| private: |
| // Fills a particular input buffer; returns false if |data_size| exceeds the |
| // input buffer's capacity (and doesn't touch the input buffer in that case). |
| - bool FillInputBuffer(int index, |
| - const uint8* data, |
| - int data_size) WARN_UNUSED_RESULT; |
| + bool FillInputBuffer(int index, const uint8* data, |
| + size_t data_size) WARN_UNUSED_RESULT; |
| // Java MediaCodec instance. |
| base::android::ScopedJavaGlobalRef<jobject> j_media_codec_; |
| @@ -193,20 +217,30 @@ class AudioCodecBridge : public MediaCodecBridge { |
| class MEDIA_EXPORT VideoCodecBridge : public MediaCodecBridge { |
| public: |
| - // Returns an VideoCodecBridge instance if |codec| is supported, or a NULL |
| - // pointer otherwise. |
| - static VideoCodecBridge* Create(const VideoCodec& codec, bool is_secure); |
| - |
| // See MediaCodecBridge::IsKnownUnaccelerated(). |
| - static bool IsKnownUnaccelerated(const VideoCodec& codec); |
| - |
| - // Start the video codec bridge. |
| - // TODO(qinmin): Pass codec specific data if available. |
| - bool Start(const VideoCodec& codec, const gfx::Size& size, jobject surface, |
| - jobject media_crypto); |
| + static bool IsKnownUnaccelerated(const VideoCodec& codec, bool is_encoder); |
| + |
| + // Create, start, and return a VideoCodecBridge decoder or NULL on failure. |
| + static VideoCodecBridge* CreateDecoder( |
| + const VideoCodec& codec, // e.g. media::kCodecVP8 |
| + bool is_secure, const gfx::Size& size, // Output frame size. |
| + jobject surface, // Output surface, optional. |
| + jobject media_crypto); // MediaCrypto object, optional. |
| + |
| + // Create, start, and return a VideoCodecBridge encoder or NULL on failure. |
| + static VideoCodecBridge* CreateEncoder( |
| + const VideoCodec& codec, // e.g. media::kCodecVP8 |
| + const gfx::Size& size, // input frame size |
| + int bit_rate, // bits/second |
| + int frame_rate, // frames/second |
| + int i_frame_interval, // count |
| + int color_format); // MediaCodecInfo.CodecCapabilities. |
| + |
| + void SetVideoBitrate(int bps); |
| + void RequestKeyFrameSoon(); |
| private: |
| - VideoCodecBridge(const std::string& mime, bool is_secure); |
| + VideoCodecBridge(const std::string& mime, bool is_secure, bool is_encoder); |
| }; |
| } // namespace media |