Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

November Patches #2

Open
wants to merge 2 commits into
base: 12.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ Return<void> DrmPlugin::getSecurityLevel(const hidl_vec<uint8_t>& sessionId,
return Void();
}

Mutex::Autolock lock(mSecurityLevelLock);
std::map<std::vector<uint8_t>, SecurityLevel>::iterator itr =
mSecurityLevel.find(sid);
if (itr == mSecurityLevel.end()) {
Expand Down Expand Up @@ -696,6 +697,7 @@ Return<Status> DrmPlugin::setSecurityLevel(const hidl_vec<uint8_t>& sessionId,
return Status::ERROR_DRM_SESSION_NOT_OPENED;
}

Mutex::Autolock lock(mSecurityLevelLock);
std::map<std::vector<uint8_t>, SecurityLevel>::iterator itr =
mSecurityLevel.find(sid);
if (itr != mSecurityLevel.end()) {
Expand Down
4 changes: 3 additions & 1 deletion drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ struct DrmPlugin : public IDrmPlugin {
std::map<std::string, std::vector<uint8_t> > mByteArrayProperties;
std::map<std::string, std::vector<uint8_t> > mReleaseKeysMap;
std::map<std::vector<uint8_t>, std::string> mPlaybackId;
std::map<std::vector<uint8_t>, SecurityLevel> mSecurityLevel;
std::map<std::vector<uint8_t>, SecurityLevel> mSecurityLevel
GUARDED_BY(mSecurityLevelLock);
sp<IDrmPluginListener> mListener;
sp<IDrmPluginListener_V1_2> mListenerV1_2;
SessionLibrary *mSessionLibrary;
Expand All @@ -435,6 +436,7 @@ struct DrmPlugin : public IDrmPlugin {
DeviceFiles mFileHandle GUARDED_BY(mFileHandleLock);
Mutex mFileHandleLock;
Mutex mSecureStopLock;
Mutex mSecurityLevelLock;

CLEARKEY_DISALLOW_COPY_AND_ASSIGN_AND_NEW(DrmPlugin);
};
Expand Down
95 changes: 34 additions & 61 deletions media/libstagefright/NuMediaExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,17 @@ NuMediaExtractor::~NuMediaExtractor() {
}
}

status_t NuMediaExtractor::setDataSource(
const sp<MediaHTTPService> &httpService,
const char *path,
const KeyedVector<String8, String8> *headers) {
Mutex::Autolock autoLock(mLock);

if (mImpl != NULL || path == NULL) {
return -EINVAL;
}

sp<DataSource> dataSource =
DataSourceFactory::getInstance()->CreateFromURI(httpService, path, headers);

if (dataSource == NULL) {
return -ENOENT;
}
status_t NuMediaExtractor::initMediaExtractor(const sp<DataSource>& dataSource) {
status_t err = OK;

mImpl = MediaExtractorFactory::Create(dataSource);

if (mImpl == NULL) {
ALOGE("%s: failed to create MediaExtractor", __FUNCTION__);
return ERROR_UNSUPPORTED;
}

setEntryPointToRemoteMediaExtractor();

status_t err = OK;
if (!mCasToken.empty()) {
err = mImpl->setMediaCas(mCasToken);
if (err != OK) {
Expand All @@ -105,6 +91,10 @@ status_t NuMediaExtractor::setDataSource(
}
}

// Get the name of the implementation.
mName = mImpl->name();

// Update the duration and bitrate
err = updateDurationAndBitrate();
if (err == OK) {
mDataSource = dataSource;
Expand All @@ -113,6 +103,27 @@ status_t NuMediaExtractor::setDataSource(
return OK;
}

status_t NuMediaExtractor::setDataSource(
const sp<MediaHTTPService> &httpService,
const char *path,
const KeyedVector<String8, String8> *headers) {
Mutex::Autolock autoLock(mLock);

if (mImpl != NULL || path == NULL) {
return -EINVAL;
}

sp<DataSource> dataSource =
DataSourceFactory::getInstance()->CreateFromURI(httpService, path, headers);

if (dataSource == NULL) {
return -ENOENT;
}

// Initialize MediaExtractor using the data source
return initMediaExtractor(dataSource);
}

status_t NuMediaExtractor::setDataSource(int fd, off64_t offset, off64_t size) {

ALOGV("setDataSource fd=%d (%s), offset=%lld, length=%lld",
Expand All @@ -131,27 +142,8 @@ status_t NuMediaExtractor::setDataSource(int fd, off64_t offset, off64_t size) {
return err;
}

mImpl = MediaExtractorFactory::Create(fileSource);

if (mImpl == NULL) {
return ERROR_UNSUPPORTED;
}
setEntryPointToRemoteMediaExtractor();

if (!mCasToken.empty()) {
err = mImpl->setMediaCas(mCasToken);
if (err != OK) {
ALOGE("%s: failed to setMediaCas (%d)", __FUNCTION__, err);
return err;
}
}

err = updateDurationAndBitrate();
if (err == OK) {
mDataSource = fileSource;
}

return OK;
// Initialize MediaExtractor using the file source
return initMediaExtractor(fileSource);
}

status_t NuMediaExtractor::setDataSource(const sp<DataSource> &source) {
Expand All @@ -166,32 +158,13 @@ status_t NuMediaExtractor::setDataSource(const sp<DataSource> &source) {
return err;
}

mImpl = MediaExtractorFactory::Create(source);

if (mImpl == NULL) {
return ERROR_UNSUPPORTED;
}
setEntryPointToRemoteMediaExtractor();

if (!mCasToken.empty()) {
err = mImpl->setMediaCas(mCasToken);
if (err != OK) {
ALOGE("%s: failed to setMediaCas (%d)", __FUNCTION__, err);
return err;
}
}

err = updateDurationAndBitrate();
if (err == OK) {
mDataSource = source;
}

return err;
// Initialize MediaExtractor using the given data source
return initMediaExtractor(source);
}

const char* NuMediaExtractor::getName() const {
Mutex::Autolock autoLock(mLock);
return mImpl == nullptr ? nullptr : mImpl->name().string();
return mImpl == nullptr ? nullptr : mName.string();
}

static String8 arrayToString(const std::vector<uint8_t> &array) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ struct NuMediaExtractor : public RefBase {
Vector<TrackInfo> mSelectedTracks;
int64_t mTotalBitrate; // in bits/sec
int64_t mDurationUs;
String8 mName;

void setEntryPointToRemoteMediaExtractor();

Expand All @@ -165,6 +166,7 @@ struct NuMediaExtractor : public RefBase {
bool getTotalBitrate(int64_t *bitRate) const;
status_t updateDurationAndBitrate();
status_t appendVorbisNumPageSamples(MediaBufferBase *mbuf, const sp<ABuffer> &buffer);
status_t initMediaExtractor(const sp<DataSource>& dataSource);

DISALLOW_EVIL_CONSTRUCTORS(NuMediaExtractor);
};
Expand Down