blob: 6bb3fa2c1a542c9f7bfbc83ebc073a1131feed63 [file] [log] [blame]
Marco Nelissen1900e772016-02-02 16:12:16 -08001/*
2**
Jeff Vander Stoepc9ea2112016-02-17 10:52:20 -08003** Copyright 2016, The Android Open Source Project
Marco Nelissen1900e772016-02-02 16:12:16 -08004**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
Jorge Lucangeli Obesfbfb8e82017-02-14 10:33:41 -050018#include <android-base/logging.h>
19
Marco Nelissen1900e772016-02-02 16:12:16 -080020// from LOCAL_C_INCLUDES
Jorge Lucangeli Obesfbfb8e82017-02-14 10:33:41 -050021#include "minijail.h"
Marco Nelissen1900e772016-02-02 16:12:16 -080022
Pawin Vongmasa620e4662017-10-27 00:12:47 -070023#include <binder/ProcessState.h>
Pawin Vongmasa9c47c972017-02-08 04:09:38 -080024#include <hidl/HidlTransportSupport.h>
Pawin Vongmasa255735a2017-07-19 11:24:56 -070025#include <media/stagefright/omx/1.0/Omx.h>
26#include <media/stagefright/omx/1.0/OmxStore.h>
Pawin Vongmasa033975f2016-12-27 03:14:55 +070027
Marco Nelissen1900e772016-02-02 16:12:16 -080028using namespace android;
29
Jorge Lucangeli Obesfbfb8e82017-02-14 10:33:41 -050030// Must match location in Android.mk.
Jeff Vander Stoep79234e42017-02-23 10:03:30 -080031static const char kSystemSeccompPolicyPath[] =
32 "/system/etc/seccomp_policy/mediacodec.policy";
33static const char kVendorSeccompPolicyPath[] =
34 "/vendor/etc/seccomp_policy/mediacodec.policy";
Jorge Lucangeli Obesfbfb8e82017-02-14 10:33:41 -050035
Marco Nelissen1900e772016-02-02 16:12:16 -080036int main(int argc __unused, char** argv)
37{
Jorge Lucangeli Obesfbfb8e82017-02-14 10:33:41 -050038 LOG(INFO) << "mediacodecservice starting";
Pawin Vongmasa620e4662017-10-27 00:12:47 -070039
40#ifdef USE_VNDBINDER
41 android::ProcessState::initWithDriver("/dev/vndbinder");
42 android::ProcessState::self()->startThreadPool();
43#endif // USE_VNDBINDER
Iliyan Malchev6772cfb2017-04-11 20:19:36 -070044
Marco Nelissen1900e772016-02-02 16:12:16 -080045 signal(SIGPIPE, SIG_IGN);
Jeff Vander Stoep79234e42017-02-23 10:03:30 -080046 SetUpMinijail(kSystemSeccompPolicyPath, kVendorSeccompPolicyPath);
Marco Nelissen1900e772016-02-02 16:12:16 -080047
48 strcpy(argv[0], "media.codec");
Pawin Vongmasa033975f2016-12-27 03:14:55 +070049
Pawin Vongmasa9c47c972017-02-08 04:09:38 -080050 ::android::hardware::configureRpcThreadpool(64, false);
Pawin Vongmasa9c47c972017-02-08 04:09:38 -080051
Pawin Vongmasa620e4662017-10-27 00:12:47 -070052 using namespace ::android::hardware::media::omx::V1_0;
53 sp<IOmxStore> omxStore = new implementation::OmxStore();
54 if (omxStore == nullptr) {
55 LOG(ERROR) << "Cannot create IOmxStore HAL service.";
56 } else if (omxStore->registerAsService() != OK) {
57 LOG(ERROR) << "Cannot register IOmxStore HAL service.";
58 }
59 sp<IOmx> omx = new implementation::Omx();
60 if (omx == nullptr) {
61 LOG(ERROR) << "Cannot create IOmx HAL service.";
62 } else if (omx->registerAsService() != OK) {
63 LOG(ERROR) << "Cannot register IOmx HAL service.";
Pawin Vongmasa9c47c972017-02-08 04:09:38 -080064 } else {
Pawin Vongmasa620e4662017-10-27 00:12:47 -070065 LOG(INFO) << "IOmx HAL service created.";
Pawin Vongmasa033975f2016-12-27 03:14:55 +070066 }
67
Pawin Vongmasa620e4662017-10-27 00:12:47 -070068 ::android::hardware::joinRpcThreadpool();
Marco Nelissen1900e772016-02-02 16:12:16 -080069}