|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This file contains structures shared by the AVRCP API with the AVRCP bearer. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 @released |
|
22 */ |
|
23 |
|
24 #include <e32std.h> |
|
25 #include <remcon/avrcpspec.h> |
|
26 #include "avrcpipc.h" |
|
27 |
|
28 |
|
29 EXPORT_C TMetadataTransferPDU RAvrcpIPC::GetPDUIdFromIPCOperationId(TInt aOperationId) |
|
30 { |
|
31 // We send the PDU id through IPC to the playerinformationapi, mediainformationapi |
|
32 // groupnavigationapi or batterystatusapi. However, PDU 0x31 (Register Notification |
|
33 // also requires sending an event id. We encode this as the top byte, and the PDU |
|
34 // id as the lower byte, so mask off the top-byte and return just the PDU id. |
|
35 return static_cast<TMetadataTransferPDU>(aOperationId & 0x00FF); |
|
36 } |
|
37 |
|
38 EXPORT_C TRegisterNotificationEvent RAvrcpIPC::GetEventIdFromIPCOperationId(TInt aOperationId) |
|
39 { |
|
40 // See the above comment in GetPDUIdFromIPCOperationId. This performs the opposite operation |
|
41 return static_cast<TRegisterNotificationEvent>((aOperationId & 0xFF00) >> 8); |
|
42 } |
|
43 |
|
44 EXPORT_C TInt RAvrcpIPC::SetIPCOperationIdFromEventId(TRegisterNotificationEvent aEventId) |
|
45 { |
|
46 // See the comment in GetPDUIdFromIPCOperationId. This sets the PDU id |
|
47 // as the lower byte to RegisterNotification (0x31) and the eventId as |
|
48 // the top byte. |
|
49 return (ERegisterNotification + (aEventId << 8)); |
|
50 } |
|
51 |
|
52 // Big-endian methods; Symbian native methods are little-endian |
|
53 // This means that we can directly send these packets into the |
|
54 // wire in the bearer, since they're big-endian. We could have |
|
55 // used the BigEndian class, but that requires a dependency on |
|
56 // the esock.lib library, so do it ourselves. |
|
57 |
|
58 TUint8 RAvrcpIPC::Read8L() |
|
59 { |
|
60 return iReadStream.ReadUint8L(); |
|
61 } |
|
62 |
|
63 TUint16 RAvrcpIPC::Read16L() |
|
64 { |
|
65 TUint16 val = 0; |
|
66 val = (static_cast<TUint16>(iReadStream.ReadUint8L()) << 8); |
|
67 val += iReadStream.ReadUint8L(); |
|
68 return val; |
|
69 } |
|
70 |
|
71 TUint32 RAvrcpIPC::Read24L() |
|
72 { |
|
73 TUint32 val = 0; |
|
74 val += (static_cast<TUint32>(iReadStream.ReadUint8L()) << 16); |
|
75 val += (static_cast<TUint32>(iReadStream.ReadUint8L()) << 8); |
|
76 val += iReadStream.ReadUint8L(); |
|
77 return val; |
|
78 } |
|
79 |
|
80 TUint32 RAvrcpIPC::Read32L() |
|
81 { |
|
82 TUint32 val = 0; |
|
83 val = (static_cast<TUint32>(iReadStream.ReadUint8L()) << 24); |
|
84 val += (static_cast<TUint32>(iReadStream.ReadUint8L()) << 16); |
|
85 val += (static_cast<TUint32>(iReadStream.ReadUint8L()) << 8); |
|
86 val += iReadStream.ReadUint8L(); |
|
87 return val; |
|
88 } |
|
89 |
|
90 TUint64 RAvrcpIPC::Read64L() |
|
91 { |
|
92 TUint64 val; |
|
93 val = (static_cast<TUint64>(iReadStream.ReadUint8L()) << 56); |
|
94 val += (static_cast<TUint64>(iReadStream.ReadUint8L()) << 48); |
|
95 val += (static_cast<TUint64>(iReadStream.ReadUint8L()) << 40); |
|
96 val += (static_cast<TUint64>(iReadStream.ReadUint8L()) << 32); |
|
97 val += (static_cast<TUint64>(iReadStream.ReadUint8L()) << 24); |
|
98 val += (static_cast<TUint64>(iReadStream.ReadUint8L()) << 16); |
|
99 val += (static_cast<TUint64>(iReadStream.ReadUint8L()) << 8); |
|
100 val += iReadStream.ReadUint8L(); |
|
101 return val; |
|
102 } |
|
103 |
|
104 void RAvrcpIPC::Write8L(TUint8 aVal) |
|
105 { |
|
106 iStream.WriteUint8L(aVal); |
|
107 } |
|
108 |
|
109 void RAvrcpIPC::Write16L(TUint16 aVal) |
|
110 { |
|
111 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 8)); |
|
112 iStream.WriteUint8L(static_cast<TUint8>(aVal)); |
|
113 } |
|
114 |
|
115 void RAvrcpIPC::Write24L(TUint32 aVal) |
|
116 { |
|
117 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 16)); |
|
118 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 8)); |
|
119 iStream.WriteUint8L(static_cast<TUint8>(aVal)); |
|
120 } |
|
121 |
|
122 void RAvrcpIPC::Write32L(TUint32 aVal) |
|
123 { |
|
124 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 24)); |
|
125 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 16)); |
|
126 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 8)); |
|
127 iStream.WriteUint8L(static_cast<TUint8>(aVal)); |
|
128 } |
|
129 |
|
130 void RAvrcpIPC::Write64L(TUint64 aVal) |
|
131 { |
|
132 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 56)); |
|
133 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 48)); |
|
134 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 40)); |
|
135 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 32)); |
|
136 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 24)); |
|
137 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 16)); |
|
138 iStream.WriteUint8L(static_cast<TUint8>(aVal >> 8)); |
|
139 iStream.WriteUint8L(static_cast<TUint8>(aVal)); |
|
140 } |
|
141 void RAvrcpIPC::Close() |
|
142 { |
|
143 iReadStream.Close(); |
|
144 iStream.Close(); |
|
145 } |
|
146 |
|
147 EXPORT_C void RAvrcpIPCError::ReadL(const TDesC8& aData) |
|
148 { |
|
149 iReadStream.Open(aData); |
|
150 iError = Read32L(); // Read Big-Endian error code |
|
151 iReadStream.Close(); |
|
152 } |
|
153 |
|
154 EXPORT_C void RAvrcpIPCError::WriteL(TDes8& aOutData) |
|
155 { |
|
156 aOutData.Zero(); // Error code is always before any other data |
|
157 iStream.Open(aOutData); |
|
158 Write32L(iError); |
|
159 iStream.CommitL(); |
|
160 } |
|
161 |