• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023-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  * Description: Cast engine service related common data stucture definitions.
15  * Author: zhangge
16  * Create: 2022-10-26
17  */
18 
19 #ifndef CAST_SERVICE_COMMON_H
20 #define CAST_SERVICE_COMMON_H
21 
22 #include <string>
23 
24 #include "cast_engine_common.h"
25 
26 namespace OHOS {
27 namespace CastEngine {
28 struct CastInnerRemoteDevice {
29     std::string deviceId;
30     std::string deviceName;
31     DeviceType deviceType{ DeviceType::DEVICE_OTHERS };
32     int deviceTypeId = 0;
33     SubDeviceType subDeviceType{ SubDeviceType::SUB_DEVICE_DEFAULT };
34     std::string ipAddress;
35     TriggerType triggerType{ TriggerType::UNSPEC_TAG };
36     std::string authData;
37     int sessionId{ INVALID_ID };
38     ChannelType channelType{ ChannelType::SOFT_BUS };
39     uint8_t sessionKey[16] = { 0 };
40     uint32_t sessionKeyLength{ 0 };
41     std::string bleMac;
42     std::string localWifiIp;
43     std::string wifiIp;
44     uint16_t wifiPort = 0;
45     std::string customData;
46     int rtspPort{ INVALID_PORT };
47     ProtocolType protocolType;
48     std::string udid;
49 
50     std::string localIp;
51     std::string remoteIp;
52     std::string networkId;
53 
54     bool operator==(const CastInnerRemoteDevice &rhs) const
55     {
56         return deviceId == rhs.deviceId && deviceName == rhs.deviceName && bleMac == rhs.bleMac
57                && wifiIp == rhs.wifiIp && wifiPort == rhs.wifiPort && customData == rhs.customData;
58     }
59 
60     bool operator!=(const CastInnerRemoteDevice &rhs) const
61     {
62         return !(rhs == *this);
63     }
64 };
65 
66 inline constexpr char PKG_NAME[] = "CastEngineService";
67 } // namespace CastEngine
68 } // namespace OHOS
69 
70 namespace std {
71 using namespace OHOS::CastEngine;
72 template<>
73 struct hash<CastInnerRemoteDevice> {
74     std::size_t operator()(const CastInnerRemoteDevice &remoteDevice) const
75     {
76         return std::hash<std::string>()(remoteDevice.deviceId)
77                 ^ std::hash<std::string>()(remoteDevice.deviceName)
78                 ^ std::hash<std::string>()(remoteDevice.bleMac)
79                 ^ std::hash<std::string>()(remoteDevice.wifiIp)
80                 ^ std::hash<uint16_t>()(remoteDevice.wifiPort)
81                 ^ std::hash<std::string>()(remoteDevice.customData);
82     }
83 };
84 }
85 #endif
86