66
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2007 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 is used for creating DRM v2 player.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <jdebug.h>
|
|
21 |
|
|
22 |
#ifndef RD_JAVA_S60_RELEASE_5_0
|
|
23 |
#include <caf/cafplatform.h>
|
|
24 |
#endif
|
|
25 |
|
|
26 |
#include <caf/stringattributeset.h>
|
|
27 |
|
|
28 |
#include <DRMCommon.h>
|
|
29 |
#include <DRMHelper.h>
|
|
30 |
|
|
31 |
#include "cmmadrmplayerfactory.h"
|
|
32 |
#include "cmmadrmaudioplayer.h"
|
|
33 |
#include "cmmadrmvolumecontrol.h"
|
|
34 |
#include "cmmastoptimecontrol.h"
|
|
35 |
#include "cmmadrmmetadatacontrol.h"
|
|
36 |
#include "cmmadrmratecontrol.h"
|
|
37 |
#include "cmmavideoplayer.h"
|
|
38 |
|
|
39 |
_LIT(KMMAAudio, "audio");
|
|
40 |
// this (get from caf) cannot be recognized is it audio or video
|
|
41 |
_LIT(KMMARMCafMimeType, "application/vnd.rn-realmedia");
|
|
42 |
// drm v2 file suffix
|
|
43 |
_LIT(KMMADRMv2SuffixODF, "odf");
|
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
// CMMADRMPlayerFactory::NewLC
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
CMMADRMPlayerFactory* CMMADRMPlayerFactory::NewLC(CMMAVideoPlayerFactory* aVideoPlayerFactory)
|
|
50 |
{
|
|
51 |
CMMADRMPlayerFactory* pFactory =
|
|
52 |
new(ELeave) CMMADRMPlayerFactory(aVideoPlayerFactory);
|
|
53 |
CleanupStack::PushL(pFactory);
|
|
54 |
return pFactory;
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
// CMMADRMPlayerFactory::CMMADRMPlayerFactory
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CMMADRMPlayerFactory::CMMADRMPlayerFactory(CMMAVideoPlayerFactory* aVideoPlayerFactory)
|
|
62 |
:iVideoPlayerFactory(aVideoPlayerFactory)
|
|
63 |
{
|
|
64 |
}
|
|
65 |
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
// CMMADRMPlayerFactory::~CMMADRMPlayerFactory
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
CMMADRMPlayerFactory::~CMMADRMPlayerFactory()
|
|
71 |
{
|
|
72 |
}
|
|
73 |
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
// CMMADRMPlayerFactory::CreatePlayerL
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
CMMAPlayer* CMMADRMPlayerFactory::CreatePlayerL(const TDesC& /*aContentType*/)
|
|
79 |
{
|
|
80 |
// only file is supported
|
|
81 |
return NULL;
|
|
82 |
}
|
|
83 |
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
// CMMADRMPlayerFactory::CreatePlayerL
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
CMMAPlayer* CMMADRMPlayerFactory::CreatePlayerL(
|
|
89 |
const TDesC& aProtocol,
|
|
90 |
const TDesC& aMiddlePart,
|
|
91 |
const TDesC& /*aProperties*/)
|
|
92 |
{
|
|
93 |
DEBUG("MMA::CMMADRMPlayerFactory::CreatePlayerL +");
|
|
94 |
CMMAPlayer* player = NULL;
|
|
95 |
if (aProtocol == KMMAFileProtocol)
|
|
96 |
{
|
|
97 |
// we are most likely going to play this file
|
|
98 |
ContentAccess::TIntent intent = ContentAccess::EPlay;
|
|
99 |
|
|
100 |
ContentAccess::CContent* contentObj = ContentAccess::CContent::NewL(aMiddlePart);
|
|
101 |
CleanupStack::PushL(contentObj);
|
|
102 |
|
|
103 |
ContentAccess::CData* dataObj = NULL;
|
|
104 |
TRAPD(openContentErr, dataObj = contentObj->OpenContentL(intent));
|
|
105 |
CleanupStack::PushL(dataObj);
|
|
106 |
|
|
107 |
DEBUG_INT("MMA::CMMADRMPlayerFactory::CreatePlayerL openContentErr: %d", openContentErr);
|
|
108 |
if (KErrCA_LowerLimit <= openContentErr && openContentErr <= KErrCA_UpperLimit)
|
|
109 |
{
|
|
110 |
// handle error, possible update rights
|
|
111 |
UpdateRightsL(openContentErr, aMiddlePart);
|
|
112 |
User::Leave(openContentErr);
|
|
113 |
}
|
|
114 |
else
|
|
115 |
{
|
|
116 |
User::LeaveIfError(openContentErr);
|
|
117 |
}
|
|
118 |
|
|
119 |
ContentAccess::RStringAttributeSet stringAttributeSet;
|
|
120 |
CleanupClosePushL(stringAttributeSet);
|
|
121 |
stringAttributeSet.AddL(ContentAccess::EMimeType);
|
|
122 |
|
|
123 |
User::LeaveIfError(dataObj->GetStringAttributeSet(stringAttributeSet));
|
|
124 |
|
|
125 |
TBuf<KMaxName> mimeType;
|
|
126 |
TInt err = stringAttributeSet.GetValue(ContentAccess::EMimeType, mimeType);
|
|
127 |
if (err == KErrNone)
|
|
128 |
{
|
|
129 |
DEBUG_STR("MMA::CMMADRMPlayerFactory::CreatePlayerL, no err, mime type = %S", mimeType);
|
|
130 |
// we use 16bit mimeType
|
|
131 |
HBufC* mimeTypeBuf = HBufC::NewLC(mimeType.Length());
|
|
132 |
mimeTypeBuf->Des().Copy(mimeType);
|
|
133 |
|
|
134 |
if (((mimeTypeBuf->Length() >= KMMAAudio().Length()) &&
|
|
135 |
(mimeTypeBuf->Left(KMMAAudio().Length()) == KMMAAudio)) ||
|
|
136 |
((KErrNone == mimeTypeBuf->Compare(KMMARMCafMimeType)) &&
|
|
137 |
(aMiddlePart.Right(KMMADRMv2SuffixODF().Length()) ==
|
|
138 |
KMMADRMv2SuffixODF())))
|
|
139 |
{
|
|
140 |
// if content-type starts with "audio" or
|
|
141 |
// if it's KMMARMCafMimeType and file suffix is ODF
|
|
142 |
// then create audio player
|
|
143 |
player = CreateAudioPlayerL(*mimeTypeBuf, aMiddlePart);
|
|
144 |
}
|
|
145 |
else
|
|
146 |
{
|
|
147 |
// otherwise try video player
|
|
148 |
player = CreateVideoPlayerL(*mimeTypeBuf, aMiddlePart);
|
|
149 |
}
|
|
150 |
CleanupStack::PopAndDestroy(mimeTypeBuf);
|
|
151 |
}
|
|
152 |
else
|
|
153 |
{
|
|
154 |
DEBUG_INT("MMA::CMMADRMPlayerFactory::CreatePlayerL get mime err: %d", err);
|
|
155 |
DEBUG_STR("MMA::CMMADRMPlayerFactory::CreatePlayerL mime type = %S", mimeType);
|
|
156 |
User::Leave(err);
|
|
157 |
}
|
|
158 |
CleanupStack::PopAndDestroy(3); //dataObj, contentObj, stringAttributeSet
|
|
159 |
}
|
|
160 |
DEBUG("MMA::CMMADRMPlayerFactory::CreatePlayerL -");
|
|
161 |
return player;
|
|
162 |
}
|
|
163 |
|
|
164 |
// ---------------------------------------------------------------------------
|
|
165 |
// CMMADRMPlayerFactory::CreatePlayerL
|
|
166 |
// ---------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
CMMAPlayer* CMMADRMPlayerFactory::CreatePlayerL(const TDesC8& /*aHeaderData*/)
|
|
169 |
{
|
|
170 |
// only file is supported
|
|
171 |
return NULL;
|
|
172 |
}
|
|
173 |
|
|
174 |
// ---------------------------------------------------------------------------
|
|
175 |
// CMMADRMPlayerFactory::GetSupportedContentTypesL
|
|
176 |
// ---------------------------------------------------------------------------
|
|
177 |
//
|
|
178 |
void CMMADRMPlayerFactory::GetSupportedContentTypesL(const TDesC& /*aProtocol*/,
|
|
179 |
CDesC16Array& /*aMimeTypeArray*/)
|
|
180 |
{
|
|
181 |
// DRM Supports same content-types as others, no need to add
|
|
182 |
}
|
|
183 |
|
|
184 |
// ---------------------------------------------------------------------------
|
|
185 |
// CMMADRMPlayerFactory::GetSupportedProtocolsL
|
|
186 |
// ---------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
void CMMADRMPlayerFactory::GetSupportedProtocolsL(
|
|
189 |
const TDesC& /*aContentType*/,
|
|
190 |
CDesC16Array& /*aProtocolArray*/)
|
|
191 |
{
|
|
192 |
// DRM Supports same protocols as others, no need to add
|
|
193 |
}
|
|
194 |
|
|
195 |
// ---------------------------------------------------------------------------
|
|
196 |
// CMMADRMPlayerFactory::UpdateRightsL
|
|
197 |
// ---------------------------------------------------------------------------
|
|
198 |
//
|
|
199 |
void CMMADRMPlayerFactory::UpdateRightsL(TInt aError,
|
|
200 |
const TDesC& aFileName)
|
|
201 |
{
|
|
202 |
DEBUG("MMA::CMMADRMPlayerFactory::UpdateRightsL +");
|
|
203 |
CDRMHelper* helper = CDRMHelper::NewLC();
|
|
204 |
TInt code = helper->HandleErrorL(aError, aFileName);
|
|
205 |
if (code == 0)
|
|
206 |
{
|
|
207 |
User::Leave(aError);
|
|
208 |
}
|
|
209 |
CleanupStack::PopAndDestroy(helper);
|
|
210 |
}
|
|
211 |
|
|
212 |
// ---------------------------------------------------------------------------
|
|
213 |
// CMMADRMPlayerFactory::CreateAudioPlayerL
|
|
214 |
// ---------------------------------------------------------------------------
|
|
215 |
//
|
|
216 |
CMMAPlayer* CMMADRMPlayerFactory::CreateAudioPlayerL(const TDesC& aContentType,
|
|
217 |
const TDesC& aFileName)
|
|
218 |
{
|
|
219 |
DEBUG("MMA::CMMADRMPlayerFactory::CreateAudioPlayerL +");
|
|
220 |
CMMADRMAudioPlayer* player = CMMADRMAudioPlayer::NewLC(aContentType,
|
|
221 |
aFileName);
|
|
222 |
|
|
223 |
CMMADRMVolumeControl* volumeControl = CMMADRMVolumeControl::NewL(player);
|
|
224 |
CleanupStack::PushL(volumeControl);
|
|
225 |
player->AddControlL(volumeControl);
|
|
226 |
CleanupStack::Pop(volumeControl);
|
|
227 |
|
|
228 |
CMMAStopTimeControl* stopTimeControl = CMMAStopTimeControl::NewL(player);
|
|
229 |
CleanupStack::PushL(stopTimeControl);
|
|
230 |
player->AddControlL(stopTimeControl);
|
|
231 |
CleanupStack::Pop(stopTimeControl);
|
|
232 |
|
|
233 |
CMMADRMMetaDataControl* metaDataControl =
|
|
234 |
new(ELeave)CMMADRMMetaDataControl(player);
|
|
235 |
CleanupStack::PushL(metaDataControl);
|
|
236 |
player->AddControlL(metaDataControl);
|
|
237 |
CleanupStack::Pop(metaDataControl);
|
|
238 |
|
|
239 |
CMMADRMRateControl* drmRateControl = CMMADRMRateControl::NewL(player);
|
|
240 |
CleanupStack::PushL(drmRateControl);
|
|
241 |
player->AddControlL(drmRateControl);
|
|
242 |
CleanupStack::Pop(drmRateControl);
|
|
243 |
|
|
244 |
CleanupStack::Pop(player);
|
|
245 |
return player;
|
|
246 |
}
|
|
247 |
|
|
248 |
// ---------------------------------------------------------------------------
|
|
249 |
// CMMADRMPlayerFactory::CreateVideoPlayerL
|
|
250 |
// ---------------------------------------------------------------------------
|
|
251 |
//
|
|
252 |
CMMAPlayer* CMMADRMPlayerFactory::CreateVideoPlayerL(const TDesC& aContentType,
|
|
253 |
const TDesC& aFileName)
|
|
254 |
{
|
|
255 |
DEBUG("MMA::CMMADRMPlayerFactory::CreateVideoPlayerL +");
|
|
256 |
CMMAPlayer* player =
|
|
257 |
iVideoPlayerFactory->CreatePlayerWithFileL(aContentType, &aFileName);
|
|
258 |
|
|
259 |
return player;
|
|
260 |
}
|
|
261 |
|
|
262 |
// END OF FILE
|