aboutsummaryrefslogtreecommitdiff
path: root/src/talker.c
blob: e7271ad2e05cdfb8a47abd3ad0e057eb70f12fdb (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
#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(message *m)
{
    audio_record(m->audio);

    m->WIDTH = X_RES;
    m->HEIGHT = Y_RES;

    memcpy(m->video, camera_get_image(&cam_handle), X_RES * Y_RES * 3);
}

int main(void)
{
    camera_params params = {0};
    params.device = CAM;
    params.x_res = X_RES;
    params.y_res = Y_RES;

    camera_init(&cam_handle, params);

    if(talker("4950", "localhost", &on_send) != 0) {
        err("talker: failed\n");
        return 1;
    }

    camera_deinit(&cam_handle);
    return 0;
}