Revert "Remove unused modules made for non-Treble OMX"
This reverts commit 37c79ffe2fa52a1eaa4db74b5e15c6d41646efbf
Bug: 68340092
Test: revert
Change-Id: If7736b745f981105bed4ffda2e63691d8862d259
diff --git a/services/mediacodec/Android.mk b/services/mediacodec/Android.mk
index d4bae2b..faeb0a7 100644
--- a/services/mediacodec/Android.mk
+++ b/services/mediacodec/Android.mk
@@ -1,11 +1,28 @@
LOCAL_PATH := $(call my-dir)
+# service library
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := MediaCodecService.cpp
+LOCAL_SHARED_LIBRARIES := \
+ libmedia_omx \
+ libbinder \
+ libgui \
+ libutils \
+ liblog \
+ libstagefright_omx \
+ libstagefright_xmlparser
+LOCAL_MODULE:= libmediacodecservice
+LOCAL_VENDOR_MODULE := true
+LOCAL_32_BIT_ONLY := true
+include $(BUILD_SHARED_LIBRARY)
+
# service executable
include $(CLEAR_VARS)
LOCAL_REQUIRED_MODULES_arm := mediacodec.policy
LOCAL_SRC_FILES := main_codecservice.cpp
LOCAL_SHARED_LIBRARIES := \
libmedia_omx \
+ libmediacodecservice \
libbinder \
libutils \
libgui \
diff --git a/services/mediacodec/MediaCodecService.cpp b/services/mediacodec/MediaCodecService.cpp
new file mode 100644
index 0000000..6b510c6
--- /dev/null
+++ b/services/mediacodec/MediaCodecService.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "MediaCodecService"
+//#define LOG_NDEBUG 0
+#include <utils/Log.h>
+
+#include "MediaCodecService.h"
+
+namespace android {
+
+sp<IOMX> MediaCodecService::getOMX() {
+
+ Mutex::Autolock autoLock(mOMXLock);
+
+ if (mOMX.get() == NULL) {
+ mOMX = new OMX();
+ }
+
+ return mOMX;
+}
+
+sp<IOMXStore> MediaCodecService::getOMXStore() {
+
+ Mutex::Autolock autoLock(mOMXStoreLock);
+
+ if (mOMXStore.get() == NULL) {
+ mOMXStore = new OMXStore();
+ }
+
+ return mOMXStore;
+}
+
+status_t MediaCodecService::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
+ uint32_t flags)
+{
+ return BnMediaCodecService::onTransact(code, data, reply, flags);
+}
+
+} // namespace android
diff --git a/services/mediacodec/MediaCodecService.h b/services/mediacodec/MediaCodecService.h
new file mode 100644
index 0000000..9301135
--- /dev/null
+++ b/services/mediacodec/MediaCodecService.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_MEDIA_CODEC_SERVICE_H
+#define ANDROID_MEDIA_CODEC_SERVICE_H
+
+#include <binder/BinderService.h>
+#include <media/IMediaCodecService.h>
+#include <media/stagefright/omx/OMX.h>
+#include <media/stagefright/omx/OMXStore.h>
+
+namespace android {
+
+class MediaCodecService : public BinderService<MediaCodecService>,
+ public BnMediaCodecService
+{
+ friend class BinderService<MediaCodecService>; // for MediaCodecService()
+public:
+ MediaCodecService() : BnMediaCodecService() { }
+ virtual ~MediaCodecService() { }
+ virtual void onFirstRef() { }
+
+ static const char* getServiceName() { return "media.codec"; }
+
+ virtual sp<IOMX> getOMX();
+
+ virtual sp<IOMXStore> getOMXStore();
+
+ virtual status_t onTransact(uint32_t code, const Parcel& data,
+ Parcel* reply, uint32_t flags);
+
+private:
+ Mutex mOMXLock;
+ sp<IOMX> mOMX;
+ Mutex mOMXStoreLock;
+ sp<IOMXStore> mOMXStore;
+};
+
+} // namespace android
+
+#endif // ANDROID_MEDIA_CODEC_SERVICE_H
diff --git a/services/mediacodec/main_codecservice.cpp b/services/mediacodec/main_codecservice.cpp
index 62c3dac..79d6da5 100644
--- a/services/mediacodec/main_codecservice.cpp
+++ b/services/mediacodec/main_codecservice.cpp
@@ -28,6 +28,7 @@
#include <android-base/logging.h>
// from LOCAL_C_INCLUDES
+#include "MediaCodecService.h"
#include "minijail.h"
#include <hidl/HidlTransportSupport.h>
@@ -45,7 +46,10 @@
int main(int argc __unused, char** argv)
{
LOG(INFO) << "mediacodecservice starting";
- android::ProcessState::initWithDriver("/dev/vndbinder");
+ bool treble = property_get_bool("persist.media.treble_omx", true);
+ if (treble) {
+ android::ProcessState::initWithDriver("/dev/vndbinder");
+ }
signal(SIGPIPE, SIG_IGN);
SetUpMinijail(kSystemSeccompPolicyPath, kVendorSeccompPolicyPath);
@@ -55,20 +59,25 @@
::android::hardware::configureRpcThreadpool(64, false);
sp<ProcessState> proc(ProcessState::self());
- using namespace ::android::hardware::media::omx::V1_0;
- sp<IOmxStore> omxStore = new implementation::OmxStore();
- if (omxStore == nullptr) {
- LOG(ERROR) << "Cannot create IOmxStore HAL service.";
- } else if (omxStore->registerAsService() != OK) {
- LOG(ERROR) << "Cannot register IOmxStore HAL service.";
- }
- sp<IOmx> omx = new implementation::Omx();
- if (omx == nullptr) {
- LOG(ERROR) << "Cannot create IOmx HAL service.";
- } else if (omx->registerAsService() != OK) {
- LOG(ERROR) << "Cannot register IOmx HAL service.";
+ if (treble) {
+ using namespace ::android::hardware::media::omx::V1_0;
+ sp<IOmxStore> omxStore = new implementation::OmxStore();
+ if (omxStore == nullptr) {
+ LOG(ERROR) << "Cannot create IOmxStore HAL service.";
+ } else if (omxStore->registerAsService() != OK) {
+ LOG(ERROR) << "Cannot register IOmxStore HAL service.";
+ }
+ sp<IOmx> omx = new implementation::Omx();
+ if (omx == nullptr) {
+ LOG(ERROR) << "Cannot create IOmx HAL service.";
+ } else if (omx->registerAsService() != OK) {
+ LOG(ERROR) << "Cannot register IOmx HAL service.";
+ } else {
+ LOG(INFO) << "Treble OMX service created.";
+ }
} else {
- LOG(INFO) << "IOmx HAL service created.";
+ MediaCodecService::instantiate();
+ LOG(INFO) << "Non-Treble OMX service created.";
}
ProcessState::self()->startThreadPool();