blob: 3993ebaae0754f3c28a3e2c8856e4da5a1a67e29 [file] [log] [blame]
Pawin Vongmasa04c0edc2018-02-26 16:27:02 -08001/*
2 * Copyright 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//#define LOG_NDEBUG 0
18#define LOG_TAG "vendor.google.media.c2@1.0-service"
19
20// TODO: Replace this with vendor's implementation
21#include <C2PlatformSupport.h>
22
23#include <codec2/hidl/1.0/ComponentStore.h>
24#include <hidl/HidlTransportSupport.h>
25#include <minijail.h>
26
27// TODO: Remove this once "setenv()" call is removed.
28#include <stdlib.h>
29
30// This is created by module "codec2.vendor.base.policy". This can be modified.
31static constexpr char kBaseSeccompPolicyPath[] =
32 "/vendor/etc/seccomp_policy/codec2.vendor.base.policy";
33
34// Additional device-specific seccomp permissions can be added in this file.
35static constexpr char kExtSeccompPolicyPath[] =
36 "/vendor/etc/seccomp_policy/codec2.vendor.ext.policy";
37
38int main(int /* argc */, char** /* argv */) {
39 ALOGD("vendor.google.media.c2@1.0-service starting...");
40
41 // TODO: Remove this when all the build settings and sepolicies are in place.
42 setenv("TREBLE_TESTING_OVERRIDE", "true", true);
43
44 signal(SIGPIPE, SIG_IGN);
45 android::SetUpMinijail(kBaseSeccompPolicyPath, kExtSeccompPolicyPath);
46
47 // Extra threads may be needed to handle a stacked IPC sequence that
48 // contains alternating binder and hwbinder calls. (See b/35283480.)
49 android::hardware::configureRpcThreadpool(8, true /* callerWillJoin */);
50
51 // Create IComponentStore service.
52 {
53 using namespace ::vendor::google::media::c2::V1_0;
54 android::sp<IComponentStore> store =
55 new implementation::ComponentStore(
56 android::GetCodec2PlatformComponentStore());
57 if (store == nullptr) {
58 ALOGE("Cannot create Codec2's IComponentStore service.");
59 } else {
60 if (store->registerAsService("default") != android::OK) {
61 ALOGE("Cannot register Codec2's "
62 "IComponentStore service.");
63 } else {
64 ALOGI("Codec2's IComponentStore service created.");
65 }
66 }
67 }
68
69 android::hardware::joinRpcThreadpool();
70 return 0;
71}
72