Skip to content

Commit

Permalink
Merge tag 'LA.BF64.1.2.2-04040-8x94.0' into HEAD
Browse files Browse the repository at this point in the history
"LA.BF64.1.2.2-04040-8x94.0"

Conflicts:
	media/libavextensions/mediaplayerservice/AVNuExtensions.h
	media/libavextensions/mediaplayerservice/AVNuUtils.cpp
	media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h
	media/libstagefright/ACodec.cpp
	media/libstagefright/Android.mk
	media/libstagefright/OMXCodec.cpp

Change-Id: I2ec90d0845708efb245f746b827f6e9d7e74378b
  • Loading branch information
gmillz committed Apr 5, 2016
2 parents be4590d + b802297 commit 81a5e4f
Show file tree
Hide file tree
Showing 40 changed files with 1,375 additions and 23 deletions.
1 change: 1 addition & 0 deletions include/media/stagefright/ACodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ struct ACodec : public AHierarchicalStateMachine, public CodecBase {
kFlagIsSecure = 1,
kFlagPushBlankBuffersToNativeWindowOnShutdown = 2,
kFlagIsGrallocUsageProtected = 4,
kFlagPushBlankBuffersToNativeWindowOnSwitch = 1 << 7,
};

enum {
Expand Down
8 changes: 6 additions & 2 deletions include/media/stagefright/DataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
#include <utils/RefBase.h>
#include <utils/threads.h>
#include <drm/DrmManagerClient.h>
#include <media/stagefright/foundation/AMessage.h>

namespace android {

struct AMessage;
struct AString;
class IDataSource;
struct IMediaHTTPService;
Expand All @@ -57,7 +57,7 @@ class DataSource : public RefBase {
static sp<DataSource> CreateMediaHTTP(const sp<IMediaHTTPService> &httpService);
static sp<DataSource> CreateFromIDataSource(const sp<IDataSource> &source);

DataSource() {}
DataSource() : mMeta(new AMessage) {}

virtual status_t initCheck() const = 0;

Expand Down Expand Up @@ -108,10 +108,14 @@ class DataSource : public RefBase {

virtual String8 getMIMEType() const;

virtual sp<AMessage> meta() { return mMeta; }

protected:
virtual ~DataSource() {}

private:
sp<AMessage> mMeta;

static Mutex gSnifferMutex;
static List<SnifferFunc> gSniffers;
static List<SnifferFunc> gExtraSniffers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 - 2015, The Linux Foundation. All rights reserved.
* Copyright (c) 2013 - 2016, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -28,6 +28,7 @@
*/

#define LOG_TAG "AVMediaServiceUtils"
//#define LOG_NDEBUG 0
#include <utils/Log.h>

#include <media/stagefright/foundation/ADebug.h>
Expand Down
1 change: 1 addition & 0 deletions media/libavextensions/mediaplayerservice/AVNuExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct AVNuUtils {
#endif
virtual void printFileName(int fd);
virtual void checkFormatChange(bool *formatChange, const sp<ABuffer> &accessUnit);
virtual void overWriteAudioOutputFormat(sp <AMessage> &dst, const sp <AMessage> &src);
#ifdef TARGET_8974
virtual void addFlagsInMeta(const sp<ABuffer> &buffer, int32_t flags, bool isAudio);
virtual uint32_t getFlags();
Expand Down
4 changes: 4 additions & 0 deletions media/libavextensions/mediaplayerservice/AVNuUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ void AVNuUtils::checkFormatChange(bool * /*formatChange*/,
const sp<ABuffer> & /*accessUnit*/) {
}

void AVNuUtils::overWriteAudioOutputFormat(
sp <AMessage> & /*dst*/, const sp <AMessage> & /*src*/) {
}

#ifdef TARGET_8974
void AVNuUtils::addFlagsInMeta(const sp<ABuffer> & /*buffer*/,
int32_t /*flags*/, bool /*isAudio*/) {
Expand Down
15 changes: 13 additions & 2 deletions media/libmediaplayerservice/nuplayer/NuPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,10 +954,21 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
audio ? "audio" : "video", formatChange);

if (formatChange) {
mDeferredActions.push_back(
new FlushDecoderAction(
int32_t seamlessChange = 0;
if (msg->findInt32("video-seamlessChange", &seamlessChange) && seamlessChange) {
ALOGE("video decoder seamlessChange in smooth streaming mode, "
"flush the video decoder");
mDeferredActions.push_back(
new FlushDecoderAction(FLUSH_CMD_NONE, FLUSH_CMD_FLUSH));
mDeferredActions.push_back(new ResumeDecoderAction(false));
processDeferredActions();
break;
} else {
mDeferredActions.push_back(
new FlushDecoderAction(
audio ? FLUSH_CMD_SHUTDOWN : FLUSH_CMD_NONE,
audio ? FLUSH_CMD_NONE : FLUSH_CMD_SHUTDOWN));
}
}

mDeferredActions.push_back(
Expand Down
23 changes: 20 additions & 3 deletions media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ NuPlayer::Decoder::Decoder(
mIsSecure(false),
mFormatChangePending(false),
mTimeChangePending(false),
mVideoFormatChangeDoFlushOnly(false),
mResumePending(false),
mComponentName("decoder") {
mCodecLooper = new ALooper;
Expand Down Expand Up @@ -264,6 +265,7 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {

mFormatChangePending = false;
mTimeChangePending = false;
mVideoFormatChangeDoFlushOnly = false;

++mBufferGeneration;

Expand Down Expand Up @@ -783,9 +785,20 @@ status_t NuPlayer::Decoder::fetchInputData(sp<AMessage> &reply) {
mTimeChangePending = true;
err = ERROR_END_OF_STREAM;
} else if (seamlessFormatChange) {
// reuse existing decoder and don't flush
rememberCodecSpecificData(newFormat);
continue;
if (!mIsAudio &&
newFormat != NULL &&
newFormat->contains("prefer-adaptive-playback")) {
ALOGV("in smooth streaming mode, "
"do video flush in video seamless format change");
mFormatChangePending = true;
mVideoFormatChangeDoFlushOnly = true;
err = ERROR_END_OF_STREAM;
} else {
// reuse existing decoder and don't flush
rememberCodecSpecificData(newFormat);
continue;
}

} else {
// This stream is unaffected by the discontinuity
return -EWOULDBLOCK;
Expand Down Expand Up @@ -1013,10 +1026,14 @@ void NuPlayer::Decoder::finishHandleDiscontinuity(bool flushOnTimeChange) {
sp<AMessage> msg = mNotify->dup();
msg->setInt32("what", kWhatInputDiscontinuity);
msg->setInt32("formatChange", mFormatChangePending);
if (mVideoFormatChangeDoFlushOnly) {
msg->setInt32("video-seamlessChange", mVideoFormatChangeDoFlushOnly);
}
msg->post();

mFormatChangePending = false;
mTimeChangePending = false;
mVideoFormatChangeDoFlushOnly = false;
}

bool NuPlayer::Decoder::supportsSeamlessAudioFormatChange(
Expand Down
1 change: 1 addition & 0 deletions media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct NuPlayer::Decoder : public DecoderBase {
bool mIsSecure;
bool mFormatChangePending;
bool mTimeChangePending;
bool mVideoFormatChangeDoFlushOnly;

bool mResumePending;
AString mComponentName;
Expand Down
2 changes: 2 additions & 0 deletions media/libmediaplayerservice/nuplayer/StreamingSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#define LOG_TAG "StreamingSource"
#include <utils/Log.h>

#include <inttypes.h>

#include "StreamingSource.h"

#include "ATSParser.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
**
** This file was modified by DTS, Inc. The portions of the
** code that are surrounded by "DTS..." are copyrighted and
** licensed separately, as follows:
**
** (C) 2015 DTS, Inc.
**
** 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
*/

#include <inttypes.h>
Expand Down Expand Up @@ -83,6 +101,11 @@
#include "ExynosHWCService.h"
#endif

#ifdef DTS_CODEC_M_
#include "include/DTSUtils.h"
#include "include/OMX_Audio_DTS.h"
#endif

namespace android {

// Treat time out as an error if we have not received any output
Expand Down Expand Up @@ -685,6 +708,20 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
CHECK(meta->findInt32(kKeySampleRate, &sampleRate));

setRawAudioFormat(kPortIndexInput, sampleRate, numChannels);
#ifdef DTS_CODEC_M_
} else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_DTS, mMIME)) {
ALOGV(" (DTS) mime == MEDIA_MIMETYPE_AUDIO_DTS");
int32_t numChannels, sampleRate;
int32_t bitWidth = 24;
CHECK(meta->findInt32(kKeyChannelCount, &numChannels));
CHECK(meta->findInt32(kKeySampleRate, &sampleRate));

status_t err = DTSUtils::setupDecoder(mOMX, mNode, sampleRate, bitWidth);

if (err != OK) {
return err;
}
#endif
}

if (!strncasecmp(mMIME, "video/", 6)) {
Expand Down Expand Up @@ -1556,6 +1593,10 @@ void OMXCodec::setComponentRole(
{ MEDIA_MIMETYPE_AUDIO_EAC3_JOC,
"audio_decoder.eac3_joc", NULL },
#endif // DOLBY_END
#ifdef DTS_CODEC_M_
{ MEDIA_MIMETYPE_AUDIO_DTS,
"audio_decoder.dts", "audio_encoder.dts" },
#endif
};

static const size_t kNumMimeToRole =
Expand Down
87 changes: 86 additions & 1 deletion media/libstagefright/ACodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
**
** This file was modified by DTS, Inc. The portions of the
** code that are surrounded by "DTS..." are copyrighted and
** licensed separately, as follows:
**
** (C) 2015 DTS, Inc.
**
** 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
*/

//#define LOG_NDEBUG 0
Expand Down Expand Up @@ -85,6 +103,11 @@
#include "DolbyACodecExtImpl.h"
#endif // DOLBY_END

#ifdef DTS_CODEC_M_
#include "include/DTSUtils.h"
#include "include/OMX_Audio_DTS.h"
#endif

namespace android {

// OMX errors are directly mapped into status_t range if
Expand Down Expand Up @@ -787,7 +810,8 @@ status_t ACodec::handleSetSurface(const sp<Surface> &surface) {
}

// push blank buffers to previous window if requested
if (mFlags & kFlagPushBlankBuffersToNativeWindowOnShutdown) {
if (mFlags & kFlagPushBlankBuffersToNativeWindowOnShutdown ||
mFlags & kFlagPushBlankBuffersToNativeWindowOnSwitch) {
pushBlankBuffersToNativeWindow(mNativeWindow.get());
}

Expand Down Expand Up @@ -945,6 +969,21 @@ status_t ACodec::setupNativeWindowSizeFormatAndUsage(
#endif

ALOGV("gralloc usage: %#x(OMX) => %#x(ACodec)", omxUsage, usage);

int32_t width = 0, height = 0;
int32_t isAdaptivePlayback = 0;

if (mInputFormat->findInt32("adaptive-playback", &isAdaptivePlayback)
&& isAdaptivePlayback
&& mInputFormat->findInt32("max-width", &width)
&& mInputFormat->findInt32("max-height", &height)) {
width = max(width, (int32_t)def.format.video.nFrameWidth);
height = max(height, (int32_t)def.format.video.nFrameHeight);
ALOGV("Adaptive playback width = %d, height = %d", width, height);
} else {
width = def.format.video.nFrameWidth;
height = def.format.video.nFrameHeight;
}
err = setNativeWindowSizeFormatAndUsage(
nativeWindow,
def.format.video.nFrameWidth,
Expand Down Expand Up @@ -1672,6 +1711,10 @@ status_t ACodec::setComponentRole(
{ MEDIA_MIMETYPE_AUDIO_EAC3_JOC,
"audio_decoder.eac3_joc", NULL },
#endif // DOLBY_END
#ifdef DTS_CODEC_M_
{ MEDIA_MIMETYPE_AUDIO_DTS,
"audio_decoder.dts", "audio_encoder.dts" },
#endif
};

static const size_t kNumMimeToRole =
Expand Down Expand Up @@ -1993,6 +2036,12 @@ status_t ACodec::configureCodec(
&& push != 0) {
mFlags |= kFlagPushBlankBuffersToNativeWindowOnShutdown;
}

int32_t val;
if (msg->findInt32("push-blank-buffers-on-switch", &val)
&& val != 0) {
mFlags |= kFlagPushBlankBuffersToNativeWindowOnSwitch;
}
}

int32_t rotationDegrees;
Expand Down Expand Up @@ -2099,6 +2148,25 @@ status_t ACodec::configureCodec(
sampleRate,
numChannels, bitsPerSample);
}
#ifdef DTS_CODEC_M_
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_DTS)) {
ALOGV(" (DTS) mime == MEDIA_MIMETYPE_AUDIO_DTS");
int32_t numChannels, sampleRate;
int32_t bitWidth = 24;
if (!msg->findInt32("channel-count", &numChannels)
|| !msg->findInt32("sample-rate", &sampleRate)) {
ALOGE(" (DTS) missing channel count or sample rate for DTS decoder");
err = INVALID_OPERATION;
} else {
ALOGI(" (DTS) bit width to setup decoder %d", bitWidth);
err = DTSUtils::setupDecoder(mOMX, mNode, sampleRate, bitWidth);
// Also update output format bit-width so ACodec client too gets to know
outputFormat->setInt32("bit-width", bitWidth);
}
if (err != OK) {
return err;
}
#endif
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) {
int32_t numChannels, sampleRate;
if (!msg->findInt32("channel-count", &numChannels)
Expand Down Expand Up @@ -4561,6 +4629,23 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp<AMessage> &notify) {
notify->setInt32("sample-rate", params.nSamplingRate);
break;
}
#ifdef DTS_CODEC_M_
case OMX_AUDIO_CodingDTSHD:
{
OMX_AUDIO_PARAM_DTSDECTYPE params;
InitOMXParams(&params);
params.nPortIndex = portIndex;

CHECK_EQ((status_t)OK, mOMX->getParameter(
mNode,
(OMX_INDEXTYPE)OMX_IndexParamAudioDTSDec,
&params,
sizeof(params)));

notify->setString("mime", MEDIA_MIMETYPE_AUDIO_DTS);
break;
}
#endif

default:
if (!strncmp(mComponentName.c_str(), "OMX.ffmpeg.", 11)) {
Expand Down
Loading

0 comments on commit 81a5e4f

Please sign in to comment.