|
1 /* |
|
2 * Copyright (c) 2008 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: Implementation of CMediaRecognizer |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 6 % |
|
19 |
|
20 |
|
21 |
|
22 #ifndef __MEDIARECOGNIZER_H |
|
23 #define __MEDIARECOGNIZER_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <e32base.h> |
|
27 #include <apgcli.h> |
|
28 #include <apmstd.h> |
|
29 #include <mmf/common/mmfcontrollerpluginresolver.h> |
|
30 |
|
31 |
|
32 NONSHARABLE_CLASS(CMediaRecognizer) : public CBase |
|
33 { |
|
34 |
|
35 public: |
|
36 // Media types |
|
37 enum TMediaType |
|
38 { |
|
39 ELocalVideoFile, |
|
40 ELocalAudioFile, |
|
41 ELocalRamFile, |
|
42 ELocalSdpFile, |
|
43 EUrl, |
|
44 ELocalAudioPlaylist, |
|
45 EProgressiveDownload, |
|
46 EFlashVideoFile, |
|
47 ELocalAsxFile, |
|
48 EUnidentified |
|
49 }; |
|
50 |
|
51 public: // Constructors and destructor |
|
52 |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 */ |
|
56 IMPORT_C static CMediaRecognizer* NewL(); |
|
57 |
|
58 /** |
|
59 * Destructor. |
|
60 */ |
|
61 IMPORT_C virtual ~CMediaRecognizer(); |
|
62 |
|
63 public: // New functions |
|
64 |
|
65 /** |
|
66 * Recognizes media type. |
|
67 * @since 2.0 |
|
68 * @param aMediaName Media file name or Url |
|
69 * @param aIncludeUrls Are Urls included or not |
|
70 * @return TMediaType |
|
71 */ |
|
72 IMPORT_C TMediaType IdentifyMediaTypeL( const TDesC& aMediaName, |
|
73 TBool aIncludeUrls = EFalse ); |
|
74 |
|
75 /** |
|
76 * Recognizes media type. |
|
77 * @since 3.0 |
|
78 * @param aMediaName Media file name or Url |
|
79 * @param aFile file handle |
|
80 * @param aIncludeUrls Are Urls included or not |
|
81 * @return TMediaType |
|
82 */ |
|
83 IMPORT_C TMediaType IdentifyMediaTypeL( const TDesC& aMediaName, |
|
84 RFile& aFile, |
|
85 TBool aIncludeUrls = EFalse ); |
|
86 |
|
87 /** |
|
88 * Recognizes Media files MimeType. |
|
89 * @since 2.0 |
|
90 * @param aLocalFile File name |
|
91 * @return TBuf<KMaxDataTypeLength>, Mime type. |
|
92 */ |
|
93 IMPORT_C TBuf<KMaxDataTypeLength> MimeTypeL( const TDesC& aLocalFile ); |
|
94 |
|
95 /** |
|
96 * Recognizes Media files MimeType. |
|
97 * @since 3.0 |
|
98 * @param aFile File handle |
|
99 * @return TBuf<KMaxDataTypeLength>, Mime type. |
|
100 */ |
|
101 IMPORT_C TBuf<KMaxDataTypeLength> MimeTypeL( RFile& aFile ); |
|
102 |
|
103 /* |
|
104 * IsValidStreamingPrefix |
|
105 * Check for a valid streaming prefix given a URL |
|
106 * @param aUrl URL |
|
107 * @return ETrue is prefix is valid |
|
108 */ |
|
109 IMPORT_C TBool IsValidStreamingPrefix( const TDesC& aUrl ); |
|
110 |
|
111 /* |
|
112 * IsValidUrlPrefix |
|
113 * Check for a valid prefix given a URL |
|
114 * @param aUrl URL |
|
115 * @return ETrue is prefix is valid |
|
116 */ |
|
117 IMPORT_C TBool IsValidUrlPrefix( const TDesC& aUrl ); |
|
118 IMPORT_C TBool IsValidUrlPrefix( const TDesC8& aUrl ); |
|
119 |
|
120 /** |
|
121 * Frees recognizer's filehandle. |
|
122 * @since 3.0 |
|
123 */ |
|
124 IMPORT_C void FreeFilehandle(); |
|
125 |
|
126 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
127 |
|
128 /** |
|
129 * Recognizes media type. |
|
130 * @since 9.2 |
|
131 * @param aMediaName Media file name or Url |
|
132 * @param aFile RFile64 file handle |
|
133 * @param aIncludeUrls Are Urls included or not |
|
134 * @return TMediaType |
|
135 */ |
|
136 IMPORT_C TMediaType IdentifyMediaTypeL( const TDesC& aMediaName, |
|
137 RFile64& aFile, |
|
138 TBool aIncludeUrls = EFalse ); |
|
139 |
|
140 /** |
|
141 * Recognizes Media files MimeType. |
|
142 * @since 9.2 |
|
143 * @param aFile RFile64 file handle |
|
144 * @return TBuf<KMaxDataTypeLength>, Mime type. |
|
145 */ |
|
146 IMPORT_C TBuf<KMaxDataTypeLength> MimeTypeL( RFile64& aFile ); |
|
147 |
|
148 #endif |
|
149 |
|
150 private: // New functions |
|
151 |
|
152 /** |
|
153 * Checks if there is video playback support. |
|
154 * @since 2.0 |
|
155 * @param aFileName |
|
156 * @param aFileRecognitionResult Recognition result |
|
157 * @return ETrue: Supported |
|
158 * EFalse: Not supported |
|
159 */ |
|
160 TBool FileHasVideoSupportL( const TDesC& aFileName, |
|
161 TDataRecognitionResult& aFileRecognitionResult, |
|
162 RMMFControllerImplInfoArray& aVideoControllers ); |
|
163 |
|
164 /** |
|
165 * Checks if there is audio playback support. |
|
166 * @since 2.0 |
|
167 * @param aFileName |
|
168 * @param aFileRecognitionResult Recognition result |
|
169 * @return ETrue: Supported |
|
170 * EFalse: Not supported |
|
171 */ |
|
172 TBool FileHasAudioSupport( const TDesC& aFileName, |
|
173 TDataRecognitionResult& aFileRecognitionResult, |
|
174 RMMFControllerImplInfoArray& aAudioControllers, |
|
175 RMMFControllerImplInfoArray& aVideoControllers ); |
|
176 |
|
177 /** |
|
178 * Creates array to hold all the controller plugins that support video. |
|
179 * @since 2.0 |
|
180 * @return void |
|
181 */ |
|
182 void CreateVideoFormatsArrayL( RMMFControllerImplInfoArray& aVideoController ); |
|
183 |
|
184 /** |
|
185 * Creates array to hold all the controller plugins that support audio. |
|
186 * @since 2.0 |
|
187 * @return void |
|
188 */ |
|
189 void CreateAudioFormatsArrayL( RMMFControllerImplInfoArray& aAudioController ); |
|
190 |
|
191 /** |
|
192 * Recognizes local file |
|
193 * @since 2.0 |
|
194 * @param aFileName. |
|
195 * This parameter is ignored if the recognizer has a valid filehandle. |
|
196 * Filehandle can be set via IdentifyMediaTypeL or MimeTypeL methods. |
|
197 * @param aFileRecognitionResult Recognition result |
|
198 * @return void |
|
199 */ |
|
200 void RecognizeFileL( const TDesC& aFileName, TDataRecognitionResult& aResult ); |
|
201 |
|
202 /** |
|
203 * Reads local file to buffer |
|
204 * @since 2.0 |
|
205 * @param aFileName |
|
206 * @param aBuf, buffer |
|
207 * @return KErrNone or one of the system wide error codes. |
|
208 */ |
|
209 TInt ReadFile( const TDesC& aFileName, TDes8& aBuf, TInt aBufSize ); |
|
210 |
|
211 /** |
|
212 * Determines presence of file handle. |
|
213 * @since 3.0 |
|
214 * @return ETrue if file handle exists. |
|
215 */ |
|
216 TBool FileHandleExists(); |
|
217 |
|
218 /** |
|
219 * Recognizes media type for non-url type |
|
220 * @return TMediaType |
|
221 */ |
|
222 TMediaType MediaTypeL( const TDesC& aMediaName ); |
|
223 |
|
224 /** |
|
225 * Reads local file to buffer using new RFile handle |
|
226 * @since 9.2 |
|
227 * @param aFileName |
|
228 * @param aBuf, buffer |
|
229 * @return KErrNone or one of the system wide error codes. |
|
230 */ |
|
231 TInt ReadFileViaNewFileHandle( const TDesC& aFileName, |
|
232 TDes8& aBuf, TInt aBufSize ); |
|
233 |
|
234 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
235 |
|
236 /** |
|
237 * Determines presence of file handle. |
|
238 * @since 9.2 |
|
239 * @return ETrue if file handle exists. |
|
240 */ |
|
241 TBool FileHandle64Exists(); |
|
242 |
|
243 /** |
|
244 * Reads local file to buffer using new RFile64 handle |
|
245 * @since 9.2 |
|
246 * @param aFileName |
|
247 * @param aBuf, buffer |
|
248 * @return KErrNone or one of the system wide error codes. |
|
249 */ |
|
250 TInt ReadFileViaNewFileHandle64( const TDesC& aFileName, |
|
251 TDes8& aBuf, TInt aBufSize ); |
|
252 |
|
253 #endif |
|
254 |
|
255 private: |
|
256 |
|
257 /** |
|
258 * C++ default constructor. |
|
259 */ |
|
260 CMediaRecognizer(); |
|
261 |
|
262 /** |
|
263 * By default Symbian 2nd phase constructor is private. |
|
264 */ |
|
265 void ConstructL(); |
|
266 |
|
267 private: // Data |
|
268 // Array to hold all the controller plugins that support video |
|
269 // Array to hold all the controller plugins that support audio |
|
270 |
|
271 // bufsize |
|
272 |
|
273 // Mime type recognizer |
|
274 RFs iFs; |
|
275 RFile iFileHandle; |
|
276 |
|
277 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
278 RFile64 iFileHandle64; |
|
279 #endif |
|
280 |
|
281 }; |
|
282 |
|
283 #endif // __MEDIARECOGNIZER_H |
|
284 |
|
285 // End of File |