blob: 1968590f7b3906928a18f96856f82baec64da917 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>
#include "socket.h"
#include "display.h"
#include "audio.h"
#include "typedef.h"
char cam_data[BUF_CAP] = {0};
unsigned int WIDTH = 1;
unsigned int HEIGHT = 1;
audio_handle aud_handle;
void *display_thread(void *arg)
{
(void)arg;
int r = display();
if(r == 0)
info("display: closed\n");
else
err("display: failed\n");
exit(r);
}
void on_recv(message *m)
{
WIDTH = m->WIDTH;
HEIGHT = m->HEIGHT;
memcpy(cam_data, m->video, WIDTH * HEIGHT * 3);
audio_play(&aud_handle, m->audio);
}
int main(void)
{
pthread_t tid;
pthread_create(&tid, NULL, display_thread, NULL);
if(audio_create(&aud_handle, PLAYBACK) != 0) {
err("audio_create: failed\n");
return 1;
}
if(listener("4950", &on_recv) != 0) {
err("listener: failed");
return 1;
}
return 0;
}
|