start with toxav interface (no callbacks yet, gonna use threading)
This commit is contained in:
parent
2f44b45e8a
commit
fae1910f1a
@ -16,6 +16,9 @@ add_executable(tomato
|
||||
./tox_client.cpp
|
||||
./auto_dirty.hpp
|
||||
./auto_dirty.cpp
|
||||
./tox_private_impl.hpp
|
||||
./tox_av.hpp
|
||||
./tox_av.cpp
|
||||
|
||||
./theme.hpp
|
||||
|
||||
|
@ -20,6 +20,7 @@ MainScreen::MainScreen(SDL_Renderer* renderer_, Theme& theme_, std::string save_
|
||||
tc(save_path, save_password),
|
||||
tpi(tc.getTox()),
|
||||
ad(tc),
|
||||
tav(tc.getTox()),
|
||||
tcm(cr, tc, tc),
|
||||
tmm(rmm, cr, tcm, tc, tc),
|
||||
ttm(rmm, cr, tcm, tc, tc),
|
||||
@ -69,6 +70,7 @@ MainScreen::MainScreen(SDL_Renderer* renderer_, Theme& theme_, std::string save_
|
||||
g_provideInstance<ToxI>("ToxI", "host", &tc);
|
||||
g_provideInstance<ToxPrivateI>("ToxPrivateI", "host", &tpi);
|
||||
g_provideInstance<ToxEventProviderI>("ToxEventProviderI", "host", &tc);
|
||||
g_provideInstance<ToxAV>("ToxAV", "host", &tav);
|
||||
g_provideInstance<ToxContactModel2>("ToxContactModel2", "host", &tcm);
|
||||
|
||||
// TODO: pm?
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <solanaceae/plugin/plugin_manager.hpp>
|
||||
#include <solanaceae/toxcore/tox_event_logger.hpp>
|
||||
#include "./tox_private_impl.hpp"
|
||||
#include "./tox_av.hpp"
|
||||
|
||||
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
|
||||
#include <solanaceae/tox_messages/tox_message_manager.hpp>
|
||||
@ -58,6 +59,7 @@ struct MainScreen final : public Screen {
|
||||
ToxClient tc;
|
||||
ToxPrivateImpl tpi;
|
||||
AutoDirty ad;
|
||||
ToxAV tav;
|
||||
ToxContactModel2 tcm;
|
||||
ToxMessageManager tmm;
|
||||
ToxTransferManager ttm;
|
||||
|
82
src/tox_av.cpp
Normal file
82
src/tox_av.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
#include "./tox_av.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
// https://almogfx.bandcamp.com/track/crushed-w-cassade
|
||||
|
||||
ToxAV::ToxAV(Tox* tox) : _tox(tox) {
|
||||
Toxav_Err_New err_new {TOXAV_ERR_NEW_OK};
|
||||
_tox_av = toxav_new(_tox, &err_new);
|
||||
// TODO: throw
|
||||
assert(err_new == TOXAV_ERR_NEW_OK);
|
||||
}
|
||||
ToxAV::~ToxAV(void) {
|
||||
toxav_kill(_tox_av);
|
||||
}
|
||||
|
||||
uint32_t ToxAV::toxavIterationInterval(void) const {
|
||||
return toxav_iteration_interval(_tox_av);
|
||||
}
|
||||
|
||||
void ToxAV::toxavIterate(void) {
|
||||
toxav_iterate(_tox_av);
|
||||
}
|
||||
|
||||
uint32_t ToxAV::toxavAudioIterationInterval(void) const {
|
||||
return toxav_audio_iteration_interval(_tox_av);
|
||||
}
|
||||
|
||||
void ToxAV::toxavAudioIterate(void) {
|
||||
toxav_audio_iterate(_tox_av);
|
||||
}
|
||||
|
||||
uint32_t ToxAV::toxavVideoIterationInterval(void) const {
|
||||
return toxav_video_iteration_interval(_tox_av);
|
||||
}
|
||||
|
||||
void ToxAV::toxavVideoIterate(void) {
|
||||
toxav_video_iterate(_tox_av);
|
||||
}
|
||||
|
||||
Toxav_Err_Call ToxAV::toxavCall(uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate) {
|
||||
Toxav_Err_Call err {TOXAV_ERR_CALL_OK};
|
||||
toxav_call(_tox_av, friend_number, audio_bit_rate, video_bit_rate, &err);
|
||||
return err;
|
||||
}
|
||||
|
||||
Toxav_Err_Answer ToxAV::toxavAnswer(uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate) {
|
||||
Toxav_Err_Answer err {TOXAV_ERR_ANSWER_OK};
|
||||
toxav_answer(_tox_av, friend_number, audio_bit_rate, video_bit_rate, &err);
|
||||
return err;
|
||||
}
|
||||
|
||||
Toxav_Err_Call_Control ToxAV::toxavCallControl(uint32_t friend_number, Toxav_Call_Control control) {
|
||||
Toxav_Err_Call_Control err {TOXAV_ERR_CALL_CONTROL_OK};
|
||||
toxav_call_control(_tox_av, friend_number, control, &err);
|
||||
return err;
|
||||
}
|
||||
|
||||
Toxav_Err_Send_Frame ToxAV::toxavAudioSendFrame(uint32_t friend_number, const int16_t pcm[], size_t sample_count, uint8_t channels, uint32_t sampling_rate) {
|
||||
Toxav_Err_Send_Frame err {TOXAV_ERR_SEND_FRAME_OK};
|
||||
toxav_audio_send_frame(_tox_av, friend_number, pcm, sample_count, channels, sampling_rate, &err);
|
||||
return err;
|
||||
}
|
||||
|
||||
Toxav_Err_Bit_Rate_Set ToxAV::toxavAudioSetBitRate(uint32_t friend_number, uint32_t bit_rate) {
|
||||
Toxav_Err_Bit_Rate_Set err {TOXAV_ERR_BIT_RATE_SET_OK};
|
||||
toxav_audio_set_bit_rate(_tox_av, friend_number, bit_rate, &err);
|
||||
return err;
|
||||
}
|
||||
|
||||
Toxav_Err_Send_Frame ToxAV::toxavVideoSendFrame(uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t y[], const uint8_t u[], const uint8_t v[]) {
|
||||
Toxav_Err_Send_Frame err {TOXAV_ERR_SEND_FRAME_OK};
|
||||
toxav_video_send_frame(_tox_av, friend_number, width, height, y, u, v, &err);
|
||||
return err;
|
||||
}
|
||||
|
||||
Toxav_Err_Bit_Rate_Set ToxAV::toxavVideoSetBitRate(uint32_t friend_number, uint32_t bit_rate) {
|
||||
Toxav_Err_Bit_Rate_Set err {TOXAV_ERR_BIT_RATE_SET_OK};
|
||||
toxav_video_set_bit_rate(_tox_av, friend_number, bit_rate, &err);
|
||||
return err;
|
||||
}
|
||||
|
37
src/tox_av.hpp
Normal file
37
src/tox_av.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <tox/toxav.h>
|
||||
|
||||
struct ToxAV {
|
||||
Tox* _tox = nullptr;
|
||||
ToxAV* _tox_av = nullptr;
|
||||
|
||||
ToxAV(Tox* tox);
|
||||
virtual ~ToxAV(void);
|
||||
|
||||
// interface
|
||||
uint32_t toxavIterationInterval(void) const;
|
||||
void toxavIterate(void);
|
||||
|
||||
uint32_t toxavAudioIterationInterval(void) const;
|
||||
void toxavAudioIterate(void);
|
||||
uint32_t toxavVideoIterationInterval(void) const;
|
||||
void toxavVideoIterate(void);
|
||||
|
||||
Toxav_Err_Call toxavCall(uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate);
|
||||
Toxav_Err_Answer toxavAnswer(uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate);
|
||||
Toxav_Err_Call_Control toxavCallControl(uint32_t friend_number, Toxav_Call_Control control);
|
||||
Toxav_Err_Send_Frame toxavAudioSendFrame(uint32_t friend_number, const int16_t pcm[], size_t sample_count, uint8_t channels, uint32_t sampling_rate);
|
||||
Toxav_Err_Bit_Rate_Set toxavAudioSetBitRate(uint32_t friend_number, uint32_t bit_rate);
|
||||
Toxav_Err_Send_Frame toxavVideoSendFrame(uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t y[/*! height * width */], const uint8_t u[/*! height/2 * width/2 */], const uint8_t v[/*! height/2 * width/2 */]);
|
||||
Toxav_Err_Bit_Rate_Set toxavVideoSetBitRate(uint32_t friend_number, uint32_t bit_rate);
|
||||
|
||||
//int32_t toxav_add_av_groupchat(Tox *tox, toxav_audio_data_cb *audio_callback, void *userdata);
|
||||
//int32_t toxav_join_av_groupchat(Tox *tox, uint32_t friendnumber, const uint8_t data[], uint16_t length, toxav_audio_data_cb *audio_callback, void *userdata);
|
||||
//int32_t toxav_group_send_audio(Tox *tox, uint32_t groupnumber, const int16_t pcm[], uint32_t samples, uint8_t channels, uint32_t sample_rate);
|
||||
//int32_t toxav_groupchat_enable_av(Tox *tox, uint32_t groupnumber, toxav_audio_data_cb *audio_callback, void *userdata);
|
||||
//int32_t toxav_groupchat_disable_av(Tox *tox, uint32_t groupnumber);
|
||||
//bool toxav_groupchat_av_enabled(Tox *tox, uint32_t groupnumber);
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user