1 /*
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 "CodecServiceRegistrant"
19 
20 #include <android-base/logging.h>
21 
22 #include <C2PlatformSupport.h>
23 #include <codec2/hidl/1.0/ComponentStore.h>
24 #include <media/CodecServiceRegistrant.h>
25 
RegisterCodecServices()26 extern "C" void RegisterCodecServices() {
27     using namespace ::android::hardware::media::c2::V1_0;
28     LOG(INFO) << "Creating software Codec2 service...";
29     android::sp<IComponentStore> store =
30         new utils::ComponentStore(
31                 android::GetCodec2PlatformComponentStore());
32     if (store == nullptr) {
33         LOG(ERROR) <<
34                 "Cannot create software Codec2 service.";
35     } else {
36         if (store->registerAsService("software") != android::OK) {
37             LOG(ERROR) <<
38                     "Cannot register software Codec2 service.";
39         } else {
40             LOG(INFO) <<
41                     "Software Codec2 service created.";
42         }
43     }
44 }
45 
46