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 16 #ifndef RECORDER_SERVICE_H 17 #define RECORDER_SERVICE_H 18 19 #include "ipc_skeleton.h" 20 #include "recorder_common.h" 21 #include "recorder_impl.h" 22 #include "serializer.h" 23 24 namespace OHOS { 25 namespace Media { 26 /* Since IPC is serialized, there is no concurrency problem */ 27 class RecorderClientMng { 28 public: 29 ~RecorderClientMng() = default; 30 31 static RecorderClientMng *GetInstance(); 32 RecorderImpl *GetRecorder(pid_t pid); 33 bool AcceptClient(pid_t pid); 34 void DropClient(pid_t pid); 35 void Dispatch(int32_t funcId, pid_t pid, IpcIo *req, IpcIo *reply); 36 37 private: 38 RecorderClientMng() = default; 39 SvcIdentity svc_; 40 pid_t client_ = -1; 41 RecorderImpl *rec_ = nullptr; 42 }; 43 44 class RecorderCallbackClient : public RecorderCallback { 45 public: 46 RecorderCallbackClient() = delete; 47 ~RecorderCallbackClient() = default; RecorderCallbackClient(SvcIdentity * sid)48 RecorderCallbackClient(SvcIdentity *sid) : sid_(*sid) {} 49 50 void OnError(int32_t errorType, int32_t errorCode) override; 51 void OnInfo(int32_t type, int32_t extra) override; 52 53 private: 54 SvcIdentity sid_; 55 }; 56 57 void RecorderServiceReg(); 58 } // namespace Media 59 } // namespace OHOS 60 #endif // RECORDER_SERVICE_H 61