51
|
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 |
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@internalComponent
|
|
21 |
@released
|
|
22 |
*/
|
|
23 |
|
|
24 |
#include <bluetoothav.h>
|
|
25 |
#include "avrcpcommandframer.h"
|
|
26 |
#include "avcframe.h"
|
|
27 |
#include "avrcplog.h"
|
|
28 |
#include <remcon/avrcpspec.h>
|
|
29 |
#include <absolutevolumeapi.h>
|
|
30 |
|
|
31 |
// The Bluetooth SIG registered VendorId, see table 4.7
|
|
32 |
const AVC::TAVCVendorId KBluetoothSIGVendorId = 0x001958;
|
|
33 |
|
|
34 |
/** Returns a new CAVCFrame representing an AV/C passthrough command.
|
|
35 |
@param aOperationId The AV/C operation id of this command.
|
|
36 |
@param aButtonAction The AV/C button action.
|
|
37 |
@return An AV/C frame representing a passthrough command.
|
|
38 |
@leave error
|
|
39 |
*/
|
|
40 |
CAVCFrame* AvrcpCommandFramer::PassthroughL(AVCPanel::TOperationId aOperationId, AVCPanel::TButtonAction aButtonAction)
|
|
41 |
{
|
|
42 |
LOG_STATIC_FUNC
|
|
43 |
CAVCFrame* frame = CAVCFrame::NewL(AVC::ECommand, AVC::EControl, AVC::EPanel, AVC::EID0);
|
|
44 |
frame->Append(TChar(AVC::EPassThrough));
|
|
45 |
frame->Append(TChar(aOperationId | aButtonAction));
|
|
46 |
frame->Append(TChar(0));
|
|
47 |
return frame;
|
|
48 |
}
|
|
49 |
|
|
50 |
/** Returns a new CAVCFrame representing an AV/C Unit Info response.
|
|
51 |
@return An AV/C frame representing a Unit Info response.
|
|
52 |
@leave error
|
|
53 |
*/
|
|
54 |
CAVCFrame* AvrcpCommandFramer::UnitInfoResponseL()
|
|
55 |
{
|
|
56 |
LOG_STATIC_FUNC
|
|
57 |
CAVCFrame* frame = CAVCFrame::NewL(AVC::EResponse, AVC::EStable, AVC::EUnit, AVC::EIgnore);
|
|
58 |
frame->Append(TChar(AVC::EUnitInfo));
|
|
59 |
frame->Append(TChar(0x7));
|
|
60 |
frame->Append(TChar(0x48));
|
|
61 |
frame->Append(TChar(0xff));
|
|
62 |
frame->Append(TChar(0xff));
|
|
63 |
frame->Append(TChar(0xff));
|
|
64 |
return frame;
|
|
65 |
}
|
|
66 |
|
|
67 |
/** Returns a new CAVCFrame representing an AV/C Subunit Info response.
|
|
68 |
@return An AV/C frame representing a Subunit Info response.
|
|
69 |
@leave error
|
|
70 |
*/
|
|
71 |
CAVCFrame* AvrcpCommandFramer::SubunitInfoResponseL()
|
|
72 |
{
|
|
73 |
LOG_STATIC_FUNC
|
|
74 |
CAVCFrame* frame = CAVCFrame::NewL(AVC::EResponse, AVC::EStable, AVC::EUnit, AVC::EIgnore);
|
|
75 |
frame->Append(TChar(AVC::ESubunitInfo));
|
|
76 |
frame->Append(TChar(0x7));
|
|
77 |
frame->Append(TChar(0x48));
|
|
78 |
frame->Append(TChar(0xff));
|
|
79 |
frame->Append(TChar(0xff));
|
|
80 |
frame->Append(TChar(0xff));
|
|
81 |
return frame;
|
|
82 |
}
|
|
83 |
|
|
84 |
/** Returns a new CAVCFrame representing an AV/C 'set absolute volume' command
|
|
85 |
@return An AV/C frame representing a 'set absolute volume' command.
|
|
86 |
@leave error
|
|
87 |
*/
|
|
88 |
CAVCFrame* AvrcpCommandFramer::SetAbsoluteVolumeCommandL(TUint8 aAbsVol)
|
|
89 |
{
|
|
90 |
LOG_STATIC_FUNC
|
|
91 |
CAVCFrame* frame = CAVCFrame::NewL(AVC::ECommand, AVC::EControl, AVC::EPanel, AVC::EID0);
|
|
92 |
frame->Append(TChar(AVC::EVendorDependent));
|
|
93 |
frame->Append(KBluetoothSIGVendorId>>16 & 0xff);
|
|
94 |
frame->Append(KBluetoothSIGVendorId>>8 & 0xff);
|
|
95 |
frame->Append(KBluetoothSIGVendorId & 0xff);
|
|
96 |
|
|
97 |
frame->Append(ESetAbsoluteVolume);
|
|
98 |
frame->Append(TChar(AVC::EASingle));
|
|
99 |
|
|
100 |
TUint16 len = KLengthSetAbsoluteVolumeRequestParameter<<8 & 0xffff;
|
|
101 |
TPckgBuf<TUint16> parameterLength(len);
|
|
102 |
frame->Append(parameterLength);
|
|
103 |
frame->Append(aAbsVol);
|
|
104 |
return frame;
|
|
105 |
}
|
|
106 |
|
|
107 |
/** Returns a new CAVCFrame representing an AV/C 'Register notification absolute volume changed' command.
|
|
108 |
@return An AV/C frame representing a 'Register notification absolute volume changed' command.
|
|
109 |
@leave error
|
|
110 |
*/
|
|
111 |
CAVCFrame* AvrcpCommandFramer::NotifyVolumeChangeCommandL()
|
|
112 |
{
|
|
113 |
LOG_STATIC_FUNC
|
|
114 |
CAVCFrame* frame = CAVCFrame::NewL(AVC::ECommand, AVC::ENotify, AVC::EPanel, AVC::EID0);
|
|
115 |
frame->Append(TChar(AVC::EVendorDependent));
|
|
116 |
frame->Append(KBluetoothSIGVendorId>>16 & 0xff);
|
|
117 |
frame->Append(KBluetoothSIGVendorId>>8 & 0xff);
|
|
118 |
frame->Append(KBluetoothSIGVendorId & 0xff);
|
|
119 |
|
|
120 |
frame->Append(ERegisterNotification);
|
|
121 |
frame->Append(TChar(AVC::EASingle));
|
|
122 |
|
|
123 |
TUint16 len = KLengthNotifyVolumeChangeRequestParameter<<8 & 0xffff;
|
|
124 |
TPckgBuf<TUint16> parameterLength(len);
|
|
125 |
frame->Append(parameterLength);
|
|
126 |
frame->Append(ERegisterNotificationVolumeChanged);
|
|
127 |
|
|
128 |
TBuf8<4> reservedBuffer(KLengthNotifyVolumeChangeRequestParameter - 1);
|
|
129 |
reservedBuffer.FillZ();
|
|
130 |
frame->Append(reservedBuffer);
|
|
131 |
return frame;
|
|
132 |
}
|