Merge "C2SoftVpxEnc: add support for levels upto 4.1" am: 985ef526be am: 972057ec1e
Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1890238
Change-Id: I982b255e4efdcb0995f073c0fe1c55f4c7934de1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp b/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp
index 32d7723..e04dd7e 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp
+++ b/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp
@@ -619,6 +619,7 @@
return Void();
}
+ Mutex::Autolock lock(mSecurityLevelLock);
std::map<std::vector<uint8_t>, SecurityLevel>::iterator itr =
mSecurityLevel.find(sid);
if (itr == mSecurityLevel.end()) {
@@ -691,6 +692,7 @@
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()) {
diff --git a/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h b/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h
index cb5c9fe..1019520 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h
+++ b/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h
@@ -414,7 +414,8 @@
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;
@@ -434,6 +435,7 @@
DeviceFiles mFileHandle;
Mutex mSecureStopLock;
+ Mutex mSecurityLevelLock;
CLEARKEY_DISALLOW_COPY_AND_ASSIGN_AND_NEW(DrmPlugin);
};
diff --git a/media/libstagefright/NuMediaExtractor.cpp b/media/libstagefright/NuMediaExtractor.cpp
index b4baf03..0536f2a 100644
--- a/media/libstagefright/NuMediaExtractor.cpp
+++ b/media/libstagefright/NuMediaExtractor.cpp
@@ -72,6 +72,37 @@
}
}
+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();
+
+ if (!mCasToken.empty()) {
+ err = mImpl->setMediaCas(mCasToken);
+ if (err != OK) {
+ ALOGE("%s: failed to setMediaCas (%d)", __FUNCTION__, err);
+ return err;
+ }
+ }
+
+ // Get the name of the implementation.
+ mName = mImpl->name();
+
+ // Update the duration and bitrate
+ err = updateDurationAndBitrate();
+ if (err == OK) {
+ mDataSource = dataSource;
+ }
+
+ return OK;
+}
+
status_t NuMediaExtractor::setDataSource(
const sp<MediaHTTPService> &httpService,
const char *path,
@@ -89,28 +120,8 @@
return -ENOENT;
}
- mImpl = MediaExtractorFactory::Create(dataSource);
-
- if (mImpl == NULL) {
- return ERROR_UNSUPPORTED;
- }
- setEntryPointToRemoteMediaExtractor();
-
- status_t err = OK;
- 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 = dataSource;
- }
-
- return OK;
+ // Initialize MediaExtractor using the data source
+ return initMediaExtractor(dataSource);
}
status_t NuMediaExtractor::setDataSource(int fd, off64_t offset, off64_t size) {
@@ -131,27 +142,8 @@
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) {
@@ -166,32 +158,13 @@
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) {
diff --git a/media/libstagefright/include/media/stagefright/NuMediaExtractor.h b/media/libstagefright/include/media/stagefright/NuMediaExtractor.h
index d17a480..52ea28b 100644
--- a/media/libstagefright/include/media/stagefright/NuMediaExtractor.h
+++ b/media/libstagefright/include/media/stagefright/NuMediaExtractor.h
@@ -146,6 +146,7 @@
Vector<TrackInfo> mSelectedTracks;
int64_t mTotalBitrate; // in bits/sec
int64_t mDurationUs;
+ String8 mName;
void setEntryPointToRemoteMediaExtractor();
@@ -165,6 +166,7 @@
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);
};
diff --git a/media/libstagefright/rtsp/AAVCAssembler.cpp b/media/libstagefright/rtsp/AAVCAssembler.cpp
index 2f516d5..ddf797c 100644
--- a/media/libstagefright/rtsp/AAVCAssembler.cpp
+++ b/media/libstagefright/rtsp/AAVCAssembler.cpp
@@ -618,13 +618,14 @@
int32_t AAVCAssembler::pickStartSeq(const Queue *queue,
uint32_t first, int64_t play, int64_t jit) {
+ CHECK(!queue->empty());
// pick the first sequence number has the start bit.
sp<ABuffer> buffer = *(queue->begin());
int32_t firstSeqNo = buffer->int32Data();
// This only works for FU-A type & non-start sequence
- unsigned nalType = buffer->data()[0] & 0x1f;
- if (nalType != 28 || buffer->data()[1] & 0x80) {
+ int32_t nalType = buffer->size() >= 1 ? buffer->data()[0] & 0x1f : -1;
+ if (nalType != 28 || (buffer->size() >= 2 && buffer->data()[1] & 0x80)) {
return firstSeqNo;
}
@@ -634,7 +635,7 @@
if (rtpTime + jit >= play) {
break;
}
- if ((data[1] & 0x80)) {
+ if (it->size() >= 2 && (data[1] & 0x80)) {
const int32_t seqNo = it->int32Data();
ALOGE("finding [HEAD] pkt. \t Seq# (%d ~ )[%d", firstSeqNo, seqNo);
firstSeqNo = seqNo;
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 7546c9d..a0c0e7d 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -9669,6 +9669,12 @@
if (isOutput()) {
ret = AudioSystem::startOutput(portId);
} else {
+ {
+ // Add the track record before starting input so that the silent status for the
+ // client can be cached.
+ Mutex::Autolock _l(mLock);
+ setClientSilencedState_l(portId, false /*silenced*/);
+ }
ret = AudioSystem::startInput(portId);
}
@@ -9687,6 +9693,7 @@
} else {
mHalStream->stop();
}
+ eraseClientSilencedState_l(portId);
return PERMISSION_DENIED;
}
@@ -9695,6 +9702,9 @@
mChannelMask, mSessionId, isOutput(),
client.attributionSource,
IPCThreadState::self()->getCallingPid(), portId);
+ if (!isOutput()) {
+ track->setSilenced_l(isClientSilenced_l(portId));
+ }
if (isOutput()) {
// force volume update when a new track is added
@@ -9752,6 +9762,7 @@
}
mActiveTracks.remove(track);
+ eraseClientSilencedState_l(track->portId());
mLock.unlock();
if (isOutput()) {
@@ -10542,6 +10553,7 @@
broadcast_l();
}
}
+ setClientSilencedIfExists_l(portId, silenced);
}
void AudioFlinger::MmapCaptureThread::toAudioPortConfig(struct audio_port_config *config)
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index a401048..2f85378 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -2105,6 +2105,26 @@
virtual bool isStreamInitialized() { return false; }
+ void setClientSilencedState_l(audio_port_handle_t portId, bool silenced) {
+ mClientSilencedStates[portId] = silenced;
+ }
+
+ size_t eraseClientSilencedState_l(audio_port_handle_t portId) {
+ return mClientSilencedStates.erase(portId);
+ }
+
+ bool isClientSilenced_l(audio_port_handle_t portId) const {
+ const auto it = mClientSilencedStates.find(portId);
+ return it != mClientSilencedStates.end() ? it->second : false;
+ }
+
+ void setClientSilencedIfExists_l(audio_port_handle_t portId, bool silenced) {
+ const auto it = mClientSilencedStates.find(portId);
+ if (it != mClientSilencedStates.end()) {
+ it->second = silenced;
+ }
+ }
+
protected:
void dumpInternals_l(int fd, const Vector<String16>& args) override;
void dumpTracks_l(int fd, const Vector<String16>& args) override;
@@ -2124,6 +2144,7 @@
AudioHwDevice* const mAudioHwDev;
ActiveTracks<MmapTrack> mActiveTracks;
float mHalVolFloat;
+ std::map<audio_port_handle_t, bool> mClientSilencedStates;
int32_t mNoCallbackWarningCount;
static constexpr int32_t kMaxNoCallbackWarnings = 5;