transcoder: plumb uid/pid to transcoder createCodec
Instead of using ResourceManagerService::overrideProcessInfo to
override the procinfo of the native MediaTranscodingService,
use the newly added AMediaCodec create methods with UID/PID.
This will allow the codec instance to be attributed to the
actual client (for battery reporting as well resource managerment
purposes), instead of all to media.transcoding.
Plumb uid/pid to transcoder to create the codec with them.
Fix up the unit test after the change.
bug: 159172726
test: transcoder unit tests.
Change-Id: Ie7e6fd813ec53f125590665ab3466758a0fd4601
diff --git a/media/libmediatranscoding/transcoder/MediaTranscoder.cpp b/media/libmediatranscoding/transcoder/MediaTranscoder.cpp
index d89b58f..07df5e0 100644
--- a/media/libmediatranscoding/transcoder/MediaTranscoder.cpp
+++ b/media/libmediatranscoding/transcoder/MediaTranscoder.cpp
@@ -154,11 +154,12 @@
mCallbacks->onProgressUpdate(this, progress);
}
-MediaTranscoder::MediaTranscoder(const std::shared_ptr<CallbackInterface>& callbacks)
- : mCallbacks(callbacks) {}
+MediaTranscoder::MediaTranscoder(const std::shared_ptr<CallbackInterface>& callbacks, pid_t pid,
+ uid_t uid)
+ : mCallbacks(callbacks), mPid(pid), mUid(uid) {}
std::shared_ptr<MediaTranscoder> MediaTranscoder::create(
- const std::shared_ptr<CallbackInterface>& callbacks,
+ const std::shared_ptr<CallbackInterface>& callbacks, pid_t pid, uid_t uid,
const std::shared_ptr<ndk::ScopedAParcel>& pausedState) {
if (pausedState != nullptr) {
LOG(INFO) << "Initializing from paused state.";
@@ -168,7 +169,7 @@
return nullptr;
}
- return std::shared_ptr<MediaTranscoder>(new MediaTranscoder(callbacks));
+ return std::shared_ptr<MediaTranscoder>(new MediaTranscoder(callbacks, pid, uid));
}
media_status_t MediaTranscoder::configureSource(int fd) {
@@ -257,7 +258,7 @@
}
}
- transcoder = VideoTrackTranscoder::create(shared_from_this());
+ transcoder = VideoTrackTranscoder::create(shared_from_this(), mPid, mUid);
AMediaFormat* mergedFormat =
mergeMediaFormats(mSourceTrackFormats[trackIndex].get(), trackFormat);