|
1 /* |
|
2 * Copyright (c) 2004-2006 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: Provides a comfort noise generator class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #ifndef MCCMSRPSOURCE_H |
|
21 #define MCCMSRPSOURCE_H |
|
22 |
|
23 #include <e32std.h> |
|
24 #include "mccdatasource.h" |
|
25 #include "mmccevents.h" |
|
26 |
|
27 #include "mccdatareceiverobserver.h" |
|
28 #include "mccmsrpinterface.h" |
|
29 #include "mccmsrpdataobserver.h" |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 |
|
33 /** |
|
34 * |
|
35 */ |
|
36 class CMccMsrpSource: public CMccDataSource, public TMccMsrpSessionParams, public MMsrpDataObserver, public MMccDataReceiverObserver |
|
37 { |
|
38 |
|
39 public: // Methods called internally or by the controller |
|
40 |
|
41 /** |
|
42 * Two-phased constructor. |
|
43 */ |
|
44 static MDataSource* NewSourceL( TUid aImplementationUid, |
|
45 const TDesC8& aInitData ); |
|
46 |
|
47 void ConstructSourceL( const TDesC8& aInitData ); |
|
48 |
|
49 ~CMccMsrpSource(); |
|
50 |
|
51 public: // From MDataSource |
|
52 |
|
53 /** |
|
54 * From MDataSource. Returns the data type as a fourCC code of the data source. |
|
55 * |
|
56 * @since Series 60 3.0 |
|
57 * @param "aMediaId" |
|
58 * This identifies the type of media eg audio or video and the stream id. |
|
59 * Only KUidMediaTypeAudio -mediatype is supported. |
|
60 * @return The fourCC code identifying the source datatype for the specified aMediaId. |
|
61 */ |
|
62 TFourCC SourceDataTypeCode( TMediaId /*aMediaId*/ ); |
|
63 |
|
64 /** |
|
65 * From MDataSource. Sets the data type as a fourCC code for the data source |
|
66 * |
|
67 * @since Series 60 3.0 |
|
68 * @param "aSourceFourCC" |
|
69 * This specifies the data type as a fourCC code to set the source to. |
|
70 * |
|
71 * @param "aMediaId" |
|
72 * This identifies the type of media eg audio or video and the stream id. |
|
73 * Only KUidMediaTypeAudio -mediatype is supported. |
|
74 * |
|
75 * @return KErrNone if successful, KErrNotSupported if the source does not support having |
|
76 * it's data type set, otherwise a system wide error code. |
|
77 */ |
|
78 TInt SetSourceDataTypeCode( TFourCC aCodec, |
|
79 TMediaId aMedia ); |
|
80 |
|
81 /** |
|
82 * From MDataSource. Not used. Leaves with KErrNotSupported. |
|
83 * |
|
84 * @since Series 60 3.0 |
|
85 * @param "aBuffer" |
|
86 * The buffer that has been emptied by a data sink and is now available for reuse |
|
87 * @return None |
|
88 */ |
|
89 void BufferEmptiedL( CMMFBuffer* aBuffer ); |
|
90 |
|
91 /** |
|
92 * From MDataSource. Method to indicate whether the data source can create a buffer. |
|
93 * |
|
94 * @since Series 60 3.0 |
|
95 * |
|
96 * @return EFalse |
|
97 */ |
|
98 TBool CanCreateSourceBuffer(); |
|
99 |
|
100 /** |
|
101 * From MDataSource. Not used. Leaves with KErrNotSupported. |
|
102 * |
|
103 * @since Series 60 3.0 |
|
104 * @param "aMediaId" |
|
105 * This identifies the type of media eg audio or video and the stream id. |
|
106 * This parameter is required in cases where the source can supply data |
|
107 * of more than one media type and/or multiple strams of data eg a multimedia file. |
|
108 * |
|
109 * @param "aReference" |
|
110 * This must be written to by the method to indicate whether the created buffer is |
|
111 * a 'reference' buffer. A 'reference' buffer is a buffer that is owned by the source |
|
112 * and should be used in preference to the sink buffer provided the sink buffer |
|
113 * is also not a reference buffer. |
|
114 * . |
|
115 * @return The created buffer |
|
116 */ |
|
117 CMMFBuffer* CreateSourceBufferL( TMediaId, |
|
118 TBool& aReference ); |
|
119 |
|
120 /** |
|
121 * From MDataSource. Method to 'logon' the data source to the same thread that source will be supplying data in. |
|
122 * |
|
123 * Jitterbuffer for incoming packets and downlink timeout timer are created here. |
|
124 * |
|
125 * @param "aEventHandler" |
|
126 * This is an MAsyncEventHandler to handle asynchronous events that occur during the |
|
127 * transfer of multimedia data. The event handler must be in the same thread as the data transfer |
|
128 * thread - hence the reason it is passed in the SourceThreadLogon as opposed to say the constructor. |
|
129 * |
|
130 * |
|
131 * @return KErrNone if successful, otherwise a system wide error code. |
|
132 */ |
|
133 TInt SourceThreadLogon( MAsyncEventHandler& aEventHandler ); |
|
134 |
|
135 /** |
|
136 * From MDataSource. Method to 'logoff' the data source from the same thread that source supplies data in. |
|
137 * |
|
138 * Jitterbuffer for incoming packets and downlink timeout timer are deleted. Datasource deletes the |
|
139 * stream(s) and unregisters itself as an observer for the RTP session for incoming RTP and RTCP packets. |
|
140 * |
|
141 * @return None |
|
142 */ |
|
143 void SourceThreadLogoff(); |
|
144 |
|
145 /** |
|
146 * From MDataSource. Method to 'prime' the data source. |
|
147 * |
|
148 * Datasource is set to primed state. |
|
149 * |
|
150 * @since Series 60 3.0 |
|
151 * @return None |
|
152 */ |
|
153 void SourcePrimeL(); |
|
154 |
|
155 /** |
|
156 * From MDataSource. Method to 'play' the data source. |
|
157 * |
|
158 * Downlink timeout timer is started and datasource is set to playing state. |
|
159 * |
|
160 * @since Series 60 3.0 |
|
161 * @return None |
|
162 */ |
|
163 void SourcePlayL(); |
|
164 |
|
165 /** |
|
166 * From MDataSource. Method to 'pause' the data source. |
|
167 * |
|
168 * Downlink timeout timer is stopped and datasource is set to paused state. |
|
169 * |
|
170 * @since Series 60 3.0 |
|
171 * @return None |
|
172 */ |
|
173 void SourcePauseL(); |
|
174 |
|
175 /** |
|
176 * From MDataSource. Method to 'stop' the data source. |
|
177 * |
|
178 * Downlink timeout timer is stopped and datasource is set to stopped state. |
|
179 * |
|
180 * @since Series 60 3.0 |
|
181 * @return None |
|
182 */ |
|
183 void SourceStopL(); |
|
184 |
|
185 /** |
|
186 * From MDataSource. Method called by a MDataSink to request the data source to fill aBuffer with data. |
|
187 * |
|
188 * Datasource gets packet from jitterbuffer and forwards it to the payloadformatdecoder |
|
189 * for further processing. Datasource works synchronously; consumers BufferFilledL |
|
190 * is called when RTP packet is got succesfully from jitterbuffer. |
|
191 * |
|
192 * @since Series 60 3.0 |
|
193 * @param "aBuffer" |
|
194 * The buffer that needs filling with data |
|
195 * |
|
196 * @param "aConsumer" |
|
197 * The data sink that consumes the data. The data source needs this to make the BufferFilledL |
|
198 * callback on aConsumer when the data source has completed filling the aBuffer. |
|
199 * |
|
200 * @param "aMediaId" |
|
201 * This identifies the type of media eg audio or video and the stream id. |
|
202 * This parameter is required in cases where the source can supply data |
|
203 * of more than one media type and/or multiple strams of data eg a multimedia file. |
|
204 * @return None |
|
205 */ |
|
206 void FillBufferL( CMMFBuffer* aBuffer, |
|
207 MDataSink* aConsumer, |
|
208 TMediaId aMediaId ); |
|
209 |
|
210 /** |
|
211 * From MDataSource |
|
212 */ |
|
213 void NegotiateSourceL( MDataSink& aDataSink ); |
|
214 |
|
215 public: |
|
216 |
|
217 /** |
|
218 * A MSRP message has been received from the network. |
|
219 * This function is called when the MSRP message was received from the network |
|
220 * the ownership is transferred |
|
221 * @param aMessage the received message |
|
222 * @param aStatus, KErrNone with complete message, KErrCancel if terminated |
|
223 */ |
|
224 void IncomingMessage( HBufC8* aMessageContent, TInt aStatus ); |
|
225 |
|
226 /** |
|
227 * A MSRP REPORT message has been received from the network |
|
228 * This function is called to indicate to the client that a recipient |
|
229 * wishes to indicate a range of bytes as received. Alternative the |
|
230 * recipient might use REPORT to indicate an error. In case of error the |
|
231 * MSRP stops sending the message. However, it is client's responsibility |
|
232 * how the handle the information |
|
233 * @param aStatus status code from the REPORT message |
|
234 * @param aRangeStart start of byte range received |
|
235 * @param aRangeEnd end of byte range received |
|
236 * @param aTotal Total number of bytes in the message |
|
237 */ |
|
238 void IncomingReport( TInt aStatus, TInt aRangeStart, |
|
239 TInt aRangeEnd, TInt aTotal ); |
|
240 |
|
241 /** |
|
242 * The SendMessage status of the message sending |
|
243 * The possible status code are defined by CMSRPConnection::TMSRPErrorCodes |
|
244 * or system wide error codes |
|
245 * @param aStatus status of the operation |
|
246 * @param aMessageId message identifier of the sent message |
|
247 */ |
|
248 void SendResult( TInt aStatus, const TDesC8& aMessageid ); |
|
249 |
|
250 /** |
|
251 * If listen port request fails this is called |
|
252 * @param aStatus error code of the operation |
|
253 */ |
|
254 void ListenPortFailure( TInt aStatus ); |
|
255 |
|
256 |
|
257 //Connection Status |
|
258 TInt iConnectStatus; |
|
259 |
|
260 public: |
|
261 |
|
262 void DataReceivedL( const TDesC8& aData ); |
|
263 |
|
264 void SetSessionParamsL( const TMccMsrpSessionParams& aParams ); |
|
265 |
|
266 /** |
|
267 * @since Series 60 3.0 |
|
268 * |
|
269 * @param aMessageContent MSRP Payload |
|
270 * @return void |
|
271 */ |
|
272 void PlayoutMsrpPacketL( HBufC8* aMessageContent ); |
|
273 |
|
274 private: |
|
275 |
|
276 CMccMsrpSource(); |
|
277 |
|
278 void SendStreamEventToClient( TMccEventType aEventType, |
|
279 TInt aError = KErrNone ); |
|
280 |
|
281 private: |
|
282 |
|
283 // The client who requested "FillBuffer" |
|
284 MDataSink* iFillBufferRequester; |
|
285 |
|
286 MAsyncEventHandler* iAsyncEventHandler; |
|
287 TBool iPaused; |
|
288 TFourCC iFourCC; |
|
289 |
|
290 |
|
291 CMMFDataBuffer* iBufferToBeFilled; |
|
292 MDataSink* iConsumer; |
|
293 |
|
294 #ifdef EUNIT_TEST |
|
295 friend class UT_CMccMsrpSource; |
|
296 #endif |
|
297 |
|
298 }; |
|
299 |
|
300 |
|
301 #endif |
|
302 |
|
303 |
|
304 // End of file |