aboutsummaryrefslogtreecommitdiff
path: root/src/talker.c
blob: 0ba299480acc92f13c01a9014465b6885c9c2ac0 (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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>

#include "socket.h"
#include "camera.h"
#include "audio.h"
#include "typedef.h"

#define CAM "/dev/video0"
#define X_RES 160
#define Y_RES 120

camera_handle cam_handle;

void on_send(char *buf, int *bytes)
{
    audio_record(buf);

    int image_sz = X_RES*Y_RES*3;
    buf[REC_CAP+0] = (unsigned char)X_RES;
    buf[REC_CAP+1] = (unsigned char)Y_RES;

    *bytes = REC_CAP + 2 + image_sz;

    memcpy(&(buf[REC_CAP+2]), camera_get_image(&cam_handle), image_sz);

}

int main(void)
{
    int ret = 1;

    camera_params params = {0};
    params.device = "/dev/video0";
    params.x_res = 160;
    params.y_res = 120;

    camera_init(&cam_handle, params);

    if(talker("4950", "localhost", &on_send) != 0) {
        goto finish;
    }

    ret = 0;
finish:
    camera_deinit(&cam_handle);
    return ret;
}