diff options
author | Gloria Wang <gwang@google.com> | 2010-06-22 13:55:38 -0700 |
---|---|---|
committer | Gloria Wang <gwang@google.com> | 2010-10-25 12:16:56 -0700 |
commit | dcd25efb46c41c8d24a0a9cf61fb57f84149709e (patch) | |
tree | 6b6d165ba952924f1cd1b77f3a0903e5da31445a /media/libstagefright/AwesomePlayer.cpp | |
parent | 2272ee27d9022d173b6eab45c409b3c3f57f30ec (diff) | |
download | frameworks_av-dcd25efb46c41c8d24a0a9cf61fb57f84149709e.zip frameworks_av-dcd25efb46c41c8d24a0a9cf61fb57f84149709e.tar.gz frameworks_av-dcd25efb46c41c8d24a0a9cf61fb57f84149709e.tar.bz2 |
DRM framework support:
- add a sniffer for DRM files
- add DRMSource and DRMExtractor for es_based DRM
- add pread in FileSource.cpp for container_based DRM
- add native DRM framework API calls in the player for
DRM audio/video playback
Change-Id: I4b9ef19165c9b4f44ff40eeededb9a665e78a90f
Diffstat (limited to 'media/libstagefright/AwesomePlayer.cpp')
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 274dad9..7bbc9eb 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -187,7 +187,8 @@ AwesomePlayer::AwesomePlayer() mExtractorFlags(0), mLastVideoBuffer(NULL), mVideoBuffer(NULL), - mSuspensionState(NULL) { + mSuspensionState(NULL), + mDecryptHandle(NULL) { CHECK_EQ(mClient.connect(), OK); DataSource::RegisterDefaultSniffers(); @@ -286,6 +287,17 @@ status_t AwesomePlayer::setDataSource_l( return UNKNOWN_ERROR; } + dataSource->getDrmInfo(&mDecryptHandle, &mDrmManagerClient); + if (mDecryptHandle != NULL) { + if (RightsStatus::RIGHTS_VALID == mDecryptHandle->status) { + if (DecryptApiType::CONTAINER_BASED == mDecryptHandle->decryptApiType) { + mDrmManagerClient->consumeRights(mDecryptHandle, Action::PLAY, true); + } + } else { + notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_NO_LICENSE); + } + } + return setDataSource_l(extractor); } @@ -316,6 +328,11 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) { } mExtractorFlags = extractor->flags(); + if (mDecryptHandle != NULL) { + if (DecryptApiType::ELEMENTARY_STREAM_BASED == mDecryptHandle->decryptApiType) { + mDrmManagerClient->consumeRights(mDecryptHandle, Action::PLAY, true); + } + } return OK; } @@ -326,6 +343,15 @@ void AwesomePlayer::reset() { } void AwesomePlayer::reset_l() { + if (mDecryptHandle != NULL) { + mDrmManagerClient->setPlaybackStatus(mDecryptHandle, + Playback::STOP, 0); + mDrmManagerClient->consumeRights(mDecryptHandle, + Action::PLAY, false); + mDecryptHandle = NULL; + mDrmManagerClient = NULL; + } + if (mFlags & PREPARING) { mFlags |= PREPARE_CANCELLED; if (mConnectingDataSource != NULL) { @@ -568,6 +594,13 @@ status_t AwesomePlayer::play_l() { seekTo_l(0); } + if (mDecryptHandle != NULL) { + int64_t position; + getPosition(&position); + mDrmManagerClient->setPlaybackStatus(mDecryptHandle, + Playback::START, position / 1000); + } + return OK; } @@ -631,6 +664,11 @@ status_t AwesomePlayer::pause_l() { mFlags &= ~PLAYING; + if (mDecryptHandle != NULL) { + mDrmManagerClient->setPlaybackStatus(mDecryptHandle, + Playback::PAUSE, 0); + } + return OK; } @@ -727,6 +765,13 @@ void AwesomePlayer::seekAudioIfNecessary_l() { mWatchForAudioSeekComplete = true; mWatchForAudioEOS = true; mSeekNotificationSent = false; + + if (mDecryptHandle != NULL) { + mDrmManagerClient->setPlaybackStatus(mDecryptHandle, + Playback::PAUSE, 0); + mDrmManagerClient->setPlaybackStatus(mDecryptHandle, + Playback::START, mSeekTimeUs / 1000); + } } } @@ -919,6 +964,13 @@ void AwesomePlayer::onVideoEvent() { mFlags |= FIRST_FRAME; mSeeking = false; mSeekNotificationSent = false; + + if (mDecryptHandle != NULL) { + mDrmManagerClient->setPlaybackStatus(mDecryptHandle, + Playback::PAUSE, 0); + mDrmManagerClient->setPlaybackStatus(mDecryptHandle, + Playback::START, timeUs / 1000); + } } if (mFlags & FIRST_FRAME) { @@ -1137,6 +1189,17 @@ status_t AwesomePlayer::finishSetDataSource_l() { return UNKNOWN_ERROR; } + dataSource->getDrmInfo(&mDecryptHandle, &mDrmManagerClient); + if (mDecryptHandle != NULL) { + if (RightsStatus::RIGHTS_VALID == mDecryptHandle->status) { + if (DecryptApiType::CONTAINER_BASED == mDecryptHandle->decryptApiType) { + mDrmManagerClient->consumeRights(mDecryptHandle, Action::PLAY, true); + } + } else { + notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_NO_LICENSE); + } + } + if (dataSource->flags() & DataSource::kWantsPrefetching) { mPrefetcher = new Prefetcher; } |