From c5619c7a6dcc1137fde7520351ad5284e3e958ab Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Tue, 8 Jul 2014 18:50:05 -0700 Subject: MediaCodec async callbacks Bug: 11990118 Change-Id: I6fe4b407d9c85cddec8d958620d5d356735273cf --- include/media/stagefright/MediaCodec.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include') diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h index 3fa7b48..046496c 100644 --- a/include/media/stagefright/MediaCodec.h +++ b/include/media/stagefright/MediaCodec.h @@ -44,6 +44,13 @@ struct MediaCodec : public AHandler { BUFFER_FLAG_EOS = 4, }; + enum { + CB_INPUT_AVAILABLE = 1, + CB_OUTPUT_AVAILABLE = 2, + CB_ERROR = 3, + CB_OUTPUT_FORMAT_CHANGED = 4, + }; + static sp CreateByType( const sp &looper, const char *mime, bool encoder); @@ -56,6 +63,8 @@ struct MediaCodec : public AHandler { const sp &crypto, uint32_t flags); + status_t setCallback(const sp &callback); + status_t createInputSurface(sp* bufferProducer); status_t start(); @@ -173,6 +182,7 @@ private: kWhatRequestActivityNotification = 'racN', kWhatGetName = 'getN', kWhatSetParameters = 'setP', + kWhatSetCallback = 'setC', }; enum { @@ -186,6 +196,7 @@ private: kFlagSawMediaServerDie = 128, kFlagIsEncoder = 256, kFlagGatherCodecSpecificData = 512, + kFlagIsAsync = 1024, }; struct BufferInfo { @@ -208,6 +219,7 @@ private: SoftwareRenderer *mSoftRenderer; sp mOutputFormat; sp mInputFormat; + sp mCallback; // Used only to synchronize asynchronous getBufferAndFormat // across all the other (synchronous) buffer state change @@ -237,6 +249,8 @@ private: static status_t PostAndAwaitResponse( const sp &msg, sp *response); + static void PostReplyWithError(int32_t replyID, int32_t err); + status_t init(const char *name, bool nameIsType, bool encoder); void setState(State newState); @@ -263,6 +277,11 @@ private: void postActivityNotificationIfPossible(); + void onInputBufferAvailable(); + void onOutputBufferAvailable(); + void onError(int32_t actionCode, status_t err); + void onOutputFormatChanged(); + status_t onSetParameters(const sp ¶ms); status_t amendOutputFormatWithCodecSpecificData(const sp &buffer); -- cgit v1.1