1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "S60mediarecognizer.h" |
|
43 #include <MPMediaRecognizer.h> |
|
44 #include <e32def.h> |
|
45 #include <e32cmn.h> |
|
46 #include <QtCore/qurl.h> |
|
47 #include <QtCore/qdir.h> |
|
48 #include <QtCore/qdebug.h> |
|
49 |
|
50 S60MediaRecognizer::S60MediaRecognizer(QObject *parent) : QObject(parent) |
|
51 { |
|
52 TRAP_IGNORE(m_recognizer = CMPMediaRecognizer::NewL()); |
|
53 } |
|
54 |
|
55 S60MediaRecognizer::~S60MediaRecognizer() |
|
56 { |
|
57 delete m_recognizer; |
|
58 m_recognizer = NULL; |
|
59 } |
|
60 |
|
61 bool S60MediaRecognizer::checkUrl(const QUrl &url) |
|
62 { |
|
63 TBool isValidUrl = false; |
|
64 TPtrC validUrlPtr (static_cast<const TUint16*>(url.toString().utf16()), url.toString().length()); |
|
65 isValidUrl = m_recognizer->ValidUrl(validUrlPtr); |
|
66 return isValidUrl; |
|
67 } |
|
68 |
|
69 S60MediaRecognizer::MediaType S60MediaRecognizer::IdentifyMediaType(const QUrl &url) |
|
70 { |
|
71 CMPMediaRecognizer::TMPMediaType type = CMPMediaRecognizer::EUnidentified; |
|
72 QString filePath = QDir::toNativeSeparators(url.toLocalFile()); |
|
73 if (filePath.isNull()) { |
|
74 filePath = url.toString(); |
|
75 } |
|
76 TPtrC16 urlPtr(reinterpret_cast<const TUint16*>(filePath.utf16())); |
|
77 |
|
78 TRAP_IGNORE(type = m_recognizer->IdentifyMediaTypeL(urlPtr, ETrue);) |
|
79 m_recognizer->FreeFilehandle(); |
|
80 |
|
81 switch (type) { |
|
82 case CMPMediaRecognizer::ELocalAudioFile: |
|
83 return Audio; |
|
84 case CMPMediaRecognizer::ELocalVideoFile: |
|
85 return Video; |
|
86 case CMPMediaRecognizer::EUrl: |
|
87 return Url; |
|
88 case CMPMediaRecognizer::ELocalAudioPlaylist: |
|
89 // TODO: Must be considered when streams will be implemented |
|
90 case CMPMediaRecognizer::ELocalRamFile: |
|
91 case CMPMediaRecognizer::ELocalSdpFile: |
|
92 // case CMPMediaRecognizer::EProgressiveDownload: |
|
93 case CMPMediaRecognizer::EUnidentified: |
|
94 default: |
|
95 break; |
|
96 } |
|
97 |
|
98 return NotSupported; |
|
99 } |
|