gst_plugins_base/gst-libs/gst/sdp/gstsdpmessage.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    67 
    67 
    68 #include <glib.h>               /* for G_OS_WIN32 */
    68 #include <glib.h>               /* for G_OS_WIN32 */
    69 #include <gst/gstinfo.h>        /* For GST_STR_NULL */
    69 #include <gst/gstinfo.h>        /* For GST_STR_NULL */
    70 
    70 
    71 #ifdef G_OS_WIN32
    71 #ifdef G_OS_WIN32
    72 /* ws2_32.dll has getaddrinfo and freeaddrinfo on Windows XP and later.
       
    73  * minwg32 headers check WINVER before allowing the use of these */
       
    74 #ifndef WINVER
       
    75 #define WINVER 0x0501
       
    76 #endif
       
    77 #ifdef _MSC_VER
    72 #ifdef _MSC_VER
    78 #include <Winsock2.h>
    73 #include <Winsock2.h>
    79 #endif
    74 #endif
    80 #include <ws2tcpip.h>
    75 #include <ws2tcpip.h>
    81 #else
    76 #else
   154 GstSDPResult gst_sdp_message_add_##method (GstSDPMessage *msg, type val) {   \
   149 GstSDPResult gst_sdp_message_add_##method (GstSDPMessage *msg, type val) {   \
   155   type v = dup_method (val);                                            \
   150   type v = dup_method (val);                                            \
   156   g_array_append_val (msg->field, v);                                   \
   151   g_array_append_val (msg->field, v);                                   \
   157   return GST_SDP_OK;                                                    \
   152   return GST_SDP_OK;                                                    \
   158 }
   153 }
       
   154 #ifdef __SYMBIAN32__
       
   155 EXPORT_C
       
   156 #endif
       
   157 
   159 
   158 
   160 static void
   159 static void
   161 gst_sdp_origin_init (GstSDPOrigin * origin)
   160 gst_sdp_origin_init (GstSDPOrigin * origin)
   162 {
   161 {
   163   FREE_STRING (origin->username);
   162   FREE_STRING (origin->username);
   327 {
   326 {
   328   struct addrinfo hints;
   327   struct addrinfo hints;
   329   struct addrinfo *ai;
   328   struct addrinfo *ai;
   330   struct addrinfo *res;
   329   struct addrinfo *res;
   331   gboolean ret = FALSE;
   330   gboolean ret = FALSE;
       
   331   int err;
   332 
   332 
   333   memset (&hints, 0, sizeof (hints));
   333   memset (&hints, 0, sizeof (hints));
   334   hints.ai_socktype = SOCK_DGRAM;
   334   hints.ai_socktype = SOCK_DGRAM;
   335 
   335 
   336   g_return_val_if_fail (host_name, FALSE);
   336   g_return_val_if_fail (host_name, FALSE);
   337 
   337 
   338   if (getaddrinfo (host_name, NULL, &hints, &res) < 0)
   338   if ((err = getaddrinfo (host_name, NULL, &hints, &res)) < 0)
   339     return FALSE;
   339     return FALSE;
   340 
   340 
   341   for (ai = res; !ret && ai; ai = ai->ai_next) {
   341   for (ai = res; !ret && ai; ai = ai->ai_next) {
   342     if (ai->ai_family == AF_INET)
   342     if (ai->ai_family == AF_INET)
   343       ret =
   343       ret =
  1740       break;
  1740       break;
  1741     case 'p':
  1741     case 'p':
  1742       gst_sdp_message_add_phone (c->msg, buffer);
  1742       gst_sdp_message_add_phone (c->msg, buffer);
  1743       break;
  1743       break;
  1744     case 'c':
  1744     case 'c':
  1745     {
  1745       READ_STRING (c->msg->connection.nettype);
  1746       GstSDPConnection conn;
  1746       READ_STRING (c->msg->connection.addrtype);
  1747       gchar *str2;
  1747       READ_STRING (c->msg->connection.address);
  1748 
  1748       READ_UINT (c->msg->connection.ttl);
  1749       memset (&conn, 0, sizeof (conn));
  1749       READ_UINT (c->msg->connection.addr_number);
  1750 
       
  1751       str2 = p;
       
  1752       while ((str2 = strchr (str2, '/')))
       
  1753         *str2++ = ' ';
       
  1754       READ_STRING (conn.nettype);
       
  1755       READ_STRING (conn.addrtype);
       
  1756       READ_STRING (conn.address);
       
  1757       READ_UINT (conn.ttl);
       
  1758       READ_UINT (conn.addr_number);
       
  1759 
       
  1760       if (c->state == SDP_SESSION) {
       
  1761         gst_sdp_message_set_connection (c->msg, conn.nettype, conn.addrtype,
       
  1762             conn.address, conn.ttl, conn.addr_number);
       
  1763       } else {
       
  1764         gst_sdp_media_add_connection (c->media, conn.nettype, conn.addrtype,
       
  1765             conn.address, conn.ttl, conn.addr_number);
       
  1766       }
       
  1767       gst_sdp_connection_init (&conn);
       
  1768       break;
  1750       break;
  1769     }
       
  1770     case 'b':
  1751     case 'b':
  1771     {
  1752     {
  1772       gchar str2[MAX_LINE_LEN];
  1753       gchar str2[MAX_LINE_LEN];
  1773 
  1754 
  1774       read_string_del (str, sizeof (str), ':', &p);
  1755       read_string_del (str, sizeof (str), ':', &p);
  1775       if (*p != '\0')
       
  1776         p++;
       
  1777       read_string (str2, sizeof (str2), &p);
  1756       read_string (str2, sizeof (str2), &p);
  1778       if (c->state == SDP_SESSION)
  1757       if (c->state == SDP_SESSION)
  1779         gst_sdp_message_add_bandwidth (c->msg, str, atoi (str2));
  1758         gst_sdp_message_add_bandwidth (c->msg, str, atoi (str2));
  1780       else
  1759       else
  1781         gst_sdp_media_add_bandwidth (c->media, str, atoi (str2));
  1760         gst_sdp_media_add_bandwidth (c->media, str, atoi (str2));
  1894 }
  1873 }
  1895 
  1874 
  1896 static void
  1875 static void
  1897 print_media (GstSDPMedia * media)
  1876 print_media (GstSDPMedia * media)
  1898 {
  1877 {
  1899   g_print ("   media:       '%s'\n", GST_STR_NULL (media->media));
  1878   g_print ("   media:       '%s'\n", media->media);
  1900   g_print ("   port:        '%u'\n", media->port);
  1879   g_print ("   port:        '%u'\n", media->port);
  1901   g_print ("   num_ports:   '%u'\n", media->num_ports);
  1880   g_print ("   num_ports:   '%u'\n", media->num_ports);
  1902   g_print ("   proto:       '%s'\n", GST_STR_NULL (media->proto));
  1881   g_print ("   proto:       '%s'\n", media->proto);
  1903   if (media->fmts->len > 0) {
  1882   if (media->fmts->len > 0) {
  1904     guint i;
  1883     guint i;
  1905 
  1884 
  1906     g_print ("   formats:\n");
  1885     g_print ("   formats:\n");
  1907     for (i = 0; i < media->fmts->len; i++) {
  1886     for (i = 0; i < media->fmts->len; i++) {
  1908       g_print ("    format  '%s'\n", g_array_index (media->fmts, gchar *, i));
  1887       g_print ("    format  '%s'\n", g_array_index (media->fmts, gchar *, i));
  1909     }
  1888     }
  1910   }
  1889   }
  1911   g_print ("   information: '%s'\n", GST_STR_NULL (media->information));
  1890   g_print ("   information: '%s'\n", media->information);
  1912   if (media->connections->len > 0) {
       
  1913     guint i;
       
  1914 
       
  1915     g_print ("   connections:\n");
       
  1916     for (i = 0; i < media->connections->len; i++) {
       
  1917       GstSDPConnection *conn =
       
  1918           &g_array_index (media->connections, GstSDPConnection, i);
       
  1919 
       
  1920       g_print ("    nettype:      '%s'\n", GST_STR_NULL (conn->nettype));
       
  1921       g_print ("    addrtype:     '%s'\n", GST_STR_NULL (conn->addrtype));
       
  1922       g_print ("    address:      '%s'\n", GST_STR_NULL (conn->address));
       
  1923       g_print ("    ttl:          '%u'\n", conn->ttl);
       
  1924       g_print ("    addr_number:  '%u'\n", conn->addr_number);
       
  1925     }
       
  1926   }
       
  1927   if (media->bandwidths->len > 0) {
       
  1928     guint i;
       
  1929 
       
  1930     g_print ("   bandwidths:\n");
       
  1931     for (i = 0; i < media->bandwidths->len; i++) {
       
  1932       GstSDPBandwidth *bw =
       
  1933           &g_array_index (media->bandwidths, GstSDPBandwidth, i);
       
  1934 
       
  1935       g_print ("    type:         '%s'\n", GST_STR_NULL (bw->bwtype));
       
  1936       g_print ("    bandwidth:    '%u'\n", bw->bandwidth);
       
  1937     }
       
  1938   }
       
  1939   g_print ("   key:\n");
  1891   g_print ("   key:\n");
  1940   g_print ("    type:       '%s'\n", GST_STR_NULL (media->key.type));
  1892   g_print ("    type:       '%s'\n", media->key.type);
  1941   g_print ("    data:       '%s'\n", GST_STR_NULL (media->key.data));
  1893   g_print ("    data:       '%s'\n", media->key.data);
  1942   if (media->attributes->len > 0) {
  1894   if (media->attributes->len > 0) {
  1943     guint i;
  1895     guint i;
  1944 
  1896 
  1945     g_print ("   attributes:\n");
  1897     g_print ("   attributes:\n");
  1946     for (i = 0; i < media->attributes->len; i++) {
  1898     for (i = 0; i < media->attributes->len; i++) {
  1998   g_print ("  nettype:      '%s'\n", GST_STR_NULL (msg->connection.nettype));
  1950   g_print ("  nettype:      '%s'\n", GST_STR_NULL (msg->connection.nettype));
  1999   g_print ("  addrtype:     '%s'\n", GST_STR_NULL (msg->connection.addrtype));
  1951   g_print ("  addrtype:     '%s'\n", GST_STR_NULL (msg->connection.addrtype));
  2000   g_print ("  address:      '%s'\n", GST_STR_NULL (msg->connection.address));
  1952   g_print ("  address:      '%s'\n", GST_STR_NULL (msg->connection.address));
  2001   g_print ("  ttl:          '%u'\n", msg->connection.ttl);
  1953   g_print ("  ttl:          '%u'\n", msg->connection.ttl);
  2002   g_print ("  addr_number:  '%u'\n", msg->connection.addr_number);
  1954   g_print ("  addr_number:  '%u'\n", msg->connection.addr_number);
  2003   if (msg->bandwidths->len > 0) {
       
  2004     guint i;
       
  2005 
       
  2006     g_print (" bandwidths:\n");
       
  2007     for (i = 0; i < msg->bandwidths->len; i++) {
       
  2008       GstSDPBandwidth *bw =
       
  2009           &g_array_index (msg->bandwidths, GstSDPBandwidth, i);
       
  2010 
       
  2011       g_print ("  type:         '%s'\n", GST_STR_NULL (bw->bwtype));
       
  2012       g_print ("  bandwidth:    '%u'\n", bw->bandwidth);
       
  2013     }
       
  2014   }
       
  2015   g_print (" key:\n");
  1955   g_print (" key:\n");
  2016   g_print ("  type:         '%s'\n", GST_STR_NULL (msg->key.type));
  1956   g_print ("  type:         '%s'\n", GST_STR_NULL (msg->key.type));
  2017   g_print ("  data:         '%s'\n", GST_STR_NULL (msg->key.data));
  1957   g_print ("  data:         '%s'\n", GST_STR_NULL (msg->key.data));
  2018   if (msg->attributes->len > 0) {
  1958   if (msg->attributes->len > 0) {
  2019     guint i;
  1959     guint i;