diff options
author | Uros Majstorovic <majstor@majstor.org> | 2018-01-19 19:08:32 +0100 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2018-01-19 19:08:32 +0100 |
commit | 544f43a7e06c9b0c63df8d3994318ea72107f64e (patch) | |
tree | 5e99fc1693ca1c538eb4d0a5743d100ace60eab1 | |
parent | 21d54fc77a32d76665223ae26c4262363a9222a6 (diff) |
pine64 vid test update
-rw-r--r-- | code/test/vid/cap.c | 12 | ||||
-rwxr-xr-x | code/test/vid/cap.sh | 2 | ||||
-rw-r--r-- | code/test/vid/client.c | 19 | ||||
-rw-r--r-- | code/test/vid/server.c | 19 | ||||
-rw-r--r-- | code/test/vid/server.h | 2 |
5 files changed, 39 insertions, 15 deletions
diff --git a/code/test/vid/cap.c b/code/test/vid/cap.c index f210bf3..e37c28f 100644 --- a/code/test/vid/cap.c +++ b/code/test/vid/cap.c @@ -486,10 +486,11 @@ int main(int argc, char *argv[]) int kframe_interval; vpx_codec_er_flags_t err_resilient; char *address; - char *key_file; + char *my_key; + char *vcs_key; - if (argc != 13) { - CAP_ERROR_RET("./cap <width> <height> <buffers [4,8]> <video mode [0,1]> <exposure [-4,4]> <hflip [0,1]> <vflip [0,1]> <kframe interval> <bitrate> <err resilient> <address> <key file>") + if (argc != 14) { + CAP_ERROR_RET("./cap <width> <height> <buffers [4,8]> <video mode [0,1]> <exposure [-4,4]> <hflip [0,1]> <vflip [0,1]> <kframe interval> <bitrate> <err resilient> <address> <my key> <vcs pub key>") } width = (int) atoi(argv[1]); height = (int) atoi(argv[2]); @@ -509,7 +510,8 @@ int main(int argc, char *argv[]) target_bitrate = (int) atoi(argv[9]); err_resilient = strtoul(argv[10], NULL, 0); address = argv[11]; - key_file = argv[12]; + my_key = argv[12]; + vcs_key = argv[13]; fprintf(stderr, "---- cap parameters -----\nwidth: %d\nheight: %d\nv4l2 buffers: %d\nexposure: %d\nhflip: %d\nvflip: %d\nMode: %s\n", width, height, n_buffers, sensor_exposure, sensor_hflip, sensor_vflip, sensor_video_mode ? "V4L2_MODE_VIDEO" : "V4L2_MODE_IMAGE"); @@ -545,7 +547,7 @@ int main(int argc, char *argv[]) vpx_image_t raw; vpx_open(codec_arg, width, height, _fps, target_bitrate, err_resilient, &codec, &raw); - init_server(address, key_file); + init_server(address, my_key, vcs_key); while (1) { if (!conn_is_open()) { diff --git a/code/test/vid/cap.sh b/code/test/vid/cap.sh index 9f306ec..bfd933e 100755 --- a/code/test/vid/cap.sh +++ b/code/test/vid/cap.sh @@ -1,3 +1,3 @@ #!/bin/sh -./cap 640 480 8 1 -999 -1 -1 25 256 1 0.0.0.0:3000 ../../keys/pine64-home.priv +./cap 640 480 8 1 -999 -1 -1 25 256 1 0.0.0.0:3000 ../../keys/pine64-home.priv ../../keys/majstor.org.pub diff --git a/code/test/vid/client.c b/code/test/vid/client.c index 692efd9..7dd8c26 100644 --- a/code/test/vid/client.c +++ b/code/test/vid/client.c @@ -24,6 +24,9 @@ ECPConnHandler handler_c; ECPNode node; ECPConnection conn; +ECPVConnection vconn; +ECPNode vconn_node; + vpx_codec_ctx_t codec; ECPRBRecv rbuf_recv; @@ -33,7 +36,7 @@ unsigned char frag_buffer[FRAG_BUF_SIZE]; SDLCanvas sdl_canvas; -ssize_t handle_msg(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsigned char *f, ssize_t sz) { +ssize_t handle_msg(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsigned char *f, ssize_t sz, ECP2Buffer *b) { vpx_codec_iter_t iter = NULL; vpx_image_t *img = NULL; @@ -52,14 +55,14 @@ ssize_t handle_msg(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsigned } static void usage(char *arg) { - fprintf(stderr, "Usage: %s <node.pub>\n", arg); + fprintf(stderr, "Usage: %s <node.pub> <vcs.pub>\n", arg); exit(1); } int main(int argc, char *argv[]) { int rv; - if (argc != 2) usage(argv[0]); + if (argc != 3) usage(argv[0]); rv = ecp_init(&ctx_c); fprintf(stderr, "ecp_init RV:%d\n", rv); @@ -82,6 +85,9 @@ int main(int argc, char *argv[]) { if (!rv) rv = ecp_util_node_load(&ctx_c, &node, argv[1]); fprintf(stderr, "ecp_util_node_load RV:%d\n", rv); + if (!rv) rv = ecp_util_node_load(&ctx, &vconn_node, argv[2]); + printf("ecp_util_node_load RV:%d\n", rv); + if (!rv) rv = ecp_conn_create(&conn, &sock_c, CTYPE_TEST); fprintf(stderr, "ecp_conn_create RV:%d\n", rv); @@ -104,8 +110,11 @@ int main(int argc, char *argv[]) { sdl_open(&sdl_canvas, 640, 480); - if (!rv) rv = ecp_conn_open(&conn, &node); - fprintf(stderr, "ecp_conn_open RV:%d\n", rv); + // if (!rv) rv = ecp_conn_open(&conn, &node); + // fprintf(stderr, "ecp_conn_open RV:%d\n", rv); + + if (!rv) rv = ecp_vconn_open(&conn, &node, &vconn, &vconn_node, 1); + printf("ecp_vconn_open RV:%d\n", rv); sdl_loop(); sdl_close(&sdl_canvas); diff --git a/code/test/vid/server.c b/code/test/vid/server.c index 2712dee..8753a7d 100644 --- a/code/test/vid/server.c +++ b/code/test/vid/server.c @@ -11,12 +11,15 @@ static ECPSocket sock_s; static ECPDHKey key_perma_s; static ECPConnHandler handler_s; -static ECPConnection *conn; +static ECPConnection *conn_in; static int is_open = 0; #define CTYPE_TEST 0 #define MTYPE_MSG 8 +ECPNode node; +ECPConnection conn; + static ssize_t handle_open(ECPConnection *c, ecp_seq_t sq, unsigned char t, unsigned char *m, ssize_t sz, ECP2Buffer *b) { ssize_t rv = ecp_conn_handle_open(c, sq, t, m, sz, b); if (rv < 0) return rv; @@ -29,14 +32,14 @@ static ssize_t handle_open(ECPConnection *c, ecp_seq_t sq, unsigned char t, unsi } ssize_t send_frame(unsigned char *buffer, size_t size, ecp_pts_t pts) { - return ecp_send(conn, MTYPE_MSG, buffer, size); + return ecp_send(conn_in, MTYPE_MSG, buffer, size); } int conn_is_open(void) { return is_open; } -int init_server(char *address, char *key) { +int init_server(char *address, char *my_key, char *vcs_key) { int rv; rv = ecp_init(&ctx_s); @@ -59,6 +62,16 @@ int init_server(char *address, char *key) { if (!rv) rv = ecp_start_receiver(&sock_s); fprintf(stderr, "ecp_start_receiver RV:%d\n", rv); + + if (!rv) rv = ecp_util_node_load(&ctx, &node, vcs_key); + printf("ecp_util_node_load RV:%d\n", rv); + + if (!rv) rv = ecp_conn_create(&conn, &sock, ECP_CTYPE_VLINK); + printf("ecp_conn_create RV:%d\n", rv); + + if (!rv) rv = ecp_conn_open(&conn, &node); + printf("ecp_conn_open RV:%d\n", rv); + return rv; } diff --git a/code/test/vid/server.h b/code/test/vid/server.h index 3f9c57e..a4024fd 100644 --- a/code/test/vid/server.h +++ b/code/test/vid/server.h @@ -2,4 +2,4 @@ ssize_t send_frame(unsigned char *buffer, size_t size, ecp_pts_t pts); int conn_is_open(void); -int init_server(char *address, char *key);
\ No newline at end of file +int init_server(char *address, char *my_key, char *vcs_key); |