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: Class for parsing and producing a response string of RTSP as rfc2326* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CCRRTSPRESPONSE_H |
|
21 #define CCRRTSPRESPONSE_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "CRRtspCommon.h" |
|
25 #include <e32base.h> |
|
26 |
|
27 // CONSTANTS |
|
28 // None |
|
29 |
|
30 // MACROS |
|
31 // None |
|
32 |
|
33 // DATA TYPES |
|
34 // None |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 // None |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * Class for parsing and producing RTSP responses. |
|
43 * |
|
44 * @lib CommonRecordingEngine.lib |
|
45 * @since Series 60 3.0 |
|
46 */ |
|
47 class CCRRtspResponse : public CCRRtspCommon |
|
48 { |
|
49 |
|
50 public: // Data types |
|
51 |
|
52 /** |
|
53 * RTSP response code. From RFC 2326 |
|
54 */ |
|
55 enum TResponseCode |
|
56 { |
|
57 ERTSPRespContinue = 100, |
|
58 ERTSPRespOK = 200, /**< OK code, everything ok */ |
|
59 ERTSPRespCreated = 201, /**< Same as 200 */ |
|
60 ERTSPRespLowOnStorageSpace = 250, |
|
61 ERTSPRespMultipleChoices = 300, |
|
62 ERTSPRespMovedPermanently = 301, |
|
63 ERTSPRespMovedTemporarily = 302, |
|
64 ERTSPRespSeeOther = 303, |
|
65 ERTSPRespNotModified = 304, |
|
66 ERTSPRespUseProxy = 305, |
|
67 ERTSPRespBadRequest = 400, |
|
68 ERTSPRespUnauthorized = 401 , /**< We must re-issue command with authentication headers */ |
|
69 ERTSPRespPaymentRequired = 402, |
|
70 ERTSPRespForbidden = 403, |
|
71 ERTSPRespNotFound = 404, |
|
72 ERTSPRespMethodNotAllowed = 405, |
|
73 ERTSPRespNotAcceptable = 406, |
|
74 ERTSPRespProxyAuthenticationRequired = 407 , /**< We must re-issue command with authentication headers */ |
|
75 ERTSPRespRequestTimeOut = 408, |
|
76 ERTSPRespGone = 410, |
|
77 ERTSPRespLengthRequired = 411, |
|
78 ERTSPRespPreconditionFailed = 412, |
|
79 ERTSPRespRequestEntityTooLarge = 413, |
|
80 ERTSPRespRequestURITooLarge = 414, |
|
81 ERTSPRespUnsupportedMediaType = 415, |
|
82 ERTSPRespParameterNotUnderstood = 451, |
|
83 ERTSPRespConferenceNotFound = 452, |
|
84 ERTSPRespNotEnoughBandwidth = 453, |
|
85 ERTSPRespSessionNotFound = 454, |
|
86 ERTSPRespMethodNotValidInThisState = 455, |
|
87 ERTSPRespHeaderFieldNotValidForResource = 456, |
|
88 ERTSPRespInvalidRange = 457, |
|
89 ERTSPRespParameterIsReadOnly = 458, |
|
90 ERTSPRespAggregateOperationNotAllowed = 459, |
|
91 ERTSPRespOnlyAggregateOperationAllowed = 460, |
|
92 ERTSPRespUnsupportedTransport = 461, |
|
93 ERTSPRespDestinationUnreachable = 462, |
|
94 ERTSPRespInternalServerError = 500, |
|
95 ERTSPRespNotImplemented = 501, |
|
96 ERTSPRespBadGateway = 502, |
|
97 ERTSPRespServiceUnavailable = 503, |
|
98 ERTSPRespGatewayTimeOut = 504, |
|
99 ERTSPRespRTSPVersionNotSupported = 505, |
|
100 ERTSPRespOptionNotSupported = 551 |
|
101 }; |
|
102 |
|
103 /** |
|
104 * Structure for storing rtp-info header contents. |
|
105 * if len of iFirstURL is zero, then the header has |
|
106 * not been seen or parsed. Normally rtp-info-header |
|
107 * has 2 urls and seq+ts for both. |
|
108 */ |
|
109 struct SRTPInfoHeader |
|
110 { |
|
111 TPtrC8 iFirstURL ; /**< URL string of first url found from header */ |
|
112 TUint iFirstSeq ; /**< Seq of first URL */ |
|
113 TUint iFirstTS ; /**< TS of first URL */ |
|
114 TPtrC8 iSecondURL ;/**< URL string of second url found from header */ |
|
115 TUint iSecondSeq ; /**< Seq of second URL */ |
|
116 TUint iSecondTS ; /**< TS of second URL */ |
|
117 }; |
|
118 |
|
119 public: // Constructors and destructor |
|
120 |
|
121 /** |
|
122 * Two-phased constructor. |
|
123 * @return CCRRtspResponse pointer to CCRRtspResponse class |
|
124 */ |
|
125 static CCRRtspResponse* NewL(); |
|
126 |
|
127 /** |
|
128 * Destructor. |
|
129 */ |
|
130 virtual ~CCRRtspResponse(); |
|
131 |
|
132 public: // New functions |
|
133 |
|
134 /** |
|
135 * Method that is used to give rtsp response to this class. |
|
136 * Response is something alike "RTSP/1.0 200 OK\rCSeq: 200000\r..." |
|
137 * @since Series 60 3.0 |
|
138 * @param aString is the response string. |
|
139 * @return none. May leave with symbian error codes. At least following may be |
|
140 * seen: KErrUnderflow if there is \r\n\r\n sequence in the string |
|
141 * marking end of response or if there is content (like SDP) and the |
|
142 * content lenght is too short; KErrNotSupported if it doesn't look |
|
143 * like RTSP at all. |
|
144 */ |
|
145 virtual void TryParseL( const TDesC8 &aString ); |
|
146 |
|
147 /** |
|
148 * Method for acquiring the response code from command string that was successfully |
|
149 * parsed. If TryParseL did leave, this may return anything. |
|
150 * @since Series 60 3.0 |
|
151 * @param none. |
|
152 * @return response code, like ERTSPRespOK if it was 200 OK. |
|
153 */ |
|
154 CCRRtspResponse::TResponseCode StatusCode( void ); |
|
155 |
|
156 /** |
|
157 * Method for getting server port. |
|
158 * @since Series 60 3.0 |
|
159 * @param none. |
|
160 * @return server port of KErrNotFound if none found. |
|
161 */ |
|
162 TInt ServerPort( void ); |
|
163 |
|
164 /** |
|
165 * Method for getting SSRC. |
|
166 * @since Series 60 3.0 |
|
167 * @param aSSRC is string descriptor allocated by caller that |
|
168 * will have its content set to block allocated by instance |
|
169 * of this class containing the SSRC. |
|
170 * @return KErrNone if no error, KErrNotFound if SSRC is not there. |
|
171 */ |
|
172 TInt SSRC( TPtrC8& aSSRC ); |
|
173 |
|
174 |
|
175 /** |
|
176 * Method for getting RTP-Info header. |
|
177 * @since Series 60 3.0 |
|
178 * @param aRTPInfoHeader is header struct allocated by caller that |
|
179 * will have its content set to strings (and numbers) allocated |
|
180 * by instance of this class so once instance of this class |
|
181 * is deleted, it is not wise to try referring to those |
|
182 * values any more. |
|
183 * @return KErrNone if no error, |
|
184 KErrNotFound if rtp-info header is not there. |
|
185 */ |
|
186 TInt RTPInfoHeader( CCRRtspResponse::SRTPInfoHeader &aRTPInfoHeader ); |
|
187 |
|
188 protected: // New Methods |
|
189 |
|
190 /** |
|
191 * Method for digging out server ports from (setup) reply |
|
192 * @since Series 60 3.0 |
|
193 * @param none. |
|
194 * @return none. |
|
195 */ |
|
196 void FindServerPorts( void ); |
|
197 |
|
198 /** |
|
199 * Method for digging out SSRC from (setup) reply |
|
200 * @since Series 60 3.0 |
|
201 * @param none. |
|
202 * @return none. |
|
203 */ |
|
204 void FindSSRC( void ); |
|
205 |
|
206 /** |
|
207 * Method for digging out and partially parsing RTP-Info -header |
|
208 * @since Series 60 3.0 |
|
209 * @param none. |
|
210 * @return none. |
|
211 */ |
|
212 void FindRTPInfoHeader( void ); |
|
213 |
|
214 /** |
|
215 * Method for digging out and partially parsing RTP-authentication -header |
|
216 * @since Series 60 3.0 |
|
217 * @param none. |
|
218 * @return none. |
|
219 */ |
|
220 void FindRTPAuthenticationL( void ); |
|
221 |
|
222 private: // Constructors and destructors |
|
223 |
|
224 /** |
|
225 * default constructor |
|
226 */ |
|
227 CCRRtspResponse( void ); |
|
228 |
|
229 /** |
|
230 * 2nd phase constructor |
|
231 */ |
|
232 void ConstructL(); |
|
233 |
|
234 private: // Data types |
|
235 |
|
236 /** |
|
237 * Code how the command went. |
|
238 */ |
|
239 TResponseCode iStatusCode; |
|
240 |
|
241 /** |
|
242 * Possible server port. |
|
243 */ |
|
244 TInt iServerPort; |
|
245 |
|
246 /** |
|
247 * Possible synchronization source id. |
|
248 */ |
|
249 TPtrC8 iSSRC; |
|
250 |
|
251 /** |
|
252 * Possible contents of rtp info header. |
|
253 */ |
|
254 SRTPInfoHeader iRTPInfoHeader; |
|
255 |
|
256 }; |
|
257 |
|
258 #endif // CCRRTSPRESPONSE_H |
|
259 |
|
260 // End of file |
|
261 |
|