1 /* |
|
2 * Copyright (c) 2006-2007 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef IRMEDIACLIENT_H |
|
21 #define IRMEDIACLIENT_H |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 #include "ircontrolparams.h" |
|
26 #include "irmediaenginedef.h" |
|
27 #include <mdaaudiooutputstream.h> |
|
28 |
|
29 class CIRCtrlCmdObserver; |
|
30 class CIRMediaEngineInterface; |
|
31 |
|
32 //========================================class declaration CIRMediaEngineInterface============================================ |
|
33 |
|
34 /** |
|
35 * This is client class for irmediaengine which a ecom dll |
|
36 * Any request to media engine is routed through media client |
|
37 * This client creates proper player for mp3 or acc/accp according |
|
38 * to the mime type To start a player StartNewPlayerL function is to be |
|
39 * used, which in turn trigger play and this should be called before |
|
40 * calling play or stop functions |
|
41 * The buffers are created and filled with data. |
|
42 * media engines instance is created and associates the filled buffer |
|
43 * to media engine, finally the media engine's and buffer associated is deleted |
|
44 * for each format we delete and recreate the player and buffer |
|
45 * This also interacts with ircommandchannel.dll for filling data,triggering |
|
46 * audiofadeout etc. |
|
47 * |
|
48 * @code |
|
49 * |
|
50 * CIRCtrlCmdObserver* channel; //instance of CIRCtrlCmdObserver defined |
|
51 * //in ircommandchannel.dll |
|
52 * client = CIRMediaClient* NewL(); //instance of media client |
|
53 * TConfig config; |
|
54 * TBuf<20> format; |
|
55 * _LIT(KFormat,"audio/mpeg"); |
|
56 * client->StartNewPlayer(config,KFormat,channel); //Initiates the player |
|
57 * //Creates buffer fills the buffer, Creates instance of player |
|
58 * //and associates filled buffer with it triggers playing. |
|
59 * //Once this done irmediaengine takes care of buffering issues |
|
60 * //Deletes the old instance of player as well as buffer associated |
|
61 * //before creating a new one |
|
62 * client->Stop(); //stop the player |
|
63 * client->Play(); //plays the player |
|
64 * client->SetVolume(); //sets the volume |
|
65 * client->MaxVolume(); //gives the maximum volume |
|
66 * client->Volume(); //returns the current volume |
|
67 * client->BufferFilled(); //is a call back when buffer is filled this has to be called |
|
68 * client->StopMediaBuffering(); //stop buffering when buffering is handled in irmediaengine |
|
69 * client->StopInitialBuffering(); //stop buffering when buffering is handled in |
|
70 * //irmediaclient |
|
71 * @endcode |
|
72 * |
|
73 */ |
|
74 |
|
75 NONSHARABLE_CLASS(CIRMediaClient) : public CBase |
|
76 { // Function declaration |
|
77 |
|
78 //Constructor functions |
|
79 public: |
|
80 |
|
81 /** |
|
82 * Function : NewL |
|
83 * Two Phase Constructor - NewL |
|
84 * @return an instance of the player component |
|
85 */ |
|
86 static CIRMediaClient* NewL(CIRCtrlCmdObserver* aChannel); |
|
87 |
|
88 /** |
|
89 * Function : NewLC |
|
90 * Two Phase Constructor - NewLC |
|
91 * @return an instance of the player component |
|
92 */ |
|
93 static CIRMediaClient* NewLC(CIRCtrlCmdObserver* aChannel); |
|
94 |
|
95 /** |
|
96 * destructor function |
|
97 * destructor of the player component |
|
98 */ |
|
99 ~CIRMediaClient(); |
|
100 |
|
101 private: |
|
102 //Constructor function |
|
103 |
|
104 /** |
|
105 * This is default Constructor |
|
106 * for the class CIRMediaClient |
|
107 */ |
|
108 CIRMediaClient(); |
|
109 |
|
110 /** |
|
111 * Two phase ConstructL |
|
112 * network component is taken as input |
|
113 * @param instance of network |
|
114 */ |
|
115 void ConstructL(CIRCtrlCmdObserver* aChannel); |
|
116 |
|
117 |
|
118 public: |
|
119 |
|
120 // Function to control the play |
|
121 |
|
122 /** |
|
123 * Function : Play |
|
124 * Starts to play the stream |
|
125 * @return KErrNone if player is existing if not it returns KErrNotFound |
|
126 */ |
|
127 TInt Play(); |
|
128 |
|
129 /** |
|
130 * Function : Stop |
|
131 * Stops to play the stream |
|
132 */ |
|
133 void Stop(); |
|
134 |
|
135 //Function to control the volume |
|
136 |
|
137 /** |
|
138 * Function : SetVolume |
|
139 * function to set the volume, |
|
140 * @param integer level of volume is the input |
|
141 */ |
|
142 void SetVolume(TInt aVolume); |
|
143 |
|
144 /** |
|
145 * Function : MaxVolume |
|
146 * @returns the maximum volume , integer value is the Output |
|
147 */ |
|
148 TInt MaxVolume() const; |
|
149 |
|
150 /** |
|
151 * Function : Volume |
|
152 * function to returns the volume |
|
153 * @return integer level of voume is the Output |
|
154 */ |
|
155 TInt Volume() const; |
|
156 |
|
157 /** |
|
158 * Function: BufferFilled |
|
159 * Set the whether a Fill Buffer is currently active |
|
160 */ |
|
161 void BufferFilled(); |
|
162 |
|
163 /** |
|
164 * Function: StartNewPlayerL |
|
165 * Set the whether a Fill Buffer is currently active |
|
166 * @param configuration settings |
|
167 * @param format type |
|
168 * @param command channel's instance |
|
169 */ |
|
170 void StartNewPlayerL(TConfig& aConfig,const TDesC8& aFormat); |
|
171 |
|
172 /** |
|
173 * Function: StopMediaBuffering |
|
174 * stops buffering of media engine |
|
175 */ |
|
176 void StopMediaBuffering(); |
|
177 |
|
178 /** |
|
179 * Function: StopMediaBuffering |
|
180 * stops buffering from media client, media engine is not stopped |
|
181 */ |
|
182 void StopInitialBuffering(); |
|
183 |
|
184 /** |
|
185 * Function: StartMediaBuffering |
|
186 * starts buffering of media engine |
|
187 */ |
|
188 void StartMediaBuffering(); |
|
189 /** |
|
190 * GetMediaClientInstance() |
|
191 * Returns the Audio Player Instance |
|
192 */ |
|
193 CMdaAudioOutputStream* GetPlayerInstance(); |
|
194 |
|
195 private: |
|
196 |
|
197 /** |
|
198 * Creates instance of the media engine ECom plugin. |
|
199 * |
|
200 * @return ETrue, if the creation succeeded, EFalse otherwise |
|
201 */ |
|
202 TBool CreatePlayer(); |
|
203 |
|
204 /** |
|
205 * initializes the player with codec settings, initialised buffer |
|
206 * and Control command instance. |
|
207 * |
|
208 * @param configuration settings |
|
209 * @param command channel's instance |
|
210 */ |
|
211 void InitializePlayer( TConfig& aConfig,CIRCtrlCmdObserver* aChannel); |
|
212 |
|
213 |
|
214 private: |
|
215 //data members |
|
216 |
|
217 |
|
218 //Instance of Interface definision |
|
219 CIRMediaEngineInterface* iPlayer; |
|
220 |
|
221 //Instance of channel through with data is sent UI |
|
222 CIRCtrlCmdObserver* iChannel; |
|
223 |
|
224 //The instance of buffer which is currently playing |
|
225 TUint8* iCurrentBuffer; |
|
226 |
|
227 //The pointer to buffer which being created for a new player |
|
228 TUint8* iTempBuffer; |
|
229 |
|
230 //pointer to buffer being filled |
|
231 TUint8* iInputBufferPtr; |
|
232 |
|
233 //holds the format type |
|
234 TBuf8<20> iFormat; |
|
235 |
|
236 //buffer which is being filled |
|
237 TPtr8 iInputBuffer; |
|
238 |
|
239 //hold the configuration information |
|
240 TConfig iConfig; |
|
241 |
|
242 //Holds the percentage of data in the buffer |
|
243 TInt iBufferPercentage; |
|
244 |
|
245 //Set of commands that can be sent to command channel |
|
246 TIRControlCommmand iCommand; |
|
247 |
|
248 //checks whether the player is a newly created player |
|
249 TBool iNewPlayer; |
|
250 |
|
251 //checks whether the execution of code is required for only first time or not |
|
252 TBool iFirstTime; |
|
253 |
|
254 //checks whether to stop buffering |
|
255 TBool iStopBuffering; |
|
256 }; |
|
257 |
|
258 #endif //IRMEDIACLIENT_H |
|
259 |
|
260 |
|