gst_plugins_base/gst-libs/gst/rtsp/gstrtspconnection.h
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
     1 /* GStreamer
     1 /* GStreamer
     2  * Copyright (C) <2005,2009> Wim Taymans <wim.taymans@gmail.com>
     2  * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
     3  *
     3  *
     4  * This library is free software; you can redistribute it and/or
     4  * This library is free software; you can redistribute it and/or
     5  * modify it under the terms of the GNU Library General Public
     5  * modify it under the terms of the GNU Library General Public
     6  * License as published by the Free Software Foundation; either
     6  * License as published by the Free Software Foundation; either
     7  * version 2 of the License, or (at your option) any later version.
     7  * version 2 of the License, or (at your option) any later version.
    43 #ifndef __GST_RTSP_CONNECTION_H__
    43 #ifndef __GST_RTSP_CONNECTION_H__
    44 #define __GST_RTSP_CONNECTION_H__
    44 #define __GST_RTSP_CONNECTION_H__
    45 
    45 
    46 #include <glib.h>
    46 #include <glib.h>
    47 
    47 
    48 #include <gst/gstconfig.h>
       
    49 #include <gst/rtsp/gstrtspdefs.h>
    48 #include <gst/rtsp/gstrtspdefs.h>
    50 #include <gst/rtsp/gstrtspurl.h>
    49 #include <gst/rtsp/gstrtspurl.h>
    51 #include <gst/rtsp/gstrtspmessage.h>
    50 #include <gst/rtsp/gstrtspmessage.h>
    52 
    51 
    53 G_BEGIN_DECLS
    52 G_BEGIN_DECLS
    54 
    53 
       
    54 typedef struct _GstRTSPConnection GstRTSPConnection;
       
    55 
    55 /**
    56 /**
    56  * GstRTSPConnection:
    57  * GstRTSPConnection:
    57  *
    58  *
    58  * Opaque RTSP connection object.
    59  * Opaque RTSP connection object.
    59  */
    60  */
    60 typedef struct _GstRTSPConnection GstRTSPConnection;
    61 struct _GstRTSPConnection
       
    62 {
       
    63   /*< private >*/
       
    64   /* URL for the connection */
       
    65   GstRTSPUrl *url;
       
    66 
       
    67   /* connection state */
       
    68   GstPollFD   fd;
       
    69   GstPoll    *fdset;
       
    70   gchar      *ip;
       
    71 
       
    72   /* Session state */
       
    73   gint          cseq;                   /* sequence number */
       
    74   gchar         session_id[512];        /* session id */
       
    75   gint          timeout;                /* session timeout in seconds */
       
    76   GTimer       *timer;                  /* timeout timer */
       
    77 
       
    78   /* Authentication */
       
    79   GstRTSPAuthMethod  auth_method;
       
    80   gchar             *username;
       
    81   gchar             *passwd;
       
    82 };
    61 
    83 
    62 /* opening/closing a connection */
    84 /* opening/closing a connection */
    63 GstRTSPResult      gst_rtsp_connection_create        (const GstRTSPUrl *url, GstRTSPConnection **conn);
    85 GstRTSPResult      gst_rtsp_connection_create        (GstRTSPUrl *url, GstRTSPConnection **conn);
    64 GstRTSPResult      gst_rtsp_connection_accept        (gint sock, GstRTSPConnection **conn);
       
    65 GstRTSPResult      gst_rtsp_connection_connect       (GstRTSPConnection *conn, GTimeVal *timeout);
    86 GstRTSPResult      gst_rtsp_connection_connect       (GstRTSPConnection *conn, GTimeVal *timeout);
    66 GstRTSPResult      gst_rtsp_connection_close         (GstRTSPConnection *conn);
    87 GstRTSPResult      gst_rtsp_connection_close         (GstRTSPConnection *conn);
    67 GstRTSPResult      gst_rtsp_connection_free          (GstRTSPConnection *conn);
    88 GstRTSPResult      gst_rtsp_connection_free          (GstRTSPConnection *conn);
    68 
       
    69 
    89 
    70 /* sending/receiving raw bytes */
    90 /* sending/receiving raw bytes */
    71 GstRTSPResult      gst_rtsp_connection_read          (GstRTSPConnection * conn, guint8 * data,
    91 GstRTSPResult      gst_rtsp_connection_read          (GstRTSPConnection * conn, guint8 * data,
    72                                                       guint size, GTimeVal * timeout);
    92                                                       guint size, GTimeVal * timeout);
    73 GstRTSPResult      gst_rtsp_connection_write         (GstRTSPConnection * conn, const guint8 * data, 
    93 GstRTSPResult      gst_rtsp_connection_write         (GstRTSPConnection * conn, const guint8 * data, 
    88 GstRTSPResult      gst_rtsp_connection_reset_timeout (GstRTSPConnection *conn);
   108 GstRTSPResult      gst_rtsp_connection_reset_timeout (GstRTSPConnection *conn);
    89 
   109 
    90 /* flushing state */
   110 /* flushing state */
    91 GstRTSPResult      gst_rtsp_connection_flush         (GstRTSPConnection *conn, gboolean flush);
   111 GstRTSPResult      gst_rtsp_connection_flush         (GstRTSPConnection *conn, gboolean flush);
    92 
   112 
    93 /* HTTP proxy support */
   113 /* Configure Authentication data */
    94 GstRTSPResult      gst_rtsp_connection_set_proxy     (GstRTSPConnection *conn,
       
    95                                                       const gchar *host, guint port);
       
    96 
       
    97 /* configure authentication data */
       
    98 GstRTSPResult      gst_rtsp_connection_set_auth      (GstRTSPConnection *conn, GstRTSPAuthMethod method,
   114 GstRTSPResult      gst_rtsp_connection_set_auth      (GstRTSPConnection *conn, GstRTSPAuthMethod method,
    99                                                       const gchar *user, const gchar *pass);
   115                                                       const gchar *user, const gchar *pass);
   100 
       
   101 void               gst_rtsp_connection_set_auth_param    (GstRTSPConnection *conn,
       
   102 		                                          const gchar * param,
       
   103 							  const gchar *value);
       
   104 void               gst_rtsp_connection_clear_auth_params (GstRTSPConnection *conn);
       
   105 
       
   106 /* configure DSCP */
       
   107 GstRTSPResult      gst_rtsp_connection_set_qos_dscp  (GstRTSPConnection *conn,
       
   108                                                       guint qos_dscp);
       
   109 
       
   110 /* accessors */
       
   111 GstRTSPUrl *       gst_rtsp_connection_get_url       (const GstRTSPConnection *conn);
       
   112 const gchar *      gst_rtsp_connection_get_ip        (const GstRTSPConnection *conn);
       
   113 void               gst_rtsp_connection_set_ip        (GstRTSPConnection *conn, const gchar *ip);
       
   114 
       
   115 gint               gst_rtsp_connection_get_readfd    (const GstRTSPConnection *conn);
       
   116 gint               gst_rtsp_connection_get_writefd   (const GstRTSPConnection *conn);
       
   117 
       
   118 /* tunneling */
       
   119 void               gst_rtsp_connection_set_tunneled  (GstRTSPConnection *conn, gboolean tunneled);
       
   120 gboolean           gst_rtsp_connection_is_tunneled   (const GstRTSPConnection *conn);
       
   121 
       
   122 const gchar *      gst_rtsp_connection_get_tunnelid  (const GstRTSPConnection *conn);
       
   123 GstRTSPResult      gst_rtsp_connection_do_tunnel     (GstRTSPConnection *conn, GstRTSPConnection *conn2);
       
   124 
       
   125 /* async IO */
       
   126 
       
   127 /**
       
   128  * GstRTSPWatch:
       
   129  *
       
   130  * Opaque RTSP watch object that can be used for asynchronous RTSP
       
   131  * operations.
       
   132  */
       
   133 typedef struct _GstRTSPWatch GstRTSPWatch;
       
   134 
       
   135 /**
       
   136  * GstRTSPWatchFuncs:
       
   137  * @message_received: callback when a message was received
       
   138  * @message_sent: callback when a message was sent
       
   139  * @closed: callback when the connection is closed
       
   140  * @error: callback when an error occured
       
   141  * @tunnel_start: a client started a tunneled connection. The tunnelid of the
       
   142  *   connection must be saved.
       
   143  * @tunnel_complete: a client finished a tunneled connection. In this callback
       
   144  *   you usually pair the tunnelid of this connection with the saved one using
       
   145  *   gst_rtsp_connection_do_tunnel().
       
   146  *
       
   147  * Callback functions from a #GstRTSPWatch.
       
   148  *
       
   149  * Since: 0.10.23
       
   150  */
       
   151 typedef struct {
       
   152   GstRTSPResult     (*message_received) (GstRTSPWatch *watch, GstRTSPMessage *message,
       
   153                                          gpointer user_data);
       
   154   GstRTSPResult     (*message_sent)     (GstRTSPWatch *watch, guint id,
       
   155                                          gpointer user_data);
       
   156   GstRTSPResult     (*closed)           (GstRTSPWatch *watch, gpointer user_data);
       
   157   GstRTSPResult     (*error)            (GstRTSPWatch *watch, GstRTSPResult result,
       
   158                                          gpointer user_data);
       
   159   GstRTSPStatusCode (*tunnel_start)     (GstRTSPWatch *watch, gpointer user_data);
       
   160   GstRTSPResult     (*tunnel_complete)  (GstRTSPWatch *watch, gpointer user_data);
       
   161 
       
   162   /*< private >*/
       
   163   gpointer _gst_reserved[GST_PADDING];
       
   164 } GstRTSPWatchFuncs;
       
   165 
       
   166 GstRTSPWatch *     gst_rtsp_watch_new                (GstRTSPConnection *conn,
       
   167                                                       GstRTSPWatchFuncs *funcs,
       
   168 						      gpointer user_data,
       
   169 						      GDestroyNotify notify);
       
   170 void               gst_rtsp_watch_reset              (GstRTSPWatch *watch);
       
   171 void               gst_rtsp_watch_unref              (GstRTSPWatch *watch);
       
   172 
       
   173 guint              gst_rtsp_watch_attach             (GstRTSPWatch *watch,
       
   174                                                       GMainContext *context);
       
   175 
       
   176 guint              gst_rtsp_watch_queue_data         (GstRTSPWatch * watch,
       
   177                                                       const guint8 * data,
       
   178                                                       guint size);
       
   179 guint              gst_rtsp_watch_queue_message      (GstRTSPWatch *watch,
       
   180                                                       GstRTSPMessage *message);
       
   181 
   116 
   182 G_END_DECLS
   117 G_END_DECLS
   183 
   118 
   184 #endif /* __GST_RTSP_CONNECTION_H__ */
   119 #endif /* __GST_RTSP_CONNECTION_H__ */