|
1 /* |
|
2 * Copyright (c) 2002 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 class uses player factories to generate different players |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <logger.h> |
|
21 #include <ecam.h> |
|
22 |
|
23 #include "cmmamanager.h" |
|
24 #include "cmmaaudioplayerfactory.h" |
|
25 #include "cmmavideoplayerfactory.h" |
|
26 #include "cmmaaudiorecorderfactory.h" |
|
27 #include "cmmacameraplayerfactory.h" |
|
28 #include "cmmamidiplayerfactory.h" |
|
29 #include "cmmavideourlplayerfactory.h" |
|
30 #include "cmmaaudiostreamplayerfactory.h" |
|
31 //#include "cmmaanimationplayerfactory.h" |
|
32 |
|
33 #ifdef RD_JAVA_OMA_DRM_V2 |
|
34 #include "cmmadrmplayerfactory.h" |
|
35 #endif // RD_JAVA_OMA_DRM_V2 |
|
36 |
|
37 // index of CMMAAudioStreamPlayerFactory in iPlayerFactories |
|
38 // if CMMAAudioStreamPlayerFactory is moved in iPlayerFactories |
|
39 // this constant should be updated accordingly |
|
40 const TInt KAudioStreamPlayerFactoryIndex = 2; |
|
41 |
|
42 CMMAManager::~CMMAManager() |
|
43 { |
|
44 iPlayerFactories.ResetAndDestroy(); |
|
45 iPlayerFactories.Close(); |
|
46 } |
|
47 |
|
48 CMMAManager::CMMAManager() |
|
49 { |
|
50 } |
|
51 |
|
52 void CMMAManager::ConstructL(TInt aMIDletSuiteID) |
|
53 { |
|
54 LOG(EJavaMMAPI, EInfo, "MMA::CMMAManager::ConstructL +"); |
|
55 // |
|
56 // Create and insert known player factories |
|
57 // |
|
58 |
|
59 CMMAVideoUrlPlayerFactory* videoUrlPlayerFactory = CMMAVideoUrlPlayerFactory::NewLC(); |
|
60 AddPlayerFactoryL(videoUrlPlayerFactory); |
|
61 CleanupStack::Pop(); // videoUrlPlayerFactory |
|
62 |
|
63 CMMAMIDIPlayerFactory* midiPlayerFactory = CMMAMIDIPlayerFactory::NewLC(); |
|
64 AddPlayerFactoryL(midiPlayerFactory); |
|
65 CleanupStack::Pop(); // midiPlayerFactory |
|
66 |
|
67 CMMAAudioStreamPlayerFactory* audioStreamPlayerFactory = |
|
68 CMMAAudioStreamPlayerFactory::NewLC(); |
|
69 AddPlayerFactoryL(audioStreamPlayerFactory); |
|
70 CleanupStack::Pop(); // audioStreamPlayerFactory |
|
71 |
|
72 CMMAVideoPlayerFactory* videoPlayerFactory = CMMAVideoPlayerFactory::NewLC(); |
|
73 AddPlayerFactoryL(videoPlayerFactory); |
|
74 CleanupStack::Pop(); // videoPlayerFactory |
|
75 |
|
76 CMMAAudioPlayerFactory* audioPlayerFactory = CMMAAudioPlayerFactory::NewLC(); |
|
77 AddPlayerFactoryL(audioPlayerFactory); |
|
78 CleanupStack::Pop(); // audioPlayerFactory |
|
79 |
|
80 CMMAAudioRecorderFactory* audioRecorderFactory = |
|
81 CMMAAudioRecorderFactory::NewLC(aMIDletSuiteID); |
|
82 AddPlayerFactoryL(audioRecorderFactory); |
|
83 CleanupStack::Pop(); // audioRecorderFactory |
|
84 |
|
85 /* |
|
86 CMMAAnimationPlayerFactory* animationPlayerFactory = |
|
87 CMMAAnimationPlayerFactory::NewLC(); |
|
88 AddPlayerFactoryL(animationPlayerFactory); |
|
89 CleanupStack::Pop(); // animationPlayerFactory |
|
90 */ |
|
91 |
|
92 // Add camera playerfactory only if there is a camera |
|
93 if (CCamera::CamerasAvailable() > 0) |
|
94 { |
|
95 CMMACameraPlayerFactory* cameraPlayerFactory = |
|
96 CMMACameraPlayerFactory::NewLC(); |
|
97 AddPlayerFactoryL(cameraPlayerFactory); |
|
98 CleanupStack::Pop(); // cameraPlayerFactory |
|
99 } |
|
100 |
|
101 #ifdef RD_JAVA_OMA_DRM_V2 |
|
102 CMMADRMPlayerFactory* drmPlayerFactory = |
|
103 CMMADRMPlayerFactory::NewLC(videoPlayerFactory); |
|
104 AddPlayerFactoryL(drmPlayerFactory); |
|
105 CleanupStack::Pop(); // drmPlayerFactory |
|
106 #endif // RD_JAVA_OMA_DRM_V2 |
|
107 |
|
108 LOG(EJavaMMAPI, EInfo, "MMA::CMMAManager::ConstructL -"); |
|
109 } |
|
110 |
|
111 void CMMAManager::StaticCreateManagerL(CMMAManager** aManager, |
|
112 TInt aMIDletSuiteID) |
|
113 { |
|
114 CMMAManager* self = new(ELeave) CMMAManager(); |
|
115 |
|
116 CleanupStack::PushL(self); |
|
117 self->ConstructL(aMIDletSuiteID); |
|
118 CleanupStack::Pop(); |
|
119 |
|
120 *aManager = self; |
|
121 } |
|
122 |
|
123 /** |
|
124 * Use factories to create a player from content type |
|
125 * |
|
126 */ |
|
127 CMMAPlayer* CMMAManager::CreatePlayerL(const TDesC& aContentType) |
|
128 { |
|
129 // Try all factories, in order |
|
130 TInt factoryCount = iPlayerFactories.Count(); |
|
131 for (TInt i = 0; i < factoryCount; i++) |
|
132 { |
|
133 CMMAPlayer* player = iPlayerFactories[ i ]->CreatePlayerL(aContentType); |
|
134 if (player) |
|
135 { |
|
136 return player; |
|
137 } |
|
138 } |
|
139 // No PlayerFactory accepted the content type |
|
140 return NULL; |
|
141 } |
|
142 |
|
143 /** |
|
144 * Use factories to create a player from locator |
|
145 * |
|
146 */ |
|
147 CMMAPlayer* CMMAManager::CreatePlayerL(const TDesC& aProtocol, |
|
148 const TDesC& aMiddlePart, |
|
149 const TDesC& aParameters) |
|
150 { |
|
151 // Try all factories, in order |
|
152 TInt factoryCount = iPlayerFactories.Count(); |
|
153 for (TInt i = 0; i < factoryCount; i++) |
|
154 { |
|
155 CMMAPlayer* player = iPlayerFactories[ i ]->CreatePlayerL(aProtocol, |
|
156 aMiddlePart, |
|
157 aParameters); |
|
158 if (player) |
|
159 { |
|
160 return player; |
|
161 } |
|
162 } |
|
163 // No PlayerFactory accepted the content type |
|
164 return NULL; |
|
165 } |
|
166 |
|
167 /** |
|
168 * Use factories to create a player from header data |
|
169 * |
|
170 */ |
|
171 CMMAPlayer* CMMAManager::CreatePlayerL(const TDesC8& aHeaderData) |
|
172 { |
|
173 // Try all factories, in order |
|
174 TInt factoryCount = iPlayerFactories.Count(); |
|
175 for (TInt i = 0; i < factoryCount; i++) |
|
176 { |
|
177 CMMAPlayer* player = iPlayerFactories[ i ]->CreatePlayerL(aHeaderData); |
|
178 if (player) |
|
179 { |
|
180 return player; |
|
181 } |
|
182 } |
|
183 // No PlayerFactory accepted the content type |
|
184 return NULL; |
|
185 } |
|
186 |
|
187 /** |
|
188 * From MMMAPlayerFactory. Get all supported protocols |
|
189 */ |
|
190 void CMMAManager::GetSupportedProtocolsL( |
|
191 const TDesC& aContentType, |
|
192 CDesC16Array& aSupportedProtocols) |
|
193 { |
|
194 // Query supported protocols from all player factories |
|
195 for (TInt i = 0; i < iPlayerFactories.Count(); i++) |
|
196 { |
|
197 iPlayerFactories[ i ]->GetSupportedProtocolsL(aContentType, |
|
198 aSupportedProtocols); |
|
199 } |
|
200 } |
|
201 |
|
202 /** |
|
203 * From MMMAPlayerFactory. Get all supported content types |
|
204 */ |
|
205 void CMMAManager::GetSupportedContentTypesL( |
|
206 const TDesC& aProtocol, |
|
207 CDesC16Array& aContentTypes) |
|
208 { |
|
209 // Get all supported content types from PlayerFactories |
|
210 for (TInt i = 0; i < iPlayerFactories.Count(); i++) |
|
211 { |
|
212 iPlayerFactories[ i ]->GetSupportedContentTypesL(aProtocol, |
|
213 aContentTypes); |
|
214 } |
|
215 } |
|
216 |
|
217 EXPORT_C void CMMAManager::AddPlayerFactoryL(MMMAPlayerFactory* aPlayerFactory) |
|
218 { |
|
219 User::LeaveIfError(iPlayerFactories.Append(aPlayerFactory)); |
|
220 } |
|
221 |
|
222 void CMMAManager::SetSourceInfoL(const TUint8* aHeader, TInt aLength) |
|
223 { |
|
224 |
|
225 if (iPlayerFactories.Count() > KAudioStreamPlayerFactoryIndex) |
|
226 { |
|
227 // assumption - iPlayerFactories[KAudioStreamPlayerFactoryIndex] is CMMAAudioStreamPlayerFactory |
|
228 CMMAAudioStreamPlayerFactory* audiostreamplayerfactory = |
|
229 static_cast<CMMAAudioStreamPlayerFactory*>(iPlayerFactories[ KAudioStreamPlayerFactoryIndex ]); |
|
230 audiostreamplayerfactory->SetSourceInfoL(aHeader, aLength); |
|
231 } |
|
232 } |
|
233 |
|
234 // END OF FILE |