baresip / baresip-android

Baresip for Android
BSD 3-Clause "New" or "Revised" License
42 stars 19 forks source link

Connect sip over websocket #37

Open Pastor02 opened 3 years ago

Pastor02 commented 3 years ago

Hi people, i'm try to connect with Android ndk but i'm new in this topic.

i have two questions.

1) Exist any documentation for use the library in C?

2) i am try to use the next functions to connect with websocket.

CREATE AGENT-->

static const char* AUDIO_CODECS = "PCMU/8000/1";
static const char* VIDEO_CODECS = "h264";
static const char* DEFAULT_TRANSPORT = "ws";
static const int DEFAULT_LIFETIME = 7200;
  char sipChar[1024];
    memset(sipChar, 0, sizeof(sipChar));

    snprintf(sipChar, sizeof(sipChar),
             "<sip:%s:%s@%s;transport=%s>;regint=%d;regq=0.5;answermode=manual;audio_codecs=%s",
             username, password,
             sip_server, DEFAULT_TRANSPORT, DEFAULT_LIFETIME,
             AUDIO_CODECS

    );
    LOGI("AGENT: %s", sipChar);

    int err = ua_alloc(&userAgent, sipChar);
    if(err) {
        LOGI("ERROR: create_agent error! %d", err);
        return EXIT_FAILURE;
    }
    return (long) &userAgent;

CALL -->

void start_audio_call(const char* peer) {
    ua_connect(userAgent, NULL, NULL, peer, 0);
}

But return session closed: Protocol error

i'm use to example this Demo but he used only tcp protocol (https://github.com/MobiSciLab/Baresip-DemoAudioCall)

Thanks for the help.