From e0fbe9d67c0d2f9673e15fb1af665c28b3a77807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20B=C3=A9rub=C3=A9?= Date: Thu, 11 Jul 2024 16:14:25 -0400 Subject: [PATCH] Remove useless common header, there's nothing really common between the modules --- src/common.h | 4 ---- src/gpio.h | 2 +- src/http_post.h | 2 +- src/jpeg.h | 1 - src/main.c | 16 +++++++-------- src/media.h | 3 ++- src/night.h | 3 ++- src/region.h | 2 +- src/rtsp/rtsp.c | 52 +++++++++++++++++++++---------------------------- src/server.h | 3 ++- src/text.h | 3 +-- src/watchdog.h | 2 +- 12 files changed, 41 insertions(+), 52 deletions(-) delete mode 100644 src/common.h diff --git a/src/common.h b/src/common.h deleted file mode 100644 index 3511925..0000000 --- a/src/common.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -#include "app_config.h" -#include "hal/support.h" \ No newline at end of file diff --git a/src/gpio.h b/src/gpio.h index 6a9e013..916856f 100644 --- a/src/gpio.h +++ b/src/gpio.h @@ -1,4 +1,4 @@ -#include "common.h" +#include "hal/macros.h" #include #include diff --git a/src/http_post.h b/src/http_post.h index 2ac3207..8248842 100644 --- a/src/http_post.h +++ b/src/http_post.h @@ -1,6 +1,6 @@ #pragma once -#include "common.h" +#include "hal/macros.h" #include "hal/tools.h" #include "jpeg.h" #include "mp4/mp4.h" diff --git a/src/jpeg.h b/src/jpeg.h index dff585a..8f5fb29 100644 --- a/src/jpeg.h +++ b/src/jpeg.h @@ -11,7 +11,6 @@ #include #include -#include "common.h" #include "error.h" #include "hal/types.h" #include "media.h" diff --git a/src/main.c b/src/main.c index c62ab0a..c0b87fd 100644 --- a/src/main.c +++ b/src/main.c @@ -1,4 +1,11 @@ -#include "common.h" +#include "app_config.h" +#include "hal/macros.h" +#include "http_post.h" +#include "media.h" +#include "night.h" +#include "rtsp/rtsp_server.h" +#include "server.h" +#include "watchdog.h" #include #include @@ -7,13 +14,6 @@ #include #include -#include "http_post.h" -#include "media.h" -#include "night.h" -#include "rtsp/rtsp_server.h" -#include "server.h" -#include "watchdog.h" - rtsp_handle rtspHandle; int main(int argc, char *argv[]) { diff --git a/src/media.h b/src/media.h index febb2f7..f3897ff 100644 --- a/src/media.h +++ b/src/media.h @@ -1,7 +1,8 @@ #pragma once -#include "common.h" +#include "app_config.h" #include "error.h" +#include "hal/types.h" #include "http_post.h" #include "lib/shine/layer3.h" #include "jpeg.h" diff --git a/src/night.h b/src/night.h index 81e4c36..95b5bb5 100644 --- a/src/night.h +++ b/src/night.h @@ -1,7 +1,8 @@ #pragma once -#include "common.h" +#include "app_config.h" #include "gpio.h" +#include "hal/macros.h" #include "media.h" #include diff --git a/src/region.h b/src/region.h index f852120..77cc564 100644 --- a/src/region.h +++ b/src/region.h @@ -1,6 +1,6 @@ #pragma once -#include "common.h" +#include "app_config.h" #include "hal/support.h" #include "text.h" diff --git a/src/rtsp/rtsp.c b/src/rtsp/rtsp.c index 5e15989..7e104ae 100644 --- a/src/rtsp/rtsp.c +++ b/src/rtsp/rtsp.c @@ -260,28 +260,35 @@ static void __method_describe(struct connection_item_t *p, rtsp_handle h) { char sdp[__RTSP_TCP_BUF_SIZE]; + const char baseRtp[] = + "v=0\r\n" + "o=- 0 0 IN IP4 127.0.0.1\r\n" + "s=librtsp\r\n" + "c=IN IP4 0.0.0.0\r\n" + "t=0 0\r\n" + "a=tool:libavformat 52.73.0\r\n"; char audioRtp[256] = "\r\n"; char audioRtpfmt[16]; if (h->audioPt != 255) { switch (h->audioPt) { case 0: - sprintf(audioRtpfmt, "PCMU"); + strncpy(audioRtpfmt, "PCMU", 16 - 1); break; case 8: - sprintf(audioRtpfmt, "PCMA"); + strncpy(audioRtpfmt, "PCMA", 16 - 1); break; case 14: - sprintf(audioRtpfmt, "MPA"); + strncpy(audioRtpfmt, "MPA", 16 - 1); break; case 18: - sprintf(audioRtpfmt, "G729"); + strncpy(audioRtpfmt, "G729", 16 - 1); break; case 96: - sprintf(audioRtpfmt, "MPEG4-GENERIC"); + strncpy(audioRtpfmt, "MPEG4-GENERIC", 16 - 1); break; default: - sprintf(audioRtpfmt, "UNKNOWN"); + strncpy(audioRtpfmt, "UNKNOWN", 16 - 1); break; } sprintf(audioRtp, @@ -305,18 +312,13 @@ static void __method_describe(struct connection_item_t *p, rtsp_handle h) DBG("PPS BASE64:%s\n",h->sprop_pps_b64->result); snprintf(sdp, __RTSP_TCP_BUF_SIZE- 1, - "v=0\r\n" - "o=- 0 0 IN IP4 127.0.0.1\r\n" - "s=librtsp\r\n" - "c=IN IP4 0.0.0.0\r\n" - "t=0 0\r\n" - "a=tool:libavformat 52.73.0\r\n" - "m=video 0 RTP/AVP 96\r\n" + "%sm=video 0 RTP/AVP 96\r\n" "a=rtpmap:96 H265/90000\r\n" "a=control:track=0\r\n" "a=fmtp:96 packetization-mode=1;" " profile-level-id=%s;" - " sprop-parameter-sets=%s,%s,%s;%s", + " sprop-parameter-sets=%s,%s,%s;%s", + baseRtp, h->sprop_sps_b16->result, h->sprop_vps_b64->result, h->sprop_sps_b64->result, @@ -333,34 +335,24 @@ static void __method_describe(struct connection_item_t *p, rtsp_handle h) DBG("PPS BASE64:%s\n",h->sprop_pps_b64->result); snprintf(sdp, __RTSP_TCP_BUF_SIZE - 1, - "v=0\r\n" - "o=- 0 0 IN IP4 127.0.0.1\r\n" - "s=librtsp\r\n" - "c=IN IP4 0.0.0.0\r\n" - "t=0 0\r\n" - "a=tool:libavformat 52.73.0\r\n" - "m=video 0 RTP/AVP 96\r\n" + "%sm=video 0 RTP/AVP 96\r\n" "a=rtpmap:96 H264/90000\r\n" "a=control:track=0\r\n" "a=fmtp:96 packetization-mode=1;" " profile-level-id=%s;" - " sprop-parameter-sets=%s,%s;%s", + " sprop-parameter-sets=%s,%s;%s", + baseRtp, h->sprop_sps_b16->result, h->sprop_sps_b64->result, h->sprop_pps_b64->result, audioRtp); } else { snprintf(sdp, __RTSP_TCP_BUF_SIZE - 1, - "v=0\r\n" - "o=- 0 0 IN IP4 127.0.0.1\r\n" - "s=librtsp\r\n" - "c=IN IP4 0.0.0.0\r\n" - "t=0 0\r\n" - "a=tool:libavformat 52.73.0\r\n" - "m=video 0 RTP/AVP 96\r\n" + "%sm=video 0 RTP/AVP 96\r\n" "a=rtpmap:96 %s/90000\r\n" "a=fmtp:96 packetization-mode=1\r\n" - "a=control:track=0%s", + "a=control:track=0%s", + baseRtp, h->isH265 ? "H265" : "H264", audioRtp); } diff --git a/src/server.h b/src/server.h index aa711a6..41cc098 100644 --- a/src/server.h +++ b/src/server.h @@ -15,7 +15,8 @@ #include #include -#include "common.h" +#include "app_config.h" +#include "hal/types.h" #include "jpeg.h" #include "media.h" #include "mp4/mp4.h" diff --git a/src/text.h b/src/text.h index ae0430e..1014a43 100644 --- a/src/text.h +++ b/src/text.h @@ -1,7 +1,6 @@ #pragma once -#include "common.h" -#include "hal/types.h" +#include "hal/support.h" #include "lib/schrift.h" #include diff --git a/src/watchdog.h b/src/watchdog.h index 55e2171..ab04586 100644 --- a/src/watchdog.h +++ b/src/watchdog.h @@ -1,6 +1,6 @@ #pragma once -#include "common.h" +#include "hal/macros.h" #include #include