gstrtspconnection.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /* GStreamer
  2. * Copyright (C) <2005,2009> Wim Taymans <[email protected]>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. /*
  20. * Unless otherwise indicated, Source Code is licensed under MIT license.
  21. * See further explanation attached in License Statement (distributed in the file
  22. * LICENSE).
  23. *
  24. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  25. * this software and associated documentation files (the "Software"), to deal in
  26. * the Software without restriction, including without limitation the rights to
  27. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  28. * of the Software, and to permit persons to whom the Software is furnished to do
  29. * so, subject to the following conditions:
  30. *
  31. * The above copyright notice and this permission notice shall be included in all
  32. * copies or substantial portions of the Software.
  33. *
  34. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  35. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  36. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  37. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  38. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  39. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  40. * SOFTWARE.
  41. */
  42. #ifndef __GST_RTSP_CONNECTION_H__
  43. #define __GST_RTSP_CONNECTION_H__
  44. #include <glib.h>
  45. #include <gst/gstconfig.h>
  46. #include <gst/rtsp/gstrtspdefs.h>
  47. #include <gst/rtsp/gstrtspurl.h>
  48. #include <gst/rtsp/gstrtspmessage.h>
  49. #include <gio/gio.h>
  50. G_BEGIN_DECLS
  51. /**
  52. * GstRTSPConnection:
  53. *
  54. * Opaque RTSP connection object.
  55. */
  56. typedef struct _GstRTSPConnection GstRTSPConnection;
  57. /* opening/closing a connection */
  58. GstRTSPResult gst_rtsp_connection_create (const GstRTSPUrl *url, GstRTSPConnection **conn);
  59. GstRTSPResult gst_rtsp_connection_create_from_socket (GSocket * socket,
  60. const gchar * ip,
  61. guint16 port,
  62. const gchar * initial_buffer,
  63. GstRTSPConnection ** conn);
  64. GstRTSPResult gst_rtsp_connection_accept (GSocket *socket, GstRTSPConnection **conn, GCancellable *cancellable);
  65. GstRTSPResult gst_rtsp_connection_connect (GstRTSPConnection *conn, GTimeVal *timeout);
  66. GstRTSPResult gst_rtsp_connection_close (GstRTSPConnection *conn);
  67. GstRTSPResult gst_rtsp_connection_free (GstRTSPConnection *conn);
  68. /* TLS connections */
  69. GTlsConnection * gst_rtsp_connection_get_tls (GstRTSPConnection * conn, GError ** error);
  70. gboolean gst_rtsp_connection_set_tls_validation_flags (GstRTSPConnection * conn, GTlsCertificateFlags flags);
  71. GTlsCertificateFlags gst_rtsp_connection_get_tls_validation_flags (GstRTSPConnection * conn);
  72. void gst_rtsp_connection_set_tls_database (GstRTSPConnection * conn, GTlsDatabase * database);
  73. GTlsDatabase * gst_rtsp_connection_get_tls_database (GstRTSPConnection * conn);
  74. /* sending/receiving raw bytes */
  75. GstRTSPResult gst_rtsp_connection_read (GstRTSPConnection * conn, guint8 * data,
  76. guint size, GTimeVal * timeout);
  77. GstRTSPResult gst_rtsp_connection_write (GstRTSPConnection * conn, const guint8 * data,
  78. guint size, GTimeVal * timeout);
  79. /* sending/receiving messages */
  80. GstRTSPResult gst_rtsp_connection_send (GstRTSPConnection *conn, GstRTSPMessage *message,
  81. GTimeVal *timeout);
  82. GstRTSPResult gst_rtsp_connection_receive (GstRTSPConnection *conn, GstRTSPMessage *message,
  83. GTimeVal *timeout);
  84. /* status management */
  85. GstRTSPResult gst_rtsp_connection_poll (GstRTSPConnection *conn, GstRTSPEvent events,
  86. GstRTSPEvent *revents, GTimeVal *timeout);
  87. /* reset the timeout */
  88. GstRTSPResult gst_rtsp_connection_next_timeout (GstRTSPConnection *conn, GTimeVal *timeout);
  89. GstRTSPResult gst_rtsp_connection_reset_timeout (GstRTSPConnection *conn);
  90. /* flushing state */
  91. GstRTSPResult gst_rtsp_connection_flush (GstRTSPConnection *conn, gboolean flush);
  92. /* HTTP proxy support */
  93. GstRTSPResult gst_rtsp_connection_set_proxy (GstRTSPConnection *conn,
  94. const gchar *host, guint port);
  95. /* configure authentication data */
  96. GstRTSPResult gst_rtsp_connection_set_auth (GstRTSPConnection *conn, GstRTSPAuthMethod method,
  97. const gchar *user, const gchar *pass);
  98. void gst_rtsp_connection_set_auth_param (GstRTSPConnection *conn,
  99. const gchar * param,
  100. const gchar *value);
  101. void gst_rtsp_connection_clear_auth_params (GstRTSPConnection *conn);
  102. /* configure DSCP */
  103. GstRTSPResult gst_rtsp_connection_set_qos_dscp (GstRTSPConnection *conn,
  104. guint qos_dscp);
  105. /* accessors */
  106. GstRTSPUrl * gst_rtsp_connection_get_url (const GstRTSPConnection *conn);
  107. const gchar * gst_rtsp_connection_get_ip (const GstRTSPConnection *conn);
  108. void gst_rtsp_connection_set_ip (GstRTSPConnection *conn, const gchar *ip);
  109. GSocket * gst_rtsp_connection_get_read_socket (const GstRTSPConnection *conn);
  110. GSocket * gst_rtsp_connection_get_write_socket (const GstRTSPConnection *conn);
  111. void gst_rtsp_connection_set_http_mode (GstRTSPConnection *conn,
  112. gboolean enable);
  113. /* tunneling */
  114. void gst_rtsp_connection_set_tunneled (GstRTSPConnection *conn, gboolean tunneled);
  115. gboolean gst_rtsp_connection_is_tunneled (const GstRTSPConnection *conn);
  116. const gchar * gst_rtsp_connection_get_tunnelid (const GstRTSPConnection *conn);
  117. GstRTSPResult gst_rtsp_connection_do_tunnel (GstRTSPConnection *conn, GstRTSPConnection *conn2);
  118. void gst_rtsp_connection_set_remember_session_id (GstRTSPConnection *conn, gboolean remember);
  119. gboolean gst_rtsp_connection_get_remember_session_id (GstRTSPConnection *conn);
  120. /* async IO */
  121. /**
  122. * GstRTSPWatch:
  123. *
  124. * Opaque RTSP watch object that can be used for asynchronous RTSP
  125. * operations.
  126. */
  127. typedef struct _GstRTSPWatch GstRTSPWatch;
  128. /**
  129. * GstRTSPWatchFuncs:
  130. * @message_received: callback when a message was received
  131. * @message_sent: callback when a message was sent
  132. * @closed: callback when the connection is closed
  133. * @error: callback when an error occured
  134. * @tunnel_start: a client started a tunneled connection. The tunnelid of the
  135. * connection must be saved.
  136. * @tunnel_complete: a client finished a tunneled connection. In this callback
  137. * you usually pair the tunnelid of this connection with the saved one using
  138. * gst_rtsp_connection_do_tunnel().
  139. * @error_full: callback when an error occured with more information than
  140. * the @error callback.
  141. * @tunnel_lost: callback when the post connection of a tunnel is closed.
  142. * @tunnel_http_response: callback when an HTTP response to the GET request
  143. * is about to be sent for a tunneled connection. The response can be
  144. * modified in the callback. Since 1.4.
  145. *
  146. * Callback functions from a #GstRTSPWatch.
  147. */
  148. typedef struct {
  149. GstRTSPResult (*message_received) (GstRTSPWatch *watch, GstRTSPMessage *message,
  150. gpointer user_data);
  151. GstRTSPResult (*message_sent) (GstRTSPWatch *watch, guint id,
  152. gpointer user_data);
  153. GstRTSPResult (*closed) (GstRTSPWatch *watch, gpointer user_data);
  154. GstRTSPResult (*error) (GstRTSPWatch *watch, GstRTSPResult result,
  155. gpointer user_data);
  156. GstRTSPStatusCode (*tunnel_start) (GstRTSPWatch *watch, gpointer user_data);
  157. GstRTSPResult (*tunnel_complete) (GstRTSPWatch *watch, gpointer user_data);
  158. GstRTSPResult (*error_full) (GstRTSPWatch *watch, GstRTSPResult result,
  159. GstRTSPMessage *message, guint id,
  160. gpointer user_data);
  161. GstRTSPResult (*tunnel_lost) (GstRTSPWatch *watch, gpointer user_data);
  162. GstRTSPResult (*tunnel_http_response) (GstRTSPWatch *watch,
  163. GstRTSPMessage *request,
  164. GstRTSPMessage *response,
  165. gpointer user_data);
  166. /*< private >*/
  167. gpointer _gst_reserved[GST_PADDING-1];
  168. } GstRTSPWatchFuncs;
  169. GstRTSPWatch * gst_rtsp_watch_new (GstRTSPConnection *conn,
  170. GstRTSPWatchFuncs *funcs,
  171. gpointer user_data,
  172. GDestroyNotify notify);
  173. void gst_rtsp_watch_reset (GstRTSPWatch *watch);
  174. void gst_rtsp_watch_unref (GstRTSPWatch *watch);
  175. guint gst_rtsp_watch_attach (GstRTSPWatch *watch,
  176. GMainContext *context);
  177. void gst_rtsp_watch_set_send_backlog (GstRTSPWatch *watch,
  178. gsize bytes, guint messages);
  179. void gst_rtsp_watch_get_send_backlog (GstRTSPWatch *watch,
  180. gsize *bytes, guint *messages);
  181. GstRTSPResult gst_rtsp_watch_write_data (GstRTSPWatch *watch,
  182. const guint8 *data,
  183. guint size, guint *id);
  184. GstRTSPResult gst_rtsp_watch_send_message (GstRTSPWatch *watch,
  185. GstRTSPMessage *message,
  186. guint *id);
  187. GstRTSPResult gst_rtsp_watch_wait_backlog (GstRTSPWatch * watch,
  188. GTimeVal *timeout);
  189. void gst_rtsp_watch_set_flushing (GstRTSPWatch * watch,
  190. gboolean flush);
  191. G_END_DECLS
  192. #endif /* __GST_RTSP_CONNECTION_H__ */