[SIPForum-discussion] am i missing something with call hold

Danish Zaidi danishzaidi54 at yahoo.com
Thu Mar 22 23:50:10 UTC 2007


Hello 

the Hold Event is sent like the INVITE the difference is only attribute is sendonly

if m correct then why its not working, this sendHold Code works if i use it for Invite Purpose only...

public void sendHold()
    {        
        try
        {
            toUser = "1112";
            outgoingCall = true;
            rtpConnection = new RtpConnection();
            localRtpPort = rtpConnection.inizialize(localRtpStartPort, localRtpEndPort, bufferLenght, minimumThreshold, enabledThreshold, packetSize);
            System.out.print("Sending INVITE...  ");
            reqUnauthInvite = null;
            reqAuthInvite = null;
            SipURI requestURI = addressFactory.createSipURI(toUser, serverIpPort);
            SipURI toAddress = addressFactory.createSipURI(toUser, serverIp);
            System.out.println("Server IP In Client.java is "+serverIp);
            Address toNameAddress = addressFactory.createAddress(toAddress);
            ToHeader toHeader = headerFactory.createToHeader(toNameAddress, null);
            System.out.println("IPAddress In Client.java is "+sipStack.getIPAddress());
            SipURI fromAddress = addressFactory.createSipURI(username, sipStack.getIPAddress());
            Address fromNameAddress = addressFactory.createAddress(fromAddress);
            FromHeader fromHeader = headerFactory.createFromHeader(fromNameAddress, userTag);
            ArrayList viaHeaders = new ArrayList();
            javax.sip.header.ViaHeader viaHeader = headerFactory.createViaHeader(sipStack.getIPAddress(), sipProvider.getListeningPoint().getPort(), transportProt, null);
            viaHeaders.add(viaHeader);
            CallIdHeader callIdHeader = cldTemp;
            CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(1, "INVITE");
            MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(70);
            Request request = messageFactory.createRequest(requestURI, "INVITE", callIdHeader, cSeqHeader, fromHeader, toHeader, viaHeaders, maxForwards);
            request.addHeader(contactHeader);
            ContentTypeHeader contentTypeHeader = headerFactory.createContentTypeHeader("application", "sdp");
            String myAddress = Globals.addr.getHostAddress();            
            String string1 = " RTP/AVP";
            String string2 = "";
            int i=0;
            //for(int i = 0; i < codecListModel.getSize(); i++)
            {
                if(String.valueOf(codecListModel.elementAt(i)).equals(" PCMU/8000 "))
                {
                    string1 = (new StringBuilder()).append(string1).append(" 0").toString();
                    string2 = (new StringBuilder()).append(string2).append("a=rtpmap:0 PCMU/8000\r\n").toString();
                    //continue;
                }
                if(String.valueOf(codecListModel.elementAt(i)).equals(" GSM/8000 "))
                {
                    string1 = (new StringBuilder()).append(string1).append(" 3").toString();
                    string2 = (new StringBuilder()).append(string2).append("a=rtpmap:3 GSM/8000\r\n").toString();
                    //continue;
                }
                if(String.valueOf(codecListModel.elementAt(i)).equals(" G723/8000 "))
                {
                    string1 = (new StringBuilder()).append(string1).append(" 4").toString();
                    string2 = (new StringBuilder()).append(string2).append("a=rtpmap:4 G723/8000\r\n").toString();
                    //continue;
                }
                if(String.valueOf(codecListModel.elementAt(i)).equals(" DVI4/8000 "))
                {
                    string1 = (new StringBuilder()).append(string1).append(" 5").toString();
                    string2 = (new StringBuilder()).append(string2).append("a=rtpmap:5 DVI4/8000\r\n").toString();
                }
            }

            string2+="a=sendonly";
            string1 = (new StringBuilder()).append(string1).append("\r\n").toString();
            String sdpData = (new StringBuilder()).append("v=0\r\no=4855 13760799956958020 13760799956958020 IN IP4  ").append(myAddress).append("\r\n").append("s=Session SDP\r\n").append("c=IN IP4  ").append(myAddress).append("\r\n").append("t=0 0\r\n").append("m=audio ").append(localRtpPort).append(string1).append(string2).toString();
            byte contents[] = sdpData.getBytes();
            request.setContent(contents, contentTypeHeader);
            request.addHeader(userAgentHeader);
            javax.sip.header.Header callInfoHeader = headerFactory.createHeader("Call-Info", "<http://www.kleis.it>");
            request.addHeader(callInfoHeader);
            inviteTid = sipProvider.getNewClientTransaction(request);
            inviteTid.sendRequest();
            dialog = inviteTid.getDialog();
            reqUnauthInvite = request;
            System.out.println("DONE");
        }
        catch(Exception ex)
        {
            System.out.println(ex.getMessage());
            ex.printStackTrace();
        }
        return;
    }


sorrry about the indentation mistakes

but plzz help me with the SIP Call HOLD

thanx in advance

 
---------------------------------
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sipforum.org/pipermail/discussion/attachments/20070322/c0560c6a/attachment-0002.html>


More information about the discussion mailing list