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 int localCastSessionId{ INVALID_ID }; 39 ChannelType channelType{ ChannelType::SOFT_BUS }; 40 uint8_t sessionKey[16] = { 0 }; 41 uint32_t sessionKeyLength{ 0 }; 42 std::string bleMac; 43 std::string localWifiIp; 44 std::string wifiIp; 45 uint16_t wifiPort = 0; 46 bool isWifiFresh = false; 47 bool isBleFresh = false; 48 std::string customData; 49 uint32_t capabilityInfo = 0; 50 uint32_t mediumTypes{ 0 }; 51 int rtspPort{ INVALID_PORT }; 52 ProtocolType protocolType; 53 std::string udid; 54 55 std::string localIp; 56 std::string remoteIp; 57 std::string networkId; 58 std::string authVersion; 59 bool isLeagacy{ false }; 60 CapabilityType capability{ CapabilityType::CAST_PLUS }; 61 uint32_t dlnaDeviceId{ static_cast<uint32_t>(INVALID_ID) }; 62 std::vector<std::string> drmCapabilities; 63 std::string modelName; 64 std::string manufacturerName; 65 bool isTrushed; 66 67 bool operator==(const CastInnerRemoteDevice &rhs) const 68 { 69 return deviceId == rhs.deviceId && deviceName == rhs.deviceName && bleMac == rhs.bleMac 70 && wifiIp == rhs.wifiIp && wifiPort == rhs.wifiPort && customData == rhs.customData 71 && isWifiFresh == rhs.isWifiFresh && isBleFresh == rhs.isBleFresh; 72 } 73 74 bool operator!=(const CastInnerRemoteDevice &rhs) const 75 { 76 return !(rhs == *this); 77 } 78 }; 79 80 inline constexpr char PKG_NAME[] = "CastEngineService"; 81 } // namespace CastEngine 82 } // namespace OHOS 83 84 namespace std { 85 using namespace OHOS::CastEngine; 86 template<> 87 struct hash<CastInnerRemoteDevice> { 88 std::size_t operator()(const CastInnerRemoteDevice &remoteDevice) const 89 { 90 return std::hash<std::string>()(remoteDevice.deviceId) 91 ^ std::hash<std::string>()(remoteDevice.deviceName) 92 ^ std::hash<std::string>()(remoteDevice.bleMac) 93 ^ std::hash<std::string>()(remoteDevice.wifiIp) 94 ^ std::hash<uint16_t>()(remoteDevice.wifiPort) 95 ^ std::hash<std::string>()(remoteDevice.customData); 96 } 97 }; 98 } 99 #endif 100