Hello all,
I have been trying to implement a call advertising example, and from
previous discussions on the group, I decided to try an Early Media
solution. However, my attempts were unsuccessful. Basically, I still
cannot make out at which points exactly I should start the RTP and
media sessions. I am still a newbie in SIP and MGCP, and I cannot find
any enlightening resources on the net, so all I can do is try to mimic
mobicents JSR 309 examples. But I was not successful upto now.
Basically, I am trying to modify the JSR 309 Media application. The
scenario is like this;
- Bob makes a call to Alice(INVITE), using Mobicents as the outbound
proxy.
- Mobicents server plays an announcement to Bob, if he presses 1, he
will listen to an advertisement and then Alice will be called. If he
presses 0, he can skip the advertisement and Alice will be called
directly.
There are 3 main stages in the JSR 309 example as far as I can see,
- Upon receiving the invite request, the example creates a new media
session, creates the network connection, and processes the SDP offer
of the UAC. Also, it sends an OK response to UAC upon an
SDPPortManager success event, sending the SDP offer of the Media
server.
- Upon receiving the ACK from UAC, it joins the media gateway and the
RTP session is ready to play announcements and DTMF events.
For an early media case, I am trying to implement the same scenario,
but changing the signalling steps a bit.. The steps I tried was like
the following;
- Upon receiving the invite, I tried sending SC_RINGING, then create
media session,create network connection, process SDP offer of the
UAC.
- Then upon receiving SDPPortManager success event, try to send a 183
to UAC, including the SDP offer of Media server.
- Wait a PRACK from UAC, and upon receiving it, send an OK to UAC, and
try to join the media gateway.
INVITE:
SipServletResponse sipServletResponse =
request.createResponse(SipServletResponse.SC_RINGING);
sipServletResponse.send();
MsControlFactory msControlFactory =
(MsControlFactory)getServletContext().getAttribute(Constants.MS_CONTROL_FACTORY);
// Create new media session and store in SipSession
MediaSession mediaSession =
(MediaSession)msControlFactory.createMediaSession();
sipSession.setAttribute("MEDIA_SESSION", mediaSession);
mediaSession.setAttribute("SIP_SESSION", sipSession);
// Store INVITE so it can be responded to later
sipSession.setAttribute("UNANSWERED_INVITE", request);
// Create a new NetworkConnection and store in SipSession
NetworkConnection conn =
mediaSession.createNetworkConnection(NetworkConnection.BASIC);
SdpPortManager sdpManag = conn.getSdpPortManager();
NetworkConnectionListener ncListener = new
NetworkConnectionListener();
sdpManag.addListener(ncListener);
byte[] sdpOffer = request.getRawContent();
sdpManag.processSdpOffer(sdpOffer);
............
Network Connection Listener onEvent method:
public void onEvent(SdpPortManagerEvent event) {
SdpPortManager sdpManager = event.getSource();
NetworkConnection conn = sdpManager.getContainer();
MediaSession mediaSession = event.getSource().getMediaSession();
SipSession sipSession =
(SipSession)mediaSession.getAttribute("SIP_SESSION");
SipServletRequest inv =
(SipServletRequest)sipSession.getAttribute("UNANSWERED_INVITE");
if(event.isSuccessful()) {
SipServletResponse resp =
inv.createResponse(SipServletResponse.SC_SESSION_PROGRESS);
try {
byte[] sdp = event.getMediaServerSdp();
resp.setContent(sdp, "application/sdp");
// Send Session Progress Response 183
resp.send();
if (logger.isDebugEnabled()) {
logger.debug("Sent OK Response for INVITE");
}
sipSession.setAttribute("NETWORK_CONNECTION", conn);
..........
PRACK:
SipServletResponse resp =
req.createResponse(SipServletResponse.SC_OK);
resp.send();
SipSession sipSession = req.getSession();
MediaSession ms =
(MediaSession)sipSession.getAttribute("MEDIA_SESSION");
try {
MediaGroup mg =
ms.createMediaGroup(MediaGroup.PLAYER_SIGNALDETECTOR);
mg.addListener(new MyJoinEventListener(getPrompter(), sipSession));
NetworkConnection nc =
(NetworkConnection)sipSession.getAttribute("NETWORK_CONNECTION");
mg.joinInitiate(Direction.DUPLEX, nc, this);
sipSession.setAttribute("MediaGroup", mg);
.....
I tried the implementation with X-Lite, without success, but it seems
X-Lite does not support early media.. So, I tried another client
(MizuPhone), but I also failed..
CDATA[INVITE
sip:al...@127.0.0.1 SIP/2.0
Via: SIP/2.0/UDP
10.32.182.17:22871;rport=22871;branch=z9hG4bK-92570808820f-27005080;received=127.0.0.1
From: "soulkitchen" <
sip:b...@127.0.0.1>;tag=127.0.0.1
To: <
sip:al...@127.0.0.1>
Max-Forwards: 70
Call-ID:
xr22271241916c15...@127.0.0.1
Sy.Device: C4283845849
Sy.LoginName: soulkitchen
Sy.NetType: pr
CSeq: 15807 INVITE
Contact: <
sip:b...@10.32.182.17:22871>
Allow:
INVITE,REGISTER,UPDATE,OPTIONS,PING,BYE,CANCEL,ACK,PRACK,COMET,REFER,MESSAGE,SUBSCRIBE,NOTIFY,PUBLISH,INFO,DO,SHAREDFN
Allow-Events: presence,refer,telephone-event,keep-alive,message-
summary,dialog
Supported: privacy,replaces,mizutech
Accept: application/sdp,application/dtmf-relay,audio/telephone-
event,message/sipfrag,text/plain,text/html
User-Agent: MizuPhone/2.1.0
FinalUA: MizuPhone
Sy.AddrList:
127.0.0.1:22871
Expires: 130
Content-Type: application/sdp
Content-Length: 536
v=0
o=bob 3 4 IN IP4 10.32.182.17
s=Mizu
c=IN IP4 10.32.182.17
t=0 0
m=audio 30755 RTP/AVP 106 105 18 0 8 97 104 4 101
a=rtpmap:106 speex/32000
a=fmtp:106 mode=8;mode=any
a=rtpmap:105 speex/16000
a=fmtp:105 mode=8;mode=any
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=30
a=rtpmap:104 speex/8000
a=fmtp:104 mode=3;mode=any
a=rtpmap:4 G7231/8000
a=fmtp:4 bitrate=6.3;annexa=yes
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
CDATA[SIP/2.0 180 Ringing
To:
<
sip:al...@127.0.0.1>;tag=71318696_2bc520d1_848e6d13-396a-4573-8d0f-5a359afce2cd
Via: SIP/2.0/UDP
10.32.182.17:22871;rport=22871;branch=z9hG4bK-92570808820f-27005080;received=127.0.0.1
CSeq: 15807 INVITE
Call-ID:
xr22271241916c15...@127.0.0.1
From: "soulkitchen" <
sip:b...@127.0.0.1>;tag=127.0.0.1
Contact: <sip:
127.0.0.1:5080>
Content-Length: 0
CDATA[SIP/2.0 488 Not Acceptable here
To:
<
sip:al...@127.0.0.1>;tag=71318696_2bc520d1_848e6d13-396a-4573-8d0f-5a359afce2cd
Via: SIP/2.0/UDP
10.32.182.17:22871;rport=22871;branch=z9hG4bK-92570808820f-27005080;received=127.0.0.1
CSeq: 15807 INVITE
Call-ID:
xr22271241916c15...@127.0.0.1
From: "soulkitchen" <
sip:b...@127.0.0.1>;tag=127.0.0.1
Contact: <sip:
127.0.0.1:5080>
Content-Length: 0
ACK sip:
127.0.0.1:5080 SIP/2.0
Via: SIP/2.0/UDP
10.32.182.17:22871;branch=z9hG4bK-92570808820f-27005080;received=127.0.0.1
From: "soulkitchen" <
sip:b...@127.0.0.1>;tag=127.0.0.1
To:
<
sip:al...@127.0.0.1>;tag=71318696_2bc520d1_848e6d13-396a-4573-8d0f-5a359afce2cd
Max-Forwards: 70
Call-ID:
xr22271241916c15...@127.0.0.1
CSeq: 15807 ACK
User-Agent: MizuPhone/2.1.0
FinalUA: MizuPhone
Content-Length: 0
As I can see from the logs, something does not go well, when I try to
send the SC-RINGING response.. My Network connection listener receives
a SdpPortManagerEvent.SDP_NOT_ACCEPTABLE event instead of a success
event. On the media server I see
01:39:35,762 ERROR [CreateConnectionAction] Could not apply remote
descriptor
java.net.SocketException: Network is unreachable: connect
at sun.nio.ch.Net.connect(Native Method)
at
sun.nio.ch.DatagramChannelImpl.connect(DatagramChannelImpl.java:530)
at
org.mobicents.media.server.impl.rtp.RtpSocketImpl.setPeer(RtpSocketImpl.java:
414)
at
org.mobicents.media.server.RtpConnectionImpl.setRemoteDescriptor(RtpConnectionImpl.java:
361)
at
org.mobicents.media.server.ctrl.mgcp.CreateConnectionAction.createRtpConnection(CreateConnectionAction.java:
121)
at
org.mobicents.media.server.ctrl.mgcp.CreateConnectionAction.call(CreateConnectionAction.java:
413)
at
org.mobicents.media.server.ctrl.mgcp.CreateConnectionAction.call(CreateConnectionAction.java:
42)
at
org.mobicents.media.server.ctrl.mgcp.MgcpController.processMgcpCommandEvent(MgcpController.java:
221)
.........
At this point, I am completely stuck.. Can somebody tell me what I am
doing wrong?
Thanks in advance,
Regards,
Fatih