From 2562d9881b74115e8df45ff605434f0dc8291763 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 5 Apr 2022 08:33:27 +0200 Subject: [PATCH] Organize sources --- Makefile | 15 ++++++++------- main_isp12.c.bak => cmd/main_isp12.c.bak | 0 main_isp13.c => cmd/main_isp13.c | 12 ++++++------ jmuxer.min.js => html/jmuxer.min.js | 0 jmuxer.min.c => html/jmuxer.min.js.c | 4 ++-- video.html => html/video.html | 0 video.html.c => html/video.html.c | 4 ++-- http.c => http/http.c | 2 +- http.h => http/http.h | 10 ++++++---- http_h264.c => http/http_h264.c | 10 +++++----- http_jpeg.c => http/http_jpeg.c | 6 +++--- http_methods.c => http/http_methods.c | 18 +++++++++--------- buffer.c => hw/buffer.c | 6 +++--- buffer.h => hw/buffer.h | 0 buffer_list.c => hw/buffer_list.c | 6 +++--- buffer_list.h => hw/buffer_list.h | 0 buffer_lock.c => hw/buffer_lock.c | 2 +- buffer_lock.h => hw/buffer_lock.h | 0 buffer_queue.c => hw/buffer_queue.c | 6 +++--- device.c => hw/device.c | 6 +++--- device.h => hw/device.h | 0 links.c => hw/links.c | 8 ++++---- links.h => hw/links.h | 0 v4l2.c => hw/v4l2.c | 2 +- v4l2.h => hw/v4l2.h | 0 25 files changed, 60 insertions(+), 57 deletions(-) rename main_isp12.c.bak => cmd/main_isp12.c.bak (100%) rename main_isp13.c => cmd/main_isp13.c (97%) rename jmuxer.min.js => html/jmuxer.min.js (100%) rename jmuxer.min.c => html/jmuxer.min.js.c (99%) rename video.html => html/video.html (100%) rename video.html.c => html/video.html.c (99%) rename http.c => http/http.c (99%) rename http.h => http/http.h (87%) rename http_h264.c => http/http_h264.c (91%) rename http_jpeg.c => http/http_jpeg.c (97%) rename http_methods.c => http/http_methods.c (73%) rename buffer.c => hw/buffer.c (96%) rename buffer.h => hw/buffer.h (100%) rename buffer_list.c => hw/buffer_list.c (98%) rename buffer_list.h => hw/buffer_list.h (100%) rename buffer_lock.c => hw/buffer_lock.c (98%) rename buffer_lock.h => hw/buffer_lock.h (100%) rename buffer_queue.c => hw/buffer_queue.c (98%) rename device.c => hw/device.c (98%) rename device.h => hw/device.h (100%) rename links.c => hw/links.c (98%) rename links.h => hw/links.h (100%) rename v4l2.c => hw/v4l2.c (98%) rename v4l2.h => hw/v4l2.h (100%) diff --git a/Makefile b/Makefile index f454a8e..8b930db 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ -camera_stream: *.c *.h - gcc -g -lpthread -o camera_stream *.c +SRC := $(wildcard **/*.c) +HEADERS := $(wildcard **/*.h) +HTML := $(wildcard html/*.js html/*.html) +HTML_SRC := $(addsuffix .c,$(HTML)) -jmuxer.min.c: jmuxer.min.js - xxd -i $< > $@.tmp - mv $@.tmp $@ - -video.html.c: video.html +camera_stream: $(SRC) $(HTML_SRC) $(HEADERS) + gcc -g -lpthread -I$(PWD) -o $@ $(filter %.c, $^) + +html/%.c: html/% xxd -i $< > $@.tmp mv $@.tmp $@ diff --git a/main_isp12.c.bak b/cmd/main_isp12.c.bak similarity index 100% rename from main_isp12.c.bak rename to cmd/main_isp12.c.bak diff --git a/main_isp13.c b/cmd/main_isp13.c similarity index 97% rename from main_isp13.c rename to cmd/main_isp13.c index 1d824b9..41b9764 100644 --- a/main_isp13.c +++ b/cmd/main_isp13.c @@ -1,9 +1,9 @@ -#include "buffer.h" -#include "buffer_list.h" -#include "device.h" -#include "links.h" -#include "v4l2.h" -#include "http.h" +#include "hw/buffer.h" +#include "hw/buffer_list.h" +#include "hw/device.h" +#include "hw/links.h" +#include "hw/v4l2.h" +#include "http/http.h" #include diff --git a/jmuxer.min.js b/html/jmuxer.min.js similarity index 100% rename from jmuxer.min.js rename to html/jmuxer.min.js diff --git a/jmuxer.min.c b/html/jmuxer.min.js.c similarity index 99% rename from jmuxer.min.c rename to html/jmuxer.min.js.c index 5c79c69..c218e10 100644 --- a/jmuxer.min.c +++ b/html/jmuxer.min.js.c @@ -1,4 +1,4 @@ -unsigned char jmuxer_min_js[] = { +unsigned char html_jmuxer_min_js[] = { 0x21, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x65, 0x2c, 0x74, 0x29, 0x7b, 0x22, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x3d, 0x3d, 0x74, 0x79, 0x70, 0x65, 0x6f, 0x66, 0x20, 0x65, 0x78, 0x70, 0x6f, @@ -2835,4 +2835,4 @@ unsigned char jmuxer_min_js[] = { 0x65, 0x64, 0x28, 0x65, 0x29, 0x7d, 0x7d, 0x5d, 0x29, 0x2c, 0x6f, 0x7d, 0x28, 0x42, 0x29, 0x7d, 0x29, 0x29, 0x3b, 0x0a }; -unsigned int jmuxer_min_js_len = 34016; +unsigned int html_jmuxer_min_js_len = 34016; diff --git a/video.html b/html/video.html similarity index 100% rename from video.html rename to html/video.html diff --git a/video.html.c b/html/video.html.c similarity index 99% rename from video.html.c rename to html/video.html.c index 0153ab7..1917ac2 100644 --- a/video.html.c +++ b/html/video.html.c @@ -1,4 +1,4 @@ -unsigned char video_html[] = { +unsigned char html_video_html[] = { 0x3c, 0x21, 0x64, 0x6f, 0x63, 0x74, 0x79, 0x70, 0x65, 0x20, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x0a, 0x0a, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x20, 0x6c, 0x61, 0x6e, 0x67, 0x3d, 0x22, 0x65, 0x6e, 0x22, 0x3e, 0x0a, 0x3c, 0x68, @@ -114,4 +114,4 @@ unsigned char video_html[] = { 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x0a, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e }; -unsigned int video_html_len = 1359; +unsigned int html_video_html_len = 1359; diff --git a/http.c b/http/http.c similarity index 99% rename from http.c rename to http/http.c index e5979fd..8a9d505 100644 --- a/http.c +++ b/http/http.c @@ -8,7 +8,7 @@ #include #include -#include "http.h" +#include "http/http.h" #define BUFSIZE 256 diff --git a/http.h b/http/http.h similarity index 87% rename from http.h rename to http/http.h index 7afc0c5..a59012d 100644 --- a/http.h +++ b/http/http.h @@ -1,11 +1,13 @@ #pragma once +#include +#include +#include +#include #include -#include "v4l2.h" -#include "buffer.h" - -struct http_worker_s; +typedef struct buffer_s buffer_t; +typedef struct http_worker_s http_worker_t; typedef void (*http_method_fn)(struct http_worker_s *worker, FILE *stream); diff --git a/http_h264.c b/http/http_h264.c similarity index 91% rename from http_h264.c rename to http/http_h264.c index 6d186a6..8bc12de 100644 --- a/http_h264.c +++ b/http/http_h264.c @@ -1,11 +1,11 @@ #include #include -#include "http.h" -#include "buffer.h" -#include "buffer_lock.h" -#include "buffer_list.h" -#include "device.h" +#include "http/http.h" +#include "hw/buffer.h" +#include "hw/buffer_lock.h" +#include "hw/buffer_list.h" +#include "hw/device.h" DEFINE_BUFFER_LOCK(http_h264); diff --git a/http_jpeg.c b/http/http_jpeg.c similarity index 97% rename from http_jpeg.c rename to http/http_jpeg.c index cd166e7..3654d16 100644 --- a/http_jpeg.c +++ b/http/http_jpeg.c @@ -1,9 +1,9 @@ #include #include -#include "http.h" -#include "buffer.h" -#include "buffer_lock.h" +#include "http/http.h" +#include "hw/buffer.h" +#include "hw/buffer_lock.h" DEFINE_BUFFER_LOCK(http_jpeg); diff --git a/http_methods.c b/http/http_methods.c similarity index 73% rename from http_methods.c rename to http/http_methods.c index ffd517e..e151409 100644 --- a/http_methods.c +++ b/http/http_methods.c @@ -1,9 +1,9 @@ #include #include -#include "http.h" -#include "buffer.h" -#include "buffer_lock.h" +#include "http/http.h" +#include "hw/buffer.h" +#include "hw/buffer_lock.h" void http_index(http_worker_t *worker, FILE *stream) { @@ -29,24 +29,24 @@ void http_404(http_worker_t *worker, FILE *stream) void http_video_html(http_worker_t *worker, FILE *stream) { - extern unsigned char video_html[]; - extern unsigned int video_html_len; + extern unsigned char html_video_html[]; + extern unsigned int html_video_html_len; fprintf(stream, "HTTP/1.1 200 OK\r\n"); fprintf(stream, "Content-Type: text/html;charset=UTF-8\r\n"); fprintf(stream, "\r\n"); - fwrite(video_html, 1, video_html_len, stream); + fwrite(html_video_html, 1, html_video_html_len, stream); fflush(stream); } void http_jmuxer_js(http_worker_t *worker, FILE *stream) { - extern unsigned char jmuxer_min_js[]; - extern unsigned int jmuxer_min_js_len; + extern unsigned char html_jmuxer_min_js[]; + extern unsigned int html_jmuxer_min_js_len; fprintf(stream, "HTTP/1.1 200 OK\r\n"); fprintf(stream, "Content-Type: text/javascript;charset=UTF-8\r\n"); fprintf(stream, "\r\n"); - fwrite(jmuxer_min_js, 1, jmuxer_min_js_len, stream); + fwrite(html_jmuxer_min_js, 1, html_jmuxer_min_js_len, stream); fflush(stream); } diff --git a/buffer.c b/hw/buffer.c similarity index 96% rename from buffer.c rename to hw/buffer.c index 81fb25d..ea3cd66 100644 --- a/buffer.c +++ b/hw/buffer.c @@ -1,6 +1,6 @@ -#include "buffer.h" -#include "buffer_list.h" -#include "device.h" +#include "hw/buffer.h" +#include "hw/buffer_list.h" +#include "hw/device.h" buffer_t *buffer_open(const char *name, buffer_list_t *buf_list, int index) { buffer_t *buf = calloc(1, sizeof(buffer_t)); diff --git a/buffer.h b/hw/buffer.h similarity index 100% rename from buffer.h rename to hw/buffer.h diff --git a/buffer_list.c b/hw/buffer_list.c similarity index 98% rename from buffer_list.c rename to hw/buffer_list.c index b66b0ef..1a3596b 100644 --- a/buffer_list.c +++ b/hw/buffer_list.c @@ -1,6 +1,6 @@ -#include "buffer.h" -#include "buffer_list.h" -#include "device.h" +#include "hw/buffer.h" +#include "hw/buffer_list.h" +#include "hw/device.h" buffer_list_t *buffer_list_open(const char *name, struct device_s *dev, unsigned type, bool do_mmap) { diff --git a/buffer_list.h b/hw/buffer_list.h similarity index 100% rename from buffer_list.h rename to hw/buffer_list.h diff --git a/buffer_lock.c b/hw/buffer_lock.c similarity index 98% rename from buffer_lock.c rename to hw/buffer_lock.c index 5ba2438..03d367d 100644 --- a/buffer_lock.c +++ b/hw/buffer_lock.c @@ -1,4 +1,4 @@ -#include "buffer_lock.h" +#include "hw/buffer_lock.h" bool buffer_lock_is_used(buffer_lock_t *buf_lock) { diff --git a/buffer_lock.h b/hw/buffer_lock.h similarity index 100% rename from buffer_lock.h rename to hw/buffer_lock.h diff --git a/buffer_queue.c b/hw/buffer_queue.c similarity index 98% rename from buffer_queue.c rename to hw/buffer_queue.c index 613d2aa..db1b68d 100644 --- a/buffer_queue.c +++ b/hw/buffer_queue.c @@ -1,6 +1,6 @@ -#include "buffer.h" -#include "buffer_list.h" -#include "device.h" +#include "hw/buffer.h" +#include "hw/buffer_list.h" +#include "hw/device.h" #include diff --git a/device.c b/hw/device.c similarity index 98% rename from device.c rename to hw/device.c index dda02c0..99e4421 100644 --- a/device.c +++ b/hw/device.c @@ -1,6 +1,6 @@ -#include "device.h" -#include "buffer.h" -#include "buffer_list.h" +#include "hw/device.h" +#include "hw/buffer.h" +#include "hw/buffer_list.h" device_t *device_open(const char *name, const char *path) { device_t *dev = calloc(1, sizeof(device_t)); diff --git a/device.h b/hw/device.h similarity index 100% rename from device.h rename to hw/device.h diff --git a/links.c b/hw/links.c similarity index 98% rename from links.c rename to hw/links.c index 130563e..3b6da37 100644 --- a/links.c +++ b/hw/links.c @@ -1,7 +1,7 @@ -#include "device.h" -#include "buffer.h" -#include "buffer_list.h" -#include "links.h" +#include "hw/device.h" +#include "hw/buffer.h" +#include "hw/buffer_list.h" +#include "hw/links.h" #define N_FDS 50 diff --git a/links.h b/hw/links.h similarity index 100% rename from links.h rename to hw/links.h diff --git a/v4l2.c b/hw/v4l2.c similarity index 98% rename from v4l2.c rename to hw/v4l2.c index 977d9c5..897b002 100644 --- a/v4l2.c +++ b/hw/v4l2.c @@ -1,4 +1,4 @@ -#include "v4l2.h" +#include "hw/v4l2.h" int xioctl(const char *name, int fd, int request, void *arg) { diff --git a/v4l2.h b/hw/v4l2.h similarity index 100% rename from v4l2.h rename to hw/v4l2.h