main_codecservice.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. **
  3. ** Copyright 2016, 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. #include <android-base/logging.h>
  18. // from LOCAL_C_INCLUDES
  19. #include "minijail.h"
  20. #include <binder/ProcessState.h>
  21. #include <cutils/properties.h>
  22. #include <hidl/HidlTransportSupport.h>
  23. #include <media/stagefright/omx/1.0/Omx.h>
  24. #include <media/stagefright/omx/1.0/OmxStore.h>
  25. #include <dlfcn.h>
  26. using namespace android;
  27. // Must match location in Android.mk.
  28. static const char kSystemSeccompPolicyPath[] =
  29. "/system/etc/seccomp_policy/mediacodec.policy";
  30. static const char kVendorSeccompPolicyPath[] =
  31. "/vendor/etc/seccomp_policy/mediacodec.policy";
  32. int main(int argc __unused, char** argv)
  33. {
  34. strcpy(argv[0], "media.codec");
  35. LOG(INFO) << "mediacodecservice starting";
  36. signal(SIGPIPE, SIG_IGN);
  37. SetUpMinijail(kSystemSeccompPolicyPath, kVendorSeccompPolicyPath);
  38. android::ProcessState::initWithDriver("/dev/vndbinder");
  39. android::ProcessState::self()->startThreadPool();
  40. ::android::hardware::configureRpcThreadpool(64, false);
  41. // Default codec services
  42. using namespace ::android::hardware::media::omx::V1_0;
  43. sp<IOmx> omx = new implementation::Omx();
  44. if (omx == nullptr) {
  45. LOG(ERROR) << "Cannot create IOmx HAL service.";
  46. } else if (omx->registerAsService() != OK) {
  47. LOG(ERROR) << "Cannot register IOmx HAL service.";
  48. } else {
  49. LOG(INFO) << "IOmx HAL service created.";
  50. }
  51. sp<IOmxStore> omxStore = new implementation::OmxStore(
  52. property_get_int64("vendor.media.omx", 1) ? omx : nullptr);
  53. if (omxStore == nullptr) {
  54. LOG(ERROR) << "Cannot create IOmxStore HAL service.";
  55. } else if (omxStore->registerAsService() != OK) {
  56. LOG(ERROR) << "Cannot register IOmxStore HAL service.";
  57. }
  58. ::android::hardware::joinRpcThreadpool();
  59. }