NuPlayer: Use a software renderer when using software codecs
This mimics what is done in AwesomePlayer and MediaCodec -
ideally this logic perhaps should be moved into ACodec to
avoid having to replicate it in every caller.
This makes HLS and RTSP playback work in the emulator.
Change-Id: I18027dc3e469889baaae3e1c4afb559de7d0f7d3
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index b89b1c8..6d95a41 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -32,6 +32,8 @@
#include "ATSParser.h"
+#include "SoftwareRenderer.h"
+
#include <cutils/properties.h> // for property_get
#include <media/stagefright/foundation/hexdump.h>
#include <media/stagefright/foundation/ABuffer.h>
@@ -114,6 +116,7 @@
: mUIDValid(false),
mSourceFlags(0),
mVideoIsAVC(false),
+ mNeedsSwRenderer(false),
mAudioEOS(false),
mVideoEOS(false),
mScanSourcesPending(false),
@@ -371,6 +374,7 @@
ALOGV("kWhatStart");
mVideoIsAVC = false;
+ mNeedsSwRenderer = false;
mAudioEOS = false;
mVideoEOS = false;
mSkipRenderingAudioUntilMediaTimeUs = -1;
@@ -607,6 +611,20 @@
notifyListener(
MEDIA_SET_VIDEO_SIZE, displayWidth, displayHeight);
+
+ if (mNeedsSwRenderer && mNativeWindow != NULL) {
+ int32_t colorFormat;
+ CHECK(codecRequest->findInt32("color-format", &colorFormat));
+
+ sp<MetaData> meta = new MetaData;
+ meta->setInt32(kKeyWidth, width);
+ meta->setInt32(kKeyHeight, height);
+ meta->setRect(kKeyCropRect, cropLeft, cropTop, cropRight, cropBottom);
+ meta->setInt32(kKeyColorFormat, colorFormat);
+
+ mRenderer->setSoftRenderer(
+ new SoftwareRenderer(mNativeWindow->getNativeWindow(), meta));
+ }
}
} else if (what == ACodec::kWhatShutdownCompleted) {
ALOGV("%s shutdown completed", audio ? "audio" : "video");
@@ -630,8 +648,13 @@
mRenderer->queueEOS(audio, UNKNOWN_ERROR);
} else if (what == ACodec::kWhatDrainThisBuffer) {
renderBuffer(audio, codecRequest);
- } else if (what != ACodec::kWhatComponentAllocated
- && what != ACodec::kWhatComponentConfigured
+ } else if (what == ACodec::kWhatComponentAllocated) {
+ if (!audio) {
+ AString name;
+ CHECK(codecRequest->findString("componentName", &name));
+ mNeedsSwRenderer = name.startsWith("OMX.google.");
+ }
+ } else if (what != ACodec::kWhatComponentConfigured
&& what != ACodec::kWhatBuffersAllocated) {
ALOGV("Unhandled codec notification %d '%c%c%c%c'.",
what,