|
1 /* |
|
2 * Copyright (c) 2009 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 CVideoPlaylistUtility |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 2 % |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 |
|
24 #include <videoplaylistutility.h> |
|
25 #include <mediarecognizer.h> |
|
26 #include <streaminglinkmodel.h> |
|
27 #include <mpxmediaarray.h> |
|
28 #include <mpxmediageneraldefs.h> |
|
29 #include <mpxmediacontainerdefs.h> |
|
30 #include <mpxmediageneralextdefs.h> |
|
31 |
|
32 #include "videoplaylistutility_log.h" |
|
33 |
|
34 |
|
35 // CONSTANTS |
|
36 const TInt KSingleLink(1); |
|
37 _LIT( KDATATYPEVIDEOHELIX, "video/videohelix" ); |
|
38 |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =================================================== |
|
41 |
|
42 // ------------------------------------------------------------------------------------------------- |
|
43 // CVideoPlaylistUtility::CVideoPlaylistUtility |
|
44 // C++ default constructor can NOT contain any code, that |
|
45 // might leave. |
|
46 // ------------------------------------------------------------------------------------------------- |
|
47 // |
|
48 CVideoPlaylistUtility::CVideoPlaylistUtility() |
|
49 : iAsx( EFalse ) |
|
50 { |
|
51 |
|
52 } |
|
53 |
|
54 // ------------------------------------------------------------------------------------------------- |
|
55 // CVideoPlaylistUtility::ConstructL |
|
56 // Symbian 2nd phase constructor can leave. |
|
57 // ------------------------------------------------------------------------------------------------- |
|
58 // |
|
59 void CVideoPlaylistUtility::ConstructL() |
|
60 { |
|
61 |
|
62 } |
|
63 |
|
64 // ------------------------------------------------------------------------------------------------- |
|
65 // CVideoPlaylistUtility::NewL |
|
66 // Two-phased constructor. |
|
67 // ------------------------------------------------------------------------------------------------- |
|
68 // |
|
69 EXPORT_C CVideoPlaylistUtility* CVideoPlaylistUtility::NewL() |
|
70 { |
|
71 VIDEOPLAYLISTUTILITY_ENTER_EXIT(_L("CVideoPlaylistUtility::NewL()")); |
|
72 |
|
73 CVideoPlaylistUtility* self = new( ELeave ) CVideoPlaylistUtility(); |
|
74 CleanupStack::PushL( self ); |
|
75 self->ConstructL(); |
|
76 CleanupStack::Pop(); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // ------------------------------------------------------------------------------------------------- |
|
81 // CVideoPlaylistUtility::~CVideoPlaylistUtility |
|
82 // Destructor |
|
83 // ------------------------------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C CVideoPlaylistUtility::~CVideoPlaylistUtility() |
|
86 { |
|
87 VIDEOPLAYLISTUTILITY_ENTER_EXIT(_L("CVideoPlaylistUtility::~CVideoPlaylistUtility()")); |
|
88 |
|
89 if(iPlaylistArray) |
|
90 { |
|
91 delete iPlaylistArray; |
|
92 iPlaylistArray = NULL; |
|
93 } |
|
94 |
|
95 if(iStreamingLinkModel) |
|
96 { |
|
97 iStreamingLinkModel->ResetLinkCount(); |
|
98 iStreamingLinkModel->FreeFilehandle(); |
|
99 |
|
100 delete iStreamingLinkModel; |
|
101 iStreamingLinkModel = NULL; |
|
102 } |
|
103 } |
|
104 |
|
105 // ------------------------------------------------------------------------------------------------- |
|
106 // CVideoPlaylistUtility::GetItemArrayL |
|
107 // ------------------------------------------------------------------------------------------------- |
|
108 // |
|
109 void CVideoPlaylistUtility::GetItemArrayL( TInt aAccessPointId ) |
|
110 { |
|
111 VIDEOPLAYLISTUTILITY_ENTER_EXIT(_L("CVideoPlaylistUtility::GetItemArrayL()" )); |
|
112 |
|
113 HBufC* tempBuffer = HBufC::NewLC( iStreamingLinkModel->MaxLinkLength() ); |
|
114 TPtr tempurl(tempBuffer->Des()); |
|
115 |
|
116 TInt linkError = KErrNone; |
|
117 TInt localUrl; |
|
118 TBool seek = ETrue; |
|
119 |
|
120 iPlaylistArray = CMPXMediaArray::NewL(); |
|
121 |
|
122 while(linkError == KErrNone) |
|
123 { |
|
124 linkError = iStreamingLinkModel->GetNextLinkL( tempurl, localUrl ); |
|
125 |
|
126 if (linkError == KErrNone) |
|
127 { |
|
128 CMPXMedia* lItem = CMPXMedia::NewL(); |
|
129 CleanupStack::PushL( lItem ); |
|
130 |
|
131 lItem->SetTObjectValueL(KMPXMediaGeneralType, EMPXItem); |
|
132 lItem->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXVideo); |
|
133 // Bump up the score during plugin resolution in the FW |
|
134 lItem->SetTextValueL(KMPXMediaGeneralMimeType, KDATATYPEVIDEOHELIX); |
|
135 lItem->SetTextValueL(KMPXMediaGeneralUri, *tempBuffer); |
|
136 if (!localUrl) |
|
137 { |
|
138 // embed the access point into the playlist |
|
139 lItem->SetTObjectValueL(KMPXMediaGeneralExtAccessPoint, aAccessPointId); |
|
140 } |
|
141 |
|
142 if ( iAsx ) |
|
143 { |
|
144 // Get asx seek attribute |
|
145 seek = iStreamingLinkModel->IsSeekable(); |
|
146 |
|
147 lItem->SetTObjectValueL<TBool>(KMPXMediaGeneralExtVideoSeekable, seek); |
|
148 } |
|
149 |
|
150 CleanupStack::Pop( lItem ); |
|
151 |
|
152 iPlaylistArray->AppendL(lItem); |
|
153 lItem = NULL; |
|
154 } |
|
155 } |
|
156 |
|
157 |
|
158 CleanupStack::Pop(); // tempBuffer |
|
159 delete tempBuffer; |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CMPlayerM3UPlaylistParser::ComposePlaylistL |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 void CVideoPlaylistUtility::ComposePlaylistL() |
|
167 { |
|
168 VIDEOPLAYLISTUTILITY_ENTER_EXIT(_L("CVideoPlaylistUtility::ComposePlaylistL()")); |
|
169 |
|
170 // instantiate a CMPXMedia object to represent the playlist |
|
171 // which will contain the CMPXMediaArray |
|
172 iPlaylist = CMPXMedia::NewL(); |
|
173 |
|
174 // set type |
|
175 iPlaylist->SetTObjectValueL(KMPXMediaGeneralType, EMPXItem); |
|
176 |
|
177 // set category |
|
178 iPlaylist->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXPlaylist); |
|
179 |
|
180 // set iPlaylist array |
|
181 iPlaylist->SetCObjectValueL(KMPXMediaArrayContents, iPlaylistArray); |
|
182 |
|
183 // set array acount |
|
184 iPlaylist->SetTObjectValueL(KMPXMediaArrayCount, iPlaylistArray->Count()); |
|
185 |
|
186 // the ownership has been transfered |
|
187 // safe to delete |
|
188 delete iPlaylistArray; |
|
189 iPlaylistArray = NULL; |
|
190 |
|
191 } |
|
192 |
|
193 // ------------------------------------------------------------------------------------------------- |
|
194 // CVideoPlaylistUtility::OpenLinkFileL |
|
195 // ------------------------------------------------------------------------------------------------- |
|
196 // |
|
197 EXPORT_C CMPXMedia* CVideoPlaylistUtility::GetPlayListL( TInt aAccessPointId ) |
|
198 { |
|
199 VIDEOPLAYLISTUTILITY_ENTER_EXIT(_L("CVideoPlaylistUtility::GetPlayListL()")); |
|
200 |
|
201 CMPXMedia* playlist = NULL; |
|
202 |
|
203 // Create the CMPXMediaItemArray that will have the links |
|
204 GetItemArrayL(aAccessPointId); |
|
205 |
|
206 // Embed the CMPXMediaItemArray into a CMPXMedia object |
|
207 ComposePlaylistL(); |
|
208 |
|
209 playlist = iPlaylist; |
|
210 iPlaylist = NULL; |
|
211 |
|
212 return playlist; |
|
213 } |
|
214 |
|
215 |
|
216 // ------------------------------------------------------------------------------------------------- |
|
217 // CVideoPlaylistUtility::GetFileInfoL |
|
218 // ------------------------------------------------------------------------------------------------- |
|
219 // |
|
220 EXPORT_C void CVideoPlaylistUtility::GetFileInfoL( const TDesC& aFileName, |
|
221 CMediaRecognizer::TMediaType aMediaType, |
|
222 TBool& aSingleLink, TBool& aLocalFile ) |
|
223 { |
|
224 VIDEOPLAYLISTUTILITY_ENTER_EXIT(_L("CVideoPlaylistUtility::GetFileInfoL() FileName ")); |
|
225 |
|
226 TInt error = KErrNone; |
|
227 aSingleLink = aLocalFile = EFalse; |
|
228 iStreamingLinkModel = CStreamingLinkModel::NewL(); |
|
229 |
|
230 |
|
231 if ( aMediaType == CMediaRecognizer::ELocalRamFile ) |
|
232 { |
|
233 error = iStreamingLinkModel->OpenLinkFileL( aFileName ); |
|
234 } |
|
235 else |
|
236 { |
|
237 error = iStreamingLinkModel->OpenAsxFileL( aFileName ); |
|
238 iAsx = ETrue; |
|
239 } |
|
240 |
|
241 if(error == KErrNone) |
|
242 { |
|
243 // check to see if its a single link file |
|
244 if (iStreamingLinkModel->MultiLinksCount() == KSingleLink) |
|
245 { |
|
246 aSingleLink = ETrue; |
|
247 } |
|
248 aLocalFile = iStreamingLinkModel->AreAllLinksLocal(); |
|
249 } |
|
250 else |
|
251 { |
|
252 User::Leave( KErrBadName ); |
|
253 } |
|
254 } |
|
255 |
|
256 // ------------------------------------------------------------------------------------------------- |
|
257 // CVideoPlaylistUtility::GetFileInfoL |
|
258 // ------------------------------------------------------------------------------------------------- |
|
259 // |
|
260 EXPORT_C void CVideoPlaylistUtility::GetFileInfoL( RFile& aFile, |
|
261 CMediaRecognizer::TMediaType aMediaType, |
|
262 TBool& aSingleLink, TBool& aLocalFile ) |
|
263 { |
|
264 VIDEOPLAYLISTUTILITY_ENTER_EXIT(_L("CVideoPlaylistUtility::GetFileInfoL() RFile")); |
|
265 |
|
266 TInt error = KErrNone; |
|
267 aSingleLink = aLocalFile = EFalse; |
|
268 iStreamingLinkModel = CStreamingLinkModel::NewL(); |
|
269 |
|
270 if ( aMediaType == CMediaRecognizer::ELocalRamFile ) |
|
271 { |
|
272 error = iStreamingLinkModel->OpenLinkFileL( aFile ); |
|
273 } |
|
274 else |
|
275 { |
|
276 error = iStreamingLinkModel->OpenAsxFileL( aFile ); |
|
277 iAsx = ETrue; |
|
278 } |
|
279 |
|
280 if(error == KErrNone) |
|
281 { |
|
282 // check to see if its a single link file |
|
283 if (iStreamingLinkModel->MultiLinksCount() == KSingleLink) |
|
284 { |
|
285 aSingleLink = ETrue; |
|
286 } |
|
287 aLocalFile = iStreamingLinkModel->AreAllLinksLocal(); |
|
288 } |
|
289 else |
|
290 { |
|
291 User::Leave( KErrBadName ); |
|
292 } |
|
293 } |
|
294 |
|
295 // ------------------------------------------------------------------------------------------------- |
|
296 // CVideoPlaylistUtility::GetLinkLC |
|
297 // ------------------------------------------------------------------------------------------------- |
|
298 // |
|
299 EXPORT_C TPtrC CVideoPlaylistUtility::GetLinkLC() |
|
300 { |
|
301 VIDEOPLAYLISTUTILITY_ENTER_EXIT(_L("CVideoPlaylistUtility::GetLinkLC()")); |
|
302 |
|
303 TBool localUrl; |
|
304 HBufC* tempBuffer = HBufC::NewLC( iStreamingLinkModel->MaxLinkLength() ); |
|
305 |
|
306 TPtr tempurl(tempBuffer->Des()); |
|
307 |
|
308 iStreamingLinkModel->GetNextLinkL( tempurl, localUrl ); |
|
309 |
|
310 // push tempBuffer to the cleanup stack again |
|
311 // caller of GetLinkLC will pop and destroy it |
|
312 return tempurl; |
|
313 } |
|
314 |
|
315 // ------------------------------------------------------------------------------------------------- |
|
316 // CVideoPlaylistUtility::IsSeekable |
|
317 // ------------------------------------------------------------------------------------------------- |
|
318 // |
|
319 EXPORT_C TBool CVideoPlaylistUtility::IsSeekable() |
|
320 { |
|
321 VIDEOPLAYLISTUTILITY_ENTER_EXIT(_L("CVideoPlaylistUtility::Seekable()")); |
|
322 |
|
323 return iStreamingLinkModel->IsSeekable(); |
|
324 } |
|
325 |
|
326 // End of File |