blob: 1729c3ff9f315db2dee434fa903aaf303ffe7c33 [file] [log] [blame]
Chong Zhang8f915432018-09-05 11:17:17 -07001/*
2**
3** Copyright 2018, The Android Open Source Project
4**
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
18#include <android-base/logging.h>
19
20// from LOCAL_C_INCLUDES
21#include "minijail.h"
22
23#include <binder/ProcessState.h>
24#include <hidl/HidlTransportSupport.h>
25#include <media/CodecServiceRegistrant.h>
26#include <dlfcn.h>
27
28using namespace android;
29
30// TODO: replace policy with software codec-only policies
31// Must match location in Android.mk.
32static const char kSystemSeccompPolicyPath[] =
33 "/system/etc/seccomp_policy/mediacodec.policy";
34static const char kVendorSeccompPolicyPath[] =
35 "/vendor/etc/seccomp_policy/mediacodec.policy";
36
37int main(int argc __unused, char** /*argv*/)
38{
39 LOG(INFO) << "media swcodec service starting";
40 signal(SIGPIPE, SIG_IGN);
41 SetUpMinijail(kSystemSeccompPolicyPath, kVendorSeccompPolicyPath);
42
43 android::ProcessState::self()->startThreadPool();
44
45 ::android::hardware::configureRpcThreadpool(64, false);
46
47 // Registration of customized codec services
48 void *registrantLib = dlopen(
49 "libmedia_codecserviceregistrant.so",
50 RTLD_NOW | RTLD_LOCAL);
51 if (registrantLib) {
52 RegisterCodecServicesFunc registerCodecServices =
53 reinterpret_cast<RegisterCodecServicesFunc>(
54 dlsym(registrantLib, "RegisterCodecServices"));
55 if (registerCodecServices) {
56 registerCodecServices();
57 } else {
58 LOG(WARNING) << "Cannot register codec services "
59 "-- corrupted library.";
60 }
61 } else {
62 LOG(ERROR) << "Cannot find codec service registrant.";
63 }
64
65 ::android::hardware::joinRpcThreadpool();
66}