From 7caa130a98baa64768dcd409bc110ce9acb0cbff Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Mon, 10 Jan 2011 10:38:31 -0800 Subject: NuPlayer now properly sends MEDIA_SET_VIDEOSIZE notifications. Change-Id: I99b4223ad6ecfd8839a3c0e737fef3165565d76d related-to-bug: 3336496 --- .../nuplayer/DecoderWrapper.cpp | 12 ++++++ media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 45 ++++++++++++++++------ 2 files changed, 45 insertions(+), 12 deletions(-) (limited to 'media/libmediaplayerservice/nuplayer') diff --git a/media/libmediaplayerservice/nuplayer/DecoderWrapper.cpp b/media/libmediaplayerservice/nuplayer/DecoderWrapper.cpp index 4d4cd8d..802d1fb 100644 --- a/media/libmediaplayerservice/nuplayer/DecoderWrapper.cpp +++ b/media/libmediaplayerservice/nuplayer/DecoderWrapper.cpp @@ -309,6 +309,18 @@ void DecoderWrapper::WrapperReader::sendFormatChange() { realNotify->setInt32("width", width); realNotify->setInt32("height", height); + + int32_t cropLeft, cropTop, cropRight, cropBottom; + if (!meta->findRect( + kKeyCropRect, + &cropLeft, &cropTop, &cropRight, &cropBottom)) { + cropLeft = 0; + cropTop = 0; + cropRight = width - 1; + cropBottom = height - 1; + } + + realNotify->setRect("crop", cropLeft, cropTop, cropRight, cropBottom); } notify->post(); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index e1b371e..7f534c0 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -271,22 +271,43 @@ void NuPlayer::onMessageReceived(const sp &msg) { finishFlushIfPossible(); } else if (what == ACodec::kWhatOutputFormatChanged) { - CHECK(audio); - - int32_t numChannels; - CHECK(codecRequest->findInt32("channel-count", &numChannels)); + if (audio) { + int32_t numChannels; + CHECK(codecRequest->findInt32("channel-count", &numChannels)); - int32_t sampleRate; - CHECK(codecRequest->findInt32("sample-rate", &sampleRate)); + int32_t sampleRate; + CHECK(codecRequest->findInt32("sample-rate", &sampleRate)); - LOGV("Audio output format changed to %d Hz, %d channels", - sampleRate, numChannels); + LOGV("Audio output format changed to %d Hz, %d channels", + sampleRate, numChannels); - mAudioSink->close(); - CHECK_EQ(mAudioSink->open(sampleRate, numChannels), (status_t)OK); - mAudioSink->start(); + mAudioSink->close(); + CHECK_EQ(mAudioSink->open(sampleRate, numChannels), (status_t)OK); + mAudioSink->start(); - mRenderer->signalAudioSinkChanged(); + mRenderer->signalAudioSinkChanged(); + } else { + // video + + int32_t width, height; + CHECK(codecRequest->findInt32("width", &width)); + CHECK(codecRequest->findInt32("height", &height)); + + int32_t cropLeft, cropTop, cropRight, cropBottom; + CHECK(codecRequest->findRect( + "crop", + &cropLeft, &cropTop, &cropRight, &cropBottom)); + + LOGV("Video output format changed to %d x %d " + "(crop: %d, %d, %d, %d)", + width, height, + cropLeft, cropTop, cropRight, cropBottom); + + notifyListener( + MEDIA_SET_VIDEO_SIZE, + cropRight - cropLeft + 1, + cropBottom - cropTop + 1); + } } else if (what == ACodec::kWhatShutdownCompleted) { LOGV("%s shutdown completed", audio ? "audio" : "video"); if (audio) { -- cgit v1.1