1 // Copyright (c) 2004-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 // |
|
15 |
|
16 #ifndef CONTROLCOMMAND_H |
|
17 #define CONTROLCOMMAND_H |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 @released |
|
23 */ |
|
24 |
|
25 #include <avctpservices.h> |
|
26 #include <e32base.h> |
|
27 #include <remconcoreapi.h> |
|
28 #include <remcon/remconbearerplugin.h> |
|
29 #include <remcon/clientid.h> |
|
30 |
|
31 #include <avcframe.h> |
|
32 |
|
33 #include "avrcpcommand.h" |
|
34 #include "avrcptimer.h" |
|
35 #include "avrcpfragmenter.h" |
|
36 |
|
37 const TInt KRcpResponseTimeOut = 30000000; // Allow remote 300ms to respond |
|
38 const TInt KRcpHoldThreshold = 300000; // After 300ms we may assume an unreleased button |
|
39 // action is a press and hold |
|
40 const TInt KRcpIncomingButtonReleaseTimeout = 1700000; // 1.7s (ie 2s - 300ms), if a button press |
|
41 // has not been released after 2s we assume the release |
|
42 // has been lost (and generate one internally) |
|
43 const TInt KRcpOutgoingButtonReleaseTimeout = 1000000; // The remote expects a press refresh within |
|
44 // 2s, it's fine to send one before that. |
|
45 |
|
46 const TUint KRemConStatusApiDefaultPageDataLength = 4; |
|
47 const TUint KRemConMetadataHeaderLength = 4; |
|
48 |
|
49 // Absolute lengths of Vendor Dependent PDU requests |
|
50 const TUint8 KLengthGetCapabilitiesPdu = 1; // PDU 0x10 |
|
51 const TUint8 KLengthListPASAttributesPdu = 0; // PDU 0x11 |
|
52 const TUint8 KLengthListPASValuesPdu = 1; // PDU 0x12 |
|
53 const TUint8 KLengthInformBatteryStatusOfCTPdu = 1; // PDU 0x18 |
|
54 const TUint8 KLengthGetPlayStatusPdu = 0; // PDU 0x30 |
|
55 const TUint8 KLengthRegisterNotification = 5; // PDU 0x31 |
|
56 const TUint8 KLengthSetAddressedPlayerPdu = 2; // PDU 0x60 |
|
57 |
|
58 // Minimum lengths of Vendor Dependent PDU requests |
|
59 const TUint8 KMinLengthGetCurrentPASValuePdu = 2; // PDU 0x13 |
|
60 const TUint8 KMinLengthSetPASValuePdu = 1; // PDU 0x14 |
|
61 const TUint8 KMinLengthGetPASAttributeTextPdu = 2; // PDU 0x15 |
|
62 const TUint8 KMinLengthGetPASValueTextPdu = 3; // PDU 0x16 |
|
63 const TUint8 KMinLengthGetElementAttributesPdu = 9; // PDU 0x20 |
|
64 const TUint8 KMinLengthAddToNowPlayingPdu = 11; // PDU 0x90 |
|
65 |
|
66 // Other lengths |
|
67 const TUint8 KLengthPlaybackPosChangedParam = 4; // Parameter length for this event (section 5.4.2) |
|
68 const TUint8 KVendorDependentNumberAttributes = 0; // Index to Number of attributes (the first byte) |
|
69 const TUint8 KVendorDependentNumberAttribsPdu16 = 1; // Index to Number of attributes for PDU 0x16 (the second byte) |
|
70 const TUint8 KVendorDependentEventId = 0; // Index to Event Id (the first byte) |
|
71 |
|
72 enum TMetadataTransferErrorCodes |
|
73 { |
|
74 EInvalidCommand = 0x0, |
|
75 EInvalidParameter = 0x1, |
|
76 EParameterNotFound = 0x2, |
|
77 EInternalError = 0x3, |
|
78 }; |
|
79 |
|
80 enum TMetaDataTransferPacketType |
|
81 { |
|
82 EUnfragmented = 0x0, |
|
83 EFragmentStart = 0x1, |
|
84 EFragmentContinue = 0x2, |
|
85 EFragmentEnd = 0x3, |
|
86 }; |
|
87 |
|
88 // Format of the first 3 bytes of a Vendor Dependent Request |
|
89 // See example packets in AVRCP Specification Appendix I (page 84) |
|
90 const TUint8 KVendorDependentRequestPDUId = 0; |
|
91 const TUint8 KVendorDependentRequestReservedByte = 1; |
|
92 const TUint8 KVendorDependentRequestParamLenMSB = 2; |
|
93 const TUint8 KVendorDependentRequestParamLenLSB = 3; |
|
94 |
|
95 //See example packets in AVRCP Specification Appendix D (Volume Change Notification) |
|
96 const TUint8 KVendorDependentNotifyEventIdOffset = 4; |
|
97 |
|
98 // Format of the first 2 bytes of a Pass Through Request |
|
99 // See example packets in AVRCP Specification Appendix I (page 89) |
|
100 const TUint8 KPassThroughRequestOperationIdMSB = 0; |
|
101 const TUint8 KPassThroughRequestOperationIdLSB = 1; |
|
102 |
|
103 const TInt KSetAddressedPlayerPlayerIdOffset = 0; |
|
104 |
|
105 const TInt KCapabilityIdOffset = 0; |
|
106 |
|
107 const TInt KNumberEventsNotInPlayerInfoApi = 5; |
|
108 |
|
109 typedef TUint8 TMetadataTransferPDUID; |
|
110 typedef TUint8 TMetadataTransferNotifyEventID; |
|
111 |
|
112 class CRcpRemoteDevice; |
|
113 class CAVRCPFragmenter; |
|
114 class CRcpIncomingCommandHandler; |
|
115 class MRemConBearerObserver; |
|
116 class CAvrcpPlayerInfoManager; |
|
117 class CAvrcpPlayerInfoManager; |
|
118 NONSHARABLE_CLASS(CControlCommand) : public CAvrcpCommand |
|
119 { |
|
120 public: |
|
121 static CControlCommand* NewL(TUid aInterfaceUid, |
|
122 TUint aCommand, |
|
123 TUint aRemConId, |
|
124 SymbianAvctp::TTransactionLabel aTransactionLabel, |
|
125 RBuf8& aCommandData, |
|
126 TBool aIsClick, |
|
127 const TBTDevAddr& aAddr, |
|
128 TBool aKnownToBearer); |
|
129 |
|
130 static CControlCommand* NewL(CAVCFrame* aFrame, |
|
131 TUint aRemConId, |
|
132 SymbianAvctp::TTransactionLabel aTransLabel, |
|
133 const TBTDevAddr& aAddr, |
|
134 const TRemConClientId& aClientId, |
|
135 CAvrcpPlayerInfoManager* aPlayerInfoManager); |
|
136 |
|
137 SymbianAvctp::TMessageType MessageType() const; |
|
138 const TDesC8& Data() const; |
|
139 |
|
140 // Called from bearer |
|
141 const TRemConClientId& ClientId() const; |
|
142 |
|
143 // Called from handlers |
|
144 TInt ParseIncomingCommandL(MRemConBearerObserver& aObserver, CAVRCPFragmenter& aFragmenter); |
|
145 void ProcessOutgoingCommandL(MRemConBearerObserver& aObserver); |
|
146 TInt ParseIncomingResponse(MRemConBearerObserver& aObserver, const CAVCFrame& aFrame); |
|
147 TInt ProcessOutgoingResponse(MRemConBearerObserver& aObserver, RBuf8& aCommandData, CAVRCPFragmenter& aFragmenter); |
|
148 void SetResponseType(TInt aErr); |
|
149 |
|
150 TDeltaTimerEntry* TimerEntry(); |
|
151 TAvrcpTimerExpiryInfo* TimerExpiryInfo(); |
|
152 void CancelTimer(CDeltaTimer& aTimer); |
|
153 |
|
154 const CAVCFrame& Frame() const; |
|
155 AVCPanel::TButtonAction ButtonAct() const; |
|
156 TBool Click() const; |
|
157 void SetClick(TBool aIsClick); |
|
158 void ReSetCoreButtonActionL(TRemConCoreApiButtonAction aButtonAct, TBool aCommand); |
|
159 |
|
160 void SetCoreButtonAction(TRemConCoreApiButtonAction aButtonAct, TBool aCommand); |
|
161 TInt InsertCoreResult(TInt aResult); |
|
162 TBool IsAvrcpPassthrough() const; |
|
163 TBool IsPassthrough() const; |
|
164 TInt SetSetAbsoluteVolumeResult(const CAVCFrame& aFrame); |
|
165 TInt SetNotifyVolumeChangeResult(const CAVCFrame& aFrame); |
|
166 TBool PlayerSpecificNotify() const; |
|
167 TBool NormalCommand(); |
|
168 |
|
169 CControlCommand* InterimResponseL(); |
|
170 |
|
171 private: |
|
172 CControlCommand(TUid aInterfaceUid, |
|
173 TUint aCommand, |
|
174 TUint aRemConId, |
|
175 SymbianAvctp::TTransactionLabel aTransactionLabel, |
|
176 RBuf8& aCommandData, |
|
177 TBool aIsClick, |
|
178 const TBTDevAddr& aAddr, |
|
179 TBool aKnownToBearer); |
|
180 |
|
181 CControlCommand(CAVCFrame* aFrame, |
|
182 TUint aRemConId, |
|
183 SymbianAvctp::TTransactionLabel aTransLabel, |
|
184 const TBTDevAddr& aAddr, |
|
185 const TRemConClientId& aClientId, |
|
186 CAvrcpPlayerInfoManager* aPlayerInfoManager); |
|
187 |
|
188 void ConstructL(); |
|
189 ~CControlCommand(); |
|
190 |
|
191 TInt ParseIncomingKnownOpcodeL(MRemConBearerObserver& aObserver); |
|
192 TInt ParseIncomingVendorCommandL(MRemConBearerObserver& aObserver, CAVRCPFragmenter& aFragmenter); |
|
193 |
|
194 void ParseIncomingUnknownResponse(MRemConBearerObserver& aObserver, const CAVCFrame& aFrame); |
|
195 |
|
196 TInt ParseInformBatteryStatusOfCT( TPtrC8& mtPayload); |
|
197 |
|
198 TInt ParseContinuingResponse(TPtrC8& mtPayload, |
|
199 CAVRCPFragmenter& aFragmenter); |
|
200 |
|
201 TInt ParseAbortContinuingResponse(TPtrC8& mtPayload, |
|
202 CAVRCPFragmenter& aFragmenter); |
|
203 |
|
204 TInt ParseSetPlayerApplicationSettingValue(TPtrC8& mtPayload); |
|
205 TInt ParseGetCapabilities(TPtrC8& aMtPayload); |
|
206 TInt ParseGetPlayStatus(TPtrC8& aMtPayload); |
|
207 TInt ParseListPlayerApplicationSettingAttributes(TPtrC8& aMtPayload); |
|
208 TInt ParseListPlayerApplicationSettingValues(TPtrC8& aMtPayload); |
|
209 TInt ParseGetCurrentPlayerApplicationSettingValue(TPtrC8& aMtPayload); |
|
210 TInt ParseGetPlayerApplicationSettingAttributeText(TPtrC8& aMtPayload); |
|
211 TInt ParseGetPlayerApplicationSettingValueText(TPtrC8& aMtPayload); |
|
212 TInt ParseGetElementAttributes(TPtrC8& aMtPayload); |
|
213 TInt ParseSetAddressedPlayer(TPtrC8& aMtPayload); |
|
214 TInt ParsePlayItem(TPtrC8& aMtPayload); |
|
215 TInt ParseAddToNowPlaying(TPtrC8& aMtPayload); |
|
216 TInt ParseUidsChangedNotification(TPtrC8& aMtPayload); |
|
217 TInt ParseInternalUidsChangedNotification(TPtrC8& aMtPayload); |
|
218 TInt ParseVolumeChangedNotification(TPtrC8& aMtPayload); |
|
219 TInt ParseSetAbsoluteVolume(TPtrC8& aMtPayload); |
|
220 void DoParseSetAbsoluteVolumeL(const TPtrC8& aMtPayload, TDes8& aPayload); |
|
221 |
|
222 TInt ParseMetadataTransferVendorCommand(CAVRCPFragmenter& aFragmenter); |
|
223 TInt ParseVendorUniquePassthroughCommand(MRemConBearerObserver& aObserver); |
|
224 TInt ParseMetadataTransferPassthroughCommand(); |
|
225 TInt GenerateMetadataResponsePayload(MRemConBearerObserver& aObserver, RBuf8& aFramePayload, const RBuf8& aResponseData); |
|
226 TInt GenerateMetadataGetCapabilitiesResponsePayloadL(MRemConBearerObserver& aObserver, RBuf8& aFramePayload, const RBuf8& aResponseData); |
|
227 void GenerateSetAbsoluteVolumeResponsePayloadL(RBuf8& aFramePayload, const TDesC8& responseData); |
|
228 void DoGenerateNotifyVolumeChangeResponsePayloadL(RBuf8& aFramePayload, const TDesC8& responseData); |
|
229 TInt GenerateNotificationResponsePayload(RBuf8& aFramePayload, const TDesC8& aResponseData); |
|
230 void GenerateMetadataRejectPayloadL(TInt aError); |
|
231 void SetVendorInfoL(TBool aIsPassthrough); |
|
232 |
|
233 void DoProcessOutgoingResponseL(MRemConBearerObserver& aObserver, RBuf8& aCommandData, |
|
234 CAVRCPFragmenter& aFragmenter); |
|
235 |
|
236 TUint8 GetPDUIdFromIPCOperationId(TInt aOperationId); |
|
237 TUint8 GetEventIdFromIPCOperationId(TInt aOperationId); |
|
238 |
|
239 TInt RespondToInforms(TMetadataTransferPDUID aMetadataPDUID); |
|
240 TInt AppendIncomingPayload(const TPtrC8& aPayload); |
|
241 |
|
242 static TInt AvrcpToRemConOperation(TUint aAvrcpOp, TUint& aRemConOp, TUid& aRemConIf); |
|
243 static TInt RemConToAvrcpOperation(TUint aRemConOp, AVCPanel::TOperationId& aAvrcpOp); |
|
244 |
|
245 TUint16 Get16(const TPtrC8& aPtr); |
|
246 |
|
247 static TInt DummyCallback(TAny*); |
|
248 |
|
249 void DoSetAbsoluteVolumeResultL(const CAVCFrame& aFrame); |
|
250 void DoSetNotifyVolumeChangeResultL(const CAVCFrame& aFrame); |
|
251 |
|
252 private: |
|
253 TBool iIsClick; |
|
254 |
|
255 TDeltaTimerEntry* iTimerEntry; |
|
256 TAvrcpTimerExpiryInfo* iTimerExpiryInfo; |
|
257 |
|
258 CAVCFrame* iFrame; |
|
259 AVC::TAVCVendorId iVendorId; |
|
260 TPtrC8 iVendorPayloadData; // ptr to the vendor data in iFrame; |
|
261 |
|
262 TRemConClientId iClientId; |
|
263 }; |
|
264 |
|
265 class MetadataTransferParser |
|
266 { |
|
267 public: |
|
268 static AVC::TAVCVendorId GetVID(const CAVCFrame& aFrame); // could be elsewhere really! |
|
269 static TMetadataTransferPDUID GetPDUID(const TPtrC8& aData); |
|
270 static TUint16 GetParamLength(const TPtrC8& aData); |
|
271 static TUint16 GetPassThroughOperationId(const TPtrC8& aData); |
|
272 static TMetadataTransferPDUID GetNotifyEventID(const TPtrC8& aData); |
|
273 }; |
|
274 |
|
275 |
|
276 #endif // CONTROLCOMMAND_H |
|