summaryrefslogtreecommitdiff
path: root/code/test
diff options
context:
space:
mode:
Diffstat (limited to 'code/test')
-rw-r--r--code/test/vid/Makefile12
-rw-r--r--code/test/vid/client.c26
-rw-r--r--code/test/vid/enc.c1
3 files changed, 21 insertions, 18 deletions
diff --git a/code/test/vid/Makefile b/code/test/vid/Makefile
index 3f78157..9ef247e 100644
--- a/code/test/vid/Makefile
+++ b/code/test/vid/Makefile
@@ -1,7 +1,7 @@
-# LIBVPX_HOME=/home/majstor/libvpx
-LIBVPX_HOME=/Users/majstor/src/libvpx
-CFLAGS=-D_V4L2_KERNEL_ -I/usr/src/linux-headers-$(uname -r) -I$(LIBVPX_HOME) -I../../core -I../../vconn -I../../util
-LDFLAGS=-L$(LIBVPX_HOME)
+LIBVPX_HOME=/home/majstor/libvpx
+# LIBVPX_HOME=/Users/majstor/src/libvpx
+CFLAGS=-D_V4L2_KERNEL_ -I/usr/src/linux-headers-$(uname -r) -I$(LIBVPX_HOME) -I/opt/local/include/SDL2 -I../../core -I../../vconn -I../../util
+LDFLAGS=-L$(LIBVPX_HOME) -L/opt/local/lib
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: client cap
@@ -12,8 +12,8 @@ all: client cap
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)
+client: client.o display.o tools.o
+ $(CC) -o $@ $< display.o tools.o -lvpx -lSDL2 -lm -pthread $(dep) $(LDFLAGS)
clean:
rm -f *.o
diff --git a/code/test/vid/client.c b/code/test/vid/client.c
index 858d2ad..2c32c51 100644
--- a/code/test/vid/client.c
+++ b/code/test/vid/client.c
@@ -9,6 +9,7 @@
#include "vpx/vpx_decoder.h"
#include "vpx/vp8cx.h"
#include "tools.h"
+#include "display.h"
#define CTYPE_TEST 0
#define MTYPE_MSG 8
@@ -23,7 +24,6 @@ ECPConnHandler handler_c;
ECPNode node;
ECPConnection conn;
-FILE *outfile;
vpx_codec_ctx_t codec;
ECPRBRecv rbuf_recv;
@@ -31,17 +31,18 @@ ECPRBMessage rbuf_r_msg[RBUF_MSG_SIZE];
ECPFragIter frag_iter;
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) {
vpx_codec_iter_t iter = NULL;
vpx_image_t *img = NULL;
- if (vpx_codec_decode(&codec, f, (unsigned int)sz, NULL, 0))
- die_codec(&codec, "Failed to decode frame.");
+
+ if (vpx_codec_decode(&codec, f, (unsigned int)sz, NULL, 0)) die_codec(&codec, "Failed to decode frame.");
while ((img = vpx_codec_get_frame(&codec, &iter)) != NULL) {
- if (!vpx_img_write_f(img, outfile)) {
- die_codec(NULL, "Failed to write image.");
- }
+ if (!vpx_img_write(img, sdl_canvas.yuvBuffer, sdl_canvas.yPlaneSz + 2 * sdl_canvas.uvPlaneSz)) die_codec(NULL, "Failed to write image.");
}
+ sdl_display_frame(&sdl_canvas);
return sz;
}
@@ -88,12 +89,8 @@ int main(int argc, char *argv[]) {
rbuf_recv.frag_iter = &frag_iter;
}
- if (!rv) rv = ecp_conn_open(&conn, &node);
- fprintf(stderr, "ecp_conn_open RV:%d\n", rv);
-
const char *codec_arg = "vp9";
const VpxInterface *decoder = get_vpx_decoder_by_name(codec_arg);
- outfile = stdout;
if (!decoder) die_codec(NULL, "Unknown input codec.");
fprintf(stderr, "Using %s\n", vpx_codec_iface_name(decoder->codec_interface()));
@@ -101,7 +98,12 @@ int main(int argc, char *argv[]) {
if (vpx_codec_dec_init(&codec, decoder->codec_interface(), NULL, 0))
die_codec(&codec, "Failed to initialize decoder.");
- while (1) sleep(1);
-
+ sdl_open(&sdl_canvas, 640, 480);
+
+ if (!rv) rv = ecp_conn_open(&conn, &node);
+ fprintf(stderr, "ecp_conn_open RV:%d\n", rv);
+
+ sdl_loop();
+ sdl_close(&sdl_canvas);
if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec");
} \ No newline at end of file
diff --git a/code/test/vid/enc.c b/code/test/vid/enc.c
index 9aebf5f..34d0be8 100644
--- a/code/test/vid/enc.c
+++ b/code/test/vid/enc.c
@@ -148,6 +148,7 @@ void vpx_open(const char *codec_arg, int width, int height, int fps, int bitrate
cfg.g_timebase.den = fps;
cfg.rc_target_bitrate = bitrate;
cfg.g_error_resilient = err_resilient;
+ cfg.g_lag_in_frames = 0;
cfg.rc_end_usage = VPX_CBR;
if (vpx_codec_enc_init(codec, encoder->codec_interface(), &cfg, 0))