• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 OHOS_AV_SYNC_MANAGER_H
17 #define OHOS_AV_SYNC_MANAGER_H
18 
19 #include <mutex>
20 
21 #include "av_sync_utils.h"
22 #include "av_trans_message.h"
23 #include "av_trans_types.h"
24 
25 namespace OHOS {
26 namespace DistributedHardware {
27 constexpr uint32_t AV_SYNC_STREAM_COUNT = 2;
28 
29 class AVSyncManager {
30 public:
31     AVSyncManager();
32     ~AVSyncManager();
33 
34     void AddStreamInfo(const AVStreamInfo &stream);
35     void RemoveStreamInfo(const AVStreamInfo &stream);
36     void HandleAvSyncMessage(const std::shared_ptr<AVTransMessage> &message);
37 
38 private:
39     void EnableSenderAVSync();
40     void DisableSenderAVSync();
41     void EnableReceiverAVSync(const std::string &groupInfo);
42     void DisableReceiverAVSync(const std::string &groupInfo);
43     bool MergeGroupInfo(std::string &syncGroupInfo);
44 
45 private:
46     std::mutex listMutex_;
47 
48     std::vector<AVStreamInfo> streamInfoList_;
49     AVTransSharedMemory sourceMemory_;
50     AVTransSharedMemory sinkMemory_;
51 };
52 }
53 }
54 #endif