Widevine extractor changes to support secure media buffer playback.

Supports either secure or insecure buffer configurations, depending
on the build-time flag REQUIRE_SECURE_BUFFERS.

Change-Id: I5b8150315eced4ed9be656b73d91485a6216819d
This commit is contained in:
Jeff Tinker
2011-06-30 15:47:43 -07:00
parent fee0126ed8
commit ba335957e9
4 changed files with 33 additions and 51 deletions

View File

@@ -4,6 +4,8 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := -DREQUIRE_SECURE_BUFFERS
LOCAL_SRC_FILES:= \
WVMLogging.cpp \
WVMExtractorImpl.cpp \

View File

@@ -260,10 +260,6 @@ status_t WVMExtractorImpl::readMetaData()
status_t status;
status = readAVCCMetaData(videoMetaData);
if (status != OK)
return status;
status = readESDSMetaData(audioMetaData);
if (status != OK)
return status;
@@ -294,52 +290,6 @@ status_t WVMExtractorImpl::readMetaData()
return OK;
}
status_t WVMExtractorImpl::readAVCCMetaData(sp<MetaData> videoMetaData)
{
WVStatus result;
const unsigned char *config;
unsigned long size;
int limit = 500;
do {
size_t bytesRead;
bool auStart, sync;
unsigned long long dts, pts;
unsigned char buf[1];
size_t bufSize = 0;
//
// In order to get the codec config data, we need to have the WVMK
// pull some video data. But we can't use it yet, so just request 0 bytes.
//
(void)WV_GetEsData(mSession, WV_EsSelector_Video, buf, bufSize,
bytesRead, auStart, dts, pts, sync);
result = WV_Info_GetCodecConfig(mSession, WV_CodecConfigType_AVCC, config, size);
if (result != WV_Status_OK)
usleep(10000);
} while (result == WV_Status_Warning_Not_Available && limit-- > 0);
if (result != WV_Status_OK) {
LOGE("WV_Info_GetCodecConfig AVCC returned error %d\n", result);
return ERROR_IO;
}
#if 0
char *filename = "/data/wvm/avcc";
FILE *f = fopen(filename, "w");
if (!f)
LOGD("Failed to open %s", filename);
else {
fwrite(config, size, 1, f);
fclose(f);
}
#endif
videoMetaData->setData(kKeyAVCC, kTypeAVCC, config, size);
return OK;
}
status_t WVMExtractorImpl::readESDSMetaData(sp<MetaData> audioMetaData)
{
WVStatus result;

View File

@@ -80,6 +80,21 @@ void WVMMediaSource::allocBufferGroup()
}
status_t WVMMediaSource::setBuffers(const Vector<MediaBuffer *> &buffers) {
#ifdef REQUIRE_SECURE_BUFFERS
LOGI("Using codec-supplied buffers");
delete mGroup;
mGroup = new MediaBufferGroup;
for (size_t i = 0; i < buffers.size(); ++i) {
mGroup->add_buffer(buffers.itemAt(i));
}
return OK;
#else
return ERROR_UNSUPPORTED;
#endif
}
status_t WVMMediaSource::start(MetaData *)
{
@@ -88,7 +103,6 @@ status_t WVMMediaSource::start(MetaData *)
CHECK(!mStarted);
allocBufferGroup();
mNewSegment = true;
mStarted = true;
@@ -102,7 +116,15 @@ status_t WVMMediaSource::start(MetaData *)
LOGE("WV_Play returned status %d in WVMMediaSource::start\n", result);
return ERROR_IO;
}
#ifndef REQUIRE_SECURE_BUFFERS
allocBufferGroup();
#endif
} else {
// audio
allocBufferGroup();
}
return OK;
}
@@ -136,6 +158,13 @@ status_t WVMMediaSource::stop()
sp<MetaData> WVMMediaSource::getFormat()
{
Mutex::Autolock autoLock(mLock);
#ifdef REQUIRE_SECURE_BUFFERS
if (mESSelector == WV_EsSelector_Video) {
mTrackMetaData->setInt32(kKeyRequiresSecureBuffers, true);
}
#endif
return mTrackMetaData;
}

View File

@@ -43,6 +43,7 @@ public:
virtual sp<MetaData> getFormat();
virtual status_t setBuffers(const Vector<MediaBuffer *> &buffers);
virtual status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL);
static int sLastError;