From d40fd9b1adab64182ce8af0b8e19cfc8a93171d7 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sat, 9 Sep 2017 15:36:21 +0200 Subject: video streaming test updated; not tested --- code/test/vid/Makefile | 15 +++-- code/test/vid/cap.c | 36 ++++++------ code/test/vid/client.c | 106 ++++++++++++++++++++++++++++++++++++ code/test/vid/enc.c | 100 +++++----------------------------- code/test/vid/enc.h | 5 +- code/test/vid/server.c | 63 +++++++++++++++++++++ code/test/vid/server.h | 5 ++ code/test/vid/tools.c | 145 +++++++++++++++++++++++++++++++++++++++++++------ code/test/vid/tools.h | 12 +++- 9 files changed, 355 insertions(+), 132 deletions(-) create mode 100644 code/test/vid/client.c create mode 100644 code/test/vid/server.c create mode 100644 code/test/vid/server.h (limited to 'code/test/vid') diff --git a/code/test/vid/Makefile b/code/test/vid/Makefile index 757429d..fbdbe15 100644 --- a/code/test/vid/Makefile +++ b/code/test/vid/Makefile @@ -1,17 +1,20 @@ LIBVPX_HOME=../libvpx -CFLAGS=-D_V4L2_KERNEL_ -I/usr/src/linux-headers-$(uname -r) -I$(LIBVPX_HOME) +CFLAGS=-D_V4L2_KERNEL_ -I/usr/src/linux-headers-$(uname -r) -I$(LIBVPX_HOME) -I../../core -I../../vconn -I../../util LDFLAGS=-L$(LIBVPX_HOME) -deps=$(LIBVPX_HOME)/ivfenc.c.o $(LIBVPX_HOME)/video_writer.c.o +dep=../../core/libecpcore.a ../../core/crypto/libecpcr.a ../../core/htable/libecpht.a ../../core/posix/libecptr.a ../../core/posix/libecptm.a ../../vconn/libecpvconn.a ../../util/libecputil.a ../init.o -all: cap +all: client cap %.o: %.c $(CC) $(CFLAGS) -c $< -cap: cap.o enc.o tools.o - $(CC) -o $@ $< enc.o tools.o $(deps) -lvpx -lm -pthread $(LDFLAGS) +cap: cap.o enc.o tools.o server.o + $(CC) -o $@ $< enc.o tools.o server.o -lvpx -lm -pthread $(dep) $(LDFLAGS) +client: client.o tools.o + $(CC) -o $@ $< tools.o -lvpx -lm -pthread $(dep) $(LDFLAGS) + clean: rm -f *.o - rm -f cap + rm -f cap client diff --git a/code/test/vid/cap.c b/code/test/vid/cap.c index c156fab..99fa500 100644 --- a/code/test/vid/cap.c +++ b/code/test/vid/cap.c @@ -398,7 +398,7 @@ int v4l2_set_mmap(int fd, int *buffers_count) return CAP_OK; } -int v4l2_retrieve_frame(int fd, int buffers_count, vpx_image_t *raw, vpx_codec_ctx_t *codec, int frame_count, int kframe_interval) +int v4l2_retrieve_frame(int fd, int buffers_count, vpx_image_t *raw, vpx_codec_ctx_t *codec, int frame_index, int kframe_interval) { int sz; fd_set fds; @@ -445,10 +445,11 @@ int v4l2_retrieve_frame(int fd, int buffers_count, vpx_image_t *raw, vpx_codec_c // printf("Length: %d \tBytesused: %d \tAddress: %p\n", buf.length, buf.bytesused, &buffers[buf.index]); sz = ALIGN_16B(width) * height * 3 / 2; - vpx_img_read(raw, buffers[buf.index].start, sz); - if (frame_count % kframe_interval == 0) - flags |= VPX_EFLAG_FORCE_KF; - vpx_encode_frame(codec, raw, frame_count, flags); + if (!vpx_img_read(raw, buffers[buf.index].start, sz)) { + die_codec(NULL, "Failed to read image."); + } + if (frame_index % kframe_interval == 0) flags |= VPX_EFLAG_FORCE_KF; + vpx_encode_frame(codec, raw, frame_index, flags); if (xioctl(fd, VIDIOC_QBUF, &buf) == -1) { CAP_ERROR_RET("failed to queue buffer."); @@ -475,7 +476,6 @@ int v4l2_close_camera(int fd, int buffers_count) int main(int argc, char *argv[]) { - int i, n; int fd; int target_bitrate = 200; double after; @@ -484,13 +484,12 @@ int main(int argc, char *argv[]) int buffers_count; int kframe_interval; vpx_codec_er_flags_t err_resilient; - int frame_count; - char *out_fname; + char *address; + char *key_file; if (argc != 13) { - CAP_ERROR_RET("./cap