blob: 6f14a429372e9663cd7fed77f68bd79d96e6b80c [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 Vongmasae7b89422017-11-16 19:33:39 -080023#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{
Pawin Vongmasae7b89422017-11-16 19:33:39 -080038 strcpy(argv[0], "media.codec");
Jorge Lucangeli Obesfbfb8e82017-02-14 10:33:41 -050039 LOG(INFO) << "mediacodecservice starting";
Marco Nelissen1900e772016-02-02 16:12:16 -080040 signal(SIGPIPE, SIG_IGN);
Jeff Vander Stoep79234e42017-02-23 10:03:30 -080041 SetUpMinijail(kSystemSeccompPolicyPath, kVendorSeccompPolicyPath);
Marco Nelissen1900e772016-02-02 16:12:16 -080042
Pawin Vongmasae7b89422017-11-16 19:33:39 -080043#ifdef USE_VNDBINDER
44 android::ProcessState::initWithDriver("/dev/vndbinder");
45 android::ProcessState::self()->startThreadPool();
46#endif // USE_VNDBINDER
Pawin Vongmasa033975f2016-12-27 03:14:55 +070047
Pawin Vongmasa9c47c972017-02-08 04:09:38 -080048 ::android::hardware::configureRpcThreadpool(64, false);
Pawin Vongmasa9c47c972017-02-08 04:09:38 -080049
Pawin Vongmasae7b89422017-11-16 19:33:39 -080050 using namespace ::android::hardware::media::omx::V1_0;
51 sp<IOmxStore> omxStore = new implementation::OmxStore();
52 if (omxStore == nullptr) {
53 LOG(ERROR) << "Cannot create IOmxStore HAL service.";
54 } else if (omxStore->registerAsService() != OK) {
55 LOG(ERROR) << "Cannot register IOmxStore HAL service.";
56 }
57 sp<IOmx> omx = new implementation::Omx();
58 if (omx == nullptr) {
59 LOG(ERROR) << "Cannot create IOmx HAL service.";
60 } else if (omx->registerAsService() != OK) {
61 LOG(ERROR) << "Cannot register IOmx HAL service.";
Pawin Vongmasa9c47c972017-02-08 04:09:38 -080062 } else {
Pawin Vongmasae7b89422017-11-16 19:33:39 -080063 LOG(INFO) << "IOmx HAL service created.";
Pawin Vongmasa033975f2016-12-27 03:14:55 +070064 }
65
Pawin Vongmasae7b89422017-11-16 19:33:39 -080066 ::android::hardware::joinRpcThreadpool();
Marco Nelissen1900e772016-02-02 16:12:16 -080067}