[gst-devel] A question about RTSP on gst-plugins-base-0.10.22
Yang Felix
felixyang_tw at hotmail.com
Thu Aug 13 11:49:05 CEST 2009
Dear All:
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.
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!
gstream version:0.10.24-1.fc11
gst-plugin-base version:0.10.23-3.fc11
//The console display
[felix at Felix-NB test_rtsp]$ ./run
parsing url "rtsp://192.168.11.167/sd.ts"...
url host: 192.168.11.167
url port: 0
url path: /sd.ts
creating connection...
opening connection...
RTSP request message 0xbfe22800
request line:
method: 'DESCRIBE'
uri: 'rtsp://192.168.11.167/sd.ts'
version: '1.0'
headers:
key: 'Accept', value: 'application/sdp'
body:
RTSP response message 0xbfe227e4
status line:
code: '200'
reason: 'OK'
version: '1.0'
headers:
key: 'CSeq', value: '1'
key: 'Date', value: 'Thu, Aug 13 2009 09:38:43 GMT'
key: 'Content-Base', value: 'rtsp://192.168.11.167/sd.ts/'
key: 'Content-Type', value: 'application/sdp'
key: 'Content-Length', value: '376'
body: length 377
00000000 (0x87608e0): 76 3d 30 0d 0a 6f 3d 2d 20 31 32 35 30 31 34 37 v=0..o=- 1250147
00000010 (0x87608f0): 39 39 39 36 39 38 31 34 32 20 31 20 49 4e 20 49 999698142 1 IN I
00000020 (0x8760900): 50 34 20 31 30 2e 31 34 34 2e 32 34 2e 38 0d 0a P4 10.144.24.8..
00000030 (0x8760910): 73 3d 4d 50 45 47 20 54 72 61 6e 73 70 6f 72 74 s=MPEG Transport
00000040 (0x8760920): 20 53 74 72 65 61 6d 2c 20 73 74 72 65 61 6d 65 Stream, streame
00000050 (0x8760930): 64 20 62 79 20 74 68 65 20 4c 49 56 45 35 35 35 d by the LIVE555
00000060 (0x8760940): 20 4d 65 64 69 61 20 53 65 72 76 65 72 0d 0a 69 Media Server..i
00000070 (0x8760950): 3d 73 64 2e 74 73 0d 0a 74 3d 30 20 30 0d 0a 61 =sd.ts..t=0 0..a
00000080 (0x8760960): 3d 74 6f 6f 6c 3a 4c 49 56 45 35 35 35 20 53 74 =tool:LIVE555 St
00000090 (0x8760970): 72 65 61 6d 69 6e 67 20 4d 65 64 69 61 20 76 32 reaming Media v2
000000a0 (0x8760980): 30 30 39 2e 30 37 2e 30 39 0d 0a 61 3d 74 79 70 009.07.09..a=typ
000000b0 (0x8760990): 65 3a 62 72 6f 61 64 63 61 73 74 0d 0a 61 3d 63 e:broadcast..a=c
000000c0 (0x87609a0): 6f 6e 74 72 6f 6c 3a 2a 0d 0a 61 3d 72 61 6e 67 ontrol:*..a=rang
000000d0 (0x87609b0): 65 3a 6e 70 74 3d 30 2d 0d 0a 61 3d 78 2d 71 74 e:npt=0-..a=x-qt
000000e0 (0x87609c0): 2d 74 65 78 74 2d 6e 61 6d 3a 4d 50 45 47 20 54 -text-nam:MPEG T
000000f0 (0x87609d0): 72 61 6e 73 70 6f 72 74 20 53 74 72 65 61 6d 2c ransport Stream,
00000100 (0x87609e0): 20 73 74 72 65 61 6d 65 64 20 62 79 20 74 68 65 streamed by the
00000110 (0x87609f0): 20 4c 49 56 45 35 35 35 20 4d 65 64 69 61 20 53 LIVE555 Media S
00000120 (0x8760a00): 65 72 76 65 72 0d 0a 61 3d 78 2d 71 74 2d 74 65 erver..a=x-qt-te
00000130 (0x8760a10): 78 74 2d 69 6e 66 3a 73 64 2e 74 73 0d 0a 6d 3d xt-inf:sd.ts..m=
00000140 (0x8760a20): 76 69 64 65 6f 20 30 20 52 54 50 2f 41 56 50 20 video 0 RTP/AVP
00000150 (0x8760a30): 33 33 0d 0a 63 3d 49 4e 20 49 50 34 20 30 2e 30 33..c=IN IP4 0.0
00000160 (0x8760a40): 2e 30 2e 30 0d 0a 61 3d 63 6f 6e 74 72 6f 6c 3a .0.0..a=control:
00000170 (0x8760a50): 74 72 61 63 6b 31 0d 0a 00 track1...
sdp packet 0xbfe22784:
version: '0'
origin:
username: '-'
sess_id: '1250147999698142'
sess_version: '1'
nettype: 'IN'
addrtype: 'IP4'
addr: '10.144.24.8'
session_name: 'MPEG Transport Stream, streamed by the LIVE555 Media Server'
information: 'sd.ts'
uri: '(NULL)'
connection:
nettype: '(NULL)'
addrtype: '(NULL)'
address: '(NULL)'
ttl: '0'
addr_number: '0'
key:
type: '(NULL)'
data: '(NULL)'
attributes:
attribute 'tool' : 'LIVE555 Streaming Media v2009.07.09'
attribute 'type' : 'broadcast'
attribute 'control' : '*'
attribute 'range' : 'npt=0-'
attribute 'x-qt-text-nam' : 'MPEG Transport Stream, streamed by the LIVE555 Media Server'
attribute 'x-qt-text-inf' : 'sd.ts'
medias:
media 0:
media: 'video'
port: '0'
num_ports: '4294967295'
proto: 'RTP/AVP'
formats:
format '33'
information: '(NULL)'
connections:
nettype: 'IN'
addrtype: 'IP4'
address: '0.0.0.0'
ttl: '0'
addr_number: '0'
key:
type: '(NULL)'
data: '(NULL)'
attributes:
attribute 'control' : 'track1'
setup media 0
setup rtsp://192.168.11.167/sd.ts/track1
RTSP request message 0xbfe22800
request line:
method: 'SETUP'
uri: 'rtsp://192.168.11.167/sd.ts/track1'
version: '1.0'
headers:
key: 'Transport', value: 'RTP/AVP/UDP;unicast;client_port=30000-30001,RTP/AVP/UDP;multicast,RTP/AVP/TCP'
body:
RTSP response message 0xbfe227e4
status line:
code: '200'
reason: 'OK'
version: '1.0'
headers:
key: 'CSeq', value: '2'
key: 'Date', value: 'Thu, Aug 13 2009 09:38:43 GMT'
key: 'Transport', value: 'RTP/AVP;unicast;destination=192.168.11.168;source=192.168.11.167;client_port=30000-30001;server_port=6972-6973'
key: 'Session', value: '52'
body: length 0
RTSP request message 0xbfe22800
request line:
method: 'PLAY'
uri: 'rtsp://192.168.11.167/sd.ts'
version: '1.0'
headers:
key: 'Accept', value: 'npt=0-'
body:
RTSP response message 0xbfe227e4
status line:
code: '200'
reason: 'OK'
version: '1.0'
headers:
key: 'CSeq', value: '3'
key: 'Date', value: 'Thu, Aug 13 2009 09:38:43 GMT'
key: 'Session', value: '52'
key: 'RTP-Info', value: 'url=rtsp://192.168.11.167/sd.ts/track1;seq=23957;rtptime=2147510730'
body: length 0
error receiving response -11
[felix at Felix-NB test_rtsp]$
///The code
#include <gst/gst.h>
#include <gst/rtsp/gstrtspconnection.h>
#include <gst/rtsp/gstrtspmessage.h>
#include <gst/rtsp/gstrtspurl.h>
#include <gst/sdp/gstsdpmessage.h>
#include <gst/rtp/gstrtppayloads.h>
#include <gst/rtsp/gstrtsprange.h>
#include <gst/check/gstcheck.h>
#include <gst/rtp/gstrtpbuffer.h>
#include <gst/rtp/gstrtcpbuffer.h>
#include <string.h>
int main(int argc,char *argv[])
{
GstRTSPUrl *pURL;
gchar *pURLStr;
GMainLoop *g_loop;
GstRTSPConnection *pConn;
GstRTSPResult nRes;
GstRTSPMessage Request_t = { 0 };
GstRTSPMessage Response_t = { 0 };
GstSDPMessage SDP_t = { 0 };
gst_init(&argc,&argv);
g_loop = g_main_loop_new (NULL, FALSE);
pURLStr="rtsp://192.168.11.167/sd.ts";
//pURLStr="rtsp://thread:5454/south-rtsp.mp3"
/*create url */
g_print ("parsing url \"%s\"...\n", pURLStr);
nRes = gst_rtsp_url_parse (pURLStr, &pURL);
if (nRes <0) {
g_print ("error parsing url \"%s\"\n", pURLStr);
return (-1);
}
g_print (" url host: %s\n", pURL->host);
g_print (" url port: %d\n", pURL->port);
g_print (" url path: %s\n", pURL->abspath);
/* create and open connection */
g_print ("creating connection...\n");
nRes = gst_rtsp_connection_create (pURL, &pConn);
if (nRes != GST_RTSP_OK) {
g_print ("error creating connection to \"%s\"\n", pURLStr);
return (-1);
}
/* open connection */
g_print ("opening connection...\n");
nRes = gst_rtsp_connection_connect (pConn, NULL);
if (nRes != GST_RTSP_OK) {
g_print ("error opening connection to \"%s\"\n", pURLStr);
return (-1);
}
/* do describe */
{
nRes = gst_rtsp_message_init_request (&Request_t, GST_RTSP_DESCRIBE, pURLStr);
if (nRes != GST_RTSP_OK) {
g_print ("error creating request\n");
return (-1);
}
gst_rtsp_message_add_header (&Request_t, GST_RTSP_HDR_ACCEPT, "application/sdp");
gst_rtsp_message_dump (&Request_t);
nRes = gst_rtsp_connection_send (pConn, &Request_t, NULL);
if (nRes != GST_RTSP_OK) {
g_print ("error sending request\n");
return (-1);
}
nRes = gst_rtsp_connection_receive (pConn, &Response_t, NULL);
if (nRes != GST_RTSP_OK) {
g_print ("error receiving response\n");
return (-1);
}
gst_rtsp_message_dump (&Response_t);
}
/* parse SDP */
{
guint8 *data;
guint size;
gst_rtsp_message_get_body (&Response_t, &data, &size);
gst_sdp_message_init (&SDP_t);
gst_sdp_message_parse_buffer (data, size, &SDP_t);
gst_sdp_message_dump (&SDP_t);
}
/* do setup */
{
gint i;
for (i = 0; i < gst_sdp_message_medias_len (&SDP_t); i++) {
GstSDPMedia *media;
gchar *pSetupURL;
gchar *pControlURL;
media = gst_sdp_message_get_media (&SDP_t, i);
g_print ("setup media %d\n", i);
pControlURL = gst_sdp_media_get_attribute_val (media, "control");
pSetupURL = g_strdup_printf ("%s/%s", pURLStr, pControlURL);
g_print ("setup %s\n", pSetupURL);
nRes = gst_rtsp_message_init_request (&Request_t, GST_RTSP_SETUP, pSetupURL);
if (nRes != GST_RTSP_OK) {
g_print ("error creating request\n");
return (-1);
}
gst_rtsp_message_add_header (&Request_t, GST_RTSP_HDR_TRANSPORT,
"RTP/AVP/UDP;unicast;client_port=30000-30001,RTP/AVP/UDP;multicast,RTP/AVP/TCP");
//"RTP/AVP;unicast;client_port=5000-5001");
// "RTP/AVP/TCP");
gst_rtsp_message_dump (&Request_t);
nRes = gst_rtsp_connection_send (pConn, &Request_t, NULL);
if (nRes != GST_RTSP_OK) {
g_print ("error sending request\n");
return (-1);
}
nRes = gst_rtsp_connection_receive (pConn, &Response_t, NULL);
if (nRes != GST_RTSP_OK) {
g_print ("error receiving response\n");
return (-1);
}
gst_rtsp_message_dump (&Response_t);
}
}
/* do play */
{
nRes = gst_rtsp_message_init_request (&Request_t, GST_RTSP_PLAY, pURLStr);
if (nRes != GST_RTSP_OK) {
g_print ("error creating request\n");
return (-1);
}
gst_rtsp_message_add_header (&Request_t, GST_RTSP_HDR_ACCEPT, "npt=0-");
gst_rtsp_message_dump (&Request_t);
nRes = gst_rtsp_connection_send (pConn, &Request_t, NULL);
if (nRes != GST_RTSP_OK) {
g_print ("error sending request\n");
return (-1);
}
nRes = gst_rtsp_connection_receive (pConn, &Response_t, NULL);
if (nRes != GST_RTSP_OK) {
g_print ("error receiving response\n");
return (-1);
}
gst_rtsp_message_dump (&Response_t);
}
while (TRUE) {
nRes = gst_rtsp_connection_receive (pConn, &Response_t, NULL);
g_print("%d\n",nRes);
if (nRes != GST_RTSP_OK) {
g_print ("error receiving response %d\n",nRes);
return (-1);
}
gst_rtsp_message_dump (&Response_t);
}
/* close connection */
g_print ("closing connection...\n");
nRes = gst_rtsp_connection_close (pConn);
if (nRes != GST_RTSP_OK) {
g_print ("error closing connection to \"%s\"\n", pURLStr);
return (-1);
}
return 0;
}
_________________________________________________________________
輕鬆分享 – 利用 Windows Live 相簿分享相片
http://download.live.com/toolbar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20090813/93bb8a55/attachment.htm>
More information about the gstreamer-devel
mailing list