|
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: Player delegate to handle RTSP live streaming |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <jdebug.h> |
|
21 |
|
22 #include "cmmavideourlplayer.h" |
|
23 |
|
24 CMMAVideoUrlPlayer::CMMAVideoUrlPlayerClipStreamDelegate:: |
|
25 CMMAVideoUrlPlayerClipStreamDelegate(CMMAVideoUrlPlayer& aPlayer) : |
|
26 CMMAVideoUrlPlayerDelegate(aPlayer) |
|
27 { |
|
28 // Nothing to be done. |
|
29 } |
|
30 |
|
31 CMMAVideoUrlPlayer::CMMAVideoUrlPlayerClipStreamDelegate::~CMMAVideoUrlPlayerClipStreamDelegate() |
|
32 { |
|
33 // Nothing to be done. |
|
34 } |
|
35 |
|
36 void CMMAVideoUrlPlayer::CMMAVideoUrlPlayerClipStreamDelegate::StartL() |
|
37 { |
|
38 iPlayer.CMMAMMFPlayerBase::StartL(); |
|
39 } |
|
40 |
|
41 void CMMAVideoUrlPlayer::CMMAVideoUrlPlayerClipStreamDelegate::StopL(TBool aPostEvent) |
|
42 { |
|
43 if (iPlayer.iState == EStarted) |
|
44 { |
|
45 User::LeaveIfError(iPlayer.iController.Pause()); |
|
46 |
|
47 if (aPostEvent) |
|
48 { |
|
49 TInt64 time; |
|
50 iPlayer.GetMediaTime(&time); |
|
51 iPlayer.PostLongEvent(CMMAPlayerEvent::EStopped, time); |
|
52 } |
|
53 // go back to prefetched state |
|
54 iPlayer.ChangeState(EPrefetched); |
|
55 } |
|
56 } |
|
57 |
|
58 void CMMAVideoUrlPlayer::CMMAVideoUrlPlayerClipStreamDelegate::GetMediaTime(TInt64* aMediaTime) |
|
59 { |
|
60 iPlayer.CMMAMMFPlayerBase::GetMediaTime(aMediaTime); |
|
61 } |
|
62 |
|
63 void CMMAVideoUrlPlayer::CMMAVideoUrlPlayerClipStreamDelegate::HandleEvent(const TMMFEvent& aEvent) |
|
64 { |
|
65 DEBUG_INT("MMA:CMMAVideoUrlPlayer: Clip stream: HandleEvent %d", aEvent.iEventType.iUid); |
|
66 DEBUG_INT("MMA:CMMAVideoUrlPlayer: Clip stream: HandleEvent error code: %d", aEvent.iErrorCode); |
|
67 |
|
68 TInt err = aEvent.iErrorCode; |
|
69 |
|
70 if ((aEvent.iEventType == KMMFEventCategoryVideoLoadingComplete) && |
|
71 (iPlayer.iState == ERealized)) |
|
72 { |
|
73 // Call pause only when doing prefetch. |
|
74 // Loading complete will come also when looping. |
|
75 if (err == KErrNone) |
|
76 { |
|
77 err = iPlayer.iController.Pause(); |
|
78 } |
|
79 |
|
80 // VideoLoadingComplete-event only completes prefetch sequence |
|
81 // for non-live streams. |
|
82 iPlayer.CompletePrefetch(err); |
|
83 } |
|
84 else if (aEvent.iEventType == KMMFEventCategoryVideoPrepareComplete) |
|
85 { |
|
86 // going to prefetch state, after Play |
|
87 // KMMFEventCategoryVideoLoadingComplete event will be received |
|
88 |
|
89 if (err == KErrNone) |
|
90 { |
|
91 iPlayer.PrepareDisplay(); |
|
92 |
|
93 // Buffering is done only for non-live streams. |
|
94 err = iPlayer.iController.Play(); |
|
95 } |
|
96 |
|
97 // For non-live streams: if error is other than |
|
98 // KErrNone, then complete prefetch. |
|
99 if (err != KErrNone) |
|
100 { |
|
101 // prefetch didn't succeed |
|
102 iPlayer.CompletePrefetch(err); |
|
103 } |
|
104 } |
|
105 else |
|
106 { |
|
107 // All other events. |
|
108 iPlayer.HandleEventToParent(aEvent); |
|
109 } |
|
110 } |
|
111 |
|
112 // END OF FILE |