• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2025 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 #include "avsession_descriptor.h"
17 #include "avsession_log.h"
18 
19 namespace OHOS::AVSession {
Marshalling(Parcel & out) const20 bool AVHistoryDescriptor::Marshalling(Parcel& out) const
21 {
22     CHECK_AND_RETURN_RET_LOG(out.WriteString(sessionId_), false, "write sessionId failed");
23     CHECK_AND_RETURN_RET_LOG(out.WriteString(bundleName_), false, "write bundleName failed");
24     CHECK_AND_RETURN_RET_LOG(out.WriteString(abilityName_), false, "write abilityName failed");
25     return true;
26 }
27 
Unmarshalling(Parcel & in)28 AVHistoryDescriptor* AVHistoryDescriptor::Unmarshalling(Parcel& in)
29 {
30     auto info = std::make_unique<AVHistoryDescriptor>();
31     CHECK_AND_RETURN_RET_LOG(info != nullptr && info->ReadFromParcel(in), nullptr, "info is nullptr");
32     return info.release();
33 }
34 
ReadFromParcel(Parcel & in)35 bool AVHistoryDescriptor::ReadFromParcel(Parcel& in)
36 {
37     CHECK_AND_RETURN_RET_LOG(in.ReadString(sessionId_), false, "Read sessionId failed");
38     CHECK_AND_RETURN_RET_LOG(in.ReadString(bundleName_), false, "Read bundleName failed");
39     CHECK_AND_RETURN_RET_LOG(in.ReadString(abilityName_), false, "Read abilityName failed");
40     return true;
41 }
42 
Marshalling(Parcel & out) const43 bool AVSessionDescriptor::Marshalling(Parcel& out) const
44 {
45     CHECK_AND_RETURN_RET_LOG(out.WriteString(sessionId_), false, "write sessionId failed");
46     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(sessionType_), false, "write sessionType failed");
47     CHECK_AND_RETURN_RET_LOG(out.WriteString(sessionTag_), false, "write sessionTag failed");
48     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(pid_), false, "write pid failed");
49     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(uid_), false, "write uid failed");
50     CHECK_AND_RETURN_RET_LOG(out.WriteBool(isActive_), false, "write isActive failed");
51     CHECK_AND_RETURN_RET_LOG(out.WriteBool(isTopSession_), false, "write isTopSession failed");
52 
53     int32_t deviceInfoSize = static_cast<int32_t>(outputDeviceInfo_.deviceInfos_.size());
54     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(deviceInfoSize), false, "write deviceInfoSize failed");
55     for (DeviceInfo deviceInfo : outputDeviceInfo_.deviceInfos_) {
56         CHECK_AND_RETURN_RET_LOG(out.WriteInt32(deviceInfo.castCategory_), false, "write castCategory failed");
57         CHECK_AND_RETURN_RET_LOG(out.WriteString(deviceInfo.deviceId_), false, "write deviceId failed");
58         CHECK_AND_RETURN_RET_LOG(out.WriteString(deviceInfo.deviceName_), false, "write deviceName failed");
59         CHECK_AND_RETURN_RET_LOG(out.WriteInt32(deviceInfo.deviceType_), false, "write deviceType failed");
60         CHECK_AND_RETURN_RET_LOG(out.WriteString(deviceInfo.ipAddress_), false, "write ipAddress failed");
61         CHECK_AND_RETURN_RET_LOG(out.WriteString(deviceInfo.networkId_), false, "write networkId failed");
62         CHECK_AND_RETURN_RET_LOG(out.WriteString(deviceInfo.manufacturer_), false, "write manufacturer failed");
63         CHECK_AND_RETURN_RET_LOG(out.WriteString(deviceInfo.modelName_), false, "write modelName failed");
64         CHECK_AND_RETURN_RET_LOG(out.WriteInt32(deviceInfo.providerId_), false, "write providerId failed");
65         CHECK_AND_RETURN_RET_LOG(out.WriteInt32(deviceInfo.supportedProtocols_), false,
66             "write supportedProtocols failed");
67         CHECK_AND_RETURN_RET_LOG(out.WriteInt32(deviceInfo.authenticationStatus_), false,
68             "write authenticationStatus failed");
69         CHECK_AND_RETURN_RET_LOG(out.WriteInt32(deviceInfo.supportedDrmCapabilities_.size()), false,
70             "write supportedDrmCapabilities size failed");
71         for (auto supportedDrmCapability : deviceInfo.supportedDrmCapabilities_) {
72             CHECK_AND_RETURN_RET_LOG(out.WriteString(supportedDrmCapability), false,
73                 "write supportedDrmCapability failed");
74         }
75         CHECK_AND_RETURN_RET_LOG(out.WriteBool(deviceInfo.isLegacy_), false, "write isLegacy failed");
76         CHECK_AND_RETURN_RET_LOG(out.WriteInt32(deviceInfo.mediumTypes_), false, "write mediumTypes failed");
77         CHECK_AND_RETURN_RET_LOG(deviceInfo.audioCapabilities_.WriteToParcel(out), false,
78             "write audioCapability failed");
79         CHECK_AND_RETURN_RET_LOG(out.WriteInt32(deviceInfo.supportedPullClients_.size()), false,
80             "write supportedPullClients size failed");
81         for (auto supportedPullClient : deviceInfo.supportedPullClients_) {
82             CHECK_AND_RETURN_RET_LOG(out.WriteUint32(supportedPullClient), false,
83                 "write supportedPullClient failed");
84         }
85     }
86     CHECK_AND_RETURN_RET_LOG(out.WriteParcelable(&elementName_), false, "write elementName failed");
87     return true;
88 }
89 
Unmarshalling(Parcel & in)90 AVSessionDescriptor* AVSessionDescriptor::Unmarshalling(Parcel& in)
91 {
92     auto info = std::make_unique<AVSessionDescriptor>();
93     CHECK_AND_RETURN_RET_LOG(info != nullptr && info->ReadFromParcel(in), nullptr, "info is nullptr");
94     return info.release();
95 }
96 
CheckBeforReadFromParcel(Parcel & in)97 bool AVSessionDescriptor::CheckBeforReadFromParcel(Parcel& in)
98 {
99     CHECK_AND_RETURN_RET_LOG(in.ReadString(sessionId_), false, "Read sessionId failed");
100     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(sessionType_), false, "Read sessionType failed");
101     CHECK_AND_RETURN_RET_LOG(in.ReadString(sessionTag_), false, "Read sessionTag failed");
102     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(pid_), false, "Read pid failed");
103     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(uid_), false, "Read uid failed");
104     CHECK_AND_RETURN_RET_LOG(in.ReadBool(isActive_), false, "Read isActive failed");
105     CHECK_AND_RETURN_RET_LOG(in.ReadBool(isTopSession_), false, "Read isTopSession failed");
106     return true;
107 }
108 
CheckBeforReadFromParcel(Parcel & in,DeviceInfo & deviceInfo)109 bool AVSessionDescriptor::CheckBeforReadFromParcel(Parcel& in, DeviceInfo& deviceInfo)
110 {
111     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(deviceInfo.castCategory_), false, "Read castCategory failed");
112     CHECK_AND_RETURN_RET_LOG(in.ReadString(deviceInfo.deviceId_), false, "Read deviceId failed");
113     CHECK_AND_RETURN_RET_LOG(in.ReadString(deviceInfo.deviceName_), false, "Read deviceName failed");
114     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(deviceInfo.deviceType_), false, "Read deviceType failed");
115     CHECK_AND_RETURN_RET_LOG(in.ReadString(deviceInfo.ipAddress_), false, "Read ipAddress failed");
116     CHECK_AND_RETURN_RET_LOG(in.ReadString(deviceInfo.networkId_), false, "Read networkId failed");
117     CHECK_AND_RETURN_RET_LOG(in.ReadString(deviceInfo.manufacturer_), false, "Read manufacturer failed");
118     CHECK_AND_RETURN_RET_LOG(in.ReadString(deviceInfo.modelName_), false, "Read modelName failed");
119     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(deviceInfo.providerId_), false, "Read providerId failed");
120     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(deviceInfo.supportedProtocols_), false,
121         "Read supportedProtocols failed");
122     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(deviceInfo.authenticationStatus_), false,
123         "Read authenticationStatus failed");
124     int32_t supportedDrmCapabilityLen = 0;
125     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(supportedDrmCapabilityLen), false,
126         "read supportedDrmCapabilityLen failed");
127     int32_t maxSupportedDrmCapabilityLen = 10;
128     CHECK_AND_RETURN_RET_LOG((supportedDrmCapabilityLen >= 0) &&
129         (supportedDrmCapabilityLen <= maxSupportedDrmCapabilityLen), false, "supportedDrmCapabilityLen is illegal");
130     std::vector<std::string> supportedDrmCapabilities;
131     for (int i = 0; i < supportedDrmCapabilityLen; i++) {
132         std::string supportedDrmCapability;
133         CHECK_AND_RETURN_RET_LOG(in.ReadString(supportedDrmCapability), false,
134             "read supportedDrmCapability failed");
135         supportedDrmCapabilities.emplace_back(supportedDrmCapability);
136     }
137     deviceInfo.supportedDrmCapabilities_ = supportedDrmCapabilities;
138     CHECK_AND_RETURN_RET_LOG(in.ReadBool(deviceInfo.isLegacy_), false, "Read isLegacy failed");
139     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(deviceInfo.mediumTypes_), false, "Read mediumTypes failed");
140     CHECK_AND_RETURN_RET_LOG(deviceInfo.audioCapabilities_.ReadFromParcel(in), false, "Read audioCapability failed");
141 
142     int32_t supportedPullClientsLen = 0;
143     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(supportedPullClientsLen), false, "read supportedPullClientsLen failed");
144     // max length of the clients vector
145     int32_t maxSupportedPullClientsLen = 256;
146     CHECK_AND_RETURN_RET_LOG((supportedPullClientsLen >= 0) &&
147         (supportedPullClientsLen <= maxSupportedPullClientsLen), false, "supportedPullClientsLen is illegal");
148     std::vector<std::uint32_t> supportedPullClients;
149     for (int j = 0; j < supportedPullClientsLen; j++) {
150         uint32_t supportedPullClient = 0;
151         CHECK_AND_RETURN_RET_LOG(in.ReadUint32(supportedPullClient), false,
152             "read supportedPullClient failed");
153         supportedPullClients.emplace_back(supportedPullClient);
154     }
155     deviceInfo.supportedPullClients_ = supportedPullClients;
156     outputDeviceInfo_.deviceInfos_.emplace_back(deviceInfo);
157     return true;
158 }
159 
ReadFromParcel(Parcel & in)160 bool AVSessionDescriptor::ReadFromParcel(Parcel& in)
161 {
162     if (!CheckBeforReadFromParcel(in)) {
163         return false;
164     }
165     int32_t deviceInfoSize = 0;
166     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(deviceInfoSize), false, "read deviceInfoSize failed");
167     int32_t maxDeviceInfoSize = 1000;
168     CHECK_AND_RETURN_RET_LOG((deviceInfoSize >= 0) && (deviceInfoSize < maxDeviceInfoSize),
169         false, "deviceInfoSize is illegal");
170     for (int j = 0; j < deviceInfoSize; j++) {
171         DeviceInfo deviceInfo;
172         if (!CheckBeforReadFromParcel(in, deviceInfo)) {
173             return false;
174         }
175     }
176 
177     sptr elementName = in.ReadParcelable<AppExecFwk::ElementName>();
178     if (elementName == nullptr) {
179         SLOGE("read element name failed");
180         return false;
181     }
182     elementName_ = *elementName;
183     return true;
184 }
185 
Marshalling(Parcel & out) const186 bool DeviceInfo::Marshalling(Parcel& out) const
187 {
188     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(castCategory_), false, "write castCategory failed");
189     CHECK_AND_RETURN_RET_LOG(out.WriteString(deviceId_), false, "write deviceId failed");
190     CHECK_AND_RETURN_RET_LOG(out.WriteString(deviceName_), false, "write deviceName failed");
191     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(deviceType_), false, "write deviceType failed");
192     CHECK_AND_RETURN_RET_LOG(out.WriteString(ipAddress_), false, "write ipAddress failed");
193     CHECK_AND_RETURN_RET_LOG(out.WriteString(networkId_), false, "write networkId failed");
194     CHECK_AND_RETURN_RET_LOG(out.WriteString(manufacturer_), false, "write manufacturer failed");
195     CHECK_AND_RETURN_RET_LOG(out.WriteString(modelName_), false, "write modelName failed");
196     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(providerId_), false, "write providerId failed");
197     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(supportedProtocols_), false,
198         "write supportedProtocols failed");
199     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(authenticationStatus_), false,
200         "write authenticationStatus failed");
201     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(supportedDrmCapabilities_.size()), false,
202         "write supportedDrmCapabilities size failed");
203     for (auto supportedDrmCapability : supportedDrmCapabilities_) {
204         CHECK_AND_RETURN_RET_LOG(out.WriteString(supportedDrmCapability), false,
205             "write supportedDrmCapability failed");
206     }
207     CHECK_AND_RETURN_RET_LOG(out.WriteBool(isLegacy_), false, "write isLegacy failed");
208     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(mediumTypes_), false, "write mediumTypes failed");
209     CHECK_AND_RETURN_RET_LOG(audioCapabilities_.WriteToParcel(out), false, "write audioCapability failed");
210 
211     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(supportedPullClients_.size()), false,
212         "write supportedPullClients size failed");
213     for (auto supportedPullClient : supportedPullClients_) {
214         CHECK_AND_RETURN_RET_LOG(out.WriteUint32(supportedPullClient), false,
215             "write supportedPullClient failed");
216     }
217     return true;
218 }
219 
Unmarshalling(Parcel & in)220 DeviceInfo* DeviceInfo::Unmarshalling(Parcel& in)
221 {
222     auto info = std::make_unique<DeviceInfo>();
223     CHECK_AND_RETURN_RET_LOG(info != nullptr && info->ReadFromParcel(in), nullptr, "info is nullptr");
224     return info.release();
225 }
226 
ReadFromParcel(Parcel & in)227 bool DeviceInfo::ReadFromParcel(Parcel& in)
228 {
229     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(castCategory_), false, "Read castCategory failed");
230     CHECK_AND_RETURN_RET_LOG(in.ReadString(deviceId_), false, "Read deviceId failed");
231     CHECK_AND_RETURN_RET_LOG(in.ReadString(deviceName_), false, "Read deviceName failed");
232     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(deviceType_), false, "Read deviceType failed");
233     CHECK_AND_RETURN_RET_LOG(in.ReadString(ipAddress_), false, "Read ipAddress failed");
234     CHECK_AND_RETURN_RET_LOG(in.ReadString(networkId_), false, "Read networkId failed");
235     CHECK_AND_RETURN_RET_LOG(in.ReadString(manufacturer_), false, "Read manufacturer failed");
236     CHECK_AND_RETURN_RET_LOG(in.ReadString(modelName_), false, "Read modelName failed");
237     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(providerId_), false, "Read providerId failed");
238     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(supportedProtocols_), false,
239         "Read supportedProtocols failed");
240     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(authenticationStatus_), false,
241         "Read authenticationStatus failed");
242     int32_t supportedDrmCapabilityLen = 0;
243     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(supportedDrmCapabilityLen), false,
244         "read supportedDrmCapabilityLen failed");
245     int32_t maxSupportedDrmCapabilityLen = 10;
246     CHECK_AND_RETURN_RET_LOG((supportedDrmCapabilityLen >= 0) &&
247         (supportedDrmCapabilityLen <= maxSupportedDrmCapabilityLen), false, "supportedDrmCapabilityLen is illegal");
248     std::vector<std::string> supportedDrmCapabilities;
249     for (int i = 0; i < supportedDrmCapabilityLen; i++) {
250         std::string supportedDrmCapability;
251         CHECK_AND_RETURN_RET_LOG(in.ReadString(supportedDrmCapability), false,
252             "read supportedDrmCapability failed");
253         supportedDrmCapabilities.emplace_back(supportedDrmCapability);
254     }
255     supportedDrmCapabilities_ = supportedDrmCapabilities;
256     CHECK_AND_RETURN_RET_LOG(in.ReadBool(isLegacy_), false, "Read isLegacy failed");
257     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(mediumTypes_), false, "Read mediumTypes failed");
258     CHECK_AND_RETURN_RET_LOG(audioCapabilities_.ReadFromParcel(in), false, "Read audioCapability failed");
259 
260     int32_t supportedPullClientsLen = 0;
261     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(supportedPullClientsLen), false, "read supportedPullClientsLen failed");
262     // max length of the clients vector
263     int32_t maxSupportedPullClientsLen = 256;
264     CHECK_AND_RETURN_RET_LOG((supportedPullClientsLen >= 0) &&
265         (supportedPullClientsLen <= maxSupportedPullClientsLen), false, "supportedPullClientsLen is illegal");
266     std::vector<uint32_t> supportedPullClients;
267     for (int j = 0; j < supportedPullClientsLen; j++) {
268         uint32_t supportedPullClient;
269         CHECK_AND_RETURN_RET_LOG(in.ReadUint32(supportedPullClient), false,
270             "read supportedPullClients failed");
271         supportedPullClients.emplace_back(supportedPullClient);
272     }
273     supportedPullClients_ = supportedPullClients;
274     return true;
275 }
276 
Marshalling(Parcel & out) const277 bool OutputDeviceInfo::Marshalling(Parcel& out) const
278 {
279     int32_t deviceInfoSize = static_cast<int32_t>(deviceInfos_.size());
280     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(deviceInfoSize), false, "write deviceInfoSize failed");
281     for (DeviceInfo deviceInfo : deviceInfos_) {
282         CHECK_AND_RETURN_RET_LOG(deviceInfo.Marshalling(out), false, "write deviceInfo failed");
283     }
284     return true;
285 }
286 
Unmarshalling(Parcel & in)287 OutputDeviceInfo* OutputDeviceInfo::Unmarshalling(Parcel& in)
288 {
289     auto info = std::make_unique<OutputDeviceInfo>();
290     CHECK_AND_RETURN_RET_LOG(info != nullptr && info->ReadFromParcel(in), nullptr, "info is nullptr");
291     return info.release();
292 }
293 
ReadFromParcel(Parcel & in)294 bool OutputDeviceInfo::ReadFromParcel(Parcel& in)
295 {
296     int32_t deviceInfoSize = 0;
297     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(deviceInfoSize), false, "write deviceInfoSize failed");
298     int32_t maxDeviceInfoSize = 1000;
299     CHECK_AND_RETURN_RET_LOG((deviceInfoSize >= 0) && (deviceInfoSize < maxDeviceInfoSize),
300         false, "deviceInfoSize is illegal");
301     for (int i = 0; i < deviceInfoSize; i++) {
302         DeviceInfo deviceInfo;
303         CHECK_AND_RETURN_RET_LOG(deviceInfo.ReadFromParcel(in), false, "read deviceInfo failed");
304         deviceInfos_.emplace_back(deviceInfo);
305     }
306     return true;
307 }
308 
WriteToParcel(Parcel & out) const309 bool AudioCapabilities::WriteToParcel(Parcel& out) const
310 {
311     int32_t streamInfoSize = static_cast<int32_t>(streamInfos_.size());
312     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(streamInfoSize), false, "write streamInfoSize failed");
313     for (AudioStreamInfo streamInfo : streamInfos_) {
314         CHECK_AND_RETURN_RET_LOG(streamInfo.WriteToParcel(out), false, "write streamInfo failed");
315     }
316     return true;
317 }
318 
ReadFromParcel(Parcel & in)319 bool AudioCapabilities::ReadFromParcel(Parcel& in)
320 {
321     int32_t streamInfoSize = 0;
322     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(streamInfoSize), false, "read streamInfoSize failed");
323     int32_t maxStreamInfoSize = 1000;
324     CHECK_AND_RETURN_RET_LOG((streamInfoSize >= 0) && (streamInfoSize < maxStreamInfoSize),
325         false, "streamInfoSize is illegal");
326     for (int i = 0; i < streamInfoSize; i++) {
327         AudioStreamInfo streamInfo {};
328         CHECK_AND_RETURN_RET_LOG(streamInfo.ReadFromParcel(in), false, "read streamInfo failed");
329         streamInfos_.emplace_back(streamInfo);
330     }
331     return true;
332 }
333 
Marshalling(Parcel & out) const334 bool CastDisplayInfo::Marshalling(Parcel& out) const
335 {
336     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(static_cast<int32_t>(displayState)), false, "write displayState failed");
337     CHECK_AND_RETURN_RET_LOG(out.WriteUint64(displayId), false, "write displayId failed");
338     CHECK_AND_RETURN_RET_LOG(out.WriteString(name), false, "write name failed");
339     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(width), false, "write width failed");
340     CHECK_AND_RETURN_RET_LOG(out.WriteInt32(height), false, "write height failed");
341     return true;
342 }
343 
Unmarshalling(Parcel & in)344 CastDisplayInfo* CastDisplayInfo::Unmarshalling(Parcel& in)
345 {
346     auto info = std::make_unique<CastDisplayInfo>();
347     CHECK_AND_RETURN_RET_LOG(info != nullptr && info->ReadFromParcel(in), nullptr, "info is nullptr");
348     return info.release();
349 }
350 
ReadFromParcel(Parcel & in)351 bool CastDisplayInfo::ReadFromParcel(Parcel& in)
352 {
353     int32_t displayStateTemp = -1;
354     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(displayStateTemp), false, "read displayState failed");
355     if (displayStateTemp < static_cast<int32_t>(CastDisplayState::STATE_OFF) ||
356         displayStateTemp > static_cast<int32_t>(CastDisplayState::STATE_ON)) {
357         return false;
358     }
359     displayState = static_cast<CastDisplayState>(displayStateTemp);
360     CHECK_AND_RETURN_RET_LOG(in.ReadUint64(displayId), false, "read displayId failed");
361     CHECK_AND_RETURN_RET_LOG(in.ReadString(name), false, "read name failed");
362     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(width), false, "read width failed");
363     CHECK_AND_RETURN_RET_LOG(in.ReadInt32(height), false, "read height failed");
364     return true;
365 }
366 } // namespace OHOS::AVSession
367