Loading media/libmediaplayerservice/nuplayer/Android.mk +2 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,8 @@ LOCAL_C_INCLUDES := \ $(TOP)/frameworks/av/media/libmediaplayerservice \ $(TOP)/frameworks/native/include/media/openmax LOCAL_CFLAGS += -Werror -Wall LOCAL_CFLAGS += -Werror -Wall -DENABLE_STAGEFRIGHT_EXPERIMENTS LOCAL_CLANG := true LOCAL_MODULE:= libstagefright_nuplayer Loading media/libmediaplayerservice/nuplayer/NuPlayer.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -623,12 +623,19 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { case kWhatSetVideoSurface: { ALOGV("kWhatSetVideoSurface"); sp<RefBase> obj; CHECK(msg->findObject("surface", &obj)); sp<Surface> surface = static_cast<Surface *>(obj.get()); if (mSource == NULL || mSource->getFormat(false /* audio */) == NULL) { ALOGD("onSetVideoSurface(%p, %s video decoder)", surface.get(), (mSource != NULL && mSource->getFormat(false /* audio */) != NULL && mVideoDecoder != NULL) ? "have" : "no"); if (mSource == NULL || mSource->getFormat(false /* audio */) == NULL // NOTE: mVideoDecoder's mSurface is always non-null || (mVideoDecoder != NULL && mVideoDecoder->setVideoSurface(surface) == OK)) { performSetSurface(surface); break; } Loading media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp +56 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,22 @@ sp<AMessage> NuPlayer::Decoder::getStats() const { return mStats; } status_t NuPlayer::Decoder::setVideoSurface(const sp<Surface> &surface) { if (surface == NULL || ADebug::isExperimentEnabled("legacy-setsurface")) { return BAD_VALUE; } sp<AMessage> msg = new AMessage(kWhatSetVideoSurface, this); msg->setObject("surface", surface); sp<AMessage> response; status_t err = msg->postAndAwaitResponse(&response); if (err == OK && response != NULL) { CHECK(response->findInt32("err", &err)); } return err; } void NuPlayer::Decoder::onMessageReceived(const sp<AMessage> &msg) { ALOGV("[%s] onMessage: %s", mComponentName.c_str(), msg->debugString().c_str()); Loading Loading @@ -169,6 +185,46 @@ void NuPlayer::Decoder::onMessageReceived(const sp<AMessage> &msg) { break; } case kWhatSetVideoSurface: { sp<AReplyToken> replyID; CHECK(msg->senderAwaitsResponse(&replyID)); sp<RefBase> obj; CHECK(msg->findObject("surface", &obj)); sp<Surface> surface = static_cast<Surface *>(obj.get()); // non-null int32_t err = INVALID_OPERATION; // NOTE: in practice mSurface is always non-null, but checking here for completeness if (mCodec != NULL && mSurface != NULL) { // TODO: once AwesomePlayer is removed, remove this automatic connecting // to the surface by MediaPlayerService. // // at this point MediaPlayerService::client has already connected to the // surface, which MediaCodec does not expect err = native_window_api_disconnect(surface.get(), NATIVE_WINDOW_API_MEDIA); if (err == OK) { err = mCodec->setSurface(surface); ALOGI_IF(err, "codec setSurface returned: %d", err); if (err == OK) { // reconnect to the old surface as MPS::Client will expect to // be able to disconnect from it. (void)native_window_api_connect(mSurface.get(), NATIVE_WINDOW_API_MEDIA); mSurface = surface; } } if (err != OK) { // reconnect to the new surface on error as MPS::Client will expect to // be able to disconnect from it. (void)native_window_api_connect(surface.get(), NATIVE_WINDOW_API_MEDIA); } } sp<AMessage> response = new AMessage; response->setInt32("err", err); response->postReply(replyID); break; } default: DecoderBase::onMessageReceived(msg); break; Loading media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h +4 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ struct NuPlayer::Decoder : public DecoderBase { virtual sp<AMessage> getStats() const; // sets the output surface of video decoders. virtual status_t setVideoSurface(const sp<Surface> &surface); protected: virtual ~Decoder(); Loading @@ -50,6 +53,7 @@ private: enum { kWhatCodecNotify = 'cdcN', kWhatRenderBuffer = 'rndr', kWhatSetVideoSurface = 'sSur' }; sp<Surface> mSurface; Loading media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.h +2 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ namespace android { struct ABuffer; struct MediaCodec; class MediaBuffer; class Surface; struct NuPlayer::DecoderBase : public AHandler { DecoderBase(const sp<AMessage> ¬ify); Loading @@ -36,6 +37,7 @@ struct NuPlayer::DecoderBase : public AHandler { void setParameters(const sp<AMessage> ¶ms); void setRenderer(const sp<Renderer> &renderer); virtual status_t setVideoSurface(const sp<Surface> &) { return INVALID_OPERATION; } status_t getInputBuffers(Vector<sp<ABuffer> > *dstBuffers) const; void signalFlush(); Loading Loading
media/libmediaplayerservice/nuplayer/Android.mk +2 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,8 @@ LOCAL_C_INCLUDES := \ $(TOP)/frameworks/av/media/libmediaplayerservice \ $(TOP)/frameworks/native/include/media/openmax LOCAL_CFLAGS += -Werror -Wall LOCAL_CFLAGS += -Werror -Wall -DENABLE_STAGEFRIGHT_EXPERIMENTS LOCAL_CLANG := true LOCAL_MODULE:= libstagefright_nuplayer Loading
media/libmediaplayerservice/nuplayer/NuPlayer.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -623,12 +623,19 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { case kWhatSetVideoSurface: { ALOGV("kWhatSetVideoSurface"); sp<RefBase> obj; CHECK(msg->findObject("surface", &obj)); sp<Surface> surface = static_cast<Surface *>(obj.get()); if (mSource == NULL || mSource->getFormat(false /* audio */) == NULL) { ALOGD("onSetVideoSurface(%p, %s video decoder)", surface.get(), (mSource != NULL && mSource->getFormat(false /* audio */) != NULL && mVideoDecoder != NULL) ? "have" : "no"); if (mSource == NULL || mSource->getFormat(false /* audio */) == NULL // NOTE: mVideoDecoder's mSurface is always non-null || (mVideoDecoder != NULL && mVideoDecoder->setVideoSurface(surface) == OK)) { performSetSurface(surface); break; } Loading
media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp +56 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,22 @@ sp<AMessage> NuPlayer::Decoder::getStats() const { return mStats; } status_t NuPlayer::Decoder::setVideoSurface(const sp<Surface> &surface) { if (surface == NULL || ADebug::isExperimentEnabled("legacy-setsurface")) { return BAD_VALUE; } sp<AMessage> msg = new AMessage(kWhatSetVideoSurface, this); msg->setObject("surface", surface); sp<AMessage> response; status_t err = msg->postAndAwaitResponse(&response); if (err == OK && response != NULL) { CHECK(response->findInt32("err", &err)); } return err; } void NuPlayer::Decoder::onMessageReceived(const sp<AMessage> &msg) { ALOGV("[%s] onMessage: %s", mComponentName.c_str(), msg->debugString().c_str()); Loading Loading @@ -169,6 +185,46 @@ void NuPlayer::Decoder::onMessageReceived(const sp<AMessage> &msg) { break; } case kWhatSetVideoSurface: { sp<AReplyToken> replyID; CHECK(msg->senderAwaitsResponse(&replyID)); sp<RefBase> obj; CHECK(msg->findObject("surface", &obj)); sp<Surface> surface = static_cast<Surface *>(obj.get()); // non-null int32_t err = INVALID_OPERATION; // NOTE: in practice mSurface is always non-null, but checking here for completeness if (mCodec != NULL && mSurface != NULL) { // TODO: once AwesomePlayer is removed, remove this automatic connecting // to the surface by MediaPlayerService. // // at this point MediaPlayerService::client has already connected to the // surface, which MediaCodec does not expect err = native_window_api_disconnect(surface.get(), NATIVE_WINDOW_API_MEDIA); if (err == OK) { err = mCodec->setSurface(surface); ALOGI_IF(err, "codec setSurface returned: %d", err); if (err == OK) { // reconnect to the old surface as MPS::Client will expect to // be able to disconnect from it. (void)native_window_api_connect(mSurface.get(), NATIVE_WINDOW_API_MEDIA); mSurface = surface; } } if (err != OK) { // reconnect to the new surface on error as MPS::Client will expect to // be able to disconnect from it. (void)native_window_api_connect(surface.get(), NATIVE_WINDOW_API_MEDIA); } } sp<AMessage> response = new AMessage; response->setInt32("err", err); response->postReply(replyID); break; } default: DecoderBase::onMessageReceived(msg); break; Loading
media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h +4 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ struct NuPlayer::Decoder : public DecoderBase { virtual sp<AMessage> getStats() const; // sets the output surface of video decoders. virtual status_t setVideoSurface(const sp<Surface> &surface); protected: virtual ~Decoder(); Loading @@ -50,6 +53,7 @@ private: enum { kWhatCodecNotify = 'cdcN', kWhatRenderBuffer = 'rndr', kWhatSetVideoSurface = 'sSur' }; sp<Surface> mSurface; Loading
media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.h +2 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ namespace android { struct ABuffer; struct MediaCodec; class MediaBuffer; class Surface; struct NuPlayer::DecoderBase : public AHandler { DecoderBase(const sp<AMessage> ¬ify); Loading @@ -36,6 +37,7 @@ struct NuPlayer::DecoderBase : public AHandler { void setParameters(const sp<AMessage> ¶ms); void setRenderer(const sp<Renderer> &renderer); virtual status_t setVideoSurface(const sp<Surface> &) { return INVALID_OPERATION; } status_t getInputBuffers(Vector<sp<ABuffer> > *dstBuffers) const; void signalFlush(); Loading