• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 WFD_DEMO_H
17 #define WFD_DEMO_H
18 
19 #include <cstdint>
20 #include <mutex>
21 #include <string>
22 #include "wifi_diaplay.h"
23 
24 namespace OHOS {
25 namespace Sharing {
26 
27 class WfdDemo : public IWfdListener,
28                 public std::enable_shared_from_this<WfdDemo> {
29 public:
30     WfdDemo() = default;
31     ~WfdDemo() = default;
32 
33     bool Init(const WfdMode mode);
34 
35     void AddDevice();
36     void InitWindow();
37     void ListDevices();
38     void RemoveDevice();
39     void SelectMediaFormat();
40 
41     void OnError(const CastErrorInfo &errorInfo) override;
42     void OnDeviceState(const CastDeviceInfo &deviceInfo) override;
43     void OnDeviceFound(const std::vector<CastDeviceInfo> &deviceInfos) override;
44 
45     void RunWfdSink();
46     void RunWfdSource();
47     void DoCmd(std::string cmd);
48 
49 private:
50     bool surfaceIsUsing_ = false;
51 
52     int32_t windowNum_ = 1;
53 
54     std::mutex mutex_;
55     std::vector<uint64_t> surfaceIds_;
56     std::vector<std::string> devicesIsPlaying_;
57     std::shared_ptr<WifiDisplay> client_ = nullptr;
58     std::map<std::string, std::function<int32_t(std::string)>> WifiDisplayTable_;
59 
60     CastCodecAttr videoAttr_;
61     CastCodecAttr audioAttr_;
62 };
63 
64 } // namespace Sharing
65 } // namespace OHOS
66 
67 #endif