Beispiel #1
0
CoreAV::CoreAV(Tox* tox)
    : coreavThread{new QThread}
    , iterateTimer{new QTimer{this}}
    , threadSwitchLock{false}
{
    coreavThread->setObjectName("qTox CoreAV");
    moveToThread(coreavThread.get());

    iterateTimer->setSingleShot(true);
    connect(iterateTimer.get(), &QTimer::timeout, this, &CoreAV::process);

    toxav = toxav_new(tox, nullptr);

    toxav_callback_call(toxav, CoreAV::callCallback, this);
    toxav_callback_call_state(toxav, CoreAV::stateCallback, this);
#if TOX_VERSION_IS_API_COMPATIBLE(0, 2, 0)
    toxav_callback_audio_bit_rate(toxav, CoreAV::audioBitrateCallback, this);
    toxav_callback_video_bit_rate(toxav, CoreAV::videoBitrateCallback, this);
#else
    toxav_callback_bit_rate_status(toxav, CoreAV::bitrateCallback, this);
#endif
    toxav_callback_audio_receive_frame(toxav, CoreAV::audioFrameCallback, this);
    toxav_callback_video_receive_frame(toxav, CoreAV::videoFrameCallback, this);

    coreavThread->start();
}
Beispiel #2
0
void setToxAvCallbacks(ToxAV* av, void* userData)
{
    toxav_callback_call(av, _friendCallRequestCb, userData);
    toxav_callback_call_state(av, _friendCallStateChangeCb, userData);
    toxav_callback_audio_receive_frame(av, _friendAudioFrameReceivedCb, userData);
    toxav_callback_video_receive_frame(av, _friendVideoFrameReceivedCb, userData);
    toxav_callback_bit_rate_status(av, _friendAvRateChangeCb, userData);

    return;
}
Beispiel #3
0
/**
 * Iterate helper
 */
static ToxAV *setup_av_instance(Tox *tox, CallControl *CC)
{
    TOXAV_ERR_NEW error;

    ToxAV *av = toxav_new(tox, &error);
    ck_assert(error == TOXAV_ERR_NEW_OK);

    toxav_callback_call(av, t_toxav_call_cb, CC);
    toxav_callback_call_state(av, t_toxav_call_state_cb, CC);
    toxav_callback_video_receive_frame(av, t_toxav_receive_video_frame_cb, CC);
    toxav_callback_audio_receive_frame(av, t_toxav_receive_audio_frame_cb, CC);

    return av;
}
Beispiel #4
0
ToxAV *init_audio(ToxWindow *self, Tox *tox)
{
    TOXAV_ERR_NEW error;
    CallControl.audio_errors = ae_None;
    CallControl.prompt = self;
    CallControl.pending_call = false;

    CallControl.av = toxav_new(tox, &error);

    CallControl.audio_enabled = true;
    CallControl.audio_bit_rate = 48;
    CallControl.audio_sample_rate = 48000;
    CallControl.audio_frame_duration = 10;
    CallControl.audio_channels = 1;

#ifndef VIDEO
    CallControl.video_enabled = false;
    CallControl.video_bit_rate = 0;
    CallControl.video_frame_duration = 0;
#endif /* VIDEO */

    memset(CallControl.calls, 0, sizeof(CallControl.calls));

    if ( !CallControl.av ) {
        CallControl.audio_errors |= ae_StartingCoreAudio;
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to init ToxAV");

        return NULL;
    }

    if ( init_devices(CallControl.av) == de_InternalError ) {
        line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to init devices");
        toxav_kill(CallControl.av);

        return CallControl.av = NULL;
    }

    toxav_callback_call(CallControl.av, call_cb, tox);
    toxav_callback_call_state(CallControl.av, callstate_cb, NULL);
    toxav_callback_audio_receive_frame(CallControl.av, receive_audio_frame_cb, NULL);

    return CallControl.av;
}