Loading media/libmediaplayerservice/nuplayer/GenericSource.cpp +41 −2 Original line number Diff line number Diff line Loading @@ -262,6 +262,12 @@ status_t NuPlayer::GenericSource::initFromDataSource() { } } mBitrate = totalBitrate; return OK; } status_t NuPlayer::GenericSource::startSources() { // Start the selected A/V tracks now before we start buffering. // Widevine sources might re-initialize crypto when starting, if we delay // this to start(), all data buffered during prepare would be wasted. Loading @@ -276,8 +282,6 @@ status_t NuPlayer::GenericSource::initFromDataSource() { return UNKNOWN_ERROR; } mBitrate = totalBitrate; return OK; } Loading Loading @@ -423,6 +427,32 @@ void NuPlayer::GenericSource::onPrepareAsync() { | FLAG_CAN_SEEK_FORWARD | FLAG_CAN_SEEK); if (mIsSecure) { // secure decoders must be instantiated before starting widevine source sp<AMessage> reply = new AMessage(kWhatSecureDecodersInstantiated, id()); notifyInstantiateSecureDecoders(reply); } else { finishPrepareAsync(); } } void NuPlayer::GenericSource::onSecureDecodersInstantiated(status_t err) { if (err != OK) { ALOGE("Failed to instantiate secure decoders!"); notifyPreparedAndCleanup(err); return; } finishPrepareAsync(); } void NuPlayer::GenericSource::finishPrepareAsync() { status_t err = startSources(); if (err != OK) { ALOGE("Failed to init start data source!"); notifyPreparedAndCleanup(err); return; } if (mIsStreaming) { mPrepareBuffering = true; Loading @@ -441,6 +471,7 @@ void NuPlayer::GenericSource::notifyPreparedAndCleanup(status_t err) { mDataSource.clear(); mCachedSource.clear(); mHttpSource.clear(); mBitrate = -1; cancelPollBuffering(); } Loading Loading @@ -870,6 +901,14 @@ void NuPlayer::GenericSource::onMessageReceived(const sp<AMessage> &msg) { break; } case kWhatSecureDecodersInstantiated: { int32_t err; CHECK(msg->findInt32("err", &err)); onSecureDecodersInstantiated(err); break; } case kWhatStopWidevine: { // mStopRead is only used for Widevine to prevent the video source Loading media/libmediaplayerservice/nuplayer/GenericSource.h +4 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ private: kWhatStopWidevine, kWhatStart, kWhatResume, kWhatSecureDecodersInstantiated, }; struct Track { Loading Loading @@ -161,6 +162,9 @@ private: status_t prefillCacheIfNecessary(); void notifyPreparedAndCleanup(status_t err); void onSecureDecodersInstantiated(status_t err); void finishPrepareAsync(); status_t startSources(); void onGetFormatMeta(sp<AMessage> msg) const; sp<MetaData> doGetFormatMeta(bool audio) const; Loading media/libmediaplayerservice/nuplayer/NuPlayer.cpp +62 −12 Original line number Diff line number Diff line Loading @@ -1004,23 +1004,41 @@ void NuPlayer::onResume() { } } void NuPlayer::onStart() { mOffloadAudio = false; mAudioEOS = false; mVideoEOS = false; mStarted = true; status_t NuPlayer::onInstantiateSecureDecoders() { status_t err; if (!(mSourceFlags & Source::FLAG_SECURE)) { return BAD_TYPE; } /* instantiate decoders now for secure playback */ if (mSourceFlags & Source::FLAG_SECURE) { if (mRenderer != NULL) { ALOGE("renderer should not be set when instantiating secure decoders"); return UNKNOWN_ERROR; } // TRICKY: We rely on mRenderer being null, so that decoder does not start requesting // data on instantiation. if (mNativeWindow != NULL) { instantiateDecoder(false, &mVideoDecoder); err = instantiateDecoder(false, &mVideoDecoder); if (err != OK) { return err; } } if (mAudioSink != NULL) { instantiateDecoder(true, &mAudioDecoder); err = instantiateDecoder(true, &mAudioDecoder); if (err != OK) { return err; } } return OK; } void NuPlayer::onStart() { mOffloadAudio = false; mAudioEOS = false; mVideoEOS = false; mStarted = true; mSource->start(); uint32_t flags = 0; Loading Loading @@ -1371,7 +1389,7 @@ void NuPlayer::flushDecoder(bool audio, bool needShutdown) { FlushStatus newStatus = needShutdown ? FLUSHING_DECODER_SHUTDOWN : FLUSHING_DECODER; mFlushComplete[audio][false /* isDecoder */] = false; mFlushComplete[audio][false /* isDecoder */] = (mRenderer == NULL); mFlushComplete[audio][true /* isDecoder */] = false; if (audio) { ALOGE_IF(mFlushingAudio != NONE, Loading Loading @@ -1656,6 +1674,23 @@ void NuPlayer::onSourceNotify(const sp<AMessage> &msg) { CHECK(msg->findInt32("what", &what)); switch (what) { case Source::kWhatInstantiateSecureDecoders: { if (mSource == NULL) { // This is a stale notification from a source that was // asynchronously preparing when the client called reset(). // We handled the reset, the source is gone. break; } sp<AMessage> reply; CHECK(msg->findMessage("reply", &reply)); status_t err = onInstantiateSecureDecoders(); reply->setInt32("err", err); reply->post(); break; } case Source::kWhatPrepared: { if (mSource == NULL) { Loading @@ -1668,6 +1703,14 @@ void NuPlayer::onSourceNotify(const sp<AMessage> &msg) { int32_t err; CHECK(msg->findInt32("err", &err)); if (err != OK) { // shut down potential secure codecs in case client never calls reset mDeferredActions.push_back( new FlushDecoderAction(FLUSH_CMD_SHUTDOWN /* audio */, FLUSH_CMD_SHUTDOWN /* video */)); processDeferredActions(); } sp<NuPlayerDriver> driver = mDriver.promote(); if (driver != NULL) { // notify duration first, so that it's definitely set when Loading Loading @@ -1952,6 +1995,13 @@ void NuPlayer::Source::notifyPrepared(status_t err) { notify->post(); } void NuPlayer::Source::notifyInstantiateSecureDecoders(const sp<AMessage> &reply) { sp<AMessage> notify = dupNotify(); notify->setInt32("what", kWhatInstantiateSecureDecoders); notify->setMessage("reply", reply); notify->post(); } void NuPlayer::Source::onMessageReceived(const sp<AMessage> & /* msg */) { TRESPASS(); } Loading media/libmediaplayerservice/nuplayer/NuPlayer.h +2 −0 Original line number Diff line number Diff line Loading @@ -201,6 +201,8 @@ private: status_t instantiateDecoder(bool audio, sp<DecoderBase> *decoder); status_t onInstantiateSecureDecoders(); void updateVideoSize( const sp<AMessage> &inputFormat, const sp<AMessage> &outputFormat = NULL); Loading media/libmediaplayerservice/nuplayer/NuPlayerSource.h +2 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ struct NuPlayer::Source : public AHandler { kWhatTimedTextData, kWhatQueueDecoderShutdown, kWhatDrmNoLicense, kWhatInstantiateSecureDecoders, }; // The provides message is used to notify the player about various Loading Loading @@ -126,6 +127,7 @@ protected: void notifyFlagsChanged(uint32_t flags); void notifyVideoSizeChanged(const sp<AMessage> &format = NULL); void notifyInstantiateSecureDecoders(const sp<AMessage> &reply); void notifyPrepared(status_t err = OK); private: Loading Loading
media/libmediaplayerservice/nuplayer/GenericSource.cpp +41 −2 Original line number Diff line number Diff line Loading @@ -262,6 +262,12 @@ status_t NuPlayer::GenericSource::initFromDataSource() { } } mBitrate = totalBitrate; return OK; } status_t NuPlayer::GenericSource::startSources() { // Start the selected A/V tracks now before we start buffering. // Widevine sources might re-initialize crypto when starting, if we delay // this to start(), all data buffered during prepare would be wasted. Loading @@ -276,8 +282,6 @@ status_t NuPlayer::GenericSource::initFromDataSource() { return UNKNOWN_ERROR; } mBitrate = totalBitrate; return OK; } Loading Loading @@ -423,6 +427,32 @@ void NuPlayer::GenericSource::onPrepareAsync() { | FLAG_CAN_SEEK_FORWARD | FLAG_CAN_SEEK); if (mIsSecure) { // secure decoders must be instantiated before starting widevine source sp<AMessage> reply = new AMessage(kWhatSecureDecodersInstantiated, id()); notifyInstantiateSecureDecoders(reply); } else { finishPrepareAsync(); } } void NuPlayer::GenericSource::onSecureDecodersInstantiated(status_t err) { if (err != OK) { ALOGE("Failed to instantiate secure decoders!"); notifyPreparedAndCleanup(err); return; } finishPrepareAsync(); } void NuPlayer::GenericSource::finishPrepareAsync() { status_t err = startSources(); if (err != OK) { ALOGE("Failed to init start data source!"); notifyPreparedAndCleanup(err); return; } if (mIsStreaming) { mPrepareBuffering = true; Loading @@ -441,6 +471,7 @@ void NuPlayer::GenericSource::notifyPreparedAndCleanup(status_t err) { mDataSource.clear(); mCachedSource.clear(); mHttpSource.clear(); mBitrate = -1; cancelPollBuffering(); } Loading Loading @@ -870,6 +901,14 @@ void NuPlayer::GenericSource::onMessageReceived(const sp<AMessage> &msg) { break; } case kWhatSecureDecodersInstantiated: { int32_t err; CHECK(msg->findInt32("err", &err)); onSecureDecodersInstantiated(err); break; } case kWhatStopWidevine: { // mStopRead is only used for Widevine to prevent the video source Loading
media/libmediaplayerservice/nuplayer/GenericSource.h +4 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ private: kWhatStopWidevine, kWhatStart, kWhatResume, kWhatSecureDecodersInstantiated, }; struct Track { Loading Loading @@ -161,6 +162,9 @@ private: status_t prefillCacheIfNecessary(); void notifyPreparedAndCleanup(status_t err); void onSecureDecodersInstantiated(status_t err); void finishPrepareAsync(); status_t startSources(); void onGetFormatMeta(sp<AMessage> msg) const; sp<MetaData> doGetFormatMeta(bool audio) const; Loading
media/libmediaplayerservice/nuplayer/NuPlayer.cpp +62 −12 Original line number Diff line number Diff line Loading @@ -1004,23 +1004,41 @@ void NuPlayer::onResume() { } } void NuPlayer::onStart() { mOffloadAudio = false; mAudioEOS = false; mVideoEOS = false; mStarted = true; status_t NuPlayer::onInstantiateSecureDecoders() { status_t err; if (!(mSourceFlags & Source::FLAG_SECURE)) { return BAD_TYPE; } /* instantiate decoders now for secure playback */ if (mSourceFlags & Source::FLAG_SECURE) { if (mRenderer != NULL) { ALOGE("renderer should not be set when instantiating secure decoders"); return UNKNOWN_ERROR; } // TRICKY: We rely on mRenderer being null, so that decoder does not start requesting // data on instantiation. if (mNativeWindow != NULL) { instantiateDecoder(false, &mVideoDecoder); err = instantiateDecoder(false, &mVideoDecoder); if (err != OK) { return err; } } if (mAudioSink != NULL) { instantiateDecoder(true, &mAudioDecoder); err = instantiateDecoder(true, &mAudioDecoder); if (err != OK) { return err; } } return OK; } void NuPlayer::onStart() { mOffloadAudio = false; mAudioEOS = false; mVideoEOS = false; mStarted = true; mSource->start(); uint32_t flags = 0; Loading Loading @@ -1371,7 +1389,7 @@ void NuPlayer::flushDecoder(bool audio, bool needShutdown) { FlushStatus newStatus = needShutdown ? FLUSHING_DECODER_SHUTDOWN : FLUSHING_DECODER; mFlushComplete[audio][false /* isDecoder */] = false; mFlushComplete[audio][false /* isDecoder */] = (mRenderer == NULL); mFlushComplete[audio][true /* isDecoder */] = false; if (audio) { ALOGE_IF(mFlushingAudio != NONE, Loading Loading @@ -1656,6 +1674,23 @@ void NuPlayer::onSourceNotify(const sp<AMessage> &msg) { CHECK(msg->findInt32("what", &what)); switch (what) { case Source::kWhatInstantiateSecureDecoders: { if (mSource == NULL) { // This is a stale notification from a source that was // asynchronously preparing when the client called reset(). // We handled the reset, the source is gone. break; } sp<AMessage> reply; CHECK(msg->findMessage("reply", &reply)); status_t err = onInstantiateSecureDecoders(); reply->setInt32("err", err); reply->post(); break; } case Source::kWhatPrepared: { if (mSource == NULL) { Loading @@ -1668,6 +1703,14 @@ void NuPlayer::onSourceNotify(const sp<AMessage> &msg) { int32_t err; CHECK(msg->findInt32("err", &err)); if (err != OK) { // shut down potential secure codecs in case client never calls reset mDeferredActions.push_back( new FlushDecoderAction(FLUSH_CMD_SHUTDOWN /* audio */, FLUSH_CMD_SHUTDOWN /* video */)); processDeferredActions(); } sp<NuPlayerDriver> driver = mDriver.promote(); if (driver != NULL) { // notify duration first, so that it's definitely set when Loading Loading @@ -1952,6 +1995,13 @@ void NuPlayer::Source::notifyPrepared(status_t err) { notify->post(); } void NuPlayer::Source::notifyInstantiateSecureDecoders(const sp<AMessage> &reply) { sp<AMessage> notify = dupNotify(); notify->setInt32("what", kWhatInstantiateSecureDecoders); notify->setMessage("reply", reply); notify->post(); } void NuPlayer::Source::onMessageReceived(const sp<AMessage> & /* msg */) { TRESPASS(); } Loading
media/libmediaplayerservice/nuplayer/NuPlayer.h +2 −0 Original line number Diff line number Diff line Loading @@ -201,6 +201,8 @@ private: status_t instantiateDecoder(bool audio, sp<DecoderBase> *decoder); status_t onInstantiateSecureDecoders(); void updateVideoSize( const sp<AMessage> &inputFormat, const sp<AMessage> &outputFormat = NULL); Loading
media/libmediaplayerservice/nuplayer/NuPlayerSource.h +2 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ struct NuPlayer::Source : public AHandler { kWhatTimedTextData, kWhatQueueDecoderShutdown, kWhatDrmNoLicense, kWhatInstantiateSecureDecoders, }; // The provides message is used to notify the player about various Loading Loading @@ -126,6 +127,7 @@ protected: void notifyFlagsChanged(uint32_t flags); void notifyVideoSizeChanged(const sp<AMessage> &format = NULL); void notifyInstantiateSecureDecoders(const sp<AMessage> &reply); void notifyPrepared(status_t err = OK); private: Loading