diff --git a/.gitignore b/.gitignore index 568de19..2ab9640 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .idea/* -cmake-build-debug/* \ No newline at end of file +cmake-build-debug/* +tests/*.o +tests/ts \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 2869390..44d0522 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,8 @@ include_directories(include) add_library(transcoder SHARED src/helper.c - src/subtitles.c) + src/subtitles.c + src/info.c) set_property(TARGET transcoder PROPERTY C_STANDARD 11) target_link_libraries(transcoder diff --git a/ffmpeg-config.txt b/ffmpeg-config.txt index 523268c..be82bfa 100644 --- a/ffmpeg-config.txt +++ b/ffmpeg-config.txt @@ -1 +1 @@ -./configure --pkg-config-flags=--static --disable-shared --enable-static --disable-zlib --disable-iconv \ No newline at end of file +./configure --pkg-config-flags=--static --disable-shared --enable-static --disable-zlib --disable-iconv --disable-asm --disable-ffplay --disable-ffprobe \ No newline at end of file diff --git a/src/helper.c b/src/helper.c index 227ea15..9ef14b5 100644 --- a/src/helper.c +++ b/src/helper.c @@ -3,12 +3,6 @@ #include "helper.h" #include "stream.h" -int init() -{ - printf("Kyoo Transcoder INITIALIZED.\n"); - return (42); -} - int open_input_context(AVFormatContext **in_ctx, const char *path) { if (avformat_open_input(in_ctx, path, NULL, NULL)) { diff --git a/src/info.c b/src/info.c index d9325e0..414946b 100644 --- a/src/info.c +++ b/src/info.c @@ -2,6 +2,16 @@ // Created by Anonymus Raccoon on 20/12/2019. // +#include +#include "stream.h" +#include "helper.h" + +int init() +{ + printf("Kyoo Transcoder INITIALIZED.\n"); + return (42); +} + stream *get_track_info(const char *path, int *stream_count, int *track_count) { AVFormatContext *ctx = NULL; diff --git a/src/subtitles.c b/src/subtitles.c index 3614e64..84671cd 100644 --- a/src/subtitles.c +++ b/src/subtitles.c @@ -112,14 +112,13 @@ void finish_up(AVFormatContext *int_ctx, AVFormatContext **output_list, unsigned stream *extract_subtitles(char *path, const char *out_path, unsigned *stream_count, unsigned *subtitle_count) { - printf("EXTRACTING THINGS\n"); AVFormatContext *int_ctx = NULL; AVFormatContext **output_list; stream *streams; char *folder_name = strchr(path, '/'); char *p; - if (!folder_name) + if (!folder_name && (folder_name = strdup(folder_name))) return (NULL); p = strchr(folder_name, '.'); if (p) diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..635c50e --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,30 @@ +# +# Created by Anonymus Raccoon on 28/12/2019. +# + +SRC = test_main.c + +OBJ = $(SRC:%.c=%.o) + +INCLUDE = -I ../include + +CFLAGS = $(INCLUDE) -Wall -Wextra -Wshadow -g + +LDFLAGS = -lm -lbz2 -lva -lva-drm -lva-x11 -lX11 -llzma -lvdpau -L ../cmake-build-debug -ltranscoder + +NAME = ts + +CC = gcc + +all: build + +build: $(OBJ) + $(CC) -o $(NAME) $(OBJ) $(LDFLAGS) + +clean: + $(RM) $(OBJ) + +fclean: clean + $(RM) $(NAME) + +re: fclean all diff --git a/tests/test_main.c b/tests/test_main.c new file mode 100644 index 0000000..9bbe0be --- /dev/null +++ b/tests/test_main.c @@ -0,0 +1,17 @@ +// +// Created by anonymus-raccoon on 12/28/19. +// + +#include +#include "transcoder.h" + + +int main(int argc, char **argv) +{ + unsigned stream_count = 0; + unsigned subtitle_count = 0; + + if (argc == 3 && !strcmp(argv[1], "es")) + extract_subtitles(argv[2], "./", &stream_count, &subtitle_count); + return (0); +} \ No newline at end of file