|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include <StereoWideningBase.h> |
|
18 #include "irqmediaplayer.h" |
|
19 #if defined(MMFADAPTER) |
|
20 #include "irqmmfadapter.h" |
|
21 #elif defined(PHONONAdapter) |
|
22 #include "irqphononadapter.h" |
|
23 #endif |
|
24 |
|
25 //Constants |
|
26 const int KDefaultStereoLevel = 100; // Default stereo level |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // IRQMediaPlayer::IRQMediaPlayer |
|
30 // Constructor |
|
31 // Creates player adpater and connect the signals |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C IRQMediaPlayer::IRQMediaPlayer() : |
|
35 iStereoEffect(NULL) |
|
36 { |
|
37 #if defined(MMFADAPTER) |
|
38 iPlayer = new IRQMMFAdapter(); |
|
39 #elif defined(PHONONAdapter) |
|
40 iPlayer = new IRQPHONONAdapter(); |
|
41 #endif |
|
42 |
|
43 connect(iPlayer, SIGNAL(connectionEstablished(int)), |
|
44 this, SIGNAL(connectionEstablished(int))); |
|
45 connect(iPlayer, SIGNAL(errorOccured(IRQError)), |
|
46 this, SIGNAL(errorOccured(IRQError))); |
|
47 connect(iPlayer, SIGNAL(percentageBuffered(int)), |
|
48 this, SIGNAL(percentageBuffered(int))); |
|
49 connect(iPlayer, SIGNAL(metaDataReceived(IRQMetaData&)), |
|
50 this, SIGNAL(metaDataReceived(IRQMetaData&))); |
|
51 connect(iPlayer, SIGNAL(volumeExpected(int&)), |
|
52 this, SIGNAL(volumeExpected(int&))); |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // IRQMediaPlayer::~IRQMediaPlayer |
|
57 // Destructor |
|
58 // Delete player adapter |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 IRQMediaPlayer::~IRQMediaPlayer() |
|
62 { |
|
63 delete iPlayer; |
|
64 iPlayer = NULL; |
|
65 |
|
66 delete iStereoEffect; |
|
67 iStereoEffect = NULL; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // IRQMediaPlayer::playStation |
|
72 // Plays a specific radio station via certain access point id |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C void IRQMediaPlayer::playStation(const QString &aUrl, int aApId) |
|
76 { |
|
77 if (iPlayer) |
|
78 { |
|
79 iPlayer->playStation(aUrl, aApId); |
|
80 } |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // IRQMediaPlayer::stop |
|
85 // Stops the playback |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C void IRQMediaPlayer::stop() |
|
89 { |
|
90 if (iPlayer) |
|
91 { |
|
92 iPlayer->stop(); |
|
93 } |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // IRQMediaPlayer::setVolume |
|
98 // Sets the volume |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 EXPORT_C void IRQMediaPlayer::setVolume(int aVolume) |
|
102 { |
|
103 if (iPlayer) |
|
104 { |
|
105 iPlayer->setVolume(aVolume); |
|
106 } |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // IRQMediaPlayer::getVolume |
|
111 // Gets the current volume of playback |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 EXPORT_C int IRQMediaPlayer::getVolume() |
|
115 { |
|
116 int val = 0; |
|
117 |
|
118 if (iPlayer) |
|
119 { |
|
120 val = iPlayer->getVolume(); |
|
121 } |
|
122 |
|
123 return val; |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // IRQMediaPlayer::enableStereoEffect |
|
128 // Turns on stereo effect |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 EXPORT_C void IRQMediaPlayer::enableStereoEffect() |
|
132 { |
|
133 if (!iPlayer || IRQPlayerAdapterInterface::EPlaying != iPlayer->iPlayState) |
|
134 { |
|
135 return; |
|
136 } |
|
137 |
|
138 TRAPD(error, enableStereoEffectL()); |
|
139 if (KErrNone != error) |
|
140 { |
|
141 emit errorOccured(EIRQPlayerErrorSetStereoFailed); |
|
142 } |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // IRQMediaPlayer::disableStereoEffect |
|
147 // Turns off stereo effect |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 EXPORT_C void IRQMediaPlayer::disableStereoEffect() |
|
151 { |
|
152 if (iStereoEffect) |
|
153 { |
|
154 if (iStereoEffect->IsEnabled()) |
|
155 { |
|
156 TRAPD(error, iStereoEffect->DisableL()); |
|
157 if (KErrNone != error) |
|
158 { |
|
159 emit errorOccured(EIRQPlayerErrorSetStereoFailed); |
|
160 } |
|
161 delete iStereoEffect; |
|
162 iStereoEffect = NULL; |
|
163 } |
|
164 } |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // IRQMediaPlayer::enableStereoEffectL |
|
169 // Turns on stereo effect |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 void IRQMediaPlayer::enableStereoEffectL() |
|
173 { |
|
174 |
|
175 TUint stereoLevel = KDefaultStereoLevel; |
|
176 |
|
177 if (!iStereoEffect) |
|
178 { |
|
179 #if defined(MMFADAPTER) |
|
180 CVideoPlayerUtility* playerInstance = (CVideoPlayerUtility*)iPlayer->getPlayerInstance(); |
|
181 #elif defined(PHONONAdapter) |
|
182 void* playerInstance = iPlayer->getPlayerInstance(); |
|
183 #endif |
|
184 iStereoEffect = CStereoWidening::NewL(*playerInstance, EFalse, stereoLevel); |
|
185 } |
|
186 |
|
187 if (!iStereoEffect->IsEnabled()) |
|
188 { |
|
189 iStereoEffect->EnableL(); |
|
190 iStereoEffect->SetStereoWideningLevelL(stereoLevel); |
|
191 iStereoEffect->ApplyL(); |
|
192 } |
|
193 } |