326 { |
327 { |
327 struct addrinfo hints; |
328 struct addrinfo hints; |
328 struct addrinfo *ai; |
329 struct addrinfo *ai; |
329 struct addrinfo *res; |
330 struct addrinfo *res; |
330 gboolean ret = FALSE; |
331 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 ((err = getaddrinfo (host_name, NULL, &hints, &res)) < 0) |
338 if (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 READ_STRING (c->msg->connection.nettype); |
1745 { |
1746 READ_STRING (c->msg->connection.addrtype); |
1746 GstSDPConnection conn; |
1747 READ_STRING (c->msg->connection.address); |
1747 gchar *str2; |
1748 READ_UINT (c->msg->connection.ttl); |
1748 |
1749 READ_UINT (c->msg->connection.addr_number); |
1749 memset (&conn, 0, sizeof (conn)); |
|
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); |
1750 break; |
1768 break; |
|
1769 } |
1751 case 'b': |
1770 case 'b': |
1752 { |
1771 { |
1753 gchar str2[MAX_LINE_LEN]; |
1772 gchar str2[MAX_LINE_LEN]; |
1754 |
1773 |
1755 read_string_del (str, sizeof (str), ':', &p); |
1774 read_string_del (str, sizeof (str), ':', &p); |
|
1775 if (*p != '\0') |
|
1776 p++; |
1756 read_string (str2, sizeof (str2), &p); |
1777 read_string (str2, sizeof (str2), &p); |
1757 if (c->state == SDP_SESSION) |
1778 if (c->state == SDP_SESSION) |
1758 gst_sdp_message_add_bandwidth (c->msg, str, atoi (str2)); |
1779 gst_sdp_message_add_bandwidth (c->msg, str, atoi (str2)); |
1759 else |
1780 else |
1760 gst_sdp_media_add_bandwidth (c->media, str, atoi (str2)); |
1781 gst_sdp_media_add_bandwidth (c->media, str, atoi (str2)); |
1873 } |
1894 } |
1874 |
1895 |
1875 static void |
1896 static void |
1876 print_media (GstSDPMedia * media) |
1897 print_media (GstSDPMedia * media) |
1877 { |
1898 { |
1878 g_print (" media: '%s'\n", media->media); |
1899 g_print (" media: '%s'\n", GST_STR_NULL (media->media)); |
1879 g_print (" port: '%u'\n", media->port); |
1900 g_print (" port: '%u'\n", media->port); |
1880 g_print (" num_ports: '%u'\n", media->num_ports); |
1901 g_print (" num_ports: '%u'\n", media->num_ports); |
1881 g_print (" proto: '%s'\n", media->proto); |
1902 g_print (" proto: '%s'\n", GST_STR_NULL (media->proto)); |
1882 if (media->fmts->len > 0) { |
1903 if (media->fmts->len > 0) { |
1883 guint i; |
1904 guint i; |
1884 |
1905 |
1885 g_print (" formats:\n"); |
1906 g_print (" formats:\n"); |
1886 for (i = 0; i < media->fmts->len; i++) { |
1907 for (i = 0; i < media->fmts->len; i++) { |
1887 g_print (" format '%s'\n", g_array_index (media->fmts, gchar *, i)); |
1908 g_print (" format '%s'\n", g_array_index (media->fmts, gchar *, i)); |
1888 } |
1909 } |
1889 } |
1910 } |
1890 g_print (" information: '%s'\n", media->information); |
1911 g_print (" information: '%s'\n", GST_STR_NULL (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 } |
1891 g_print (" key:\n"); |
1939 g_print (" key:\n"); |
1892 g_print (" type: '%s'\n", media->key.type); |
1940 g_print (" type: '%s'\n", GST_STR_NULL (media->key.type)); |
1893 g_print (" data: '%s'\n", media->key.data); |
1941 g_print (" data: '%s'\n", GST_STR_NULL (media->key.data)); |
1894 if (media->attributes->len > 0) { |
1942 if (media->attributes->len > 0) { |
1895 guint i; |
1943 guint i; |
1896 |
1944 |
1897 g_print (" attributes:\n"); |
1945 g_print (" attributes:\n"); |
1898 for (i = 0; i < media->attributes->len; i++) { |
1946 for (i = 0; i < media->attributes->len; i++) { |
1950 g_print (" nettype: '%s'\n", GST_STR_NULL (msg->connection.nettype)); |
1998 g_print (" nettype: '%s'\n", GST_STR_NULL (msg->connection.nettype)); |
1951 g_print (" addrtype: '%s'\n", GST_STR_NULL (msg->connection.addrtype)); |
1999 g_print (" addrtype: '%s'\n", GST_STR_NULL (msg->connection.addrtype)); |
1952 g_print (" address: '%s'\n", GST_STR_NULL (msg->connection.address)); |
2000 g_print (" address: '%s'\n", GST_STR_NULL (msg->connection.address)); |
1953 g_print (" ttl: '%u'\n", msg->connection.ttl); |
2001 g_print (" ttl: '%u'\n", msg->connection.ttl); |
1954 g_print (" addr_number: '%u'\n", msg->connection.addr_number); |
2002 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 } |
1955 g_print (" key:\n"); |
2015 g_print (" key:\n"); |
1956 g_print (" type: '%s'\n", GST_STR_NULL (msg->key.type)); |
2016 g_print (" type: '%s'\n", GST_STR_NULL (msg->key.type)); |
1957 g_print (" data: '%s'\n", GST_STR_NULL (msg->key.data)); |
2017 g_print (" data: '%s'\n", GST_STR_NULL (msg->key.data)); |
1958 if (msg->attributes->len > 0) { |
2018 if (msg->attributes->len > 0) { |
1959 guint i; |
2019 guint i; |