Loading cmds/stagefright/SimplePlayer.cpp +5 −9 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/MediaCodec.h> #include <media/stagefright/MediaErrors.h> #include <media/stagefright/NativeWindowWrapper.h> #include <media/stagefright/NuMediaExtractor.h> namespace android { Loading Loading @@ -74,8 +73,7 @@ status_t SimplePlayer::setSurface(const sp<IGraphicBufferProducer> &bufferProduc surface = new Surface(bufferProducer); } msg->setObject( "native-window", new NativeWindowWrapper(surface)); msg->setObject("surface", surface); sp<AMessage> response; return PostAndAwaitResponse(msg, &response); Loading Loading @@ -133,10 +131,8 @@ void SimplePlayer::onMessageReceived(const sp<AMessage> &msg) { err = INVALID_OPERATION; } else { sp<RefBase> obj; CHECK(msg->findObject("native-window", &obj)); mNativeWindow = static_cast<NativeWindowWrapper *>(obj.get()); CHECK(msg->findObject("surface", &obj)); mSurface = static_cast<Surface *>(obj.get()); err = OK; } Loading Loading @@ -325,7 +321,7 @@ status_t SimplePlayer::onPrepare() { err = state->mCodec->configure( format, isVideo ? mNativeWindow->getSurfaceTextureClient() : NULL, isVideo ? mSurface : NULL, NULL /* crypto */, 0 /* flags */); Loading Loading @@ -412,7 +408,7 @@ status_t SimplePlayer::onReset() { mStateByTrackIndex.clear(); mCodecLooper.clear(); mExtractor.clear(); mNativeWindow.clear(); mSurface.clear(); mPath.clear(); return OK; Loading cmds/stagefright/SimplePlayer.h +2 −2 Original line number Diff line number Diff line Loading @@ -25,8 +25,8 @@ struct ALooper; struct AudioTrack; class IGraphicBufferProducer; struct MediaCodec; struct NativeWindowWrapper; struct NuMediaExtractor; class Surface; struct SimplePlayer : public AHandler { SimplePlayer(); Loading Loading @@ -84,7 +84,7 @@ private: State mState; AString mPath; sp<NativeWindowWrapper> mNativeWindow; sp<Surface> mSurface; sp<NuMediaExtractor> mExtractor; sp<ALooper> mCodecLooper; Loading cmds/stagefright/sf2.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -38,10 +38,10 @@ #include <media/stagefright/MediaExtractor.h> #include <media/stagefright/MediaSource.h> #include <media/stagefright/MetaData.h> #include <media/stagefright/NativeWindowWrapper.h> #include <media/stagefright/Utils.h> #include <gui/SurfaceComposerClient.h> #include <gui/Surface.h> #include "include/ESDS.h" Loading Loading @@ -154,8 +154,7 @@ protected: sp<AMessage> format = makeFormat(mSource->getFormat()); if (mSurface != NULL) { format->setObject( "native-window", new NativeWindowWrapper(mSurface)); format->setObject("surface", mSurface); } mCodec->initiateSetup(format); Loading include/media/stagefright/NativeWindowWrapper.hdeleted 100644 → 0 +0 −50 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef NATIVE_WINDOW_WRAPPER_H_ #define NATIVE_WINDOW_WRAPPER_H_ #include <gui/Surface.h> namespace android { // Surface derives from ANativeWindow which derives from multiple // base classes, in order to carry it in AMessages, we'll temporarily wrap it // into a NativeWindowWrapper. struct NativeWindowWrapper : RefBase { NativeWindowWrapper( const sp<Surface> &surfaceTextureClient) : mSurfaceTextureClient(surfaceTextureClient) { } sp<ANativeWindow> getNativeWindow() const { return mSurfaceTextureClient; } sp<Surface> getSurfaceTextureClient() const { return mSurfaceTextureClient; } private: const sp<Surface> mSurfaceTextureClient; DISALLOW_EVIL_CONSTRUCTORS(NativeWindowWrapper); }; } // namespace android #endif // NATIVE_WINDOW_WRAPPER_H_ media/libmediaplayerservice/nuplayer/NuPlayer.cpp +24 −28 Original line number Diff line number Diff line Loading @@ -48,7 +48,9 @@ #include <media/stagefright/MediaDefs.h> #include <media/stagefright/MediaErrors.h> #include <media/stagefright/MetaData.h> #include <gui/IGraphicBufferProducer.h> #include <gui/Surface.h> #include "avc_utils.h" Loading Loading @@ -99,16 +101,16 @@ private: }; struct NuPlayer::SetSurfaceAction : public Action { SetSurfaceAction(const sp<NativeWindowWrapper> &wrapper) : mWrapper(wrapper) { SetSurfaceAction(const sp<Surface> &surface) : mSurface(surface) { } virtual void execute(NuPlayer *player) { player->performSetSurface(mWrapper); player->performSetSurface(mSurface); } private: sp<NativeWindowWrapper> mWrapper; sp<Surface> mSurface; DISALLOW_EVIL_CONSTRUCTORS(SetSurfaceAction); }; Loading Loading @@ -311,15 +313,12 @@ void NuPlayer::prepareAsync() { void NuPlayer::setVideoSurfaceTextureAsync( const sp<IGraphicBufferProducer> &bufferProducer) { sp<AMessage> msg = new AMessage(kWhatSetVideoNativeWindow, this); sp<AMessage> msg = new AMessage(kWhatSetVideoSurface, this); if (bufferProducer == NULL) { msg->setObject("native-window", NULL); msg->setObject("surface", NULL); } else { msg->setObject( "native-window", new NativeWindowWrapper( new Surface(bufferProducer, true /* controlledByApp */))); msg->setObject("surface", new Surface(bufferProducer, true /* controlledByApp */)); } msg->post(); Loading Loading @@ -610,15 +609,15 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { break; } case kWhatSetVideoNativeWindow: case kWhatSetVideoSurface: { ALOGV("kWhatSetVideoNativeWindow"); ALOGV("kWhatSetVideoSurface"); sp<RefBase> obj; CHECK(msg->findObject("native-window", &obj)); CHECK(msg->findObject("surface", &obj)); sp<Surface> surface = static_cast<Surface *>(obj.get()); if (mSource == NULL || mSource->getFormat(false /* audio */) == NULL) { performSetSurface(static_cast<NativeWindowWrapper *>(obj.get())); performSetSurface(surface); break; } Loading @@ -626,9 +625,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { new FlushDecoderAction(FLUSH_CMD_FLUSH /* audio */, FLUSH_CMD_SHUTDOWN /* video */)); mDeferredActions.push_back( new SetSurfaceAction( static_cast<NativeWindowWrapper *>(obj.get()))); mDeferredActions.push_back(new SetSurfaceAction(surface)); if (obj != NULL) { if (mStarted) { Loading Loading @@ -813,7 +810,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { // initialize video before audio because successful initialization of // video may change deep buffer mode of audio. if (mNativeWindow != NULL) { if (mSurface != NULL) { instantiateDecoder(false, &mVideoDecoder); } Loading Loading @@ -861,7 +858,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { } if ((mAudioDecoder == NULL && mAudioSink != NULL) || (mVideoDecoder == NULL && mNativeWindow != NULL)) { || (mVideoDecoder == NULL && mSurface != NULL)) { msg->post(100000ll); mScanSourcesPending = true; } Loading Loading @@ -1207,7 +1204,7 @@ status_t NuPlayer::onInstantiateSecureDecoders() { // TRICKY: We rely on mRenderer being null, so that decoder does not start requesting // data on instantiation. if (mNativeWindow != NULL) { if (mSurface != NULL) { err = instantiateDecoder(false, &mVideoDecoder); if (err != OK) { return err; Loading Loading @@ -1454,10 +1451,10 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<DecoderBase> *decoder) { notify->setInt32("generation", mVideoDecoderGeneration); *decoder = new Decoder( notify, mSource, mRenderer, mNativeWindow, mCCDecoder); notify, mSource, mRenderer, mSurface, mCCDecoder); // enable FRC if high-quality AV sync is requested, even if not // queuing to native window, as this will even improve textureview // directly queuing to display, as this will even improve textureview // playback. { char value[PROPERTY_VALUE_MAX]; Loading Loading @@ -1629,9 +1626,8 @@ void NuPlayer::queueDecoderShutdown( status_t NuPlayer::setVideoScalingMode(int32_t mode) { mVideoScalingMode = mode; if (mNativeWindow != NULL) { status_t ret = native_window_set_scaling_mode( mNativeWindow->getNativeWindow().get(), mVideoScalingMode); if (mSurface != NULL) { status_t ret = native_window_set_scaling_mode(mSurface.get(), mVideoScalingMode); if (ret != OK) { ALOGE("Failed to set scaling mode (%d): %s", -ret, strerror(-ret)); Loading Loading @@ -1825,10 +1821,10 @@ void NuPlayer::performScanSources() { } } void NuPlayer::performSetSurface(const sp<NativeWindowWrapper> &wrapper) { void NuPlayer::performSetSurface(const sp<Surface> &surface) { ALOGV("performSetSurface"); mNativeWindow = wrapper; mSurface = surface; // XXX - ignore error from setVideoScalingMode for now setVideoScalingMode(mVideoScalingMode); Loading Loading
cmds/stagefright/SimplePlayer.cpp +5 −9 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/MediaCodec.h> #include <media/stagefright/MediaErrors.h> #include <media/stagefright/NativeWindowWrapper.h> #include <media/stagefright/NuMediaExtractor.h> namespace android { Loading Loading @@ -74,8 +73,7 @@ status_t SimplePlayer::setSurface(const sp<IGraphicBufferProducer> &bufferProduc surface = new Surface(bufferProducer); } msg->setObject( "native-window", new NativeWindowWrapper(surface)); msg->setObject("surface", surface); sp<AMessage> response; return PostAndAwaitResponse(msg, &response); Loading Loading @@ -133,10 +131,8 @@ void SimplePlayer::onMessageReceived(const sp<AMessage> &msg) { err = INVALID_OPERATION; } else { sp<RefBase> obj; CHECK(msg->findObject("native-window", &obj)); mNativeWindow = static_cast<NativeWindowWrapper *>(obj.get()); CHECK(msg->findObject("surface", &obj)); mSurface = static_cast<Surface *>(obj.get()); err = OK; } Loading Loading @@ -325,7 +321,7 @@ status_t SimplePlayer::onPrepare() { err = state->mCodec->configure( format, isVideo ? mNativeWindow->getSurfaceTextureClient() : NULL, isVideo ? mSurface : NULL, NULL /* crypto */, 0 /* flags */); Loading Loading @@ -412,7 +408,7 @@ status_t SimplePlayer::onReset() { mStateByTrackIndex.clear(); mCodecLooper.clear(); mExtractor.clear(); mNativeWindow.clear(); mSurface.clear(); mPath.clear(); return OK; Loading
cmds/stagefright/SimplePlayer.h +2 −2 Original line number Diff line number Diff line Loading @@ -25,8 +25,8 @@ struct ALooper; struct AudioTrack; class IGraphicBufferProducer; struct MediaCodec; struct NativeWindowWrapper; struct NuMediaExtractor; class Surface; struct SimplePlayer : public AHandler { SimplePlayer(); Loading Loading @@ -84,7 +84,7 @@ private: State mState; AString mPath; sp<NativeWindowWrapper> mNativeWindow; sp<Surface> mSurface; sp<NuMediaExtractor> mExtractor; sp<ALooper> mCodecLooper; Loading
cmds/stagefright/sf2.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -38,10 +38,10 @@ #include <media/stagefright/MediaExtractor.h> #include <media/stagefright/MediaSource.h> #include <media/stagefright/MetaData.h> #include <media/stagefright/NativeWindowWrapper.h> #include <media/stagefright/Utils.h> #include <gui/SurfaceComposerClient.h> #include <gui/Surface.h> #include "include/ESDS.h" Loading Loading @@ -154,8 +154,7 @@ protected: sp<AMessage> format = makeFormat(mSource->getFormat()); if (mSurface != NULL) { format->setObject( "native-window", new NativeWindowWrapper(mSurface)); format->setObject("surface", mSurface); } mCodec->initiateSetup(format); Loading
include/media/stagefright/NativeWindowWrapper.hdeleted 100644 → 0 +0 −50 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef NATIVE_WINDOW_WRAPPER_H_ #define NATIVE_WINDOW_WRAPPER_H_ #include <gui/Surface.h> namespace android { // Surface derives from ANativeWindow which derives from multiple // base classes, in order to carry it in AMessages, we'll temporarily wrap it // into a NativeWindowWrapper. struct NativeWindowWrapper : RefBase { NativeWindowWrapper( const sp<Surface> &surfaceTextureClient) : mSurfaceTextureClient(surfaceTextureClient) { } sp<ANativeWindow> getNativeWindow() const { return mSurfaceTextureClient; } sp<Surface> getSurfaceTextureClient() const { return mSurfaceTextureClient; } private: const sp<Surface> mSurfaceTextureClient; DISALLOW_EVIL_CONSTRUCTORS(NativeWindowWrapper); }; } // namespace android #endif // NATIVE_WINDOW_WRAPPER_H_
media/libmediaplayerservice/nuplayer/NuPlayer.cpp +24 −28 Original line number Diff line number Diff line Loading @@ -48,7 +48,9 @@ #include <media/stagefright/MediaDefs.h> #include <media/stagefright/MediaErrors.h> #include <media/stagefright/MetaData.h> #include <gui/IGraphicBufferProducer.h> #include <gui/Surface.h> #include "avc_utils.h" Loading Loading @@ -99,16 +101,16 @@ private: }; struct NuPlayer::SetSurfaceAction : public Action { SetSurfaceAction(const sp<NativeWindowWrapper> &wrapper) : mWrapper(wrapper) { SetSurfaceAction(const sp<Surface> &surface) : mSurface(surface) { } virtual void execute(NuPlayer *player) { player->performSetSurface(mWrapper); player->performSetSurface(mSurface); } private: sp<NativeWindowWrapper> mWrapper; sp<Surface> mSurface; DISALLOW_EVIL_CONSTRUCTORS(SetSurfaceAction); }; Loading Loading @@ -311,15 +313,12 @@ void NuPlayer::prepareAsync() { void NuPlayer::setVideoSurfaceTextureAsync( const sp<IGraphicBufferProducer> &bufferProducer) { sp<AMessage> msg = new AMessage(kWhatSetVideoNativeWindow, this); sp<AMessage> msg = new AMessage(kWhatSetVideoSurface, this); if (bufferProducer == NULL) { msg->setObject("native-window", NULL); msg->setObject("surface", NULL); } else { msg->setObject( "native-window", new NativeWindowWrapper( new Surface(bufferProducer, true /* controlledByApp */))); msg->setObject("surface", new Surface(bufferProducer, true /* controlledByApp */)); } msg->post(); Loading Loading @@ -610,15 +609,15 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { break; } case kWhatSetVideoNativeWindow: case kWhatSetVideoSurface: { ALOGV("kWhatSetVideoNativeWindow"); ALOGV("kWhatSetVideoSurface"); sp<RefBase> obj; CHECK(msg->findObject("native-window", &obj)); CHECK(msg->findObject("surface", &obj)); sp<Surface> surface = static_cast<Surface *>(obj.get()); if (mSource == NULL || mSource->getFormat(false /* audio */) == NULL) { performSetSurface(static_cast<NativeWindowWrapper *>(obj.get())); performSetSurface(surface); break; } Loading @@ -626,9 +625,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { new FlushDecoderAction(FLUSH_CMD_FLUSH /* audio */, FLUSH_CMD_SHUTDOWN /* video */)); mDeferredActions.push_back( new SetSurfaceAction( static_cast<NativeWindowWrapper *>(obj.get()))); mDeferredActions.push_back(new SetSurfaceAction(surface)); if (obj != NULL) { if (mStarted) { Loading Loading @@ -813,7 +810,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { // initialize video before audio because successful initialization of // video may change deep buffer mode of audio. if (mNativeWindow != NULL) { if (mSurface != NULL) { instantiateDecoder(false, &mVideoDecoder); } Loading Loading @@ -861,7 +858,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { } if ((mAudioDecoder == NULL && mAudioSink != NULL) || (mVideoDecoder == NULL && mNativeWindow != NULL)) { || (mVideoDecoder == NULL && mSurface != NULL)) { msg->post(100000ll); mScanSourcesPending = true; } Loading Loading @@ -1207,7 +1204,7 @@ status_t NuPlayer::onInstantiateSecureDecoders() { // TRICKY: We rely on mRenderer being null, so that decoder does not start requesting // data on instantiation. if (mNativeWindow != NULL) { if (mSurface != NULL) { err = instantiateDecoder(false, &mVideoDecoder); if (err != OK) { return err; Loading Loading @@ -1454,10 +1451,10 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<DecoderBase> *decoder) { notify->setInt32("generation", mVideoDecoderGeneration); *decoder = new Decoder( notify, mSource, mRenderer, mNativeWindow, mCCDecoder); notify, mSource, mRenderer, mSurface, mCCDecoder); // enable FRC if high-quality AV sync is requested, even if not // queuing to native window, as this will even improve textureview // directly queuing to display, as this will even improve textureview // playback. { char value[PROPERTY_VALUE_MAX]; Loading Loading @@ -1629,9 +1626,8 @@ void NuPlayer::queueDecoderShutdown( status_t NuPlayer::setVideoScalingMode(int32_t mode) { mVideoScalingMode = mode; if (mNativeWindow != NULL) { status_t ret = native_window_set_scaling_mode( mNativeWindow->getNativeWindow().get(), mVideoScalingMode); if (mSurface != NULL) { status_t ret = native_window_set_scaling_mode(mSurface.get(), mVideoScalingMode); if (ret != OK) { ALOGE("Failed to set scaling mode (%d): %s", -ret, strerror(-ret)); Loading Loading @@ -1825,10 +1821,10 @@ void NuPlayer::performScanSources() { } } void NuPlayer::performSetSurface(const sp<NativeWindowWrapper> &wrapper) { void NuPlayer::performSetSurface(const sp<Surface> &surface) { ALOGV("performSetSurface"); mNativeWindow = wrapper; mSurface = surface; // XXX - ignore error from setVideoScalingMode for now setVideoScalingMode(mVideoScalingMode); Loading