]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rtsp.h
Reindent
[ffmpeg] / libavformat / rtsp.h
index e88d365a10e83a8d3a435608db535934a0092798..a3222812825b1c7993ebd2f855317342ecd191d9 100644 (file)
@@ -121,6 +121,10 @@ typedef struct RTSPMessageHeader {
      * should be re-transmitted by the client in every RTSP command. */
     char session_id[512];
 
+    /** the "Location:" field. This value is used to handle redirection.
+     */
+    char location[4096];
+
     /** the "RealChallenge1:" field from the server */
     char real_challenge[64];
 
@@ -154,7 +158,7 @@ typedef struct RTSPMessageHeader {
  */
 enum RTSPClientState {
     RTSP_STATE_IDLE,    /**< not initialized */
-    RTSP_STATE_PLAYING, /**< initialized and receiving data */
+    RTSP_STATE_STREAMING, /**< initialized and sending/receiving data */
     RTSP_STATE_PAUSED,  /**< initialized, but not receiving data */
     RTSP_STATE_SEEKING, /**< initialized, requesting a seek */
 };
@@ -228,6 +232,9 @@ typedef struct RTSPState {
      * of RTSPMessageHeader->real_challenge */
     enum RTSPServerType server_type;
 
+    /** base64-encoded authorization lines (username:password) */
+    char *auth_b64;
+
     /** The last reply of the server to a RTSP command */
     char last_reply[2048]; /* XXX: allocate ? */
 
@@ -259,6 +266,14 @@ typedef struct RTSPState {
      * data packet in the bytecontext for each incoming RTSP packet. */
     uint64_t asf_pb_pos;
     //@}
+
+    /** some MS RTSP streams contain a URL in the SDP that we need to use
+     * for all subsequent RTSP requests, rather than the input URI; in
+     * other cases, this is a copy of AVFormatContext->filename. */
+    char control_uri[1024];
+
+    /** The synchronized start time of the output streams. */
+    int64_t start_time;
 } RTSPState;
 
 /**
@@ -269,7 +284,7 @@ typedef struct RTSPState {
  */
 typedef struct RTSPStream {
     URLContext *rtp_handle;   /**< RTP stream handle (if UDP) */
-    void *transport_priv; /**< RTP/RDT parse context */
+    void *transport_priv; /**< RTP/RDT parse context if input, RTP AVFormatContext if output */
 
     /** corresponding stream index, if any. -1 if none (MPEG2TS case) */
     int stream_index;
@@ -303,8 +318,7 @@ typedef struct RTSPStream {
     //@}
 } RTSPStream;
 
-int rtsp_init(void);
-void rtsp_parse_line(RTSPMessageHeader *reply, const char *buf);
+void ff_rtsp_parse_line(RTSPMessageHeader *reply, const char *buf);
 
 #if LIBAVFORMAT_VERSION_INT < (53 << 16)
 extern int rtsp_default_protocols;
@@ -312,7 +326,94 @@ extern int rtsp_default_protocols;
 extern int rtsp_rtp_port_min;
 extern int rtsp_rtp_port_max;
 
-int rtsp_pause(AVFormatContext *s);
-int rtsp_resume(AVFormatContext *s);
+/**
+ * Send a command to the RTSP server without waiting for the reply.
+ *
+ * @param s RTSP (de)muxer context
+ * @param cmd the full first line of the request
+ * @param send_content if non-null, the data to send as request body content
+ * @param send_content_length the length of the send_content data, or 0 if
+ *                            send_content is null
+ */
+void ff_rtsp_send_cmd_with_content_async(AVFormatContext *s,
+                                         const char *cmd,
+                                         const unsigned char *send_content,
+                                         int send_content_length);
+/**
+ * Send a command to the RTSP server without waiting for the reply.
+ *
+ * @see rtsp_send_cmd_with_content_async
+ */
+void ff_rtsp_send_cmd_async(AVFormatContext *s, const char *cmd);
+
+/**
+ * Send a command to the RTSP server and wait for the reply.
+ *
+ * @param s RTSP (de)muxer context
+ * @param cmd the full first line of the request
+ * @param reply pointer where the RTSP message header will be stored
+ * @param content_ptr pointer where the RTSP message body, if any, will
+ *                    be stored (length is in reply)
+ * @param send_content if non-null, the data to send as request body content
+ * @param send_content_length the length of the send_content data, or 0 if
+ *                            send_content is null
+ */
+void ff_rtsp_send_cmd_with_content(AVFormatContext *s,
+                                   const char *cmd,
+                                   RTSPMessageHeader *reply,
+                                   unsigned char **content_ptr,
+                                   const unsigned char *send_content,
+                                   int send_content_length);
+
+/**
+ * Send a command to the RTSP server and wait for the reply.
+ *
+ * @see rtsp_send_cmd_with_content
+ */
+void ff_rtsp_send_cmd(AVFormatContext *s, const char *cmd,
+                      RTSPMessageHeader *reply, unsigned char **content_ptr);
+
+/**
+ * Read a RTSP message from the server, or prepare to read data
+ * packets if we're reading data interleaved over the TCP/RTSP
+ * connection as well.
+ *
+ * @param s RTSP (de)muxer context
+ * @param reply pointer where the RTSP message header will be stored
+ * @param content_ptr pointer where the RTSP message body, if any, will
+ *                    be stored (length is in reply)
+ * @param return_on_interleaved_data whether the function may return if we
+ *                   encounter a data marker ('$'), which precedes data
+ *                   packets over interleaved TCP/RTSP connections. If this
+ *                   is set, this function will return 1 after encountering
+ *                   a '$'. If it is not set, the function will skip any
+ *                   data packets (if they are encountered), until a reply
+ *                   has been fully parsed. If no more data is available
+ *                   without parsing a reply, it will return an error.
+ *
+ * @returns 1 if a data packets is ready to be received, -1 on error,
+ *          and 0 on success.
+ */
+int ff_rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply,
+                       unsigned char **content_ptr,
+                       int return_on_interleaved_data);
+
+/**
+ * Connect to the RTSP server and set up the individual media streams.
+ * This can be used for both muxers and demuxers.
+ *
+ * @param s RTSP (de)muxer context
+ *
+ * @returns 0 on success, < 0 on error. Cleans up all allocations done
+ *          within the function on error.
+ */
+int ff_rtsp_connect(AVFormatContext *s);
+
+/**
+ * Close and free all streams within the RTSP (de)muxer
+ *
+ * @param s RTSP (de)muxer context
+ */
+void ff_rtsp_close_streams(AVFormatContext *s);
 
 #endif /* AVFORMAT_RTSP_H */