1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-26 00:03:02 +01:00

Half-hearted attempt at making toxic work on osx.

Video has no chance without X11 for now.
This commit is contained in:
iphydf 2020-03-30 13:35:34 +01:00
parent 98cb7f58c0
commit 46513017e3
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
4 changed files with 44 additions and 35 deletions

View File

@ -5,17 +5,25 @@ project()
cc_binary(
name = "toxic",
srcs = glob([
srcs = glob(
[
"src/*.c",
"src/*.h",
]),
],
exclude = ["src/video*"],
) + select({
"//tools/config:linux": glob(["src/video*"]),
"//tools/config:osx": [],
}),
copts = [
"-DAUDIO",
"-DPACKAGE_DATADIR='\"data\"'",
"-DPYTHON",
"-DQRCODE",
"-DVIDEO",
],
] + select({
"//tools/config:linux": ["-DVIDEO"],
"//tools/config:osx": [],
}),
deps = [
"//c-toxcore",
"@curl",
@ -25,6 +33,8 @@ cc_binary(
"@ncurses",
"@openal",
"@python3//:python",
"@x11",
],
] + select({
"//tools/config:linux": ["@x11"],
"//tools/config:osx": [],
}),
)

View File

@ -29,17 +29,12 @@
#include "line_info.h"
#include "settings.h"
#ifdef __APPLE__
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
#else
#include <AL/al.h>
#include <AL/alc.h>
/* compatibility with older versions of OpenAL */
#ifndef ALC_ALL_DEVICES_SPECIFIER
#include <AL/alext.h>
#endif /* ALC_ALL_DEVICES_SPECIFIER */
#endif /* __APPLE__ */
#include <stdbool.h>
#include <string.h>

View File

@ -24,15 +24,15 @@
#include "video_call.h"
#include <sys/ioctl.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <vpx/vpx_image.h>
#if defined(__OSX__)
#if defined(__OSX__) || defined(__APPLE__)
#import "osx_video.h"
#else
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
@ -42,7 +42,7 @@
#else
#include <linux/videodev2.h>
#endif /* defined(__OpenBSD__) || defined(__NetBSD__) */
#endif /* __OSX__ */
#endif /* __OSX__ || __APPLE__ */
#include "line_info.h"
#include "settings.h"
@ -72,7 +72,7 @@ typedef struct VideoDevice {
void *cb_data; /* Data to be passed to callback */
int32_t friend_number; /* ToxAV friend number */
#if !defined(__OSX__)
#if !(defined(__OSX__) || defined(__APPLE__))
int fd; /* File descriptor of video device selected/opened */
struct v4l2_format fmt;
struct VideoBuffer *buffers;
@ -137,7 +137,7 @@ static void yuv420tobgr(uint16_t width, uint16_t height, const uint8_t *y,
}
}
#if !defined(__OSX__)
#if !(defined(__OSX__) || defined(__APPLE__))
static void yuv422to420(uint8_t *plane_y, uint8_t *plane_u, uint8_t *plane_v,
uint8_t *input, uint16_t width, uint16_t height)
{
@ -186,13 +186,13 @@ VideoDeviceError init_video_devices()
{
size[vdt_input] = 0;
#if defined(__OSX__)
#if defined(__OSX__) || defined(__APPLE__)
if (osx_video_init((char **)video_devices_names[vdt_input], &size[vdt_input]) != 0) {
return vde_InternalError;
}
#else /* not __OSX__*/
#else /* not __OSX__ || __APPLE__ */
for (; size[vdt_input] <= MAX_DEVICES; ++size[vdt_input]) {
int fd;
@ -270,9 +270,9 @@ VideoDeviceError terminate_video_devices(void)
return (VideoDeviceError) vde_InternalError;
}
#ifdef __OSX__
#if defined(__OSX__) || defined(__APPLE__)
osx_video_release();
#endif /* __OSX__ */
#endif /* __OSX__ || __APPLE__ */
return (VideoDeviceError) vde_None;
}
@ -280,13 +280,13 @@ VideoDeviceError terminate_video_devices(void)
VideoDeviceError register_video_device_callback(int32_t friend_number, uint32_t device_idx,
VideoDataHandleCallback callback, void *data)
{
#if defined(__OSX__)
#if defined(__OSX__) || defined(__APPLE__)
if (size[vdt_input] <= device_idx || !video_devices_running[vdt_input][device_idx]) {
return vde_InvalidSelection;
}
#else /* not __OSX__ */
#else /* not __OSX__ || __APPLE__ */
if (size[vdt_input] <= device_idx || !video_devices_running[vdt_input][device_idx]
|| !video_devices_running[vdt_input][device_idx]->fd) {
@ -370,7 +370,7 @@ VideoDeviceError open_video_device(VideoDeviceType type, int32_t selection, uint
if (type == vdt_input) {
video_thread_paused = true;
#if defined(__OSX__)
#if defined(__OSX__) || defined(__APPLE__)
if (osx_video_open_device(selection, &device->video_width, &device->video_height) != 0) {
free(device);
@ -378,7 +378,7 @@ VideoDeviceError open_video_device(VideoDeviceType type, int32_t selection, uint
return vde_FailedStart;
}
#else /* not __OSX__*/
#else /* not __OSX__ || __APPLE__ */
/* Open selected device */
char device_address[] = "/dev/videoXX";
snprintf(device_address + 10, sizeof(device_address) - 10, "%i", selection);
@ -690,14 +690,14 @@ void *video_thread_poll(void *arg) // TODO: maybe use thread for every input so
uint8_t *u = device->input.planes[1];
uint8_t *v = device->input.planes[2];
#if defined(__OSX__)
#if defined(__OSX__) || defined(__APPLE__)
if (osx_video_read_device(y, u, v, &video_width, &video_height) != 0) {
unlock;
continue;
}
#else /* not __OSX__*/
#else /* not __OSX__ || __APPLE__ */
struct v4l2_buffer buf;
memset(&(buf), 0, sizeof(buf));
@ -751,7 +751,7 @@ void *video_thread_poll(void *arg) // TODO: maybe use thread for every input so
XFlush(device->x_display);
free(img_data);
#if !defined(__OSX__)
#if !(defined(__OSX__) || defined(__APPLE__))
if (-1 == xioctl(device->fd, VIDIOC_QBUF, &buf)) {
unlock;
@ -792,10 +792,10 @@ VideoDeviceError close_video_device(VideoDeviceType type, uint32_t device_idx)
if (!device->ref_count) {
if (type == vdt_input) {
#if defined(__OSX__)
#if defined(__OSX__) || defined(__APPLE__)
osx_video_close_device(device_idx);
#else /* not __OSX__ */
#else /* not __OSX__ || __APPLE__ */
enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (-1 == xioctl(device->fd, VIDIOC_STREAMOFF, &buf_type)) {}
@ -816,9 +816,9 @@ VideoDeviceError close_video_device(VideoDeviceType type, uint32_t device_idx)
XCloseDisplay(device->x_display);
pthread_mutex_destroy(device->mutex);
#if !defined(__OSX__)
#if !(defined(__OSX__) || defined(__APPLE__))
free(device->buffers);
#endif /* not __OSX__ */
#endif /* not __OSX__ || __APPLE__ */
free(device);
} else {

View File

@ -23,6 +23,8 @@
#include "xtra.h"
#include "misc_tools.h"
#ifndef __APPLE__
#include <X11/Xlib.h>
#include <X11/Xatom.h>
@ -419,3 +421,5 @@ void terminate_xtra(void)
while (Xtra.display); /* Wait for termination */
}
#endif /* !__APPLE__ */