From 8a66c3fa4cba72384a961d223c4497df897a9980 Mon Sep 17 00:00:00 2001 From: cnhenry Date: Wed, 12 Aug 2015 08:24:43 -0500 Subject: [PATCH] Changed to toggle video command rather than two separate commands --- src/chat_commands.h | 1 - src/execute.c | 1 - src/help.c | 5 ++-- src/video_call.c | 56 ++++++++++++--------------------------------- src/video_device.c | 10 +++++--- 5 files changed, 23 insertions(+), 50 deletions(-) diff --git a/src/chat_commands.h b/src/chat_commands.h index 698ab22..9389329 100644 --- a/src/chat_commands.h +++ b/src/chat_commands.h @@ -45,7 +45,6 @@ void cmd_sense(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE #ifdef VIDEO void cmd_video(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); -void cmd_end_video(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_ccur_video_device(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); #endif /* VIDEO */ diff --git a/src/execute.c b/src/execute.c index f8ffc97..c4c53f6 100644 --- a/src/execute.c +++ b/src/execute.c @@ -84,7 +84,6 @@ static struct cmd_func chat_commands[] = { #endif /* AUDIO */ #ifdef VIDEO { "/video", cmd_video }, - { "/endvideo", cmd_end_video }, #endif /* VIDEO */ { NULL, NULL }, }; diff --git a/src/help.c b/src/help.c index 8173082..1f6ff66 100644 --- a/src/help.c +++ b/src/help.c @@ -216,8 +216,7 @@ static void help_draw_chat(ToxWindow *self) wattron(win, A_BOLD); wprintw(win, "\n Video:\n"); wattroff(win, A_BOLD); - wprintw(win, " /video : Send video capture\n"); - wprintw(win, " /endvideo : End video capture\n"); + wprintw(win, " /video : Toggle video call\n"); #endif /* VIDEO */ help_draw_bottom_menu(win); @@ -300,7 +299,7 @@ void help_onKey(ToxWindow *self, wint_t key) case 'c': #ifdef VIDEO - help_init_window(self, 23, 80); + help_init_window(self, 22, 80); #elif AUDIO help_init_window(self, 19, 80); #else diff --git a/src/video_call.c b/src/video_call.c index 57b66e9..4e06ff7 100644 --- a/src/video_call.c +++ b/src/video_call.c @@ -138,7 +138,7 @@ int start_video_transmission(ToxWindow *self, ToxAV *av, Call *call) return -1; } - if ( register_video_device_callback(self->num, call->vin_idx, read_video_device_callback, &self->num) != vde_None) + if ( register_video_device_callback(self->num, call->vin_idx, read_video_device_callback, &self->num) != vde_None ) line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to register input video handler!"); return 0; @@ -257,49 +257,21 @@ void cmd_video(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[M goto on_error; } - if ( !self->stb->connection ) { - error_str = "Friend is offline."; - goto on_error; - } - - if ( !self->is_call ) { - error_str = "Not in call!"; - goto on_error; - } - - if ( this_call->vin_idx != -1 ) { - error_str = "Video is already sending in this call."; - goto on_error; - } - - callback_video_starting(self->num); - - return; -on_error: - print_err (self, error_str); -} - -void cmd_end_video(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) -{ - const char *error_str; - Call* this_call = &CallControl.calls[self->num]; - - if ( argc != 0 ) { - error_str = "Unknown arguments."; - goto on_error; - } - - if ( !CallControl.av ) { - error_str = "ToxAV not supported!"; - goto on_error; - } - if ( this_call->vin_idx == -1 ) { - error_str = "Video is not running in this call."; - goto on_error; - } + if ( !self->stb->connection ) { + error_str = "Friend is offline."; + goto on_error; + } - callback_video_end(self->num); + if ( !self->is_call ) { + error_str = "Not in call!"; + goto on_error; + } + + callback_video_starting(self->num); + } else { + callback_video_end(self->num); + } return; on_error: diff --git a/src/video_device.c b/src/video_device.c index 47c8ac0..4be81a2 100644 --- a/src/video_device.c +++ b/src/video_device.c @@ -171,7 +171,7 @@ VideoDeviceError init_video_devices() { size[vdt_input] = 0; - #ifdef __linux__ +#ifdef __linux__ for (; size[vdt_input] <= MAX_DEVICES; ++size[vdt_input]) { int fd; char device_address[] = "/dev/videoXX"; @@ -186,6 +186,7 @@ VideoDeviceError init_video_devices() /* Query V4L for capture capabilities */ if ( ioctl(fd, VIDIOC_QUERYCAP, &cap) != -1 ) { + //strcpy(video_input_name,cap.card); video_input_name = cap.card; } else { video_input_name = device_address; @@ -195,11 +196,13 @@ VideoDeviceError init_video_devices() close(fd); } } - #endif /* __linux__ */ +#else /* __OSX__ */ /* TODO: Add OSX implementation for listing input video devices */ +#endif + size[vdt_output] = 1; - char* video_output_name = "Video Receiver"; + char* video_output_name = "Toxic Video Receiver"; video_devices_names[vdt_output][0] = video_output_name; // Start poll thread @@ -598,6 +601,7 @@ void* video_thread_poll (void* arg) // TODO: maybe use thread for every input so u = device->input.planes[1]; v = device->input.planes[2]; #else /* __OSX__*/ + #endif /* Convert frame image data to YUV420 for ToxAV */