|
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: This file contains the base class from which specific audio |
|
15 * play controllers are derived. This class encapsulates common |
|
16 * behavior for all audio play controllers. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "AdvancedAudioPlayController.h" |
|
23 #include "AdvancedAudioResource.h" |
|
24 #include <AudioOutput.h> |
|
25 #include <MetaDataFieldContainer.h> |
|
26 #include <MetaDataUtility.h> |
|
27 #include <mmfformatimplementationuids.hrh> |
|
28 #include <mmfmeta.h> |
|
29 #include <MultimediaDataSourceEvents.h> |
|
30 #include <MultimediaDataSourceFactory.h> |
|
31 #include <oma2dcf.h> |
|
32 |
|
33 // CONSTANTS |
|
34 |
|
35 // ============================= LOCAL FUNCTIONS =============================== |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS =============================== |
|
38 |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CAdvancedAudioPlayController::GetNumberOfMetaDataEntriesL |
|
42 // Returns the number of metadata entries found in source, if supported. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C void CAdvancedAudioPlayController::GetNumberOfMetaDataEntriesL( |
|
46 TInt& aNumberOfEntries) |
|
47 { |
|
48 #ifdef _DEBUG |
|
49 RDebug::Print(_L("CAdvancedAudioPlayController::GetNumberOfMetaDataEntriesL")); |
|
50 #endif |
|
51 |
|
52 if (!iMetaDataSupport) |
|
53 { |
|
54 User::Leave(KErrNotSupported); |
|
55 } |
|
56 |
|
57 if (!iMetaDataRead) |
|
58 { |
|
59 if (!iDataSource) |
|
60 { |
|
61 User::Leave(KErrNotReady); |
|
62 } |
|
63 |
|
64 CMetaDataUtility* metaDataUtility = CMetaDataUtility::NewL(); |
|
65 CleanupStack::PushL(metaDataUtility); |
|
66 |
|
67 RArray<TMetaDataFieldId> wantedFields; |
|
68 CleanupClosePushL(wantedFields); |
|
69 wantedFields.Append(EMetaDataSongTitle); |
|
70 wantedFields.Append(EMetaDataArtist); |
|
71 wantedFields.Append(EMetaDataAlbum); |
|
72 wantedFields.Append(EMetaDataYear); |
|
73 wantedFields.Append(EMetaDataComment); |
|
74 wantedFields.Append(EMetaDataAlbumTrack); |
|
75 wantedFields.Append(EMetaDataGenre); |
|
76 wantedFields.Append(EMetaDataComposer); |
|
77 wantedFields.Append(EMetaDataCopyright); |
|
78 wantedFields.Append(EMetaDataOriginalArtist); |
|
79 wantedFields.Append(EMetaDataUrl); |
|
80 wantedFields.Append(EMetaDataJpeg); |
|
81 wantedFields.Append(EMetaDataUserUrl); |
|
82 |
|
83 if (iSourceType == KUidMmfFileSource || |
|
84 iSourceType == TUid::Uid(0x10207A7C) ) // progressive download |
|
85 { |
|
86 CMMFFile* file = static_cast<CMMFFile*>(iDataSource); |
|
87 file->SourcePrimeL(); |
|
88 metaDataUtility->OpenFileL(file->FileL(), wantedFields); |
|
89 } |
|
90 else if(iSourceType == KUidMmfDescriptorSource) |
|
91 { |
|
92 CMMFClip* clip = static_cast<CMMFClip*>(iDataSource); |
|
93 CMMFDataBuffer* buf = CreateSourceBufferOfSizeLC(clip->Size()); |
|
94 clip->SourcePrimeL(); |
|
95 clip->ReadBufferL(buf, 0); |
|
96 metaDataUtility->OpenDesL(buf->Data(), wantedFields); |
|
97 CleanupStack::PopAndDestroy(buf); // buf |
|
98 } |
|
99 else |
|
100 { |
|
101 CleanupStack::PopAndDestroy(&wantedFields); |
|
102 CleanupStack::PopAndDestroy(metaDataUtility); |
|
103 User::Leave(KErrNotSupported); |
|
104 } |
|
105 |
|
106 TInt count = metaDataUtility->MetaDataCount(); |
|
107 |
|
108 if (count > 0) |
|
109 { |
|
110 const CMetaDataFieldContainer& container = metaDataUtility->MetaDataFieldsL(); |
|
111 TMetaDataFieldId id; |
|
112 for (TInt i = 0; i < count; i++) |
|
113 { |
|
114 TPtrC content = container.At(i, id); |
|
115 CMMFMetaDataEntry* metaData = NULL; |
|
116 switch (id) |
|
117 { |
|
118 case EMetaDataSongTitle: |
|
119 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntrySongTitle, content); |
|
120 break; |
|
121 case EMetaDataArtist: |
|
122 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntryArtist, content); |
|
123 break; |
|
124 case EMetaDataAlbum: |
|
125 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntryAlbum, content); |
|
126 break; |
|
127 case EMetaDataYear: |
|
128 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntryYear, content); |
|
129 break; |
|
130 case EMetaDataComment: |
|
131 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntryComment, content); |
|
132 break; |
|
133 case EMetaDataAlbumTrack: |
|
134 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntryAlbumTrack, content); |
|
135 break; |
|
136 case EMetaDataGenre: |
|
137 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntryGenre, content); |
|
138 break; |
|
139 case EMetaDataComposer: |
|
140 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntryComposer, content); |
|
141 break; |
|
142 case EMetaDataCopyright: |
|
143 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntryCopyright, content); |
|
144 break; |
|
145 case EMetaDataOriginalArtist: |
|
146 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntryOriginalArtist, content); |
|
147 break; |
|
148 case EMetaDataUrl: |
|
149 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntryWOAF, content); |
|
150 break; |
|
151 case EMetaDataJpeg: |
|
152 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntryAPIC, content); |
|
153 break; |
|
154 case EMetaDataUserUrl: |
|
155 metaData = CMMFMetaDataEntry::NewL(KMMFMetaEntryWXXX, content); |
|
156 break; |
|
157 default: // Should never get here really... |
|
158 break; |
|
159 } |
|
160 if (metaData) |
|
161 { |
|
162 CleanupStack::PushL(metaData); |
|
163 User::LeaveIfError(iMetaDataEntries.Append(metaData)); |
|
164 CleanupStack::Pop(metaData); // metaData |
|
165 } |
|
166 } |
|
167 } |
|
168 iMetaDataRead = ETrue; |
|
169 CleanupStack::PopAndDestroy(&wantedFields); // wantedFields |
|
170 CleanupStack::PopAndDestroy(metaDataUtility); //metaDataUtility |
|
171 } |
|
172 |
|
173 aNumberOfEntries = iMetaDataEntries.Count(); |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CAdvancedAudioPlayController::GetMetaDataEntryL |
|
178 // Returns the metadata in the specified index. |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 EXPORT_C CMMFMetaDataEntry* CAdvancedAudioPlayController::GetMetaDataEntryL( |
|
182 TInt aIndex) |
|
183 { |
|
184 #ifdef _DEBUG |
|
185 RDebug::Print(_L("CAdvancedAudioPlayController::GetMetaDataEntryL [%d]"), aIndex); |
|
186 #endif |
|
187 |
|
188 if (!iMetaDataSupport) |
|
189 { |
|
190 User::Leave(KErrNotSupported); |
|
191 } |
|
192 |
|
193 if (aIndex > iMetaDataEntries.Count() - 1) |
|
194 { |
|
195 User::Leave(KErrArgument); |
|
196 } |
|
197 |
|
198 return CMMFMetaDataEntry::NewL(*iMetaDataEntries[aIndex]); |
|
199 } |
|
200 |
|
201 // End of file |