Loading include/media/stagefright/MediaCodec.h +5 −3 Original line number Original line Diff line number Diff line Loading @@ -64,14 +64,15 @@ struct MediaCodec : public AHandler { }; }; static const pid_t kNoPid = -1; static const pid_t kNoPid = -1; static const uid_t kNoUid = -1; static sp<MediaCodec> CreateByType( static sp<MediaCodec> CreateByType( const sp<ALooper> &looper, const AString &mime, bool encoder, status_t *err = NULL, const sp<ALooper> &looper, const AString &mime, bool encoder, status_t *err = NULL, pid_t pid = kNoPid); pid_t pid = kNoPid, uid_t uid = kNoUid); static sp<MediaCodec> CreateByComponentName( static sp<MediaCodec> CreateByComponentName( const sp<ALooper> &looper, const AString &name, status_t *err = NULL, const sp<ALooper> &looper, const AString &name, status_t *err = NULL, pid_t pid = kNoPid); pid_t pid = kNoPid, uid_t uid = kNoUid); static sp<PersistentSurface> CreatePersistentInputSurface(); static sp<PersistentSurface> CreatePersistentInputSurface(); Loading Loading @@ -286,6 +287,7 @@ private: }; }; State mState; State mState; uid_t mUid; bool mReleasedByResourceManager; bool mReleasedByResourceManager; sp<ALooper> mLooper; sp<ALooper> mLooper; sp<ALooper> mCodecLooper; sp<ALooper> mCodecLooper; Loading Loading @@ -345,7 +347,7 @@ private: bool mHaveInputSurface; bool mHaveInputSurface; bool mHavePendingInputBuffers; bool mHavePendingInputBuffers; MediaCodec(const sp<ALooper> &looper, pid_t pid); MediaCodec(const sp<ALooper> &looper, pid_t pid, uid_t uid); static sp<CodecBase> GetCodecBase(const AString &name, bool nameIsType = false); static sp<CodecBase> GetCodecBase(const AString &name, bool nameIsType = false); Loading media/libmediaplayerservice/nuplayer/NuPlayer.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -1641,7 +1641,7 @@ status_t NuPlayer::instantiateDecoder( } else { } else { mSource->setOffloadAudio(false /* offload */); mSource->setOffloadAudio(false /* offload */); *decoder = new Decoder(notify, mSource, mPID, mRenderer); *decoder = new Decoder(notify, mSource, mPID, mUID, mRenderer); } } } else { } else { sp<AMessage> notify = new AMessage(kWhatVideoNotify, this); sp<AMessage> notify = new AMessage(kWhatVideoNotify, this); Loading @@ -1649,7 +1649,7 @@ status_t NuPlayer::instantiateDecoder( notify->setInt32("generation", mVideoDecoderGeneration); notify->setInt32("generation", mVideoDecoderGeneration); *decoder = new Decoder( *decoder = new Decoder( notify, mSource, mPID, mRenderer, mSurface, mCCDecoder); notify, mSource, mPID, mUID, mRenderer, mSurface, mCCDecoder); // enable FRC if high-quality AV sync is requested, even if not // enable FRC if high-quality AV sync is requested, even if not // directly queuing to display, as this will even improve textureview // directly queuing to display, as this will even improve textureview Loading media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp +4 −2 Original line number Original line Diff line number Diff line Loading @@ -58,6 +58,7 @@ NuPlayer::Decoder::Decoder( const sp<AMessage> ¬ify, const sp<AMessage> ¬ify, const sp<Source> &source, const sp<Source> &source, pid_t pid, pid_t pid, uid_t uid, const sp<Renderer> &renderer, const sp<Renderer> &renderer, const sp<Surface> &surface, const sp<Surface> &surface, const sp<CCDecoder> &ccDecoder) const sp<CCDecoder> &ccDecoder) Loading @@ -67,6 +68,7 @@ NuPlayer::Decoder::Decoder( mRenderer(renderer), mRenderer(renderer), mCCDecoder(ccDecoder), mCCDecoder(ccDecoder), mPid(pid), mPid(pid), mUid(uid), mSkipRenderingUntilMediaTimeUs(-1ll), mSkipRenderingUntilMediaTimeUs(-1ll), mNumFramesTotal(0ll), mNumFramesTotal(0ll), mNumInputFramesDropped(0ll), mNumInputFramesDropped(0ll), Loading Loading @@ -266,7 +268,7 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) { ALOGV("[%s] onConfigure (surface=%p)", mComponentName.c_str(), mSurface.get()); ALOGV("[%s] onConfigure (surface=%p)", mComponentName.c_str(), mSurface.get()); mCodec = MediaCodec::CreateByType( mCodec = MediaCodec::CreateByType( mCodecLooper, mime.c_str(), false /* encoder */, NULL /* err */, mPid); mCodecLooper, mime.c_str(), false /* encoder */, NULL /* err */, mPid, mUid); int32_t secure = 0; int32_t secure = 0; if (format->findInt32("secure", &secure) && secure != 0) { if (format->findInt32("secure", &secure) && secure != 0) { if (mCodec != NULL) { if (mCodec != NULL) { Loading @@ -275,7 +277,7 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) { mCodec->release(); mCodec->release(); ALOGI("[%s] creating", mComponentName.c_str()); ALOGI("[%s] creating", mComponentName.c_str()); mCodec = MediaCodec::CreateByComponentName( mCodec = MediaCodec::CreateByComponentName( mCodecLooper, mComponentName.c_str(), NULL /* err */, mPid); mCodecLooper, mComponentName.c_str(), NULL /* err */, mPid, mUid); } } } } if (mCodec == NULL) { if (mCodec == NULL) { Loading media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ struct NuPlayer::Decoder : public DecoderBase { Decoder(const sp<AMessage> ¬ify, Decoder(const sp<AMessage> ¬ify, const sp<Source> &source, const sp<Source> &source, pid_t pid, pid_t pid, uid_t uid, const sp<Renderer> &renderer = NULL, const sp<Renderer> &renderer = NULL, const sp<Surface> &surface = NULL, const sp<Surface> &surface = NULL, const sp<CCDecoder> &ccDecoder = NULL); const sp<CCDecoder> &ccDecoder = NULL); Loading Loading @@ -85,6 +86,7 @@ private: Vector<size_t> mDequeuedInputBuffers; Vector<size_t> mDequeuedInputBuffers; const pid_t mPid; const pid_t mPid; const uid_t mUid; int64_t mSkipRenderingUntilMediaTimeUs; int64_t mSkipRenderingUntilMediaTimeUs; int64_t mNumFramesTotal; int64_t mNumFramesTotal; int64_t mNumInputFramesDropped; int64_t mNumInputFramesDropped; Loading media/libstagefright/MediaCodec.cpp +13 −7 Original line number Original line Diff line number Diff line Loading @@ -173,8 +173,9 @@ bool MediaCodec::ResourceManagerServiceProxy::reclaimResource( // static // static sp<MediaCodec> MediaCodec::CreateByType( sp<MediaCodec> MediaCodec::CreateByType( const sp<ALooper> &looper, const AString &mime, bool encoder, status_t *err, pid_t pid) { const sp<ALooper> &looper, const AString &mime, bool encoder, status_t *err, pid_t pid, sp<MediaCodec> codec = new MediaCodec(looper, pid); uid_t uid) { sp<MediaCodec> codec = new MediaCodec(looper, pid, uid); const status_t ret = codec->init(mime, true /* nameIsType */, encoder); const status_t ret = codec->init(mime, true /* nameIsType */, encoder); if (err != NULL) { if (err != NULL) { Loading @@ -185,8 +186,8 @@ sp<MediaCodec> MediaCodec::CreateByType( // static // static sp<MediaCodec> MediaCodec::CreateByComponentName( sp<MediaCodec> MediaCodec::CreateByComponentName( const sp<ALooper> &looper, const AString &name, status_t *err, pid_t pid) { const sp<ALooper> &looper, const AString &name, status_t *err, pid_t pid, uid_t uid) { sp<MediaCodec> codec = new MediaCodec(looper, pid); sp<MediaCodec> codec = new MediaCodec(looper, pid, uid); const status_t ret = codec->init(name, false /* nameIsType */, false /* encoder */); const status_t ret = codec->init(name, false /* nameIsType */, false /* encoder */); if (err != NULL) { if (err != NULL) { Loading Loading @@ -234,7 +235,7 @@ sp<PersistentSurface> MediaCodec::CreatePersistentInputSurface() { return new PersistentSurface(bufferProducer, bufferSource); return new PersistentSurface(bufferProducer, bufferSource); } } MediaCodec::MediaCodec(const sp<ALooper> &looper, pid_t pid) MediaCodec::MediaCodec(const sp<ALooper> &looper, pid_t pid, uid_t uid) : mState(UNINITIALIZED), : mState(UNINITIALIZED), mReleasedByResourceManager(false), mReleasedByResourceManager(false), mLooper(looper), mLooper(looper), Loading @@ -256,6 +257,11 @@ MediaCodec::MediaCodec(const sp<ALooper> &looper, pid_t pid) mDequeueOutputReplyID(0), mDequeueOutputReplyID(0), mHaveInputSurface(false), mHaveInputSurface(false), mHavePendingInputBuffers(false) { mHavePendingInputBuffers(false) { if (uid == kNoUid) { mUid = IPCThreadState::self()->getCallingUid(); } else { mUid = uid; } } } MediaCodec::~MediaCodec() { MediaCodec::~MediaCodec() { Loading Loading @@ -2904,10 +2910,10 @@ void MediaCodec::updateBatteryStat() { } } if (mState == CONFIGURED && !mBatteryStatNotified) { if (mState == CONFIGURED && !mBatteryStatNotified) { BatteryNotifier::getInstance().noteStartVideo(); BatteryNotifier::getInstance().noteStartVideo(mUid); mBatteryStatNotified = true; mBatteryStatNotified = true; } else if (mState == UNINITIALIZED && mBatteryStatNotified) { } else if (mState == UNINITIALIZED && mBatteryStatNotified) { BatteryNotifier::getInstance().noteStopVideo(); BatteryNotifier::getInstance().noteStopVideo(mUid); mBatteryStatNotified = false; mBatteryStatNotified = false; } } } } Loading Loading
include/media/stagefright/MediaCodec.h +5 −3 Original line number Original line Diff line number Diff line Loading @@ -64,14 +64,15 @@ struct MediaCodec : public AHandler { }; }; static const pid_t kNoPid = -1; static const pid_t kNoPid = -1; static const uid_t kNoUid = -1; static sp<MediaCodec> CreateByType( static sp<MediaCodec> CreateByType( const sp<ALooper> &looper, const AString &mime, bool encoder, status_t *err = NULL, const sp<ALooper> &looper, const AString &mime, bool encoder, status_t *err = NULL, pid_t pid = kNoPid); pid_t pid = kNoPid, uid_t uid = kNoUid); static sp<MediaCodec> CreateByComponentName( static sp<MediaCodec> CreateByComponentName( const sp<ALooper> &looper, const AString &name, status_t *err = NULL, const sp<ALooper> &looper, const AString &name, status_t *err = NULL, pid_t pid = kNoPid); pid_t pid = kNoPid, uid_t uid = kNoUid); static sp<PersistentSurface> CreatePersistentInputSurface(); static sp<PersistentSurface> CreatePersistentInputSurface(); Loading Loading @@ -286,6 +287,7 @@ private: }; }; State mState; State mState; uid_t mUid; bool mReleasedByResourceManager; bool mReleasedByResourceManager; sp<ALooper> mLooper; sp<ALooper> mLooper; sp<ALooper> mCodecLooper; sp<ALooper> mCodecLooper; Loading Loading @@ -345,7 +347,7 @@ private: bool mHaveInputSurface; bool mHaveInputSurface; bool mHavePendingInputBuffers; bool mHavePendingInputBuffers; MediaCodec(const sp<ALooper> &looper, pid_t pid); MediaCodec(const sp<ALooper> &looper, pid_t pid, uid_t uid); static sp<CodecBase> GetCodecBase(const AString &name, bool nameIsType = false); static sp<CodecBase> GetCodecBase(const AString &name, bool nameIsType = false); Loading
media/libmediaplayerservice/nuplayer/NuPlayer.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -1641,7 +1641,7 @@ status_t NuPlayer::instantiateDecoder( } else { } else { mSource->setOffloadAudio(false /* offload */); mSource->setOffloadAudio(false /* offload */); *decoder = new Decoder(notify, mSource, mPID, mRenderer); *decoder = new Decoder(notify, mSource, mPID, mUID, mRenderer); } } } else { } else { sp<AMessage> notify = new AMessage(kWhatVideoNotify, this); sp<AMessage> notify = new AMessage(kWhatVideoNotify, this); Loading @@ -1649,7 +1649,7 @@ status_t NuPlayer::instantiateDecoder( notify->setInt32("generation", mVideoDecoderGeneration); notify->setInt32("generation", mVideoDecoderGeneration); *decoder = new Decoder( *decoder = new Decoder( notify, mSource, mPID, mRenderer, mSurface, mCCDecoder); notify, mSource, mPID, mUID, mRenderer, mSurface, mCCDecoder); // enable FRC if high-quality AV sync is requested, even if not // enable FRC if high-quality AV sync is requested, even if not // directly queuing to display, as this will even improve textureview // directly queuing to display, as this will even improve textureview Loading
media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp +4 −2 Original line number Original line Diff line number Diff line Loading @@ -58,6 +58,7 @@ NuPlayer::Decoder::Decoder( const sp<AMessage> ¬ify, const sp<AMessage> ¬ify, const sp<Source> &source, const sp<Source> &source, pid_t pid, pid_t pid, uid_t uid, const sp<Renderer> &renderer, const sp<Renderer> &renderer, const sp<Surface> &surface, const sp<Surface> &surface, const sp<CCDecoder> &ccDecoder) const sp<CCDecoder> &ccDecoder) Loading @@ -67,6 +68,7 @@ NuPlayer::Decoder::Decoder( mRenderer(renderer), mRenderer(renderer), mCCDecoder(ccDecoder), mCCDecoder(ccDecoder), mPid(pid), mPid(pid), mUid(uid), mSkipRenderingUntilMediaTimeUs(-1ll), mSkipRenderingUntilMediaTimeUs(-1ll), mNumFramesTotal(0ll), mNumFramesTotal(0ll), mNumInputFramesDropped(0ll), mNumInputFramesDropped(0ll), Loading Loading @@ -266,7 +268,7 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) { ALOGV("[%s] onConfigure (surface=%p)", mComponentName.c_str(), mSurface.get()); ALOGV("[%s] onConfigure (surface=%p)", mComponentName.c_str(), mSurface.get()); mCodec = MediaCodec::CreateByType( mCodec = MediaCodec::CreateByType( mCodecLooper, mime.c_str(), false /* encoder */, NULL /* err */, mPid); mCodecLooper, mime.c_str(), false /* encoder */, NULL /* err */, mPid, mUid); int32_t secure = 0; int32_t secure = 0; if (format->findInt32("secure", &secure) && secure != 0) { if (format->findInt32("secure", &secure) && secure != 0) { if (mCodec != NULL) { if (mCodec != NULL) { Loading @@ -275,7 +277,7 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) { mCodec->release(); mCodec->release(); ALOGI("[%s] creating", mComponentName.c_str()); ALOGI("[%s] creating", mComponentName.c_str()); mCodec = MediaCodec::CreateByComponentName( mCodec = MediaCodec::CreateByComponentName( mCodecLooper, mComponentName.c_str(), NULL /* err */, mPid); mCodecLooper, mComponentName.c_str(), NULL /* err */, mPid, mUid); } } } } if (mCodec == NULL) { if (mCodec == NULL) { Loading
media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ struct NuPlayer::Decoder : public DecoderBase { Decoder(const sp<AMessage> ¬ify, Decoder(const sp<AMessage> ¬ify, const sp<Source> &source, const sp<Source> &source, pid_t pid, pid_t pid, uid_t uid, const sp<Renderer> &renderer = NULL, const sp<Renderer> &renderer = NULL, const sp<Surface> &surface = NULL, const sp<Surface> &surface = NULL, const sp<CCDecoder> &ccDecoder = NULL); const sp<CCDecoder> &ccDecoder = NULL); Loading Loading @@ -85,6 +86,7 @@ private: Vector<size_t> mDequeuedInputBuffers; Vector<size_t> mDequeuedInputBuffers; const pid_t mPid; const pid_t mPid; const uid_t mUid; int64_t mSkipRenderingUntilMediaTimeUs; int64_t mSkipRenderingUntilMediaTimeUs; int64_t mNumFramesTotal; int64_t mNumFramesTotal; int64_t mNumInputFramesDropped; int64_t mNumInputFramesDropped; Loading
media/libstagefright/MediaCodec.cpp +13 −7 Original line number Original line Diff line number Diff line Loading @@ -173,8 +173,9 @@ bool MediaCodec::ResourceManagerServiceProxy::reclaimResource( // static // static sp<MediaCodec> MediaCodec::CreateByType( sp<MediaCodec> MediaCodec::CreateByType( const sp<ALooper> &looper, const AString &mime, bool encoder, status_t *err, pid_t pid) { const sp<ALooper> &looper, const AString &mime, bool encoder, status_t *err, pid_t pid, sp<MediaCodec> codec = new MediaCodec(looper, pid); uid_t uid) { sp<MediaCodec> codec = new MediaCodec(looper, pid, uid); const status_t ret = codec->init(mime, true /* nameIsType */, encoder); const status_t ret = codec->init(mime, true /* nameIsType */, encoder); if (err != NULL) { if (err != NULL) { Loading @@ -185,8 +186,8 @@ sp<MediaCodec> MediaCodec::CreateByType( // static // static sp<MediaCodec> MediaCodec::CreateByComponentName( sp<MediaCodec> MediaCodec::CreateByComponentName( const sp<ALooper> &looper, const AString &name, status_t *err, pid_t pid) { const sp<ALooper> &looper, const AString &name, status_t *err, pid_t pid, uid_t uid) { sp<MediaCodec> codec = new MediaCodec(looper, pid); sp<MediaCodec> codec = new MediaCodec(looper, pid, uid); const status_t ret = codec->init(name, false /* nameIsType */, false /* encoder */); const status_t ret = codec->init(name, false /* nameIsType */, false /* encoder */); if (err != NULL) { if (err != NULL) { Loading Loading @@ -234,7 +235,7 @@ sp<PersistentSurface> MediaCodec::CreatePersistentInputSurface() { return new PersistentSurface(bufferProducer, bufferSource); return new PersistentSurface(bufferProducer, bufferSource); } } MediaCodec::MediaCodec(const sp<ALooper> &looper, pid_t pid) MediaCodec::MediaCodec(const sp<ALooper> &looper, pid_t pid, uid_t uid) : mState(UNINITIALIZED), : mState(UNINITIALIZED), mReleasedByResourceManager(false), mReleasedByResourceManager(false), mLooper(looper), mLooper(looper), Loading @@ -256,6 +257,11 @@ MediaCodec::MediaCodec(const sp<ALooper> &looper, pid_t pid) mDequeueOutputReplyID(0), mDequeueOutputReplyID(0), mHaveInputSurface(false), mHaveInputSurface(false), mHavePendingInputBuffers(false) { mHavePendingInputBuffers(false) { if (uid == kNoUid) { mUid = IPCThreadState::self()->getCallingUid(); } else { mUid = uid; } } } MediaCodec::~MediaCodec() { MediaCodec::~MediaCodec() { Loading Loading @@ -2904,10 +2910,10 @@ void MediaCodec::updateBatteryStat() { } } if (mState == CONFIGURED && !mBatteryStatNotified) { if (mState == CONFIGURED && !mBatteryStatNotified) { BatteryNotifier::getInstance().noteStartVideo(); BatteryNotifier::getInstance().noteStartVideo(mUid); mBatteryStatNotified = true; mBatteryStatNotified = true; } else if (mState == UNINITIALIZED && mBatteryStatNotified) { } else if (mState == UNINITIALIZED && mBatteryStatNotified) { BatteryNotifier::getInstance().noteStopVideo(); BatteryNotifier::getInstance().noteStopVideo(mUid); mBatteryStatNotified = false; mBatteryStatNotified = false; } } } } Loading