|
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 the License "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: Streaming handler* |
|
15 */ |
|
16 |
|
17 |
|
18 // Version : %version: 8 % |
|
19 |
|
20 #include <eikon.hrh> |
|
21 #include <avkon.hrh> |
|
22 #include <mpxmessage.h> |
|
23 #include <mpxmessage2.h> |
|
24 #include <mpxcommand.h> |
|
25 #include <mpxcommandgeneraldefs.h> |
|
26 #include <mpxmessagegeneraldefs.h> |
|
27 #include <mpxplaybackmessage.h> |
|
28 #include <mpxplaybackutility.h> |
|
29 #include <mpxcollectionmessage.h> |
|
30 #include <mpxmediageneraldefs.h> |
|
31 #include <mpxcollectionmessagedefs.h> |
|
32 #include <vcxmyvideosdefs.h> |
|
33 |
|
34 #include "IptvDebug.h" |
|
35 #include "vcxnsstreaminghandler.h" |
|
36 #include "vcxnscontent.h" |
|
37 #include "vcxnsuiengine.h" |
|
38 #include "vcxnscontentprovider.h" |
|
39 |
|
40 // Get spec for this. |
|
41 const TInt KMinIntervalFromBegin = 1000; // 1 sec |
|
42 const TInt KMinIntervalFromEnd = 5000; // 5 sec |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CVcxNsStreamingHandler::CVcxNsStreamingHandler |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CVcxNsStreamingHandler::CVcxNsStreamingHandler( CVcxNsUiEngine& aUiEngine ) : |
|
49 iUiEngine ( aUiEngine ) |
|
50 { |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CVcxNsStreamingHandler::NewL |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CVcxNsStreamingHandler* CVcxNsStreamingHandler::NewL( CVcxNsUiEngine& aUiEngine ) |
|
58 { |
|
59 CVcxNsStreamingHandler* self = new( ELeave) CVcxNsStreamingHandler( aUiEngine ); |
|
60 CleanupStack::PushL(self); |
|
61 self->ConstructL(); |
|
62 CleanupStack::Pop(self); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CVcxNsStreamingHandler::ConstructL |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CVcxNsStreamingHandler::ConstructL() |
|
71 { |
|
72 IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsStreamingHandler::ConstructL"); |
|
73 |
|
74 IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsStreamingHandler::ConstructL"); |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CVcxNsStreamingHandler::~CVcxNsStreamingHandler |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CVcxNsStreamingHandler::~CVcxNsStreamingHandler() |
|
82 { |
|
83 HandleCloseStream(); |
|
84 |
|
85 if ( iPlaybackUtility ) |
|
86 { |
|
87 TRAP_IGNORE( iPlaybackUtility->RemoveObserverL( *this ) ); |
|
88 iPlaybackUtility->Close(); |
|
89 } |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // From MMPXPlaybackObserver |
|
94 // Handle playback message. |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CVcxNsStreamingHandler::HandlePlaybackMessage( CMPXMessage* aMessage, TInt aError ) |
|
98 { |
|
99 IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsStreamingHandler::HandlePlaybackMessage"); |
|
100 |
|
101 if ( aError == KErrNone && aMessage ) |
|
102 { |
|
103 TRAP_IGNORE( DoHandlePlaybackMessageL( *aMessage ) ); |
|
104 } |
|
105 |
|
106 IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsStreamingHandler::HandlePlaybackMessage"); |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // Handle playback message. |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void CVcxNsStreamingHandler::DoHandlePlaybackMessageL( const CMPXMessage& aMessage ) |
|
114 { |
|
115 IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsStreamingHandler::DoHandlePlaybackMessageL"); |
|
116 |
|
117 TMPXMessageId id( *aMessage.Value< TMPXMessageId >( KMPXMessageGeneralId ) ); |
|
118 |
|
119 IPTVLOGSTRING2_LOW_LEVEL("CVcxNsStreamingHandler::DoHandlePlaybackMessageL TMPXMessageId = 0x%08x", id ); |
|
120 |
|
121 if ( KMPXMessageGeneral == id ) |
|
122 { |
|
123 TInt event = *aMessage.Value<TInt>( KMPXMessageGeneralEvent ); |
|
124 |
|
125 IPTVLOGSTRING2_LOW_LEVEL("CVcxNsStreamingHandler::DoHandlePlaybackMessageL: event = %d", event ); |
|
126 |
|
127 switch ( event ) |
|
128 { |
|
129 case TMPXPlaybackMessage::EPropertyChanged: |
|
130 { |
|
131 HandlePropertyChangedL( aMessage ); |
|
132 } |
|
133 break; |
|
134 case TMPXPlaybackMessage::EStateChanged: |
|
135 { |
|
136 HandleStateChangedL( aMessage ); |
|
137 } |
|
138 break; |
|
139 default: |
|
140 break; |
|
141 } |
|
142 } |
|
143 |
|
144 IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsStreamingHandler::DoHandlePlaybackMessageL"); |
|
145 } |
|
146 |
|
147 // ------------------------------------------------------------------------------------------------- |
|
148 // CVcxNsStreamingHandler::HandleStateChangedL |
|
149 // ------------------------------------------------------------------------------------------------- |
|
150 // |
|
151 void CVcxNsStreamingHandler::HandleStateChangedL( const CMPXMessage& aMessage ) |
|
152 { |
|
153 IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsStreamingHandler::HandleStateChangedL"); |
|
154 |
|
155 if ( iContent && |
|
156 aMessage.IsSupported( KMPXMessageGeneralType ) ) |
|
157 { |
|
158 iCurrentState = *aMessage.Value<TInt>( KMPXMessageGeneralType ); |
|
159 |
|
160 IPTVLOGSTRING2_LOW_LEVEL("CVcxNsStreamingHandler::HandleStateChangedL: state = %d", iCurrentState ); |
|
161 |
|
162 switch ( iCurrentState ) |
|
163 { |
|
164 case EPbStateInitialised: |
|
165 { |
|
166 if ( iLastPosPending ) |
|
167 { |
|
168 SeekToLastPosL(); |
|
169 } |
|
170 } |
|
171 break; |
|
172 case EPbStateStopped: |
|
173 case EPbStateShuttingDown: |
|
174 { |
|
175 HandleCloseStream(); |
|
176 } |
|
177 break; |
|
178 case EPbStatePlaying: |
|
179 { |
|
180 GetDurationL(); |
|
181 } |
|
182 break; |
|
183 default: |
|
184 break; |
|
185 } |
|
186 } |
|
187 |
|
188 IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsStreamingHandler::HandleStateChangedL"); |
|
189 } |
|
190 |
|
191 // ------------------------------------------------------------------------------------------------- |
|
192 // CVcxNsStreamingHandler::HandlePropertyChangedL |
|
193 // ------------------------------------------------------------------------------------------------- |
|
194 // |
|
195 void CVcxNsStreamingHandler::HandlePropertyChangedL( const CMPXMessage& aMessage ) |
|
196 { |
|
197 IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsStreamingHandler::HandlePropertyChangedL"); |
|
198 |
|
199 if( iContent && |
|
200 aMessage.IsSupported( KMPXMessageGeneralType ) && |
|
201 aMessage.IsSupported( KMPXMessageGeneralData ) ) |
|
202 { |
|
203 TInt property = *aMessage.Value<TInt>( KMPXMessageGeneralType ); |
|
204 TInt data = *aMessage.Value<TInt>( KMPXMessageGeneralData ); |
|
205 |
|
206 if( property == EPbPropertyPosition ) |
|
207 { |
|
208 IPTVLOGSTRING2_LOW_LEVEL("CVcxNsStreamingHandler::HandlePropertyChangedL(): pos = %d", data ); |
|
209 |
|
210 iContent->SetLastPlaybackPosition( TReal32 ( data ), |
|
211 CVcxNsContent::EVcxContentTypeStream ); |
|
212 } |
|
213 } |
|
214 |
|
215 IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsStreamingHandler::HandlePropertyChangedL"); |
|
216 } |
|
217 |
|
218 // ------------------------------------------------------------------------------------------------- |
|
219 // CVcxNsStreamingHandler::HandleOpenStreamL |
|
220 // ------------------------------------------------------------------------------------------------- |
|
221 // |
|
222 void CVcxNsStreamingHandler::HandleOpenStreamL( CVcxNsContent* aContent ) |
|
223 { |
|
224 IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsStreamingHandler::HandleOpenStreamL"); |
|
225 |
|
226 HandleCloseStream(); |
|
227 |
|
228 if ( !iPlaybackUtility ) |
|
229 { |
|
230 iPlaybackUtility = MMPXPlaybackUtility::UtilityL( EMPXCategoryVideo, KPbModeDefault ); |
|
231 iPlaybackUtility->AddObserverL( *this ); |
|
232 } |
|
233 |
|
234 iContent = CVcxNsContent::NewL( *aContent ); |
|
235 |
|
236 TInt prevPos = iContent->GetLastPlaybackPosition( CVcxNsContent::EVcxContentTypeStream ); |
|
237 |
|
238 if ( prevPos > KMinIntervalFromBegin ) |
|
239 { |
|
240 iLastPosPending = ETrue; |
|
241 iResumePos = prevPos; |
|
242 } |
|
243 else |
|
244 { |
|
245 iLastPosPending = EFalse; |
|
246 iResumePos = 0; |
|
247 } |
|
248 |
|
249 IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsStreamingHandler::HandleOpenStreamL"); |
|
250 } |
|
251 |
|
252 // ------------------------------------------------------------------------------------------------- |
|
253 // CVcxNsStreamingHandler::HandleCloseStream |
|
254 // ------------------------------------------------------------------------------------------------- |
|
255 // |
|
256 void CVcxNsStreamingHandler::HandleCloseStream() |
|
257 { |
|
258 IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsStreamingHandler::HandleCloseStream"); |
|
259 |
|
260 TRAP_IGNORE( StoreLastPosL() ); |
|
261 |
|
262 delete iContent; |
|
263 iContent = NULL; |
|
264 |
|
265 iLastPosPending = EFalse; |
|
266 iResumePos = 0; |
|
267 iDuration = 0; |
|
268 iCurrentState = EPbStateNotInitialised; |
|
269 |
|
270 IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsStreamingHandler::HandleCloseStream"); |
|
271 } |
|
272 |
|
273 // ------------------------------------------------------------------------------------------------- |
|
274 // CVcxNsStreamingHandler::SeekToLastPosL |
|
275 // ------------------------------------------------------------------------------------------------- |
|
276 // |
|
277 void CVcxNsStreamingHandler::SeekToLastPosL() |
|
278 { |
|
279 IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsStreamingHandler::SeekToLastPosL"); |
|
280 |
|
281 iLastPosPending = EFalse; |
|
282 |
|
283 if ( iResumePos != 0 ) |
|
284 { |
|
285 iPlaybackUtility->SetL( EPbPropertyPosition, iResumePos ); |
|
286 iResumePos = 0; |
|
287 } |
|
288 |
|
289 IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsStreamingHandler::SeekToLastPosL"); |
|
290 } |
|
291 |
|
292 // ------------------------------------------------------------------------------------------------- |
|
293 // CVcxNsStreamingHandler::StoreLastPosL |
|
294 // ------------------------------------------------------------------------------------------------- |
|
295 // |
|
296 void CVcxNsStreamingHandler::StoreLastPosL() |
|
297 { |
|
298 IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsStreamingHandler::StoreLastPosL"); |
|
299 |
|
300 if( iContent && iUiEngine.ContentProvider() ) |
|
301 { |
|
302 TInt pos = iContent->GetLastPlaybackPosition( CVcxNsContent::EVcxContentTypeStream ); |
|
303 |
|
304 if ( pos <= iDuration - KMinIntervalFromEnd && pos >= KMinIntervalFromBegin ) |
|
305 { |
|
306 iUiEngine.ContentProvider()->StoreLastPlayPosL( iContent, |
|
307 CVcxNsContent::EVcxContentTypeStream, |
|
308 TReal32( pos ) ); |
|
309 } |
|
310 else |
|
311 { |
|
312 iUiEngine.ContentProvider()->StoreLastPlayPosL( iContent, |
|
313 CVcxNsContent::EVcxContentTypeStream, |
|
314 TReal32 ( 0 ) ); |
|
315 } |
|
316 } |
|
317 |
|
318 IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsStreamingHandler::StoreLastPosL"); |
|
319 } |
|
320 |
|
321 |
|
322 // ------------------------------------------------------------------------------------------------- |
|
323 // CVcxNsStreamingHandler::GetDurationL |
|
324 // ------------------------------------------------------------------------------------------------- |
|
325 // |
|
326 void CVcxNsStreamingHandler::GetDurationL() |
|
327 { |
|
328 IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsStreamingHandler::GetDurationL"); |
|
329 |
|
330 iPlaybackUtility->PropertyL( *this, EPbPropertyDuration ); |
|
331 |
|
332 IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsStreamingHandler::GetDurationL"); |
|
333 } |
|
334 |
|
335 // ------------------------------------------------------------------------------------------------- |
|
336 // CVcxNsStreamingHandler::HandlePropertyL |
|
337 // ------------------------------------------------------------------------------------------------- |
|
338 // |
|
339 void CVcxNsStreamingHandler::HandlePropertyL( TMPXPlaybackProperty aProperty, |
|
340 TInt aValue, |
|
341 TInt aError ) |
|
342 { |
|
343 IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsStreamingHandler::HandlePropertyL"); |
|
344 |
|
345 if ( aError == KErrNone && |
|
346 aProperty == EPbPropertyDuration ) |
|
347 { |
|
348 iDuration = aValue; |
|
349 } |
|
350 |
|
351 IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsStreamingHandler::HandlePropertyL"); |
|
352 } |
|
353 |
|
354 // ------------------------------------------------------------------------------------------------- |
|
355 // CVcxNsStreamingHandler::HandleSubPlayerNamesL |
|
356 // ------------------------------------------------------------------------------------------------- |
|
357 // |
|
358 void CVcxNsStreamingHandler::HandleSubPlayerNamesL( TUid /*aPlayer*/, |
|
359 const MDesCArray* /*aSubPlayers*/, |
|
360 TBool /*aComplete*/, |
|
361 TInt /*aError*/ ) |
|
362 { |
|
363 IPTVLOGSTRING_LOW_LEVEL("CVcxNsStreamingHandler::HandleSubPlayerNamesL"); |
|
364 } |
|
365 |
|
366 // ------------------------------------------------------------------------------------------------- |
|
367 // CVcxNsStreamingHandler::HandleMediaL |
|
368 // ------------------------------------------------------------------------------------------------- |
|
369 // |
|
370 void CVcxNsStreamingHandler::HandleMediaL( const CMPXMedia& /*aProperties*/, |
|
371 TInt /*aError*/ ) |
|
372 { |
|
373 IPTVLOGSTRING_LOW_LEVEL("CVcxNsStreamingHandler::HandleMediaL"); |
|
374 } |