summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/media/stagefright/MediaCodec.h14
-rw-r--r--media/libmediaplayerservice/MediaPlayerFactory.cpp13
-rw-r--r--media/libmediaplayerservice/MediaPlayerFactory.h5
-rw-r--r--media/libmediaplayerservice/MediaPlayerService.cpp2
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.cpp7
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.h3
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp7
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h2
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp4
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDriver.h2
-rw-r--r--media/libstagefright/MediaCodec.cpp19
11 files changed, 47 insertions, 31 deletions
diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h
index b621b9c..c10963d 100644
--- a/include/media/stagefright/MediaCodec.h
+++ b/include/media/stagefright/MediaCodec.h
@@ -61,11 +61,15 @@ struct MediaCodec : public AHandler {
CB_RESOURCE_RECLAIMED = 5,
};
+ static const pid_t kNoPid = -1;
+
static sp<MediaCodec> CreateByType(
- const sp<ALooper> &looper, const char *mime, bool encoder, status_t *err = NULL);
+ const sp<ALooper> &looper, const char *mime, bool encoder, status_t *err = NULL,
+ pid_t pid = kNoPid);
static sp<MediaCodec> CreateByComponentName(
- const sp<ALooper> &looper, const char *name, status_t *err = NULL);
+ const sp<ALooper> &looper, const char *name, status_t *err = NULL,
+ pid_t pid = kNoPid);
static sp<PersistentSurface> CreatePersistentInputSurface();
@@ -251,7 +255,7 @@ private:
};
struct ResourceManagerServiceProxy : public IBinder::DeathRecipient {
- ResourceManagerServiceProxy();
+ ResourceManagerServiceProxy(pid_t pid);
~ResourceManagerServiceProxy();
void init();
@@ -271,7 +275,7 @@ private:
private:
Mutex mLock;
sp<IResourceManagerService> mService;
- int mPid;
+ pid_t mPid;
};
State mState;
@@ -333,7 +337,7 @@ private:
bool mHaveInputSurface;
bool mHavePendingInputBuffers;
- MediaCodec(const sp<ALooper> &looper);
+ MediaCodec(const sp<ALooper> &looper, pid_t pid);
static status_t PostAndAwaitResponse(
const sp<AMessage> &msg, sp<AMessage> *response);
diff --git a/media/libmediaplayerservice/MediaPlayerFactory.cpp b/media/libmediaplayerservice/MediaPlayerFactory.cpp
index e8d495b..d5d12f7 100644
--- a/media/libmediaplayerservice/MediaPlayerFactory.cpp
+++ b/media/libmediaplayerservice/MediaPlayerFactory.cpp
@@ -135,7 +135,8 @@ player_type MediaPlayerFactory::getPlayerType(const sp<IMediaPlayer>& client,
sp<MediaPlayerBase> MediaPlayerFactory::createPlayer(
player_type playerType,
void* cookie,
- notify_callback_f notifyFunc) {
+ notify_callback_f notifyFunc,
+ pid_t pid) {
sp<MediaPlayerBase> p;
IFactory* factory;
status_t init_result;
@@ -149,7 +150,7 @@ sp<MediaPlayerBase> MediaPlayerFactory::createPlayer(
factory = sFactoryMap.valueFor(playerType);
CHECK(NULL != factory);
- p = factory->createPlayer();
+ p = factory->createPlayer(pid);
if (p == NULL) {
ALOGE("Failed to create player object of type %d, create failed",
@@ -217,7 +218,7 @@ class StagefrightPlayerFactory :
return 0.0;
}
- virtual sp<MediaPlayerBase> createPlayer() {
+ virtual sp<MediaPlayerBase> createPlayer(pid_t /* pid */) {
ALOGV(" create StagefrightPlayer");
return new StagefrightPlayer();
}
@@ -279,9 +280,9 @@ class NuPlayerFactory : public MediaPlayerFactory::IFactory {
return 1.0;
}
- virtual sp<MediaPlayerBase> createPlayer() {
+ virtual sp<MediaPlayerBase> createPlayer(pid_t pid) {
ALOGV(" create NuPlayer");
- return new NuPlayerDriver;
+ return new NuPlayerDriver(pid);
}
};
@@ -297,7 +298,7 @@ class TestPlayerFactory : public MediaPlayerFactory::IFactory {
return 0.0;
}
- virtual sp<MediaPlayerBase> createPlayer() {
+ virtual sp<MediaPlayerBase> createPlayer(pid_t /* pid */) {
ALOGV("Create Test Player stub");
return new TestPlayerStub();
}
diff --git a/media/libmediaplayerservice/MediaPlayerFactory.h b/media/libmediaplayerservice/MediaPlayerFactory.h
index 7f9b3b5..e22a56f 100644
--- a/media/libmediaplayerservice/MediaPlayerFactory.h
+++ b/media/libmediaplayerservice/MediaPlayerFactory.h
@@ -47,7 +47,7 @@ class MediaPlayerFactory {
const sp<DataSource> &/*source*/,
float /*curScore*/) { return 0.0; }
- virtual sp<MediaPlayerBase> createPlayer() = 0;
+ virtual sp<MediaPlayerBase> createPlayer(pid_t pid) = 0;
};
static status_t registerFactory(IFactory* factory,
@@ -66,7 +66,8 @@ class MediaPlayerFactory {
static sp<MediaPlayerBase> createPlayer(player_type playerType,
void* cookie,
- notify_callback_f notifyFunc);
+ notify_callback_f notifyFunc,
+ pid_t pid);
static void registerBuiltinFactories();
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index abbbc20..d49ba93 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -633,7 +633,7 @@ sp<MediaPlayerBase> MediaPlayerService::Client::createPlayer(player_type playerT
p.clear();
}
if (p == NULL) {
- p = MediaPlayerFactory::createPlayer(playerType, this, notify);
+ p = MediaPlayerFactory::createPlayer(playerType, this, notify, mPid);
}
if (p != NULL) {
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 2fdc196..8e3e460 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -166,8 +166,9 @@ private:
////////////////////////////////////////////////////////////////////////////////
-NuPlayer::NuPlayer()
+NuPlayer::NuPlayer(pid_t pid)
: mUIDValid(false),
+ mPID(pid),
mSourceFlags(0),
mOffloadAudio(false),
mAudioDecoderGeneration(0),
@@ -1525,7 +1526,7 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<DecoderBase> *decoder) {
format->setInt32("has-video", hasVideo);
*decoder = new DecoderPassThrough(notify, mSource, mRenderer);
} else {
- *decoder = new Decoder(notify, mSource, mRenderer);
+ *decoder = new Decoder(notify, mSource, mPID, mRenderer);
}
} else {
sp<AMessage> notify = new AMessage(kWhatVideoNotify, this);
@@ -1533,7 +1534,7 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<DecoderBase> *decoder) {
notify->setInt32("generation", mVideoDecoderGeneration);
*decoder = new Decoder(
- notify, mSource, mRenderer, mSurface, mCCDecoder);
+ notify, mSource, mPID, mRenderer, mSurface, mCCDecoder);
// enable FRC if high-quality AV sync is requested, even if not
// directly queuing to display, as this will even improve textureview
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h
index 9f4c462..9456d5d 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h
@@ -33,7 +33,7 @@ class MetaData;
struct NuPlayerDriver;
struct NuPlayer : public AHandler {
- NuPlayer();
+ NuPlayer(pid_t pid);
void setUID(uid_t uid);
@@ -139,6 +139,7 @@ private:
wp<NuPlayerDriver> mDriver;
bool mUIDValid;
uid_t mUID;
+ pid_t mPID;
sp<Source> mSource;
uint32_t mSourceFlags;
sp<Surface> mSurface;
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
index dcc28c4..3646828 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
@@ -48,6 +48,7 @@ static inline bool getAudioDeepBufferSetting() {
NuPlayer::Decoder::Decoder(
const sp<AMessage> &notify,
const sp<Source> &source,
+ pid_t pid,
const sp<Renderer> &renderer,
const sp<Surface> &surface,
const sp<CCDecoder> &ccDecoder)
@@ -56,6 +57,7 @@ NuPlayer::Decoder::Decoder(
mSource(source),
mRenderer(renderer),
mCCDecoder(ccDecoder),
+ mPid(pid),
mSkipRenderingUntilMediaTimeUs(-1ll),
mNumFramesTotal(0ll),
mNumInputFramesDropped(0ll),
@@ -249,7 +251,8 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
mComponentName.append(" decoder");
ALOGV("[%s] onConfigure (surface=%p)", mComponentName.c_str(), mSurface.get());
- mCodec = MediaCodec::CreateByType(mCodecLooper, mime.c_str(), false /* encoder */);
+ mCodec = MediaCodec::CreateByType(
+ mCodecLooper, mime.c_str(), false /* encoder */, NULL /* err */, mPid);
int32_t secure = 0;
if (format->findInt32("secure", &secure) && secure != 0) {
if (mCodec != NULL) {
@@ -258,7 +261,7 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
mCodec->release();
ALOGI("[%s] creating", mComponentName.c_str());
mCodec = MediaCodec::CreateByComponentName(
- mCodecLooper, mComponentName.c_str());
+ mCodecLooper, mComponentName.c_str(), NULL /* err */, mPid);
}
}
if (mCodec == NULL) {
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
index ed0be62..eeb4af4 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
@@ -26,6 +26,7 @@ namespace android {
struct NuPlayer::Decoder : public DecoderBase {
Decoder(const sp<AMessage> &notify,
const sp<Source> &source,
+ pid_t pid,
const sp<Renderer> &renderer = NULL,
const sp<Surface> &surface = NULL,
const sp<CCDecoder> &ccDecoder = NULL);
@@ -77,6 +78,7 @@ private:
Vector<MediaBuffer *> mMediaBuffers;
Vector<size_t> mDequeuedInputBuffers;
+ const pid_t mPid;
int64_t mSkipRenderingUntilMediaTimeUs;
int64_t mNumFramesTotal;
int64_t mNumInputFramesDropped;
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp
index 3882dcd..7370224 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp
@@ -33,7 +33,7 @@
namespace android {
-NuPlayerDriver::NuPlayerDriver()
+NuPlayerDriver::NuPlayerDriver(pid_t pid)
: mState(STATE_IDLE),
mIsAsyncPrepare(false),
mAsyncResult(UNKNOWN_ERROR),
@@ -55,7 +55,7 @@ NuPlayerDriver::NuPlayerDriver()
true, /* canCallJava */
PRIORITY_AUDIO);
- mPlayer = new NuPlayer;
+ mPlayer = new NuPlayer(pid);
mLooper->registerHandler(mPlayer);
mPlayer->setDriver(this);
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h
index 9da7fc1..d009fd7 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h
@@ -24,7 +24,7 @@ struct ALooper;
struct NuPlayer;
struct NuPlayerDriver : public MediaPlayerInterface {
- NuPlayerDriver();
+ NuPlayerDriver(pid_t pid);
virtual status_t initCheck();
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index b444687..cd59709 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -104,8 +104,11 @@ private:
DISALLOW_EVIL_CONSTRUCTORS(ResourceManagerClient);
};
-MediaCodec::ResourceManagerServiceProxy::ResourceManagerServiceProxy()
- : mPid(IPCThreadState::self()->getCallingPid()) {
+MediaCodec::ResourceManagerServiceProxy::ResourceManagerServiceProxy(pid_t pid)
+ : mPid(pid) {
+ if (mPid == MediaCodec::kNoPid) {
+ mPid = IPCThreadState::self()->getCallingPid();
+ }
}
MediaCodec::ResourceManagerServiceProxy::~ResourceManagerServiceProxy() {
@@ -161,8 +164,8 @@ bool MediaCodec::ResourceManagerServiceProxy::reclaimResource(
// static
sp<MediaCodec> MediaCodec::CreateByType(
- const sp<ALooper> &looper, const char *mime, bool encoder, status_t *err) {
- sp<MediaCodec> codec = new MediaCodec(looper);
+ const sp<ALooper> &looper, const char *mime, bool encoder, status_t *err, pid_t pid) {
+ sp<MediaCodec> codec = new MediaCodec(looper, pid);
const status_t ret = codec->init(mime, true /* nameIsType */, encoder);
if (err != NULL) {
@@ -173,8 +176,8 @@ sp<MediaCodec> MediaCodec::CreateByType(
// static
sp<MediaCodec> MediaCodec::CreateByComponentName(
- const sp<ALooper> &looper, const char *name, status_t *err) {
- sp<MediaCodec> codec = new MediaCodec(looper);
+ const sp<ALooper> &looper, const char *name, status_t *err, pid_t pid) {
+ sp<MediaCodec> codec = new MediaCodec(looper, pid);
const status_t ret = codec->init(name, false /* nameIsType */, false /* encoder */);
if (err != NULL) {
@@ -232,7 +235,7 @@ sp<PersistentSurface> MediaCodec::CreatePersistentInputSurface() {
return new PersistentSurface(bufferProducer, bufferConsumer);
}
-MediaCodec::MediaCodec(const sp<ALooper> &looper)
+MediaCodec::MediaCodec(const sp<ALooper> &looper, pid_t pid)
: mState(UNINITIALIZED),
mReleasedByResourceManager(false),
mLooper(looper),
@@ -242,7 +245,7 @@ MediaCodec::MediaCodec(const sp<ALooper> &looper)
mStickyError(OK),
mSoftRenderer(NULL),
mResourceManagerClient(new ResourceManagerClient(this)),
- mResourceManagerService(new ResourceManagerServiceProxy()),
+ mResourceManagerService(new ResourceManagerServiceProxy(pid)),
mBatteryStatNotified(false),
mIsVideo(false),
mVideoWidth(0),