summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLajos Molnar <lajos@google.com>2015-04-30 18:18:34 -0700
committerLajos Molnar <lajos@google.com>2015-04-30 18:53:52 -0700
commit1de1e25cba872bd4c077c2e394f8ca9c70b65856 (patch)
tree7f01e01b5a3731a9c345684e38755d97e6a67f19
parent31de88566257d5546cf4eee9064d96926a4b0c24 (diff)
downloadframeworks_av-1de1e25cba872bd4c077c2e394f8ca9c70b65856.zip
frameworks_av-1de1e25cba872bd4c077c2e394f8ca9c70b65856.tar.gz
frameworks_av-1de1e25cba872bd4c077c2e394f8ca9c70b65856.tar.bz2
stagefright: remove NativeWindowWrapper
Now that Surface and SurfaceTextureClient are the same and Surface, it does not add value. Bug: 19489395 Change-Id: I016ecd1cf5cc51ce6244b6fa34ecd75f84e3db01
-rw-r--r--cmds/stagefright/SimplePlayer.cpp14
-rw-r--r--cmds/stagefright/SimplePlayer.h4
-rw-r--r--cmds/stagefright/sf2.cpp5
-rw-r--r--include/media/stagefright/NativeWindowWrapper.h50
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.cpp52
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.h7
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp25
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h4
-rw-r--r--media/libstagefright/ACodec.cpp14
-rw-r--r--media/libstagefright/MediaCodec.cpp11
10 files changed, 56 insertions, 130 deletions
diff --git a/cmds/stagefright/SimplePlayer.cpp b/cmds/stagefright/SimplePlayer.cpp
index bd33d86..50913cd 100644
--- a/cmds/stagefright/SimplePlayer.cpp
+++ b/cmds/stagefright/SimplePlayer.cpp
@@ -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 {
@@ -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);
@@ -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;
}
@@ -325,7 +321,7 @@ status_t SimplePlayer::onPrepare() {
err = state->mCodec->configure(
format,
- isVideo ? mNativeWindow->getSurfaceTextureClient() : NULL,
+ isVideo ? mSurface : NULL,
NULL /* crypto */,
0 /* flags */);
@@ -412,7 +408,7 @@ status_t SimplePlayer::onReset() {
mStateByTrackIndex.clear();
mCodecLooper.clear();
mExtractor.clear();
- mNativeWindow.clear();
+ mSurface.clear();
mPath.clear();
return OK;
diff --git a/cmds/stagefright/SimplePlayer.h b/cmds/stagefright/SimplePlayer.h
index ce993e8..ae9dfd2 100644
--- a/cmds/stagefright/SimplePlayer.h
+++ b/cmds/stagefright/SimplePlayer.h
@@ -25,8 +25,8 @@ struct ALooper;
struct AudioTrack;
class IGraphicBufferProducer;
struct MediaCodec;
-struct NativeWindowWrapper;
struct NuMediaExtractor;
+class Surface;
struct SimplePlayer : public AHandler {
SimplePlayer();
@@ -84,7 +84,7 @@ private:
State mState;
AString mPath;
- sp<NativeWindowWrapper> mNativeWindow;
+ sp<Surface> mSurface;
sp<NuMediaExtractor> mExtractor;
sp<ALooper> mCodecLooper;
diff --git a/cmds/stagefright/sf2.cpp b/cmds/stagefright/sf2.cpp
index 891d84b..0d64d2f 100644
--- a/cmds/stagefright/sf2.cpp
+++ b/cmds/stagefright/sf2.cpp
@@ -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"
@@ -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);
diff --git a/include/media/stagefright/NativeWindowWrapper.h b/include/media/stagefright/NativeWindowWrapper.h
deleted file mode 100644
index cfeec22..0000000
--- a/include/media/stagefright/NativeWindowWrapper.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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_
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 4e30093..9963353 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -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"
@@ -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);
};
@@ -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();
@@ -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;
}
@@ -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) {
@@ -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);
}
@@ -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;
}
@@ -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;
@@ -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];
@@ -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));
@@ -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);
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h
index 88e929d..fcf6841 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h
@@ -21,7 +21,6 @@
#include <media/AudioResamplerPublic.h>
#include <media/MediaPlayerInterface.h>
#include <media/stagefright/foundation/AHandler.h>
-#include <media/stagefright/NativeWindowWrapper.h>
namespace android {
@@ -112,7 +111,7 @@ private:
enum {
kWhatSetDataSource = '=DaS',
kWhatPrepare = 'prep',
- kWhatSetVideoNativeWindow = '=NaW',
+ kWhatSetVideoSurface = '=VSu',
kWhatSetAudioSink = '=AuS',
kWhatMoreDataQueued = 'more',
kWhatConfigPlayback = 'cfPB',
@@ -141,7 +140,7 @@ private:
uid_t mUID;
sp<Source> mSource;
uint32_t mSourceFlags;
- sp<NativeWindowWrapper> mNativeWindow;
+ sp<Surface> mSurface;
sp<MediaPlayerBase::AudioSink> mAudioSink;
sp<DecoderBase> mVideoDecoder;
bool mOffloadAudio;
@@ -251,7 +250,7 @@ private:
void performDecoderFlush(FlushCommand audio, FlushCommand video);
void performReset();
void performScanSources();
- void performSetSurface(const sp<NativeWindowWrapper> &wrapper);
+ void performSetSurface(const sp<Surface> &wrapper);
void performResumeDecoders(bool needNotify);
void onSourceNotify(const sp<AMessage> &msg);
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
index 3c4d695..376c93a 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
@@ -33,6 +33,8 @@
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaErrors.h>
+#include <gui/Surface.h>
+
#include "avc_utils.h"
#include "ATSParser.h"
@@ -42,10 +44,10 @@ NuPlayer::Decoder::Decoder(
const sp<AMessage> &notify,
const sp<Source> &source,
const sp<Renderer> &renderer,
- const sp<NativeWindowWrapper> &nativeWindow,
+ const sp<Surface> &surface,
const sp<CCDecoder> &ccDecoder)
: DecoderBase(notify),
- mNativeWindow(nativeWindow),
+ mSurface(surface),
mSource(source),
mRenderer(renderer),
mCCDecoder(ccDecoder),
@@ -178,14 +180,9 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
mIsAudio = !strncasecmp("audio/", mime.c_str(), 6);
mIsVideoAVC = !strcasecmp(MEDIA_MIMETYPE_VIDEO_AVC, mime.c_str());
- sp<Surface> surface = NULL;
- if (mNativeWindow != NULL) {
- surface = mNativeWindow->getSurfaceTextureClient();
- }
-
mComponentName = mime;
mComponentName.append(" decoder");
- ALOGV("[%s] onConfigure (surface=%p)", mComponentName.c_str(), surface.get());
+ ALOGV("[%s] onConfigure (surface=%p)", mComponentName.c_str(), mSurface.get());
mCodec = MediaCodec::CreateByType(mCodecLooper, mime.c_str(), false /* encoder */);
int32_t secure = 0;
@@ -210,17 +207,17 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
mCodec->getName(&mComponentName);
status_t err;
- if (mNativeWindow != NULL) {
+ if (mSurface != NULL) {
// disconnect from surface as MediaCodec will reconnect
err = native_window_api_disconnect(
- surface.get(), NATIVE_WINDOW_API_MEDIA);
+ mSurface.get(), NATIVE_WINDOW_API_MEDIA);
// We treat this as a warning, as this is a preparatory step.
// Codec will try to connect to the surface, which is where
// any error signaling will occur.
ALOGW_IF(err != OK, "failed to disconnect from surface: %d", err);
}
err = mCodec->configure(
- format, surface, NULL /* crypto */, 0 /* flags */);
+ format, mSurface, NULL /* crypto */, 0 /* flags */);
if (err != OK) {
ALOGE("Failed to configure %s decoder (err=%d)", mComponentName.c_str(), err);
mCodec->release();
@@ -337,12 +334,10 @@ void NuPlayer::Decoder::onShutdown(bool notifyComplete) {
mCodec = NULL;
++mBufferGeneration;
- if (mNativeWindow != NULL) {
+ if (mSurface != NULL) {
// reconnect to surface as MediaCodec disconnected from it
status_t error =
- native_window_api_connect(
- mNativeWindow->getNativeWindow().get(),
- NATIVE_WINDOW_API_MEDIA);
+ native_window_api_connect(mSurface.get(), NATIVE_WINDOW_API_MEDIA);
ALOGW_IF(error != NO_ERROR,
"[%s] failed to connect to native window, error=%d",
mComponentName.c_str(), error);
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
index dd84620..070d51a 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
@@ -27,7 +27,7 @@ struct NuPlayer::Decoder : public DecoderBase {
Decoder(const sp<AMessage> &notify,
const sp<Source> &source,
const sp<Renderer> &renderer = NULL,
- const sp<NativeWindowWrapper> &nativeWindow = NULL,
+ const sp<Surface> &surface = NULL,
const sp<CCDecoder> &ccDecoder = NULL);
virtual void getStats(
@@ -54,7 +54,7 @@ private:
kWhatRenderBuffer = 'rndr',
};
- sp<NativeWindowWrapper> mNativeWindow;
+ sp<Surface> mSurface;
sp<Source> mSource;
sp<Renderer> mRenderer;
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 4fcee90..7b87676 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -24,6 +24,8 @@
#include <inttypes.h>
#include <utils/Trace.h>
+#include <gui/Surface.h>
+
#include <media/stagefright/ACodec.h>
#include <binder/MemoryDealer.h>
@@ -37,7 +39,6 @@
#include <media/stagefright/BufferProducerWrapper.h>
#include <media/stagefright/MediaCodecList.h>
#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/NativeWindowWrapper.h>
#include <media/stagefright/OMXClient.h>
#include <media/stagefright/OMXCodec.h>
@@ -1316,9 +1317,8 @@ status_t ACodec::configureCodec(
}
}
if (haveNativeWindow) {
- sp<NativeWindowWrapper> windowWrapper(
- static_cast<NativeWindowWrapper *>(obj.get()));
- sp<ANativeWindow> nativeWindow = windowWrapper->getNativeWindow();
+ sp<ANativeWindow> nativeWindow =
+ static_cast<ANativeWindow *>(static_cast<Surface *>(obj.get()));
// START of temporary support for automatic FRC - THIS WILL BE REMOVED
int32_t autoFrc;
@@ -1477,10 +1477,8 @@ status_t ACodec::configureCodec(
}
if (haveNativeWindow) {
- sp<NativeWindowWrapper> nativeWindow(
- static_cast<NativeWindowWrapper *>(obj.get()));
- CHECK(nativeWindow != NULL);
- mNativeWindow = nativeWindow->getNativeWindow();
+ mNativeWindow = static_cast<Surface *>(obj.get());
+ CHECK(mNativeWindow != NULL);
native_window_set_scaling_mode(
mNativeWindow.get(), NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 8a2dc35..25887ef 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -42,7 +42,6 @@
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MediaFilter.h>
#include <media/stagefright/MetaData.h>
-#include <media/stagefright/NativeWindowWrapper.h>
#include <private/android_filesystem_config.h>
#include <utils/Log.h>
#include <utils/Singleton.h>
@@ -481,9 +480,7 @@ status_t MediaCodec::configure(
msg->setInt32("flags", flags);
if (nativeWindow != NULL) {
- msg->setObject(
- "native-window",
- new NativeWindowWrapper(nativeWindow));
+ msg->setObject("native-window", nativeWindow);
}
if (crypto != NULL) {
@@ -1614,11 +1611,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
if (obj != NULL) {
format->setObject("native-window", obj);
-
- status_t err = setNativeWindow(
- static_cast<NativeWindowWrapper *>(obj.get())
- ->getSurfaceTextureClient());
-
+ status_t err = setNativeWindow(static_cast<Surface *>(obj.get()));
if (err != OK) {
PostReplyWithError(replyID, err);
break;