|
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 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: |
|
15 * Implementation of Scheme handler interface implementation for rtsp:// scheme |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "RtspHandler.h" |
|
24 #include "SchemeDispLogger.h" |
|
25 #include <ECom.h> // For REComSession |
|
26 #include <eikenv.h> |
|
27 #include <DocumentHandler.h> |
|
28 #include <apgcli.h> |
|
29 #include <apparc.h> |
|
30 #include <eikdoc.h> |
|
31 #include <eikproc.h> |
|
32 #include <f32file.h> |
|
33 #include <AknLaunchAppService.h> |
|
34 |
|
35 // ================= CONSTANTS ======================= |
|
36 |
|
37 LOCAL_C const TUid KUidMediaPlayer = { 0x10005A3E }; |
|
38 _LIT( KRtspFileName, "c:\\system\\temp\\RtspTemp.ram" ); |
|
39 |
|
40 // ================= MEMBER FUNCTIONS ======================= |
|
41 |
|
42 // --------------------------------------------------------- |
|
43 // CRtspHandler::NewL() |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 CRtspHandler* CRtspHandler::NewL( const TDesC& aUrl ) |
|
47 { |
|
48 CLOG_ENTERFN( "CRtspHandler::NewL()" ); |
|
49 |
|
50 CRtspHandler* self=new(ELeave) CRtspHandler(); |
|
51 CleanupStack::PushL(self); |
|
52 self->ConstructL( aUrl ); |
|
53 CleanupStack::Pop(self); |
|
54 |
|
55 CLOG_LEAVEFN( "CRtspHandler::NewL()" ); |
|
56 |
|
57 return self; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // CRtspHandler::~CRtspHandler() |
|
62 // --------------------------------------------------------- |
|
63 // |
|
64 CRtspHandler::~CRtspHandler() |
|
65 { |
|
66 CLOG_ENTERFN( "CRtspHandler::~CRtspHandler()" ); |
|
67 |
|
68 if(iDoc != NULL) |
|
69 { |
|
70 CEikProcess* hostProcess = CEikonEnv::Static()->Process(); |
|
71 hostProcess->DestroyDocument(iDoc); |
|
72 iDoc = NULL; |
|
73 } |
|
74 |
|
75 if( iLaunchAppService ) |
|
76 { |
|
77 delete iLaunchAppService; |
|
78 } |
|
79 |
|
80 if( iDocHandler ) |
|
81 { |
|
82 delete iDocHandler; |
|
83 } |
|
84 |
|
85 CLOG_LEAVEFN( "CRtspHandler::~CRtspHandler()" ); |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // CRtspHandler::CRtspHandler() |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 CRtspHandler::CRtspHandler() : CBaseHandler() |
|
93 { |
|
94 // Deliberately do nothing here : See ConstructL() for initialisation completion. |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------- |
|
98 // CRtspHandler::ConstructL() |
|
99 // --------------------------------------------------------- |
|
100 // |
|
101 void CRtspHandler::ConstructL( const TDesC& aUrl ) |
|
102 { |
|
103 BaseConstructL( aUrl ); |
|
104 |
|
105 iSync = EFalse; |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------- |
|
109 // CRtspHandler::HandleUrlEmbeddedL() |
|
110 // --------------------------------------------------------- |
|
111 // |
|
112 void CRtspHandler::HandleUrlEmbeddedL() |
|
113 { |
|
114 CLOG_ENTERFN( "CRtspHandler::HandleUrlEmbeddedL()" ); |
|
115 |
|
116 /* Launch the appropriate application in embedded mode */ |
|
117 |
|
118 CLOG_WRITE(" :launching RTSP url via temp RAM file"); |
|
119 // |
|
120 RFs rfs; |
|
121 RFile ramFile; |
|
122 |
|
123 // 8-bit buffer is required. |
|
124 HBufC8* urlBuf = HBufC8::NewLC( iParsedUrl->Size() ); |
|
125 CLOG_WRITE(" :HBufC8::NewL() ok"); |
|
126 urlBuf->Des().Copy( *iParsedUrl ); |
|
127 // Open the file. |
|
128 User::LeaveIfError(rfs.Connect()); |
|
129 CleanupClosePushL(rfs); |
|
130 |
|
131 // Replace file if exists or Create file if not exist yet |
|
132 User::LeaveIfError( ramFile.Replace( rfs, KRtspFileName, EFileWrite | EFileShareAny ) ); |
|
133 CleanupClosePushL(ramFile); |
|
134 |
|
135 // Write to file |
|
136 User::LeaveIfError( ramFile.Write( *urlBuf ) ); |
|
137 ramFile.Flush(); |
|
138 ramFile.Close(); |
|
139 |
|
140 CleanupStack::PopAndDestroy(/*ramFile*/); |
|
141 CleanupStack::PopAndDestroy(/*rfs*/); |
|
142 CleanupStack::PopAndDestroy( /*urlBuf*/ ); |
|
143 |
|
144 RFile ramDocTempFile; |
|
145 if( !iDocHandler ) |
|
146 { |
|
147 iDocHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() ); |
|
148 CLOG_WRITE(" :CDocumentHandler::NewL() ok"); |
|
149 } |
|
150 iDocHandler->SetExitObserver( this ); |
|
151 |
|
152 iDocHandler->OpenTempFileL( KRtspFileName, ramDocTempFile ); |
|
153 CLOG_WRITE(" :iDocHandler->OpenTempFileL() ok"); |
|
154 CleanupClosePushL( ramDocTempFile ); |
|
155 // |
|
156 TDataType dataType( _L8("audio/x-pn-realaudio") ); |
|
157 CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC(); |
|
158 TAiwVariant filename( _L8("c:\\system\\temp\\RtspTemp.ram") ); |
|
159 TAiwGenericParam param( EGenericParamFile, filename ); |
|
160 paramList->AppendL( param ); |
|
161 |
|
162 // Allow save among Options |
|
163 TBool allowSave( ETrue ); |
|
164 TAiwVariant allowSaveVariant( allowSave ); |
|
165 TAiwGenericParam genericParamAllowSave |
|
166 ( EGenericParamAllowSave, allowSaveVariant ); |
|
167 paramList->AppendL( genericParamAllowSave ); |
|
168 |
|
169 // If iParamList is not empty, let's get it and attach to the paramlist |
|
170 if (iParamList) |
|
171 { |
|
172 paramList->AppendL(*iParamList); |
|
173 } |
|
174 |
|
175 // launch RAM file via DocHandler |
|
176 iDocHandler->OpenFileEmbeddedL( ramDocTempFile, dataType, *paramList ); |
|
177 CLOG_WRITE(" OpenFileEmbeddedL OK"); |
|
178 // |
|
179 CleanupStack::PopAndDestroy( paramList ); |
|
180 CleanupStack::PopAndDestroy( &ramDocTempFile ); |
|
181 |
|
182 CLOG_LEAVEFN( "CRtspHandler::HandleUrlEmbeddedL()" ); |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------- |
|
186 // CRtspHandler::HandleUrlStandaloneL() |
|
187 // --------------------------------------------------------- |
|
188 // |
|
189 void CRtspHandler::HandleUrlStandaloneL() |
|
190 { |
|
191 CLOG_ENTERFN( "CRtspHandler::HandleUrlStandaloneL()" ); |
|
192 |
|
193 RApaLsSession appArcSession; |
|
194 User::LeaveIfError( appArcSession.Connect() ); |
|
195 TThreadId id; |
|
196 |
|
197 appArcSession.StartDocument( iParsedUrl->Des(), KUidMediaPlayer , id ); |
|
198 |
|
199 appArcSession.Close(); |
|
200 |
|
201 CLOG_LEAVEFN( "CRtspHandler::HandleUrlStandaloneL()" ); |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------- |
|
205 // CRtspHandler::HandleServerAppExit() |
|
206 // --------------------------------------------------------- |
|
207 // |
|
208 void CRtspHandler::HandleServerAppExit(TInt aReason) |
|
209 { |
|
210 CLOG_ENTERFN( "CRtspHandler::HandleServerAppExit" ); |
|
211 |
|
212 if( iSync ) |
|
213 { |
|
214 if( iWait.IsStarted() ) |
|
215 { |
|
216 iWait.AsyncStop(); // stop the wait loop. |
|
217 } // Now DoMakeCallL will return |
|
218 } |
|
219 |
|
220 if( NULL != iSchemeDoc ) |
|
221 { |
|
222 iSchemeDoc->HandleServerAppExit( aReason ); |
|
223 } |
|
224 |
|
225 CLOG_LEAVEFN( "CRtspHandler::HandleServerAppExit" ); |
|
226 } |
|
227 |