Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
update CMakeLists.txt for proper build artifact generation
Browse files Browse the repository at this point in the history
  • Loading branch information
MGTheTrain committed Apr 19, 2024
1 parent ae55c96 commit 033d918
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
6 changes: 5 additions & 1 deletion apps/video-player/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ project(${TARGET})

add_definitions(-DVIDEO_PLAYER)

find_package(FFMPEG REQUIRED)
find_package(SDL2 CONFIG REQUIRED)

include_directories(../include
../../../modules/video/include
)
Expand All @@ -39,6 +42,7 @@ elseif(APPLE OR UNIX)
else()
message(WARNING "Unsupported platform")
endif()
target_link_libraries(${TARGET} PRIVATE video)

target_link_libraries(${TARGET} PRIVATE video ${FFMPEG_LIBRARIES} SDL2::SDL2-static)

install(TARGETS ${TARGET})
9 changes: 4 additions & 5 deletions modules/video/include/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@

#pragma once

#include <iostream>

#ifdef __cplusplus
extern "C" {
#include <SDL2/SDL.h>
#include <SDL2/SDL_thread.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>

#include <iostream>

#ifdef __cplusplus
extern "C" {
#endif
static AVFormatContext* formatContext = nullptr;
static AVCodecParameters* codecParameters = nullptr;
Expand Down
8 changes: 6 additions & 2 deletions modules/video/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ set(VIDEO_SRC
)

add_library(${TARGET} STATIC ${VIDEO_SRC})
target_link_libraries(${TARGET} PRIVATE ${FFMPEG_LIBRARIES} SDL2::SDL2main SDL2::SDL2-static)
target_include_directories(${TARGET} PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_link_directories(${TARGET} PRIVATE ${FFMPEG_LIBRARY_DIRS})
target_link_libraries(${TARGET} PRIVATE ${FFMPEG_LIBRARIES} SDL2::SDL2-static)

add_library(${TARGET}_wrapper SHARED ${VIDEO_SRC}) # required for bindings
target_link_libraries(${TARGET}_wrapper PRIVATE ${FFMPEG_LIBRARIES} SDL2::SDL2main SDL2::SDL2-static)
target_include_directories(${TARGET}_wrapper PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_link_directories(${TARGET}_wrapper PRIVATE ${FFMPEG_LIBRARY_DIRS})
target_link_libraries(${TARGET}_wrapper PRIVATE ${FFMPEG_LIBRARIES} SDL2::SDL2-static)

install(TARGETS ${TARGET} ${TARGET}_wrapper)
2 changes: 1 addition & 1 deletion modules/video/src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bool initVideoPlayer() {
return false;
}

av_register_all();
// av_register_all();
if (avformat_network_init() < 0) {
std::cerr << "Failed to initialize FFmpeg network\n";
return false;
Expand Down
4 changes: 2 additions & 2 deletions modules/video/test/video-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ TEST_F(VideoPlaybackTest, LoadVideoFileTest) {
TEST_F(VideoPlaybackTest, StartPlaybackTest) {
const char* filename = "assets/mp4/file_example_MP4_1280_10MG.mp4";
EXPECT_TRUE(loadVideo(filename));
EXPECT_TRUE(startPlayback());
playVideo();
}

// Test case for closing video file and terminating video player
TEST_F(VideoPlaybackTest, CloseVideoFileTest) {
const char* filename = "assets/mp4/file_example_MP4_1280_10MG.mp4";
EXPECT_TRUE(loadVideo(filename));
EXPECT_TRUE(startPlayback());
playVideo();
closeVideoPlayer();
}

Expand Down

0 comments on commit 033d918

Please sign in to comment.