blob: 141a3f3b6ae61728c3c82d1c417be8e0175c41c4 (
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
|
#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];
void *display_thread(void *arg)
{
(void)arg;
int r = display();
if(r == 0)
info("display: closed\n");
else
err("display: failed\n");
exit(r);
// pthread_exit(0);
}
void on_recv(char *buf, int numbytes)
{
memcpy(cam_data, &(buf[REC_CAP]), BUF_CAP-REC_CAP);
audio_play(buf);
}
int main(void)
{
memset(cam_data, 0, BUF_CAP);
pthread_t tid;
pthread_create(&tid, NULL, display_thread, NULL);
if(listener("4950", &on_recv) != 0) {
err("listener: failed");
return 1;
}
return 0;
}
|