1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "hal_camera.h"
16 #include "samgr_lite.h"
17 #ifndef ENABLE_PASSTHROUGH_MODE
18 #include "player_server.h"
19 #endif
20 #include "camera_server.h"
21 #include "recorder_service.h"
22 #include "audio_capturer_server.h"
23 #include "ohos_init.h"
24 
25 #include <csignal>
26 #include <cstdint>
27 #include <iostream>
28 #include <unistd.h>
29 
30 using namespace OHOS;
31 using namespace OHOS::Media;
OHOS_SystemInit(void)32 extern "C" void __attribute__((weak)) OHOS_SystemInit(void)
33 {
34     SAMGR_Bootstrap();
35 }
36 
37 using namespace std;
main()38 int main()
39 {
40     OHOS_SystemInit();
41 #ifdef SUPPORT_CAMERA_LITE
42     cout << "Camera server start." << endl;
43     CameraServer::GetInstance()->InitCameraServer();
44 #endif
45 #ifndef ENABLE_PASSTHROUGH_MODE
46     cout << "Player server start" << endl;
47     PlayerServer::GetInstance()->PlayerServerInit();
48 
49     cout << "AudioCapturer server start" << endl;
50     AudioCapturerServer::GetInstance()->AudioCapturerServerInit();
51 #endif
52     cout << "Media server initialize succeed." << endl;
53 
54     sigset_t signalSet;
55     sigemptyset(&signalSet);
56     sigaddset(&signalSet, SIGABRT);
57     sigaddset(&signalSet, SIGINT);
58     sigaddset(&signalSet, SIGTERM);
59 
60     int32_t sig;
61     sigwait(&signalSet, &sig);
62     return 0;
63 }
64 #ifndef ENABLE_PASSTHROUGH_MODE
65 SYSEX_SERVICE_INIT(RecorderServiceReg);
66 SYSEX_SERVICE_INIT(AudioCapturerServiceReg);
67 #endif
68