Skip to content

Commit c1c45a4

Browse files
Gloria WangAndroid Code Review
authored andcommitted
Merge "- Move the business rule management down to DRM agents. - Do not register DRM sniffer because drmserver is not enabled."
2 parents 5b4d0e8 + eab18ea commit c1c45a4

File tree

2 files changed

+14
-24
lines changed

2 files changed

+14
-24
lines changed

media/libstagefright/AwesomePlayer.cpp

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,9 @@ status_t AwesomePlayer::setDataSource_l(
288288
}
289289

290290
dataSource->getDrmInfo(&mDecryptHandle, &mDrmManagerClient);
291-
if (mDecryptHandle != NULL) {
292-
if (RightsStatus::RIGHTS_VALID == mDecryptHandle->status) {
293-
if (DecryptApiType::CONTAINER_BASED == mDecryptHandle->decryptApiType) {
294-
mDrmManagerClient->consumeRights(mDecryptHandle, Action::PLAY, true);
295-
}
296-
} else {
297-
notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_NO_LICENSE);
298-
}
291+
if (mDecryptHandle != NULL
292+
&& RightsStatus::RIGHTS_VALID != mDecryptHandle->status) {
293+
notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_NO_LICENSE);
299294
}
300295

301296
return setDataSource_l(extractor);
@@ -328,11 +323,6 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
328323
}
329324

330325
mExtractorFlags = extractor->flags();
331-
if (mDecryptHandle != NULL) {
332-
if (DecryptApiType::ELEMENTARY_STREAM_BASED == mDecryptHandle->decryptApiType) {
333-
mDrmManagerClient->consumeRights(mDecryptHandle, Action::PLAY, true);
334-
}
335-
}
336326

337327
return OK;
338328
}
@@ -346,8 +336,6 @@ void AwesomePlayer::reset_l() {
346336
if (mDecryptHandle != NULL) {
347337
mDrmManagerClient->setPlaybackStatus(mDecryptHandle,
348338
Playback::STOP, 0);
349-
mDrmManagerClient->consumeRights(mDecryptHandle,
350-
Action::PLAY, false);
351339
mDecryptHandle = NULL;
352340
mDrmManagerClient = NULL;
353341
}
@@ -1190,14 +1178,9 @@ status_t AwesomePlayer::finishSetDataSource_l() {
11901178
}
11911179

11921180
dataSource->getDrmInfo(&mDecryptHandle, &mDrmManagerClient);
1193-
if (mDecryptHandle != NULL) {
1194-
if (RightsStatus::RIGHTS_VALID == mDecryptHandle->status) {
1195-
if (DecryptApiType::CONTAINER_BASED == mDecryptHandle->decryptApiType) {
1196-
mDrmManagerClient->consumeRights(mDecryptHandle, Action::PLAY, true);
1197-
}
1198-
} else {
1199-
notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_NO_LICENSE);
1200-
}
1181+
if (mDecryptHandle != NULL
1182+
&& RightsStatus::RIGHTS_VALID != mDecryptHandle->status) {
1183+
notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, ERROR_NO_LICENSE);
12011184
}
12021185

12031186
if (dataSource->flags() & DataSource::kWantsPrefetching) {

media/libstagefright/DataSource.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <media/stagefright/MediaErrors.h>
2929
#include <utils/String8.h>
3030

31+
#include <cutils/properties.h>
32+
3133
namespace android {
3234

3335
bool DataSource::getUInt16(off_t offset, uint16_t *x) {
@@ -95,7 +97,12 @@ void DataSource::RegisterDefaultSniffers() {
9597
RegisterSniffer(SniffAMR);
9698
RegisterSniffer(SniffWAV);
9799
RegisterSniffer(SniffOgg);
98-
RegisterSniffer(SniffDRM);
100+
101+
char value[PROPERTY_VALUE_MAX];
102+
if (property_get("drm.service.enabled", value, NULL)
103+
&& (!strcmp(value, "1") || !strcasecmp(value, "true"))) {
104+
RegisterSniffer(SniffDRM);
105+
}
99106
}
100107

101108
// static

0 commit comments

Comments
 (0)