mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-14 08:03:02 +01:00
Fix some build issues
This commit is contained in:
parent
49f5efaab0
commit
6cc1525daa
@ -13,12 +13,14 @@ ifneq ($(AUDIO), disabled)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
# Check if we want build video support
|
# Check if we want build video support
|
||||||
VIDEO = $*shell if [ -z "$(DISABLE_AV)" ] || [ "$(DISABLE_AV)" = "0" ] ; then echo enabled ; else echo disabled ; fi)
|
VIDEO = $(shell if [ -z "$(DISABLE_AV)" ] || [ "$(DISABLE_AV)" = "0" ] ; then echo enabled ; else echo disabled ; fi)
|
||||||
|
ifneq ($(X11), disabled)
|
||||||
ifneq ($(AUDIO), disabled)
|
ifneq ($(AUDIO), disabled)
|
||||||
ifneq ($(VIDEO), disabled)
|
ifneq ($(VIDEO), disabled)
|
||||||
-include $(CHECKS_DIR)/video.mk
|
-include $(CHECKS_DIR)/video.mk
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
# Check if we want build sound notifications support
|
# Check if we want build sound notifications support
|
||||||
SND_NOTIFY = $(shell if [ -z "$(DISABLE_SOUND_NOTIFY)" ] || [ "$(DISABLE_SOUND_NOTIFY)" = "0" ] ; then echo enabled ; else echo disabled ; fi)
|
SND_NOTIFY = $(shell if [ -z "$(DISABLE_SOUND_NOTIFY)" ] || [ "$(DISABLE_SOUND_NOTIFY)" = "0" ] ; then echo enabled ; else echo disabled ; fi)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
# Variables for sound notifications support
|
# Variables for sound notifications support
|
||||||
SND_NOTIFY_LIBS = openal freealut
|
SND_NOTIFY_LIBS = openal freealut
|
||||||
SND_NOTIFY_CFLAGS = -DSOUND_NOTIFY
|
SND_NOTIFY_CFLAGS = -DSOUND_NOTIFY
|
||||||
ifneq (, $(findstring device.o, $(OBJ)))
|
ifneq (, $(findstring audio_device.o, $(OBJ)))
|
||||||
SND_NOTIFY_OBJ =
|
SND_NOTIFY_OBJ =
|
||||||
else
|
else
|
||||||
SND_NOTIFY_OBJ = device.o
|
SND_NOTIFY_OBJ = audio_device.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Check if we can build sound notifications support
|
# Check if we can build sound notifications support
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <tox/toxav.h>
|
#include <tox/toxav.h>
|
||||||
|
|
||||||
#include "audio_device.h"
|
#include "audio_device.h"
|
||||||
|
|
||||||
#define MAX_CALLS 10
|
#define MAX_CALLS 10
|
||||||
|
|
||||||
typedef enum _AudioError {
|
typedef enum _AudioError {
|
||||||
@ -75,13 +75,10 @@ struct CallControl {
|
|||||||
int32_t audio_frame_duration;
|
int32_t audio_frame_duration;
|
||||||
uint32_t audio_sample_rate;
|
uint32_t audio_sample_rate;
|
||||||
uint8_t audio_channels;
|
uint8_t audio_channels;
|
||||||
|
|
||||||
#ifdef VIDEO
|
|
||||||
uint32_t video_bit_rate;
|
uint32_t video_bit_rate;
|
||||||
int32_t video_frame_duration;
|
int32_t video_frame_duration;
|
||||||
|
|
||||||
#endif /* VIDEO */
|
|
||||||
|
|
||||||
} CallControl;
|
} CallControl;
|
||||||
|
|
||||||
struct CallControl CallControl;
|
struct CallControl CallControl;
|
||||||
|
@ -52,6 +52,7 @@ FriendRequests FrndRequests;
|
|||||||
#ifdef VIDEO
|
#ifdef VIDEO
|
||||||
#define AC_NUM_GLOB_COMMANDS 21
|
#define AC_NUM_GLOB_COMMANDS 21
|
||||||
#elif AUDIO
|
#elif AUDIO
|
||||||
|
#define AC_NUM_GLOB_COMMANDS 19
|
||||||
#else
|
#else
|
||||||
#define AC_NUM_GLOB_COMMANDS 17
|
#define AC_NUM_GLOB_COMMANDS 17
|
||||||
#endif
|
#endif
|
||||||
@ -87,9 +88,9 @@ static const char glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE] = {
|
|||||||
|
|
||||||
{ "/lsvdev" },
|
{ "/lsvdev" },
|
||||||
{ "/svdev" },
|
{ "/svdev" },
|
||||||
|
|
||||||
#endif /* VIDEO */
|
#endif /* VIDEO */
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void kill_prompt_window(ToxWindow *self)
|
void kill_prompt_window(ToxWindow *self)
|
||||||
|
@ -65,13 +65,13 @@ typedef struct VideoDevice {
|
|||||||
VideoDataHandleCallback cb; /* Use this to handle data from input device usually */
|
VideoDataHandleCallback cb; /* Use this to handle data from input device usually */
|
||||||
void* cb_data; /* Data to be passed to callback */
|
void* cb_data; /* Data to be passed to callback */
|
||||||
int32_t friend_number; /* ToxAV friend number */
|
int32_t friend_number; /* ToxAV friend number */
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
int fd; /* File descriptor of video device selected/opened */
|
int fd; /* File descriptor of video device selected/opened */
|
||||||
struct v4l2_format fmt;
|
struct v4l2_format fmt;
|
||||||
struct VideoBuffer *buffers;
|
struct VideoBuffer *buffers;
|
||||||
uint32_t n_buffers;
|
uint32_t n_buffers;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t ref_count;
|
uint32_t ref_count;
|
||||||
int32_t selection;
|
int32_t selection;
|
||||||
@ -107,8 +107,8 @@ bool video_thread_running = true,
|
|||||||
|
|
||||||
void* video_thread_poll(void*);
|
void* video_thread_poll(void*);
|
||||||
|
|
||||||
static void yuv420tobgr(uint16_t width, uint16_t height, const uint8_t *y,
|
static void yuv420tobgr(uint16_t width, uint16_t height, const uint8_t *y,
|
||||||
const uint8_t *u, const uint8_t *v, unsigned int ystride,
|
const uint8_t *u, const uint8_t *v, unsigned int ystride,
|
||||||
unsigned int ustride, unsigned int vstride, uint8_t *out)
|
unsigned int ustride, unsigned int vstride, uint8_t *out)
|
||||||
{
|
{
|
||||||
unsigned long int i, j;
|
unsigned long int i, j;
|
||||||
@ -133,7 +133,7 @@ static void yuv420tobgr(uint16_t width, uint16_t height, const uint8_t *y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
static void yuv422to420(uint8_t *plane_y, uint8_t *plane_u, uint8_t *plane_v,
|
static void yuv422to420(uint8_t *plane_y, uint8_t *plane_u, uint8_t *plane_v,
|
||||||
uint8_t *input, uint16_t width, uint16_t height)
|
uint8_t *input, uint16_t width, uint16_t height)
|
||||||
{
|
{
|
||||||
uint8_t *end = input + width * height * 2;
|
uint8_t *end = input + width * height * 2;
|
||||||
@ -255,14 +255,14 @@ VideoDeviceError terminate_video_devices()
|
|||||||
return (VideoDeviceError) vde_None;
|
return (VideoDeviceError) vde_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoDeviceError register_video_device_callback(int32_t friend_number, uint32_t device_idx,
|
VideoDeviceError register_video_device_callback(int32_t friend_number, uint32_t device_idx,
|
||||||
VideoDataHandleCallback callback, void* data)
|
VideoDataHandleCallback callback, void* data)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
if ( size[vdt_input] <= device_idx || !video_devices_running[vdt_input][device_idx] || !video_devices_running[vdt_input][device_idx]->fd )
|
if ( size[vdt_input] <= device_idx || !video_devices_running[vdt_input][device_idx] || !video_devices_running[vdt_input][device_idx]->fd )
|
||||||
return vde_InvalidSelection;
|
return vde_InvalidSelection;
|
||||||
#else /* __OSX__ */
|
#else /* __OSX__ */
|
||||||
if ( size[vdt_input] <= device_idx || !video_devices_running[vdt_input][device_idx] )
|
if ( size[vdt_input] <= device_idx || !video_devices_running[vdt_input][device_idx] )
|
||||||
return vde_InvalidSelection;
|
return vde_InvalidSelection;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -278,9 +278,9 @@ VideoDeviceError register_video_device_callback(int32_t friend_number, uint32_t
|
|||||||
VideoDeviceError set_primary_video_device(VideoDeviceType type, int32_t selection)
|
VideoDeviceError set_primary_video_device(VideoDeviceType type, int32_t selection)
|
||||||
{
|
{
|
||||||
if ( size[type] <= selection || selection < 0 ) return vde_InvalidSelection;
|
if ( size[type] <= selection || selection < 0 ) return vde_InvalidSelection;
|
||||||
|
|
||||||
primary_video_device[type] = selection;
|
primary_video_device[type] = selection;
|
||||||
|
|
||||||
return vde_None;
|
return vde_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,35 +297,35 @@ void get_primary_video_device_name(VideoDeviceType type, char *buf, int size)
|
|||||||
VideoDeviceError open_video_device(VideoDeviceType type, int32_t selection, uint32_t* device_idx)
|
VideoDeviceError open_video_device(VideoDeviceType type, int32_t selection, uint32_t* device_idx)
|
||||||
{
|
{
|
||||||
if ( size[type] <= selection || selection < 0 ) return vde_InvalidSelection;
|
if ( size[type] <= selection || selection < 0 ) return vde_InvalidSelection;
|
||||||
|
|
||||||
lock;
|
lock;
|
||||||
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
for (i = 0; i < MAX_DEVICES && video_devices_running[type][i]; ++i);
|
for (i = 0; i < MAX_DEVICES && video_devices_running[type][i]; ++i);
|
||||||
|
|
||||||
if (i == MAX_DEVICES) { unlock; return vde_AllDevicesBusy; }
|
if (i == MAX_DEVICES) { unlock; return vde_AllDevicesBusy; }
|
||||||
else *device_idx = i;
|
else *device_idx = i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_DEVICES; i ++) { /* Check if any device has the same selection */
|
for (i = 0; i < MAX_DEVICES; i ++) { /* Check if any device has the same selection */
|
||||||
if ( video_devices_running[type][i] && video_devices_running[type][i]->selection == selection ) {
|
if ( video_devices_running[type][i] && video_devices_running[type][i]->selection == selection ) {
|
||||||
|
|
||||||
video_devices_running[type][*device_idx] = video_devices_running[type][i];
|
video_devices_running[type][*device_idx] = video_devices_running[type][i];
|
||||||
video_devices_running[type][i]->ref_count ++;
|
video_devices_running[type][i]->ref_count ++;
|
||||||
|
|
||||||
unlock;
|
unlock;
|
||||||
return vde_None;
|
return vde_None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoDevice* device = video_devices_running[type][*device_idx] = calloc(1, sizeof(VideoDevice));
|
VideoDevice* device = video_devices_running[type][*device_idx] = calloc(1, sizeof(VideoDevice));
|
||||||
device->selection = selection;
|
device->selection = selection;
|
||||||
|
|
||||||
if ( pthread_mutex_init(device->mutex, NULL) != 0 ) {
|
if ( pthread_mutex_init(device->mutex, NULL) != 0 ) {
|
||||||
free(device);
|
free(device);
|
||||||
unlock;
|
unlock;
|
||||||
return vde_InternalError;
|
return vde_InternalError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( type == vdt_input ) {
|
if ( type == vdt_input ) {
|
||||||
video_thread_paused = true;
|
video_thread_paused = true;
|
||||||
|
|
||||||
@ -466,7 +466,7 @@ VideoDeviceError open_video_device(VideoDeviceType type, int32_t selection, uint
|
|||||||
int screen = DefaultScreen(device->x_display);
|
int screen = DefaultScreen(device->x_display);
|
||||||
|
|
||||||
if ( !(device->x_window = XCreateSimpleWindow(device->x_display, RootWindow(device->x_display, screen), 0, 0,
|
if ( !(device->x_window = XCreateSimpleWindow(device->x_display, RootWindow(device->x_display, screen), 0, 0,
|
||||||
device->video_width, device->video_height, 0, BlackPixel(device->x_display, screen),
|
device->video_width, device->video_height, 0, BlackPixel(device->x_display, screen),
|
||||||
BlackPixel(device->x_display, screen))) ) {
|
BlackPixel(device->x_display, screen))) ) {
|
||||||
close_video_device(vdt_input, *device_idx);
|
close_video_device(vdt_input, *device_idx);
|
||||||
|
|
||||||
@ -532,7 +532,7 @@ VideoDeviceError open_video_device(VideoDeviceType type, int32_t selection, uint
|
|||||||
|
|
||||||
vpx_img_alloc(&device->input, VPX_IMG_FMT_I420, device->video_width, device->video_height, 1);
|
vpx_img_alloc(&device->input, VPX_IMG_FMT_I420, device->video_width, device->video_height, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock;
|
unlock;
|
||||||
return vde_None;
|
return vde_None;
|
||||||
}
|
}
|
||||||
@ -603,7 +603,7 @@ void* video_thread_poll (void* arg) // TODO: maybe use thread for every input so
|
|||||||
*/
|
*/
|
||||||
(void)arg;
|
(void)arg;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
while (video_thread_running)
|
while (video_thread_running)
|
||||||
{
|
{
|
||||||
if ( video_thread_paused ) usleep(10000); /* Wait for unpause. */
|
if ( video_thread_paused ) usleep(10000); /* Wait for unpause. */
|
||||||
@ -612,7 +612,7 @@ void* video_thread_poll (void* arg) // TODO: maybe use thread for every input so
|
|||||||
for (i = 0; i < size[vdt_input]; ++i)
|
for (i = 0; i < size[vdt_input]; ++i)
|
||||||
{
|
{
|
||||||
lock;
|
lock;
|
||||||
if ( video_devices_running[vdt_input][i] != NULL )
|
if ( video_devices_running[vdt_input][i] != NULL )
|
||||||
{
|
{
|
||||||
/* Obtain frame image data from device buffers */
|
/* Obtain frame image data from device buffers */
|
||||||
VideoDevice* device = video_devices_running[vdt_input][i];
|
VideoDevice* device = video_devices_running[vdt_input][i];
|
||||||
@ -632,7 +632,7 @@ void* video_thread_poll (void* arg) // TODO: maybe use thread for every input so
|
|||||||
if ( -1 == ioctl(device->fd, VIDIOC_DQBUF, &buf) ) {
|
if ( -1 == ioctl(device->fd, VIDIOC_DQBUF, &buf) ) {
|
||||||
unlock;
|
unlock;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *data = (void*)device->buffers[buf.index].start;
|
void *data = (void*)device->buffers[buf.index].start;
|
||||||
|
|
||||||
@ -652,7 +652,7 @@ void* video_thread_poll (void* arg) // TODO: maybe use thread for every input so
|
|||||||
|
|
||||||
/* Convert YUV420 data to BGR */
|
/* Convert YUV420 data to BGR */
|
||||||
uint8_t *img_data = malloc(video_width * video_height * 4);
|
uint8_t *img_data = malloc(video_width * video_height * 4);
|
||||||
yuv420tobgr(video_width, video_height, y, u, v,
|
yuv420tobgr(video_width, video_height, y, u, v,
|
||||||
video_width, video_width/2, video_width/2, img_data);
|
video_width, video_width/2, video_width/2, img_data);
|
||||||
|
|
||||||
/* Allocate image data in X11 */
|
/* Allocate image data in X11 */
|
||||||
@ -686,34 +686,34 @@ void* video_thread_poll (void* arg) // TODO: maybe use thread for every input so
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
|
|
||||||
}
|
}
|
||||||
unlock;
|
unlock;
|
||||||
}
|
}
|
||||||
usleep(1000 * 1000 / 24);
|
usleep(1000 * 1000 / 24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoDeviceError close_video_device(VideoDeviceType type, uint32_t device_idx)
|
VideoDeviceError close_video_device(VideoDeviceType type, uint32_t device_idx)
|
||||||
{
|
{
|
||||||
if ( device_idx >= MAX_DEVICES ) return vde_InvalidSelection;
|
if ( device_idx >= MAX_DEVICES ) return vde_InvalidSelection;
|
||||||
|
|
||||||
lock;
|
lock;
|
||||||
VideoDevice *device = video_devices_running[type][device_idx];
|
VideoDevice *device = video_devices_running[type][device_idx];
|
||||||
VideoDeviceError rc = vde_None;
|
VideoDeviceError rc = vde_None;
|
||||||
|
|
||||||
if ( !device ) {
|
if ( !device ) {
|
||||||
unlock;
|
unlock;
|
||||||
return vde_DeviceNotActive;
|
return vde_DeviceNotActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
video_devices_running[type][device_idx] = NULL;
|
video_devices_running[type][device_idx] = NULL;
|
||||||
|
|
||||||
if ( !device->ref_count ) {
|
if ( !device->ref_count ) {
|
||||||
|
|
||||||
if ( type == vdt_input ) {
|
if ( type == vdt_input ) {
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
@ -740,18 +740,18 @@ VideoDeviceError close_video_device(VideoDeviceType type, uint32_t device_idx)
|
|||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
|
|
||||||
free(device);
|
free(device);
|
||||||
} else {
|
} else {
|
||||||
vpx_img_free(&device->input);
|
vpx_img_free(&device->input);
|
||||||
XDestroyWindow(device->x_display, device->x_window);
|
XDestroyWindow(device->x_display, device->x_window);
|
||||||
XFlush(device->x_display);
|
XFlush(device->x_display);
|
||||||
XCloseDisplay(device->x_display);
|
XCloseDisplay(device->x_display);
|
||||||
pthread_mutex_destroy(device->mutex);
|
pthread_mutex_destroy(device->mutex);
|
||||||
free(device);
|
free(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else device->ref_count--;
|
else device->ref_count--;
|
||||||
|
|
||||||
unlock;
|
unlock;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -769,4 +769,4 @@ void print_video_devices(ToxWindow* self, VideoDeviceType type)
|
|||||||
VideoDeviceError video_selection_valid(VideoDeviceType type, int32_t selection)
|
VideoDeviceError video_selection_valid(VideoDeviceType type, int32_t selection)
|
||||||
{
|
{
|
||||||
return (size[type] <= selection || selection < 0) ? vde_InvalidSelection : vde_None;
|
return (size[type] <= selection || selection < 0) ? vde_InvalidSelection : vde_None;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user