<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 9pt;
font-family:新細明體
}
</style>
</head>
<body class='hmmessage'>
Dear All:<BR>
I have port the rtsp test program on the Fedora 11,. The following is the code and it is modified from the test.c in the previous version of gst-plugins-base. I use live555 media server to do the rtsp server. <BR>
When I built and run it, it will stop when the "PLAY" finishs. I use the sniffer and I am sure the server start to sending the data. After a while, the gst_rtsp_connection_receive return -11. Do someone help me? Thanks!<BR>
<BR>
<BR>
gstream version:0.10.24-1.fc11<BR>
gst-plugin-base version:0.10.23-3.fc11<BR>
<BR>
//The console display<BR>
<BR>
[felix@Felix-NB test_rtsp]$ ./run<BR>parsing url "rtsp://192.168.11.167/sd.ts"...<BR> url host: 192.168.11.167<BR> url port: 0<BR> url path: /sd.ts<BR>creating connection...<BR>opening connection...<BR>RTSP request message 0xbfe22800<BR> request line:<BR> method: 'DESCRIBE'<BR> uri: 'rtsp://192.168.11.167/sd.ts'<BR> version: '1.0'<BR> headers:<BR> key: 'Accept', value: 'application/sdp'<BR> body:<BR>RTSP response message 0xbfe227e4<BR> status line:<BR> code: '200'<BR> reason: 'OK'<BR> version: '1.0'<BR> headers:<BR> key: 'CSeq', value: '1'<BR> key: 'Date', value: 'Thu, Aug 13 2009 09:38:43 GMT'<BR> key: 'Content-Base', value: 'rtsp://192.168.11.167/sd.ts/'<BR> key: 'Content-Type', value: 'application/sdp'<BR> key: 'Content-Length', value: '376'<BR> body: length 377<BR>00000000 (0x87608e0): 76 3d 30 0d 0a 6f 3d 2d 20 31 32 35 30 31 34 37 v=0..o=- 1250147<BR>00000010 (0x87608f0): 39 39 39 36 39 38 31 34 32 20 31 20 49 4e 20 49 999698142 1 IN I<BR>00000020 (0x8760900): 50 34 20 31 30 2e 31 34 34 2e 32 34 2e 38 0d 0a P4 10.144.24.8..<BR>00000030 (0x8760910): 73 3d 4d 50 45 47 20 54 72 61 6e 73 70 6f 72 74 s=MPEG Transport<BR>00000040 (0x8760920): 20 53 74 72 65 61 6d 2c 20 73 74 72 65 61 6d 65 Stream, streame<BR>00000050 (0x8760930): 64 20 62 79 20 74 68 65 20 4c 49 56 45 35 35 35 d by the LIVE555<BR>00000060 (0x8760940): 20 4d 65 64 69 61 20 53 65 72 76 65 72 0d 0a 69 Media Server..i<BR>00000070 (0x8760950): 3d 73 64 2e 74 73 0d 0a 74 3d 30 20 30 0d 0a 61 =sd.ts..t=0 0..a<BR>00000080 (0x8760960): 3d 74 6f 6f 6c 3a 4c 49 56 45 35 35 35 20 53 74 =tool:LIVE555 St<BR>00000090 (0x8760970): 72 65 61 6d 69 6e 67 20 4d 65 64 69 61 20 76 32 reaming Media v2<BR>000000a0 (0x8760980): 30 30 39 2e 30 37 2e 30 39 0d 0a 61 3d 74 79 70 009.07.09..a=typ<BR>000000b0 (0x8760990): 65 3a 62 72 6f 61 64 63 61 73 74 0d 0a 61 3d 63 e:broadcast..a=c<BR>000000c0 (0x87609a0): 6f 6e 74 72 6f 6c 3a 2a 0d 0a 61 3d 72 61 6e 67 ontrol:*..a=rang<BR>000000d0 (0x87609b0): 65 3a 6e 70 74 3d 30 2d 0d 0a 61 3d 78 2d 71 74 e:npt=0-..a=x-qt<BR>000000e0 (0x87609c0): 2d 74 65 78 74 2d 6e 61 6d 3a 4d 50 45 47 20 54 -text-nam:MPEG T<BR>000000f0 (0x87609d0): 72 61 6e 73 70 6f 72 74 20 53 74 72 65 61 6d 2c ransport Stream,<BR>00000100 (0x87609e0): 20 73 74 72 65 61 6d 65 64 20 62 79 20 74 68 65 streamed by the<BR>00000110 (0x87609f0): 20 4c 49 56 45 35 35 35 20 4d 65 64 69 61 20 53 LIVE555 Media S<BR>00000120 (0x8760a00): 65 72 76 65 72 0d 0a 61 3d 78 2d 71 74 2d 74 65 erver..a=x-qt-te<BR>00000130 (0x8760a10): 78 74 2d 69 6e 66 3a 73 64 2e 74 73 0d 0a 6d 3d xt-inf:sd.ts..m=<BR>00000140 (0x8760a20): 76 69 64 65 6f 20 30 20 52 54 50 2f 41 56 50 20 video 0 RTP/AVP<BR>00000150 (0x8760a30): 33 33 0d 0a 63 3d 49 4e 20 49 50 34 20 30 2e 30 33..c=IN IP4 0.0<BR>00000160 (0x8760a40): 2e 30 2e 30 0d 0a 61 3d 63 6f 6e 74 72 6f 6c 3a .0.0..a=control:<BR>00000170 (0x8760a50): 74 72 61 63 6b 31 0d 0a 00 track1...<BR>sdp packet 0xbfe22784:<BR> version: '0'<BR> origin:<BR> username: '-'<BR> sess_id: '1250147999698142'<BR> sess_version: '1'<BR> nettype: 'IN'<BR> addrtype: 'IP4'<BR> addr: '10.144.24.8'<BR> session_name: 'MPEG Transport Stream, streamed by the LIVE555 Media Server'<BR> information: 'sd.ts'<BR> uri: '(NULL)'<BR> connection:<BR> nettype: '(NULL)'<BR> addrtype: '(NULL)'<BR> address: '(NULL)'<BR> ttl: '0'<BR> addr_number: '0'<BR> key:<BR> type: '(NULL)'<BR> data: '(NULL)'<BR> attributes:<BR> attribute 'tool' : 'LIVE555 Streaming Media v2009.07.09'<BR> attribute 'type' : 'broadcast'<BR> attribute 'control' : '*'<BR> attribute 'range' : 'npt=0-'<BR> attribute 'x-qt-text-nam' : 'MPEG Transport Stream, streamed by the LIVE555 Media Server'<BR> attribute 'x-qt-text-inf' : 'sd.ts'<BR> medias:<BR> media 0:<BR> media: 'video'<BR> port: '0'<BR> num_ports: '4294967295'<BR> proto: 'RTP/AVP'<BR> formats:<BR> format '33'<BR> information: '(NULL)'<BR> connections:<BR> nettype: 'IN'<BR> addrtype: 'IP4'<BR> address: '0.0.0.0'<BR> ttl: '0'<BR> addr_number: '0'<BR> key:<BR> type: '(NULL)'<BR> data: '(NULL)'<BR> attributes:<BR> attribute 'control' : 'track1'<BR>setup media 0<BR>setup rtsp://192.168.11.167/sd.ts/track1<BR>RTSP request message 0xbfe22800<BR> request line:<BR> method: 'SETUP'<BR> uri: 'rtsp://192.168.11.167/sd.ts/track1'<BR> version: '1.0'<BR> headers:<BR> key: 'Transport', value: 'RTP/AVP/UDP;unicast;client_port=30000-30001,RTP/AVP/UDP;multicast,RTP/AVP/TCP'<BR> body:<BR>RTSP response message 0xbfe227e4<BR> status line:<BR> code: '200'<BR> reason: 'OK'<BR> version: '1.0'<BR> headers:<BR> key: 'CSeq', value: '2'<BR> key: 'Date', value: 'Thu, Aug 13 2009 09:38:43 GMT'<BR> key: 'Transport', value: 'RTP/AVP;unicast;destination=192.168.11.168;source=192.168.11.167;client_port=30000-30001;server_port=6972-6973'<BR> key: 'Session', value: '52'<BR> body: length 0<BR>RTSP request message 0xbfe22800<BR> request line:<BR> method: 'PLAY'<BR> uri: 'rtsp://192.168.11.167/sd.ts'<BR> version: '1.0'<BR> headers:<BR> key: 'Accept', value: 'npt=0-'<BR> body:<BR>RTSP response message 0xbfe227e4<BR> status line:<BR> code: '200'<BR> reason: 'OK'<BR> version: '1.0'<BR> headers:<BR> key: 'CSeq', value: '3'<BR> key: 'Date', value: 'Thu, Aug 13 2009 09:38:43 GMT'<BR> key: 'Session', value: '52'<BR> key: 'RTP-Info', value: 'url=rtsp://192.168.11.167/sd.ts/track1;seq=23957;rtptime=2147510730'<BR> body: length 0<BR>error receiving response -11<BR>[felix@Felix-NB test_rtsp]$<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
///The code<BR>
#include <gst/gst.h><BR>#include <gst/rtsp/gstrtspconnection.h><BR>#include <gst/rtsp/gstrtspmessage.h><BR>#include <gst/rtsp/gstrtspurl.h><BR>#include <gst/sdp/gstsdpmessage.h><BR>#include <gst/rtp/gstrtppayloads.h><BR>#include <gst/rtsp/gstrtsprange.h><BR>#include <gst/check/gstcheck.h><BR>#include <gst/rtp/gstrtpbuffer.h><BR>#include <gst/rtp/gstrtcpbuffer.h><BR>#include <string.h><BR>
int main(int argc,char *argv[])<BR>{<BR> GstRTSPUrl *pURL;<BR> gchar *pURLStr;<BR> GMainLoop *g_loop;<BR> GstRTSPConnection *pConn;<BR> GstRTSPResult nRes; <BR> GstRTSPMessage Request_t = { 0 };<BR> GstRTSPMessage Response_t = { 0 };<BR> GstSDPMessage SDP_t = { 0 };<BR> <BR> <BR> gst_init(&argc,&argv);<BR>
g_loop = g_main_loop_new (NULL, FALSE);<BR> <BR> pURLStr="rtsp://192.168.11.167/sd.ts";<BR> //pURLStr="rtsp://thread:5454/south-rtsp.mp3"<BR> <BR> /*create url */ <BR> g_print ("parsing url \"%s\"...\n", pURLStr);<BR> <BR> nRes = gst_rtsp_url_parse (pURLStr, &pURL);<BR> if (nRes <0) {<BR> g_print ("error parsing url \"%s\"\n", pURLStr);<BR> return (-1);<BR> }<BR> g_print (" url host: %s\n", pURL->host);<BR> g_print (" url port: %d\n", pURL->port);<BR> g_print (" url path: %s\n", pURL->abspath);<BR> <BR> <BR> /* create and open connection */<BR> g_print ("creating connection...\n");<BR> nRes = gst_rtsp_connection_create (pURL, &pConn);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error creating connection to \"%s\"\n", pURLStr);<BR> return (-1);<BR> }<BR> <BR> /* open connection */<BR> g_print ("opening connection...\n");<BR> nRes = gst_rtsp_connection_connect (pConn, NULL);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error opening connection to \"%s\"\n", pURLStr);<BR> return (-1);<BR> }<BR>
/* do describe */<BR> {<BR> nRes = gst_rtsp_message_init_request (&Request_t, GST_RTSP_DESCRIBE, pURLStr);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error creating request\n");<BR> return (-1);<BR> }<BR> gst_rtsp_message_add_header (&Request_t, GST_RTSP_HDR_ACCEPT, "application/sdp");<BR>
gst_rtsp_message_dump (&Request_t);<BR>
nRes = gst_rtsp_connection_send (pConn, &Request_t, NULL);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error sending request\n");<BR> return (-1);<BR> }<BR>
nRes = gst_rtsp_connection_receive (pConn, &Response_t, NULL);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error receiving response\n");<BR> return (-1);<BR> }<BR> gst_rtsp_message_dump (&Response_t);<BR> }<BR>
/* parse SDP */<BR> {<BR> guint8 *data;<BR> guint size;<BR>
gst_rtsp_message_get_body (&Response_t, &data, &size);<BR>
gst_sdp_message_init (&SDP_t);<BR> gst_sdp_message_parse_buffer (data, size, &SDP_t);<BR>
gst_sdp_message_dump (&SDP_t);<BR> }<BR> <BR> <BR> /* do setup */<BR> {<BR> gint i;<BR>
for (i = 0; i < gst_sdp_message_medias_len (&SDP_t); i++) {<BR> GstSDPMedia *media;<BR> gchar *pSetupURL;<BR> gchar *pControlURL;<BR>
media = gst_sdp_message_get_media (&SDP_t, i);<BR>
g_print ("setup media %d\n", i);<BR> pControlURL = gst_sdp_media_get_attribute_val (media, "control");<BR>
pSetupURL = g_strdup_printf ("%s/%s", pURLStr, pControlURL);<BR>
g_print ("setup %s\n", pSetupURL);<BR> nRes = gst_rtsp_message_init_request (&Request_t, GST_RTSP_SETUP, pSetupURL);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error creating request\n");<BR> return (-1);<BR> }<BR>
gst_rtsp_message_add_header (&Request_t, GST_RTSP_HDR_TRANSPORT,<BR> "RTP/AVP/UDP;unicast;client_port=30000-30001,RTP/AVP/UDP;multicast,RTP/AVP/TCP");<BR> //"RTP/AVP;unicast;client_port=5000-5001");<BR> // "RTP/AVP/TCP");<BR> gst_rtsp_message_dump (&Request_t);<BR>
nRes = gst_rtsp_connection_send (pConn, &Request_t, NULL);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error sending request\n");<BR> return (-1);<BR> }<BR>
nRes = gst_rtsp_connection_receive (pConn, &Response_t, NULL);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error receiving response\n");<BR> return (-1);<BR> }<BR> gst_rtsp_message_dump (&Response_t);<BR> } <BR> }<BR>
/* do play */<BR> {<BR> nRes = gst_rtsp_message_init_request (&Request_t, GST_RTSP_PLAY, pURLStr);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error creating request\n");<BR> return (-1);<BR> }<BR> <BR> gst_rtsp_message_add_header (&Request_t, GST_RTSP_HDR_ACCEPT, "npt=0-");<BR> <BR> gst_rtsp_message_dump (&Request_t);<BR>
nRes = gst_rtsp_connection_send (pConn, &Request_t, NULL);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error sending request\n");<BR> return (-1);<BR> }<BR>
nRes = gst_rtsp_connection_receive (pConn, &Response_t, NULL);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error receiving response\n");<BR> return (-1);<BR> }<BR> gst_rtsp_message_dump (&Response_t);<BR> }<BR>
<BR> while (TRUE) {<BR>
nRes = gst_rtsp_connection_receive (pConn, &Response_t, NULL);<BR>
g_print("%d\n",nRes);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error receiving response %d\n",nRes);<BR> return (-1);<BR> }<BR> gst_rtsp_message_dump (&Response_t);<BR> }<BR>
/* close connection */<BR> g_print ("closing connection...\n");<BR> nRes = gst_rtsp_connection_close (pConn);<BR> if (nRes != GST_RTSP_OK) {<BR> g_print ("error closing connection to \"%s\"\n", pURLStr);<BR> return (-1);<BR> }<BR> return 0;<BR>}<BR><br /><hr />聰明搜尋和瀏覽網路的免費工具列 — <a href='http://download.live.com/toolbar' target='_new'>Windows Live 工具列</a></body>
</html>