Problem with the app_rtsp module of Asterisk

Hello,

We are students currently working on the app_rtsp module of Asterisk (in 1.6 version). We’re trying to read the video stream of an IP camera but we only get a black screen instead of the video.
We are using an Axis M1011-W camera which works with the H264 codec. Thanks to VLC, we can read the stream and it works perfectly. As a softphone we use Linphone, with the H264 codec installed. In the extensions.conf file of Asterisk, we wrote this:

[code]exten => 6011,1,goto(rtsp,s,1)

exten => s,1,Answer()

exten => s,2,rtsp(rtsp://147.215.7.101:554/axis-media/media.amp)

exten => s,3,Hangup()[/code]

When we call 6011, we get a black screen, but the RTSP app seams to work, as the initializations work and the loop in the rtsp_play function doesn’t end (while(!player->end)). Here is what we get in the Asterisk CLI (we kept only the most interesting messages) :

[code][Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:419 GetUdpPorts:
-GetUdpPorts [37777,38476]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:441 GetUdpPorts:
-GetUdpPorts [38476,38477]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:419 GetUdpPorts:
-GetUdpPorts [50811,58195]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:441 GetUdpPorts:
-GetUdpPorts [58195,58196]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:441 GetUdpPorts:
-GetUdpPorts [58196,58197]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:743 RtspPlayerDescribe:

DESCRIBE [/axis-media/media.amp] 

[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:775 RtspPlayerDescribe:
<DESCRIBE [/axis-media/media.amp]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1434 rtsp_play: -rtsp play
loop [0]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1537 rtsp_play: -Describe
response code [200]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line [v=0]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line [o=-
1339675393980214 1339675393980214 IN IP4 147.215.7.101]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[s=Media Presentation]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[e=NONE]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line [c=IN
IP4 0.0.0.0]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[b=AS:50000]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line [t=0
0]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[a=control:*]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[a=range:npt=0.000000-]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[m=video 0 RTP/AVP 96]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1026 CreateMedia: -creating
media [1,m=video 0 RTP/AVP 96]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[b=AS:50000]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[a=framerate:30.0]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[a=transform:1,0,0;0,1,0;0,0,1]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[a=control:trackID=1]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[a=rtpmap:96 H264/90000]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[a=fmtp:96 packetization-mode=1; profile-level-id=420029;
sprop-parameter-sets=Z0IAKeNQFAe2AtwEBAaQeJEV,aM48gA==]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[0,0;0,1,0;0,0,1]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[a=control:trackID=1]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[a=rtpmap:96 H264/90000]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1081 CreateSDP: -line
[a=fmtp:96 packetization-mode=1; profile-level-id=420029;
sprop-parameter-sets=Z0IAKeNQFAe2AtwEBAaQeJEV,aM48gA==]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1621 rtsp_play: -Finding
compatible codecs [300004]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1662 rtsp_play: -video
[200000,96,trackID=1]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1673 rtsp_play: Found best
video codec
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1679 rtsp_play: -Set write
format [200000,0,200000]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:838 RtspPlayerSetupVideo:
-SETUP VIDEO [trackID=1]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:890 RtspPlayerPlay: -PLAY
[/axis-media/media.amp]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:1853 rtsp_play: -Started
playback [0]
[Jun 15 12:52:32] DEBUG[23476]: app_rtsp.c:2065 rtsp_play: -Init RTCP
timer

[/code]
During the loop, we also get these messages and don’t really understand what they mean:

[Jun 16 23:06:56] DEBUG[10002]: app_rtsp.c:2015 rtsp_play: -Sent rtcp video report [11]

And

[code][Jun 16 23:06:56] DEBUG[10002]: app_rtsp.c:2044 rtsp_play: -Sent rtcp
audio report [89]
[Jun 16 23:06:56] DEBUG[10002]: app_rtsp.c:2056 rtsp_play: -Sent rtcp
video report [89]
[Jun 16 23:06:56] DEBUG[10002]: app_rtsp.c:712 RtspPlayerOptions:

OPTIONS [/axis-media/media.amp] 

[Jun 16 23:06:56] DEBUG[10002]: app_rtsp.c:732 RtspPlayerOptions:
<OPTIONS [/axis-media/media.amp]
[Jun 16 23:06:56] DEBUG[10002]: app_rtsp.c:2061 rtsp_play: -Sending
OPTIONS and reseting RTCP timer[/code]

Moreover, we noticed that in the principal loop, the test “if (ast_waitfor_nandfds(&chan,1,infds,5,NULL,&outfd,&ms))” often returns true, causing a kind of waiting loop.
The condition “else if ((outfd==player->audioRtp) || (outfd==player->videoRtp) )”, in which the video is transmited, is true about one or two times within 10 “waiting loops”.
Is it normal ?

For example:

[Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1476 rtsp_play: Ast_waitfor_nandfs : outfd=-99999 [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:2025 rtsp_play: player->state==RTSP_PLAYING [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1441 rtsp_play: ************LOOP : 60*************** [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1476 rtsp_play: Ast_waitfor_nandfs : outfd=-99999 [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:2025 rtsp_play: player->state==RTSP_PLAYING [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1441 rtsp_play: ************LOOP : 61*************** [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1476 rtsp_play: Ast_waitfor_nandfs : outfd=-99999 [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:2025 rtsp_play: player->state==RTSP_PLAYING [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1441 rtsp_play: ************LOOP : 62*************** [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1476 rtsp_play: Ast_waitfor_nandfs : outfd=-99999 [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:2025 rtsp_play: player->state==RTSP_PLAYING [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1441 rtsp_play: ************LOOP : 63*************** [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1878 rtsp_play: outfd=player->videoRtp, outfd=34 [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:2025 rtsp_play: player->state==RTSP_PLAYING [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1441 rtsp_play: ************LOOP : 64*************** [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1878 rtsp_play: outfd=player->videoRtp, outfd=34 [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:2025 rtsp_play: player->state==RTSP_PLAYING [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1441 rtsp_play: ************LOOP : 65*************** [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1476 rtsp_play: Ast_waitfor_nandfs : outfd=-99999 [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:2025 rtsp_play: player->state==RTSP_PLAYING [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1441 rtsp_play: ************LOOP : 66*************** [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:1476 rtsp_play: Ast_waitfor_nandfs : outfd=-99999 [Jun 15 12:52:32] WARNING[23476]: app_rtsp.c:2025 rtsp_play: player->state==RTSP_PLAYING

When outfd=-99999, it’s the waiting loop.

We don’t know how to resolve our problem and hope that you will be able to help us.

By the way, is the app_rtsp module supposed to work on Asterisk 1.6 ?

Thanks.

Please help us, we have to resolve this problem before one week. :smile:

You are supposed to wait 24 hours before bumping a thread.

If the problem does relate to the scheduling code, you should probably be on the developer mailing list or IRC channel.

Not many people here will be using video, and they may never have had similar problems.