gst_plugins_base/gst-libs/gst/rtsp/gstrtspdefs.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    58 
    58 
    59 extern int h_errno;
    59 extern int h_errno;
    60 
    60 
    61 #include "gstrtspdefs.h"
    61 #include "gstrtspdefs.h"
    62 
    62 
    63 #ifdef G_OS_WIN32
    63 #ifndef G_OS_WIN32
    64 #include <winsock2.h>
       
    65 #else
       
    66 #include <netdb.h>
    64 #include <netdb.h>
    67 #endif
    65 #endif
    68 
    66 
    69 static const gchar *rtsp_results[] = {
    67 static const gchar *rtsp_results[] = {
    70   "OK",
    68   "OK",
    81   "Windows sockets are not version 0x202",
    79   "Windows sockets are not version 0x202",
    82   "Received end-of-file",
    80   "Received end-of-file",
    83   "Network error: %s",
    81   "Network error: %s",
    84   "Host is not a valid IP address",
    82   "Host is not a valid IP address",
    85   "Timeout while waiting for server response",
    83   "Timeout while waiting for server response",
    86   "Tunnel GET request received",
       
    87   "Tunnel POST request received",
       
    88   "Unknown error (%d)",
    84   "Unknown error (%d)",
    89   NULL
    85   NULL
    90 };
    86 };
    91 
    87 
    92 static const gchar *rtsp_methods[] = {
    88 static const gchar *rtsp_methods[] = {
   159   "SupportsMaximumASMBandwidth",        /* SupportsMaximumASMBandwidth */
   155   "SupportsMaximumASMBandwidth",        /* SupportsMaximumASMBandwidth */
   160   "Language",                   /* Language */
   156   "Language",                   /* Language */
   161   "PlayerStarttime",            /* PlayerStarttime */
   157   "PlayerStarttime",            /* PlayerStarttime */
   162 
   158 
   163   "Location",                   /* Location */
   159   "Location",                   /* Location */
   164   "ETag",                       /* ETag */
       
   165   "If-Match",                   /* If-Match */
       
   166 
       
   167   /* WM extensions [MS-RTSP] */
       
   168   "Accept-Charset",             /* Accept-Charset */
       
   169   "Supported",                  /* Supported */
       
   170   "Vary",                       /* Vary */
       
   171   "X-Accelerate-Streaming",     /* X-Accelerate-Streaming */
       
   172   "X-Accept-Authentication",    /* X-Accept-Authentication */
       
   173   "X-Accept-Proxy-Authentication",      /* X-Accept-Proxy-Authentication */
       
   174   "X-Broadcast-Id",             /* X-Broadcast-Id */
       
   175   "X-Burst-Streaming",          /* X-Burst-Streaming */
       
   176   "X-Notice",                   /* X-Notice */
       
   177   "X-Player-Lag-Time",          /* X-Player-Lag-Time */
       
   178   "X-Playlist",                 /* X-Playlist */
       
   179   "X-Playlist-Change-Notice",   /* X-Playlist-Change-Notice */
       
   180   "X-Playlist-Gen-Id",          /* X-Playlist-Gen-Id */
       
   181   "X-Playlist-Seek-Id",         /* X-Playlist-Seek-Id */
       
   182   "X-Proxy-Client-Agent",       /* X-Proxy-Client-Agent */
       
   183   "X-Proxy-Client-Verb",        /* X-Proxy-Client-Verb */
       
   184   "X-Receding-PlaylistChange",  /* X-Receding-PlaylistChange */
       
   185   "X-RTP-Info",                 /* X-RTP-Info */
       
   186   "X-StartupProfile",           /* X-StartupProfile */
       
   187   "Timestamp",                  /* Timestamp */
       
   188 
   160 
   189   NULL
   161   NULL
   190 };
   162 };
   191 
   163 
   192 #define DEF_STATUS(c, t) \
   164 #define DEF_STATUS(c, t) \
   269 
   241 
   270   idx = ABS (result);
   242   idx = ABS (result);
   271   idx = CLAMP (idx, 0, -GST_RTSP_ELAST);
   243   idx = CLAMP (idx, 0, -GST_RTSP_ELAST);
   272 
   244 
   273   switch (idx) {
   245   switch (idx) {
   274 #ifdef G_OS_WIN32
       
   275     case -GST_RTSP_ESYS:
       
   276     case -GST_RTSP_ENET:
       
   277     {
       
   278       gchar *msg = g_win32_error_message (WSAGetLastError ());
       
   279       res = g_strdup_printf (rtsp_results[idx], msg);
       
   280       g_free (msg);
       
   281       break;
       
   282     }
       
   283 #else
       
   284     case -GST_RTSP_ESYS:
   246     case -GST_RTSP_ESYS:
   285       res = g_strdup_printf (rtsp_results[idx], g_strerror (errno));
   247       res = g_strdup_printf (rtsp_results[idx], g_strerror (errno));
   286       break;
   248       break;
   287     case -GST_RTSP_ENET:
   249     case -GST_RTSP_ENET:
       
   250 #ifndef G_OS_WIN32
   288       res = g_strdup_printf (rtsp_results[idx], hstrerror (h_errno));
   251       res = g_strdup_printf (rtsp_results[idx], hstrerror (h_errno));
       
   252 #else
       
   253       res =
       
   254           g_strdup
       
   255           ("not supported on win32, implement me in a different way ??");
   289 #endif
   256 #endif
   290       break;
   257       break;
   291     case -GST_RTSP_ELAST:
   258     case -GST_RTSP_ELAST:
   292       res = g_strdup_printf (rtsp_results[idx], result);
   259       res = g_strdup_printf (rtsp_results[idx], result);
   293       break;
   260       break;
   419       return (1 << idx);
   386       return (1 << idx);
   420     }
   387     }
   421   }
   388   }
   422   return GST_RTSP_INVALID;
   389   return GST_RTSP_INVALID;
   423 }
   390 }
   424 
       
   425 /**
       
   426  * gst_rtsp_options_as_text:
       
   427  * @options: one or more #GstRTSPMethod
       
   428  *
       
   429  * Convert @options to a string.
       
   430  *
       
   431  * Returns: a new string of @options. g_free() after usage.
       
   432  *
       
   433  * Since: 0.10.23
       
   434  */
       
   435 gchar *
       
   436 gst_rtsp_options_as_text (GstRTSPMethod options)
       
   437 {
       
   438   GString *str;
       
   439 
       
   440   str = g_string_new ("");
       
   441 
       
   442   if (options & GST_RTSP_OPTIONS)
       
   443     g_string_append (str, "OPTIONS, ");
       
   444   if (options & GST_RTSP_DESCRIBE)
       
   445     g_string_append (str, "DESCRIBE, ");
       
   446   if (options & GST_RTSP_ANNOUNCE)
       
   447     g_string_append (str, "ANNOUNCE, ");
       
   448   if (options & GST_RTSP_GET_PARAMETER)
       
   449     g_string_append (str, "GET_PARAMETER, ");
       
   450   if (options & GST_RTSP_PAUSE)
       
   451     g_string_append (str, "PAUSE, ");
       
   452   if (options & GST_RTSP_PLAY)
       
   453     g_string_append (str, "PLAY, ");
       
   454   if (options & GST_RTSP_RECORD)
       
   455     g_string_append (str, "RECORD, ");
       
   456   if (options & GST_RTSP_REDIRECT)
       
   457     g_string_append (str, "REDIRECT, ");
       
   458   if (options & GST_RTSP_SETUP)
       
   459     g_string_append (str, "SETUP, ");
       
   460   if (options & GST_RTSP_SET_PARAMETER)
       
   461     g_string_append (str, "SET_PARAMETER, ");
       
   462   if (options & GST_RTSP_TEARDOWN)
       
   463     g_string_append (str, "TEARDOWN, ");
       
   464 
       
   465   /* remove trailing ", " if there is one */
       
   466   if (str->len > 2)
       
   467     str = g_string_truncate (str, str->len - 2);
       
   468 
       
   469   return g_string_free (str, FALSE);
       
   470 }