0

It is my first time creating working with JAIN SIP. I have created Android SIP Client using JAIN SIP. I am able to get a notification of an incoming call and receive it but am not able to get the audio stream working. I guess the problem might be the way define the Session Description Protocol(SDP) for an audio stream.

Below is my acceptCall method:

public void acceptCall() throws IllegalStateException {
    soundManager.setupAudioStream();
    Request request = incomingRequest.getRequest();
    remoteIP = SDPBuilder.getRemoteIP(incomingRequest.getRequest());
    try {
        Response response = messageFactory.createResponse(Response.OK, request);
        response.addHeader(localContactHeader);
        ContentTypeHeader contentTypeHeader = headerFactory.createContentTypeHeader("application", "sdp");
        response.setContent(getSDPData().getBytes(), contentTypeHeader);
        SipResponder responder = new SipResponder(sipProvider, incomingRequest, currentServerTransaction);
        responder.execute(response);
    } catch (Exception e) {
        if (BuildConfig.DEBUG) e.printStackTrace();
        direction = CallDirection.NONE;
        notifySessionFailed("couldn't establish call");
    }
}

Here is my method that returns SDP Data:

private String getSDPData()
{

    return "v=0\r\n"
            + "o=4855 13760799956958020 13760799956958020"
            + " IN IP4 " + localIP + "\r\n"
            + "s=mysession session\r\n"
            + "c=IN IP4 "
            + localIP + "\r\n" + "t=0 0\r\n"
            + "m=audio " + String.valueOf(port)
            + " RTP/AVP 0 4 18\r\n"
            + "a=rtpmap:0 PCMU/8000\r\n"
            + "a=rtpmap:4 G723/8000\r\n"
            + "a=rtpmap:18 G729A/8000\r\n" + "a=ptime:20\r\n";
}

Lastly my SIP Responder class:

public class SipResponder extends AsyncTask<Response, String, ServerTransaction> {
private static final String TAG = "BACKGROUND";
private SipProvider sipProvider;
private RequestEvent requestEvent;
private ServerTransaction transaction;

public SipResponder(SipProvider provider, RequestEvent event, ServerTransaction transaction) {
    sipProvider = provider;
    requestEvent = event;
    this.transaction = transaction;
}

@Override
protected ServerTransaction doInBackground(Response... responses) {
    Thread.currentThread().setPriority(Thread.MAX_PRIORITY);

    Request request = requestEvent.getRequest();
    Response response = responses[0];

    try {
        if (transaction == null)
            transaction = requestEvent.getServerTransaction();
        if (transaction == null) {
            transaction = sipProvider.getNewServerTransaction(request);
        }
        transaction.sendResponse(response);

        return transaction;
    } catch (TransactionAlreadyExistsException e) {
        Log.e(TAG, "that race condition. UGH");
        e.printStackTrace();
        return null;
    } catch (Exception e) {
        Log.e(TAG, "the response failed. UGH");
        e.printStackTrace();
        return null;
    }
}}

It has been a struggle for a while now. Kindly help.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Dismas Imaya
  • 96
  • 1
  • 6
  • In theory if all configs are correct, this should work, but without both debug logs and full network capture on both sides, it is difficult to tell where it fails. – Vladimir Ralev Aug 06 '18 at 16:04
  • Fixed. Thanks for the response and help. Sure everything was correct except for the port i used on the SDP Data method wasn't the audio stream local port but the SIP Port 5060. – Dismas Imaya Aug 07 '18 at 08:36

0 Answers0