OLD | NEW |
1 /* | 1 /* |
2 * RTSP definitions | 2 * RTSP definitions |
3 * Copyright (c) 2002 Fabrice Bellard | 3 * Copyright (c) 2002 Fabrice Bellard |
4 * | 4 * |
5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
6 * | 6 * |
7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 int notice; | 151 int notice; |
152 } RTSPMessageHeader; | 152 } RTSPMessageHeader; |
153 | 153 |
154 /** | 154 /** |
155 * Client state, i.e. whether we are currently receiving data (PLAYING) or | 155 * Client state, i.e. whether we are currently receiving data (PLAYING) or |
156 * setup-but-not-receiving (PAUSED). State can be changed in applications | 156 * setup-but-not-receiving (PAUSED). State can be changed in applications |
157 * by calling av_read_play/pause(). | 157 * by calling av_read_play/pause(). |
158 */ | 158 */ |
159 enum RTSPClientState { | 159 enum RTSPClientState { |
160 RTSP_STATE_IDLE, /**< not initialized */ | 160 RTSP_STATE_IDLE, /**< not initialized */ |
161 RTSP_STATE_PLAYING, /**< initialized and receiving data */ | 161 RTSP_STATE_STREAMING, /**< initialized and sending/receiving data */ |
162 RTSP_STATE_PAUSED, /**< initialized, but not receiving data */ | 162 RTSP_STATE_PAUSED, /**< initialized, but not receiving data */ |
163 RTSP_STATE_SEEKING, /**< initialized, requesting a seek */ | 163 RTSP_STATE_SEEKING, /**< initialized, requesting a seek */ |
164 }; | 164 }; |
165 | 165 |
166 /** | 166 /** |
167 * Identifies particular servers that require special handling, such as | 167 * Identifies particular servers that require special handling, such as |
168 * standards-incompliant "Transport:" lines in the SETUP request. | 168 * standards-incompliant "Transport:" lines in the SETUP request. |
169 */ | 169 */ |
170 enum RTSPServerType { | 170 enum RTSPServerType { |
171 RTSP_SERVER_RTP, /**< Standards-compliant RTP-server */ | 171 RTSP_SERVER_RTP, /**< Standards-compliant RTP-server */ |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 } RTSPState; | 274 } RTSPState; |
275 | 275 |
276 /** | 276 /** |
277 * Describes a single stream, as identified by a single m= line block in the | 277 * Describes a single stream, as identified by a single m= line block in the |
278 * SDP content. In the case of RDT, one RTSPStream can represent multiple | 278 * SDP content. In the case of RDT, one RTSPStream can represent multiple |
279 * AVStreams. In this case, each AVStream in this set has similar content | 279 * AVStreams. In this case, each AVStream in this set has similar content |
280 * (but different codec/bitrate). | 280 * (but different codec/bitrate). |
281 */ | 281 */ |
282 typedef struct RTSPStream { | 282 typedef struct RTSPStream { |
283 URLContext *rtp_handle; /**< RTP stream handle (if UDP) */ | 283 URLContext *rtp_handle; /**< RTP stream handle (if UDP) */ |
284 void *transport_priv; /**< RTP/RDT parse context */ | 284 void *transport_priv; /**< RTP/RDT parse context if input, RTP AVFormatConte
xt if output */ |
285 | 285 |
286 /** corresponding stream index, if any. -1 if none (MPEG2TS case) */ | 286 /** corresponding stream index, if any. -1 if none (MPEG2TS case) */ |
287 int stream_index; | 287 int stream_index; |
288 | 288 |
289 /** interleave IDs; copies of RTSPTransportField->interleaved_min/max | 289 /** interleave IDs; copies of RTSPTransportField->interleaved_min/max |
290 * for the selected transport. Only used for TCP. */ | 290 * for the selected transport. Only used for TCP. */ |
291 int interleaved_min, interleaved_max; | 291 int interleaved_min, interleaved_max; |
292 | 292 |
293 char control_url[1024]; /**< url for this stream (from SDP) */ | 293 char control_url[1024]; /**< url for this stream (from SDP) */ |
294 | 294 |
(...skipping 13 matching lines...) Expand all Loading... |
308 /** The following are used for dynamic protocols (rtp_*.c/rdt.c) */ | 308 /** The following are used for dynamic protocols (rtp_*.c/rdt.c) */ |
309 //@{ | 309 //@{ |
310 /** handler structure */ | 310 /** handler structure */ |
311 RTPDynamicProtocolHandler *dynamic_handler; | 311 RTPDynamicProtocolHandler *dynamic_handler; |
312 | 312 |
313 /** private data associated with the dynamic protocol */ | 313 /** private data associated with the dynamic protocol */ |
314 PayloadContext *dynamic_protocol_context; | 314 PayloadContext *dynamic_protocol_context; |
315 //@} | 315 //@} |
316 } RTSPStream; | 316 } RTSPStream; |
317 | 317 |
318 int rtsp_init(void); | 318 void ff_rtsp_parse_line(RTSPMessageHeader *reply, const char *buf); |
319 void rtsp_parse_line(RTSPMessageHeader *reply, const char *buf); | |
320 | 319 |
321 #if LIBAVFORMAT_VERSION_INT < (53 << 16) | 320 #if LIBAVFORMAT_VERSION_INT < (53 << 16) |
322 extern int rtsp_default_protocols; | 321 extern int rtsp_default_protocols; |
323 #endif | 322 #endif |
324 extern int rtsp_rtp_port_min; | 323 extern int rtsp_rtp_port_min; |
325 extern int rtsp_rtp_port_max; | 324 extern int rtsp_rtp_port_max; |
326 | 325 |
327 int rtsp_pause(AVFormatContext *s); | 326 /** |
328 int rtsp_resume(AVFormatContext *s); | 327 * Send a command to the RTSP server without waiting for the reply. |
| 328 * |
| 329 * @param s RTSP (de)muxer context |
| 330 * @param cmd the full first line of the request |
| 331 * @param send_content if non-null, the data to send as request body content |
| 332 * @param send_content_length the length of the send_content data, or 0 if |
| 333 * send_content is null |
| 334 */ |
| 335 void ff_rtsp_send_cmd_with_content_async(AVFormatContext *s, |
| 336 const char *cmd, |
| 337 const unsigned char *send_content, |
| 338 int send_content_length); |
| 339 /** |
| 340 * Send a command to the RTSP server without waiting for the reply. |
| 341 * |
| 342 * @see rtsp_send_cmd_with_content_async |
| 343 */ |
| 344 void ff_rtsp_send_cmd_async(AVFormatContext *s, const char *cmd); |
| 345 |
| 346 /** |
| 347 * Send a command to the RTSP server and wait for the reply. |
| 348 * |
| 349 * @param s RTSP (de)muxer context |
| 350 * @param cmd the full first line of the request |
| 351 * @param reply pointer where the RTSP message header will be stored |
| 352 * @param content_ptr pointer where the RTSP message body, if any, will |
| 353 * be stored (length is in reply) |
| 354 * @param send_content if non-null, the data to send as request body content |
| 355 * @param send_content_length the length of the send_content data, or 0 if |
| 356 * send_content is null |
| 357 */ |
| 358 void ff_rtsp_send_cmd_with_content(AVFormatContext *s, |
| 359 const char *cmd, |
| 360 RTSPMessageHeader *reply, |
| 361 unsigned char **content_ptr, |
| 362 const unsigned char *send_content, |
| 363 int send_content_length); |
| 364 |
| 365 /** |
| 366 * Send a command to the RTSP server and wait for the reply. |
| 367 * |
| 368 * @see rtsp_send_cmd_with_content |
| 369 */ |
| 370 void ff_rtsp_send_cmd(AVFormatContext *s, const char *cmd, |
| 371 RTSPMessageHeader *reply, unsigned char **content_ptr); |
| 372 |
| 373 /** |
| 374 * Read a RTSP message from the server, or prepare to read data |
| 375 * packets if we're reading data interleaved over the TCP/RTSP |
| 376 * connection as well. |
| 377 * |
| 378 * @param s RTSP (de)muxer context |
| 379 * @param reply pointer where the RTSP message header will be stored |
| 380 * @param content_ptr pointer where the RTSP message body, if any, will |
| 381 * be stored (length is in reply) |
| 382 * @param return_on_interleaved_data whether the function may return if we |
| 383 * encounter a data marker ('$'), which precedes data |
| 384 * packets over interleaved TCP/RTSP connections. If this |
| 385 * is set, this function will return 1 after encountering |
| 386 * a '$'. If it is not set, the function will skip any |
| 387 * data packets (if they are encountered), until a reply |
| 388 * has been fully parsed. If no more data is available |
| 389 * without parsing a reply, it will return an error. |
| 390 * |
| 391 * @returns 1 if a data packets is ready to be received, -1 on error, |
| 392 * and 0 on success. |
| 393 */ |
| 394 int ff_rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply, |
| 395 unsigned char **content_ptr, |
| 396 int return_on_interleaved_data); |
| 397 |
| 398 /** |
| 399 * Connect to the RTSP server and set up the individual media streams. |
| 400 * This can be used for both muxers and demuxers. |
| 401 * |
| 402 * @param s RTSP (de)muxer context |
| 403 * |
| 404 * @returns 0 on success, < 0 on error. Cleans up all allocations done |
| 405 * within the function on error. |
| 406 */ |
| 407 int ff_rtsp_connect(AVFormatContext *s); |
| 408 |
| 409 /** |
| 410 * Close and free all streams within the RTSP (de)muxer |
| 411 * |
| 412 * @param s RTSP (de)muxer context |
| 413 */ |
| 414 void ff_rtsp_close_streams(AVFormatContext *s); |
329 | 415 |
330 #endif /* AVFORMAT_RTSP_H */ | 416 #endif /* AVFORMAT_RTSP_H */ |
OLD | NEW |