summaryrefslogtreecommitdiff
path: root/main.h
blob: 73fa96e4a1ce1d73d1180f6d6ed16279aeafa189 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once

#include <signal.h> /* for sig_atomic_t */
#include <string.h> /* for memset(3) */

#define UNUSED __attribute__((__unused__))
#define ZERO(x) memset(&(x), 0, sizeof(x))

#ifndef _
#define _(str) str
#endif

extern volatile sig_atomic_t running;
extern int httpsock;

struct frame {
	ssize_t len;
	size_t cap;
	char *data;
};

struct mpjpeg_stream {
	struct frame a;
	struct frame b;

	struct frame *front;
	struct frame *back;
	pthread_mutex_t frontlock;
};

struct wg;

void finish(int sig);
void thread_kinect(int video_fd, int depth_fd, int accel_fd);
void thread_http_listen(int fd);
void thread_mpjpeg_reader(struct mpjpeg_stream *s, int fd, const char *boundary);
void thread_mpjpeg_writer(struct mpjpeg_stream *s, int fd, const char *boundary);
void thread_http_listener(struct wg *wg, struct mpjpeg_stream *video, struct mpjpeg_stream *depth);
void init_mpjpeg_stream();

void * xrealloc(void *ptr, size_t size);