Loading include/media/stagefright/MediaCodec.h +3 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,9 @@ private: void extractCSD(const sp<AMessage> &format); status_t queueCSDInputBuffer(size_t bufferIndex); status_t setNativeWindow( const sp<SurfaceTextureClient> &surfaceTextureClient); DISALLOW_EVIL_CONSTRUCTORS(MediaCodec); }; Loading media/libstagefright/MediaCodec.cpp +49 −10 Original line number Diff line number Diff line Loading @@ -796,9 +796,6 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { break; } mReplyID = replyID; setState(CONFIGURING); sp<RefBase> obj; if (!msg->findObject("native-window", &obj)) { obj.clear(); Loading @@ -810,15 +807,24 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { if (obj != NULL) { format->setObject("native-window", obj); if (mFlags & kFlagIsSoftwareCodec) { mNativeWindow = status_t err = setNativeWindow( static_cast<NativeWindowWrapper *>(obj.get()) ->getSurfaceTextureClient(); ->getSurfaceTextureClient()); if (err != OK) { sp<AMessage> response = new AMessage; response->setInt32("err", err); response->postReply(replyID); break; } } else { mNativeWindow.clear(); setNativeWindow(NULL); } mReplyID = replyID; setState(CONFIGURING); void *crypto; if (!msg->findPointer("crypto", &crypto)) { crypto = NULL; Loading Loading @@ -1180,12 +1186,12 @@ status_t MediaCodec::queueCSDInputBuffer(size_t bufferIndex) { } void MediaCodec::setState(State newState) { if (newState == INITIALIZED) { if (newState == INITIALIZED || newState == UNINITIALIZED) { delete mSoftRenderer; mSoftRenderer = NULL; mCrypto.clear(); mNativeWindow.clear(); setNativeWindow(NULL); mOutputFormat.clear(); mFlags &= ~kFlagOutputFormatChanged; Loading Loading @@ -1425,4 +1431,37 @@ ssize_t MediaCodec::dequeuePortBuffer(int32_t portIndex) { return index; } status_t MediaCodec::setNativeWindow( const sp<SurfaceTextureClient> &surfaceTextureClient) { status_t err; if (mNativeWindow != NULL) { err = native_window_api_disconnect( mNativeWindow.get(), NATIVE_WINDOW_API_MEDIA); if (err != OK) { ALOGW("native_window_api_disconnect returned an error: %s (%d)", strerror(-err), err); } mNativeWindow.clear(); } if (surfaceTextureClient != NULL) { err = native_window_api_connect( surfaceTextureClient.get(), NATIVE_WINDOW_API_MEDIA); if (err != OK) { ALOGE("native_window_api_connect returned an error: %s (%d)", strerror(-err), err); return err; } mNativeWindow = surfaceTextureClient; } return OK; } } // namespace android Loading
include/media/stagefright/MediaCodec.h +3 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,9 @@ private: void extractCSD(const sp<AMessage> &format); status_t queueCSDInputBuffer(size_t bufferIndex); status_t setNativeWindow( const sp<SurfaceTextureClient> &surfaceTextureClient); DISALLOW_EVIL_CONSTRUCTORS(MediaCodec); }; Loading
media/libstagefright/MediaCodec.cpp +49 −10 Original line number Diff line number Diff line Loading @@ -796,9 +796,6 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { break; } mReplyID = replyID; setState(CONFIGURING); sp<RefBase> obj; if (!msg->findObject("native-window", &obj)) { obj.clear(); Loading @@ -810,15 +807,24 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { if (obj != NULL) { format->setObject("native-window", obj); if (mFlags & kFlagIsSoftwareCodec) { mNativeWindow = status_t err = setNativeWindow( static_cast<NativeWindowWrapper *>(obj.get()) ->getSurfaceTextureClient(); ->getSurfaceTextureClient()); if (err != OK) { sp<AMessage> response = new AMessage; response->setInt32("err", err); response->postReply(replyID); break; } } else { mNativeWindow.clear(); setNativeWindow(NULL); } mReplyID = replyID; setState(CONFIGURING); void *crypto; if (!msg->findPointer("crypto", &crypto)) { crypto = NULL; Loading Loading @@ -1180,12 +1186,12 @@ status_t MediaCodec::queueCSDInputBuffer(size_t bufferIndex) { } void MediaCodec::setState(State newState) { if (newState == INITIALIZED) { if (newState == INITIALIZED || newState == UNINITIALIZED) { delete mSoftRenderer; mSoftRenderer = NULL; mCrypto.clear(); mNativeWindow.clear(); setNativeWindow(NULL); mOutputFormat.clear(); mFlags &= ~kFlagOutputFormatChanged; Loading Loading @@ -1425,4 +1431,37 @@ ssize_t MediaCodec::dequeuePortBuffer(int32_t portIndex) { return index; } status_t MediaCodec::setNativeWindow( const sp<SurfaceTextureClient> &surfaceTextureClient) { status_t err; if (mNativeWindow != NULL) { err = native_window_api_disconnect( mNativeWindow.get(), NATIVE_WINDOW_API_MEDIA); if (err != OK) { ALOGW("native_window_api_disconnect returned an error: %s (%d)", strerror(-err), err); } mNativeWindow.clear(); } if (surfaceTextureClient != NULL) { err = native_window_api_connect( surfaceTextureClient.get(), NATIVE_WINDOW_API_MEDIA); if (err != OK) { ALOGE("native_window_api_connect returned an error: %s (%d)", strerror(-err), err); return err; } mNativeWindow = surfaceTextureClient; } return OK; } } // namespace android