mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-14 05:33:03 +01:00
added /bitrate
This commit is contained in:
parent
922c184195
commit
2ede39369a
@ -342,6 +342,7 @@ void audio_bit_rate_status_cb(ToxAV *av, uint32_t friend_number, uint32_t audio_
|
||||
uint32_t video_bit_rate, void *user_data)
|
||||
{
|
||||
CallControl.audio_bit_rate = audio_bit_rate;
|
||||
toxav_bit_rate_set(av, friend_number, audio_bit_rate, video_bit_rate, user_data);
|
||||
}
|
||||
|
||||
void callback_recv_invite(Tox *m, uint32_t friend_number)
|
||||
@ -387,7 +388,7 @@ void callback_recv_starting(uint32_t friend_number)
|
||||
windows[i].onStarting(&windows[i], CallControl.av, friend_number, CallControl.call_state);
|
||||
|
||||
if ( 0 != start_transmission(&windows[i], &CallControl.calls[friend_number]) ) /* YEAH! */
|
||||
line_info_add(&windows[i], NULL, NULL, NULL, SYS_MSG, 0, 0 , "Error starting transmission!");
|
||||
line_info_add(&windows[i], NULL, NULL, NULL, SYS_MSG, 0, 0, "Error starting transmission!");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -834,6 +835,55 @@ on_error:
|
||||
print_err (self, error_str);
|
||||
}
|
||||
|
||||
void cmd_bitrate(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||
{
|
||||
char *error_str;
|
||||
|
||||
if ( argc != 1 ) {
|
||||
error_str = "Must have value!";
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
if ( self->is_call == false ) {
|
||||
error_str = "Must be in a call";
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
const uint32_t bitrate = strtol(argv[1], NULL, 10);
|
||||
|
||||
TOXAV_ERR_BIT_RATE_SET error;
|
||||
audio_bit_rate_status_cb(CallControl.av, self->num, bitrate, -1, &error);
|
||||
|
||||
if (error != TOXAV_ERR_BIT_RATE_SET_OK) {
|
||||
switch (error) {
|
||||
case TOXAV_ERR_BIT_RATE_SET_SYNC:
|
||||
error_str = "Syncronization error occured";
|
||||
break;
|
||||
|
||||
case TOXAV_ERR_BIT_RATE_SET_INVALID_AUDIO_BIT_RATE:
|
||||
error_str = "Invalid audio bit rate value (valid is 6-510)";
|
||||
break;
|
||||
|
||||
case TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_FOUND:
|
||||
error_str = "Friend not found";
|
||||
break;
|
||||
|
||||
case TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_IN_CALL:
|
||||
error_str = "Friend is not in the call";
|
||||
break;
|
||||
|
||||
default:
|
||||
error_str = "Unknown error";
|
||||
}
|
||||
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
on_error:
|
||||
print_err (self, error_str);
|
||||
}
|
||||
|
||||
void stop_current_call(ToxWindow *self)
|
||||
{
|
||||
|
@ -66,9 +66,9 @@ static void kill_infobox(ToxWindow *self);
|
||||
#endif /* AUDIO */
|
||||
|
||||
#if defined(AUDIO) && defined(PYTHON)
|
||||
#define AC_NUM_CHAT_COMMANDS 31
|
||||
#define AC_NUM_CHAT_COMMANDS 32
|
||||
#elif AUDIO
|
||||
#define AC_NUM_CHAT_COMMANDS 30
|
||||
#define AC_NUM_CHAT_COMMANDS 31
|
||||
#elif PYTHON
|
||||
#define AC_NUM_CHAT_COMMANDS 23
|
||||
#else
|
||||
@ -110,6 +110,7 @@ static const char chat_cmd_list[AC_NUM_CHAT_COMMANDS][MAX_CMDNAME_SIZE] = {
|
||||
{ "/mute" },
|
||||
{ "/sense" },
|
||||
{ "/video" },
|
||||
{ "/bitrate" },
|
||||
|
||||
#endif /* AUDIO */
|
||||
|
||||
|
@ -41,6 +41,7 @@ void cmd_cancel(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZ
|
||||
void cmd_ccur_device(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||
void cmd_mute(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||
void cmd_sense(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||
void cmd_bitrate(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||
#endif /* AUDIO */
|
||||
|
||||
#ifdef VIDEO
|
||||
|
@ -66,7 +66,7 @@ static struct cmd_func global_commands[] = {
|
||||
#endif /* AUDIO */
|
||||
#ifdef VIDEO
|
||||
{ "/lsvdev", cmd_list_video_devices },
|
||||
{ "/svdev" , cmd_change_video_device },
|
||||
{ "/svdev", cmd_change_video_device },
|
||||
#endif /* VIDEO */
|
||||
#ifdef PYTHON
|
||||
{ "/run", cmd_run },
|
||||
@ -87,6 +87,7 @@ static struct cmd_func chat_commands[] = {
|
||||
{ "/hangup", cmd_hangup },
|
||||
{ "/mute", cmd_mute },
|
||||
{ "/sense", cmd_sense },
|
||||
{ "/bitrate", cmd_bitrate },
|
||||
#endif /* AUDIO */
|
||||
#ifdef VIDEO
|
||||
{ "/video", cmd_video },
|
||||
|
@ -242,6 +242,7 @@ static void help_draw_chat(ToxWindow *self)
|
||||
wprintw(win, " /sdev <type> <id> : Change active device\n");
|
||||
wprintw(win, " /mute <type> : Mute active device if in call\n");
|
||||
wprintw(win, " /sense <n> : VAD sensitivity threshold\n");
|
||||
wprintw(win, " /bitrate <n> : Set the audio encoding bitrate\n");
|
||||
#endif /* AUDIO */
|
||||
|
||||
#ifdef VIDEO
|
||||
@ -355,9 +356,9 @@ void help_onKey(ToxWindow *self, wint_t key)
|
||||
|
||||
case 'c':
|
||||
#ifdef VIDEO
|
||||
help_init_window(self, 22, 80);
|
||||
help_init_window(self, 23, 80);
|
||||
#elif AUDIO
|
||||
help_init_window(self, 19, 80);
|
||||
help_init_window(self, 20, 80);
|
||||
#else
|
||||
help_init_window(self, 10, 80);
|
||||
#endif
|
||||
|
@ -208,10 +208,10 @@ void bgrxtoyuv420(uint8_t *plane_y, uint8_t *plane_u, uint8_t *plane_v, uint8_t
|
||||
// TODO possibly get a better pixel format
|
||||
if (_shouldMangleDimensions) {
|
||||
[_linkerVideo setVideoSettings: @ {
|
||||
(id)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_32BGRA),
|
||||
(id)kCVPixelBufferWidthKey: @640,
|
||||
(id)kCVPixelBufferHeightKey: @480
|
||||
}];
|
||||
(id)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_32BGRA),
|
||||
(id)kCVPixelBufferWidthKey: @640,
|
||||
(id)kCVPixelBufferHeightKey: @480
|
||||
}];
|
||||
} else {
|
||||
[_linkerVideo setVideoSettings: @ {(id)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_32BGRA)}];
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ static void prompt_onDraw(ToxWindow *self, Tox *m)
|
||||
help_onDraw(self);
|
||||
}
|
||||
|
||||
static void prompt_onConnectionChange(ToxWindow *self, Tox *m, uint32_t friendnum , TOX_CONNECTION connection_status)
|
||||
static void prompt_onConnectionChange(ToxWindow *self, Tox *m, uint32_t friendnum, TOX_CONNECTION connection_status)
|
||||
{
|
||||
ChatContext *ctx = self->chatwin;
|
||||
|
||||
|
@ -358,7 +358,7 @@ VideoDeviceError open_video_device(VideoDeviceType type, int32_t selection, uint
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
/* Open selected device */
|
||||
char device_address[] = "/dev/videoXX";
|
||||
snprintf(device_address + 10 , sizeof(device_address) - 10, "%i", selection);
|
||||
snprintf(device_address + 10, sizeof(device_address) - 10, "%i", selection);
|
||||
|
||||
device->fd = open(device_address, O_RDWR);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user