• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 "bluetooth_a2dp_a2dpCodecInfo.h"
17 
18 namespace OHOS {
19 namespace Bluetooth {
Marshalling(Parcel & parcel) const20 bool BluetoothA2dpCodecInfo::Marshalling(Parcel &parcel) const
21 {
22     if (!parcel.WriteUint8(codecPriority)) {
23         return false;
24     }
25     if (!parcel.WriteUint8(codecType)) {
26         return false;
27     }
28     if (!parcel.WriteUint32(sampleRate)) {
29         return false;
30     }
31     if (!parcel.WriteUint8(bitsPerSample)) {
32         return false;
33     }
34     if (!parcel.WriteUint8(channelMode)) {
35         return false;
36     }
37     if (!parcel.WriteUint64(codecSpecific1)) {
38         return false;
39     }
40     if (!parcel.WriteUint64(codecSpecific2)) {
41         return false;
42     }
43     if (!parcel.WriteUint64(codecSpecific3)) {
44         return false;
45     }
46     if (!parcel.WriteUint64(codecSpecific4)) {
47         return false;
48     }
49     return true;
50 }
51 
WriteToParcel(Parcel & parcel)52 bool BluetoothA2dpCodecInfo::WriteToParcel(Parcel &parcel)
53 {
54     return Marshalling(parcel);
55 }
56 
Unmarshalling(Parcel & parcel)57 BluetoothA2dpCodecInfo *BluetoothA2dpCodecInfo::Unmarshalling(Parcel &parcel)
58 {
59     BluetoothA2dpCodecInfo *codecData = new BluetoothA2dpCodecInfo();
60     if (codecData != nullptr && !codecData->ReadFromParcel(parcel)) {
61         delete codecData;
62         codecData = nullptr;
63     }
64     return codecData;
65 }
66 
ReadFromParcel(Parcel & parcel)67 bool BluetoothA2dpCodecInfo::ReadFromParcel(Parcel &parcel)
68 {
69     if (!parcel.ReadUint8(codecPriority)) {
70         return false;
71     }
72     if (!parcel.ReadUint8(codecType)) {
73         return false;
74     }
75     if (!parcel.ReadUint32(sampleRate)) {
76         return false;
77     }
78     if (!parcel.ReadUint8(bitsPerSample)) {
79         return false;
80     }
81     if (!parcel.ReadUint8(channelMode)) {
82         return false;
83     }
84     if (!parcel.ReadUint64(codecSpecific1)) {
85         return false;
86     }
87     if (!parcel.ReadUint64(codecSpecific2)) {
88         return false;
89     }
90     if (!parcel.ReadUint64(codecSpecific3)) {
91         return false;
92     }
93     if (!parcel.ReadUint64(codecSpecific4)) {
94         return false;
95     }
96     return true;
97 }
98 
99 }  // namespace Bluetooth
100 }  // namespace OHOS
101