|
1 /* |
|
2 * Copyright (c) 2006 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 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MCEFILESOURCE_H |
|
22 #define MCEFILESOURCE_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32std.h> |
|
26 #include <mcemediasource.h> |
|
27 #include <mcemediastream.h> |
|
28 |
|
29 // CONSTANTS |
|
30 const TMceSourceType KMceFileSource = 4; |
|
31 |
|
32 //FORWARD DECLARATIONS |
|
33 class CMceManager; |
|
34 class CMceItcSender; |
|
35 class TMceFileInfo; |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * Class representing file source in MCE. |
|
41 * |
|
42 * CMceFileSource can be used for streaming file contents. The file may contain |
|
43 * both audio and video data. If the user wants to stream both media types, |
|
44 * the same file source should be attached to audio stream and video stream. |
|
45 * |
|
46 * The file may contain also several elements of the same media type (e.g. |
|
47 * 3 audio channels) and the user might want to use only some of those. |
|
48 * This can be handled by defining index of the file's current media element: |
|
49 * |
|
50 * - Get number of audio media elements within the file (e.g. returns 3) |
|
51 * - Set current audio element index to be 0 |
|
52 * - Attach the file source to the audioStreamOne (audio element 0 is attached) |
|
53 * - Set current audio element index to be 2 |
|
54 * - Attach the file source to the audioStreamTwo (audio element 2 is attached) |
|
55 * - Consequently, file's audio channel 0 would be streamed over the audioStreamOne |
|
56 * and channel 2 over the audioStreamTwo. Channel 1 would be ignored. |
|
57 * |
|
58 * Enable (continue) and Disable (pause) operations to it are considered |
|
59 * to be local, so they are not signalled to remote terminal. |
|
60 * |
|
61 * @lib mceclient.lib |
|
62 */ |
|
63 class CMceFileSource : public CMceMediaSource |
|
64 { |
|
65 |
|
66 public: // Constructors and destructor |
|
67 |
|
68 /** |
|
69 * Two-phased constructor. |
|
70 * @param aManager associated MCE manager |
|
71 * @param aFileName name of the file including full path info |
|
72 */ |
|
73 IMPORT_C static CMceFileSource* NewL( CMceManager& aManager, |
|
74 const TFileName& aFileName ); |
|
75 |
|
76 /** |
|
77 * Two-phased constructor. |
|
78 * @param aManager associated MCE manager |
|
79 * @param aFileName name of the file including full path info |
|
80 */ |
|
81 IMPORT_C static CMceFileSource* NewLC( CMceManager& aManager, |
|
82 const TFileName& aFileName ); |
|
83 |
|
84 /** |
|
85 * Destructor. |
|
86 */ |
|
87 IMPORT_C ~CMceFileSource(); |
|
88 |
|
89 |
|
90 public: // From CMceMediaSource |
|
91 |
|
92 /** |
|
93 * Enables the source explicitly. |
|
94 */ |
|
95 IMPORT_C void EnableL(); |
|
96 |
|
97 /** |
|
98 * Disables the source explicitly. |
|
99 */ |
|
100 IMPORT_C void DisableL(); |
|
101 |
|
102 |
|
103 public: // Functions |
|
104 |
|
105 /** |
|
106 * Updates file for the source. |
|
107 * @param aFileName name of the file including full path info |
|
108 */ |
|
109 IMPORT_C void UpdateL ( const TFileName& aFileName ); |
|
110 |
|
111 /** |
|
112 * Determines how many media elements of the spesified type the file |
|
113 * source contains. E.g. audio file may contain N number of audio |
|
114 * channels which has to be streamed over N number of audio streams. |
|
115 * @param aType the type of media |
|
116 * @return the number of media elements (of spesified type) |
|
117 * the file contains |
|
118 */ |
|
119 IMPORT_C TInt MediaElementCountL( TMceMediaType aType ) const; |
|
120 |
|
121 /** |
|
122 * Sets currently managed media element of the spesified media type. |
|
123 * The setting is effective when the file source is attached to |
|
124 * media stream of the spesified type. Current media element can be |
|
125 * defined for each media type the file contains. By default, media |
|
126 * element 0 of each media type is used. |
|
127 * @param aType the type of media |
|
128 * @param aIndex new index of the current media element |
|
129 * @leave KErrArgument if media element spesified by input parameters |
|
130 * does not exist |
|
131 */ |
|
132 IMPORT_C void SetCurrentMediaElementL( TMceMediaType aType, TInt aIndex ); |
|
133 |
|
134 /** |
|
135 * Gets currently managed media element of the spesified media type. |
|
136 * @param aType the type of media |
|
137 * @return index of the current media element or KErrNotFound if no media |
|
138 * elements of the spesified type exists |
|
139 */ |
|
140 IMPORT_C TInt CurrentMediaElement( TMceMediaType aType ); |
|
141 |
|
142 /** |
|
143 * Sets the position within the file from where to start playback. |
|
144 * @pre IsEnabled() == EFalse and contains audio/video |
|
145 * @param aPosition from start of the file in microseconds |
|
146 */ |
|
147 IMPORT_C void SetPositionL( const TTimeIntervalMicroSeconds& aPosition ); |
|
148 |
|
149 /** |
|
150 * Gets the current playback position in microseconds from the start of the file. |
|
151 * @pre contains audio/video |
|
152 * @return current position from start of the file in microseconds |
|
153 */ |
|
154 IMPORT_C TTimeIntervalMicroSeconds PositionL() const; |
|
155 |
|
156 /** |
|
157 * Returns the duration of the file in microseconds. |
|
158 * @pre contains audio/video |
|
159 * @return duration of the file in microseconds. |
|
160 */ |
|
161 IMPORT_C TTimeIntervalMicroSeconds DurationL() const; |
|
162 |
|
163 /** |
|
164 * Sets fast forward on/off. |
|
165 * @pre contains video |
|
166 * @param aUseFFWD ETrue if fast forward is enabled; otherwise EFalse |
|
167 */ |
|
168 IMPORT_C void SetFastForwardL( TBool aUseFFWD ); |
|
169 |
|
170 /** |
|
171 * Sets fast rewind on/off. |
|
172 * @pre contains video |
|
173 * @param aUseFRWD ETrue if fast rewind is enabled; otherwise EFalse |
|
174 */ |
|
175 IMPORT_C void SetFastRewindL( TBool aUseFRWD ); |
|
176 |
|
177 /** |
|
178 * Starts transcoding of file. After the transcoding is complete, |
|
179 * file of this source is changed into the transcoded file. |
|
180 * @pre CMceMediaStream::State() == ETranscodingRequired |
|
181 * @post CMceMediaStream::State() == ETranscoding |
|
182 * @param aFileName Name of the transcoding output file. |
|
183 */ |
|
184 IMPORT_C void TranscodeL( const TFileName& aFileName ); |
|
185 |
|
186 /** |
|
187 * Cancels transcoding of file. |
|
188 * @pre CMceMediaStream::State() == ETranscoding |
|
189 * @post CMceMediaStream::State() == ETranscodingRequired |
|
190 */ |
|
191 IMPORT_C void CancelTranscodeL(); |
|
192 |
|
193 /** |
|
194 * Gets the current transcoding progress in percentage. |
|
195 * Value is updated with MMceStreamObserver::StreamStateChanged() event. |
|
196 * @pre CMceMediaStream::State() == ETranscoding |
|
197 * @return Transcoding progress in persentage (0-100). |
|
198 */ |
|
199 IMPORT_C TInt TranscodingProgressL() const; |
|
200 |
|
201 public: // internal |
|
202 |
|
203 /** |
|
204 * Initializes |
|
205 * @param aManager the manager. Ownership is NOT transferred |
|
206 */ |
|
207 void InitializeL( CMceManager* aManager ); |
|
208 |
|
209 /** |
|
210 * returns supported video codec of this file |
|
211 * @return supported video codec of this file |
|
212 */ |
|
213 const TDesC8& SupportedVideo(); |
|
214 |
|
215 /** |
|
216 * returns supported audio codec of this file |
|
217 * @return supported audio codec of this file |
|
218 */ |
|
219 const TDesC8& SupportedAudio(); |
|
220 |
|
221 /** |
|
222 * returns details of this file |
|
223 * @return details of this file |
|
224 */ |
|
225 const TMceFileInfo& FileInfo(); |
|
226 |
|
227 public: //from CMceMediaSource |
|
228 |
|
229 /** |
|
230 * Traversal event handler |
|
231 * @param aEvent the event |
|
232 * @return status, if event was consumed or not or object needs update |
|
233 */ |
|
234 TInt EventReceivedL( TMceEvent& aEvent ); |
|
235 |
|
236 /** |
|
237 * Handles event |
|
238 * @param aEvent the event |
|
239 * @return status, if event was consumed or not or object needs update |
|
240 */ |
|
241 TInt HandleEvent( TMceEvent& aEvent ); |
|
242 |
|
243 /** |
|
244 * Called after update |
|
245 */ |
|
246 void Updated(); |
|
247 |
|
248 /** |
|
249 * Stream has been added to session |
|
250 * @param aParent the parent stream |
|
251 */ |
|
252 void StreamAddedL( CMceMediaStream& aParent ); |
|
253 |
|
254 public: |
|
255 |
|
256 /** |
|
257 * Two-phased constructor. |
|
258 */ |
|
259 static CMceFileSource* NewL(); |
|
260 |
|
261 /** |
|
262 * Two-phased constructor. |
|
263 */ |
|
264 static CMceFileSource* NewLC(); |
|
265 |
|
266 /** |
|
267 * Gets manager |
|
268 * @return manager, or NULL if not present |
|
269 */ |
|
270 CMceManager* Manager(); |
|
271 |
|
272 private: |
|
273 |
|
274 /** |
|
275 * C++ default constructor. |
|
276 */ |
|
277 CMceFileSource(); |
|
278 |
|
279 /** |
|
280 * Second-phase constructor. |
|
281 */ |
|
282 void ConstructL( CMceManager* aManager, |
|
283 const TFileName& aFileName ); |
|
284 |
|
285 |
|
286 void SynchronizeWithStreamL(); |
|
287 void UpdateState( CMceMediaStream::TState aState ); |
|
288 void GetFileInfoL( TBool aUseSession = ETrue ); |
|
289 void SetFileInfoL(); |
|
290 void TranscodingCompletedL( TMceEvent& aEvent ); |
|
291 void DoCancelTranscodeL(); |
|
292 |
|
293 private: // Data |
|
294 |
|
295 CMceManager* iManager; //Not owned |
|
296 |
|
297 private: // Reserved for future use |
|
298 |
|
299 TAny* iReserved; |
|
300 |
|
301 friend class CMceManager; |
|
302 |
|
303 |
|
304 //for testing |
|
305 |
|
306 MCE_UNIT_TEST_DEFS |
|
307 |
|
308 }; |
|
309 |
|
310 |
|
311 #endif |