1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 //#define LOG_NDEBUG 0 6 #define LOG_TAG "android.hardware.media.c2@1.0-service-goldfish" 7 8 #include <C2Component.h> 9 #include <codec2/hidl/1.0/ComponentStore.h> 10 #include <hidl/HidlTransportSupport.h> 11 #include <log/log.h> 12 #include <minijail.h> 13 14 #include <goldfish_codec2/store/GoldfishComponentStore.h> 15 16 // Default policy for codec2.0 service. 17 static constexpr char kBaseSeccompPolicyPath[] = 18 "/vendor/etc/seccomp_policy/" 19 "android.hardware.media.c2-default-seccomp_policy"; 20 21 // Additional device-specific seccomp permissions can be added in this file. 22 static constexpr char kExtSeccompPolicyPath[] = 23 "/vendor/etc/seccomp_policy/codec2.vendor.ext.policy"; 24 main(int,char **)25int main(int /* argc */, char ** /* argv */) { 26 ALOGD("Goldfish C2 Service starting..."); 27 28 signal(SIGPIPE, SIG_IGN); 29 android::SetUpMinijail(kBaseSeccompPolicyPath, kExtSeccompPolicyPath); 30 31 android::hardware::configureRpcThreadpool(8, true /* callerWillJoin */); 32 33 // Create IComponentStore service. 34 { 35 using namespace ::android::hardware::media::c2::V1_0; 36 37 ALOGD("Instantiating Codec2's Goldfish IComponentStore service..."); 38 android::sp<IComponentStore> store(new utils::ComponentStore( 39 android::GoldfishComponentStore::Create())); 40 if (store == nullptr) { 41 ALOGE("Cannot create Codec2's Goldfish IComponentStore service."); 42 } else if (store->registerAsService("default") != android::OK) { 43 ALOGE("Cannot register Codec2's IComponentStore service."); 44 } else { 45 ALOGI("Codec2's IComponentStore service created."); 46 } 47 } 48 49 android::hardware::joinRpcThreadpool(); 50 ALOGD("Service shutdown."); 51 return 0; 52 } 53