Marco Nelissen | 1900e77 | 2016-02-02 16:12:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** |
Jeff Vander Stoep | c9ea211 | 2016-02-17 10:52:20 -0800 | [diff] [blame] | 3 | ** Copyright 2016, The Android Open Source Project |
Marco Nelissen | 1900e77 | 2016-02-02 16:12:16 -0800 | [diff] [blame] | 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 | |
Jorge Lucangeli Obes | fbfb8e8 | 2017-02-14 10:33:41 -0500 | [diff] [blame] | 18 | #include <android-base/logging.h> |
| 19 | |
Marco Nelissen | 1900e77 | 2016-02-02 16:12:16 -0800 | [diff] [blame] | 20 | // from LOCAL_C_INCLUDES |
Jorge Lucangeli Obes | fbfb8e8 | 2017-02-14 10:33:41 -0500 | [diff] [blame] | 21 | #include "minijail.h" |
Marco Nelissen | 1900e77 | 2016-02-02 16:12:16 -0800 | [diff] [blame] | 22 | |
Pawin Vongmasa | e7b8942 | 2017-11-16 19:33:39 -0800 | [diff] [blame] | 23 | #include <binder/ProcessState.h> |
Pawin Vongmasa | 9c47c97 | 2017-02-08 04:09:38 -0800 | [diff] [blame] | 24 | #include <hidl/HidlTransportSupport.h> |
Pawin Vongmasa | 255735a | 2017-07-19 11:24:56 -0700 | [diff] [blame] | 25 | #include <media/stagefright/omx/1.0/Omx.h> |
| 26 | #include <media/stagefright/omx/1.0/OmxStore.h> |
Pawin Vongmasa | 033975f | 2016-12-27 03:14:55 +0700 | [diff] [blame] | 27 | |
Pawin Vongmasa | a66243a | 2018-04-18 01:38:29 -0700 | [diff] [blame] | 28 | #include <dlfcn.h> |
| 29 | |
Marco Nelissen | 1900e77 | 2016-02-02 16:12:16 -0800 | [diff] [blame] | 30 | using namespace android; |
| 31 | |
Jorge Lucangeli Obes | fbfb8e8 | 2017-02-14 10:33:41 -0500 | [diff] [blame] | 32 | // Must match location in Android.mk. |
Jeff Vander Stoep | 79234e4 | 2017-02-23 10:03:30 -0800 | [diff] [blame] | 33 | static const char kSystemSeccompPolicyPath[] = |
| 34 | "/system/etc/seccomp_policy/mediacodec.policy"; |
| 35 | static const char kVendorSeccompPolicyPath[] = |
| 36 | "/vendor/etc/seccomp_policy/mediacodec.policy"; |
Jorge Lucangeli Obes | fbfb8e8 | 2017-02-14 10:33:41 -0500 | [diff] [blame] | 37 | |
Marco Nelissen | 1900e77 | 2016-02-02 16:12:16 -0800 | [diff] [blame] | 38 | int main(int argc __unused, char** argv) |
| 39 | { |
Pawin Vongmasa | e7b8942 | 2017-11-16 19:33:39 -0800 | [diff] [blame] | 40 | strcpy(argv[0], "media.codec"); |
Jorge Lucangeli Obes | fbfb8e8 | 2017-02-14 10:33:41 -0500 | [diff] [blame] | 41 | LOG(INFO) << "mediacodecservice starting"; |
Marco Nelissen | 1900e77 | 2016-02-02 16:12:16 -0800 | [diff] [blame] | 42 | signal(SIGPIPE, SIG_IGN); |
Jeff Vander Stoep | 79234e4 | 2017-02-23 10:03:30 -0800 | [diff] [blame] | 43 | SetUpMinijail(kSystemSeccompPolicyPath, kVendorSeccompPolicyPath); |
Marco Nelissen | 1900e77 | 2016-02-02 16:12:16 -0800 | [diff] [blame] | 44 | |
Pawin Vongmasa | e7b8942 | 2017-11-16 19:33:39 -0800 | [diff] [blame] | 45 | android::ProcessState::initWithDriver("/dev/vndbinder"); |
| 46 | android::ProcessState::self()->startThreadPool(); |
Pawin Vongmasa | 033975f | 2016-12-27 03:14:55 +0700 | [diff] [blame] | 47 | |
Pawin Vongmasa | 9c47c97 | 2017-02-08 04:09:38 -0800 | [diff] [blame] | 48 | ::android::hardware::configureRpcThreadpool(64, false); |
Pawin Vongmasa | 9c47c97 | 2017-02-08 04:09:38 -0800 | [diff] [blame] | 49 | |
Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 50 | // Default codec services |
| 51 | using namespace ::android::hardware::media::omx::V1_0; |
Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 52 | sp<IOmx> omx = new implementation::Omx(); |
| 53 | if (omx == nullptr) { |
| 54 | LOG(ERROR) << "Cannot create IOmx HAL service."; |
| 55 | } else if (omx->registerAsService() != OK) { |
| 56 | LOG(ERROR) << "Cannot register IOmx HAL service."; |
Pawin Vongmasa | 9c47c97 | 2017-02-08 04:09:38 -0800 | [diff] [blame] | 57 | } else { |
Chong Zhang | 8f91543 | 2018-09-05 11:17:17 -0700 | [diff] [blame] | 58 | LOG(INFO) << "IOmx HAL service created."; |
Pawin Vongmasa | 033975f | 2016-12-27 03:14:55 +0700 | [diff] [blame] | 59 | } |
Lajos Molnar | 3c3d1d2 | 2019-04-08 17:22:26 -0700 | [diff] [blame] | 60 | sp<IOmxStore> omxStore = new implementation::OmxStore(omx); |
| 61 | if (omxStore == nullptr) { |
| 62 | LOG(ERROR) << "Cannot create IOmxStore HAL service."; |
| 63 | } else if (omxStore->registerAsService() != OK) { |
| 64 | LOG(ERROR) << "Cannot register IOmxStore HAL service."; |
| 65 | } |
Pawin Vongmasa | 033975f | 2016-12-27 03:14:55 +0700 | [diff] [blame] | 66 | |
Pawin Vongmasa | e7b8942 | 2017-11-16 19:33:39 -0800 | [diff] [blame] | 67 | ::android::hardware::joinRpcThreadpool(); |
Marco Nelissen | 1900e77 | 2016-02-02 16:12:16 -0800 | [diff] [blame] | 68 | } |