Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unpacked SDL_kitchensink repo
- Loading branch information
Showing
63 changed files
with
6,835 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Object files | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
# Debug files | ||
*.dSYM/ | ||
|
||
# VSCode | ||
.vscode | ||
|
||
# Other | ||
build/ | ||
doc/doxygen_sqlite3.db | ||
doc/html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
language: c | ||
|
||
sudo: required | ||
dist: trusty | ||
|
||
compiler: | ||
- gcc | ||
|
||
script: | ||
- wget https://www.libsdl.org/release/SDL2-2.0.8.tar.gz -O - | tar -xz | ||
- cd SDL2-2.0.8 && CC=gcc-7 ./configure --prefix=/usr && make -j2 && sudo make install && cd .. | ||
- cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_EXAMPLES=On -DUSE_DYNAMIC_LIBASS=Off -DCMAKE_C_COMPILER=/usr/bin/gcc-7 . | ||
- build-wrapper-linux-x86-64 --out-dir bw-output make && sonar-scanner | ||
|
||
notifications: | ||
email: false | ||
|
||
addons: | ||
sonarcloud: | ||
organization: "katajakasa-github" | ||
apt: | ||
sources: | ||
- sourceline: 'ppa:ubuntu-toolchain-r/test' | ||
- sourceline: 'ppa:george-edison55/cmake-3.x' | ||
- sourceline: 'ppa:jonathonf/ffmpeg-3' | ||
packages: | ||
- cmake | ||
- gcc-7 | ||
- libass-dev | ||
- libavcodec-dev | ||
- libavformat-dev | ||
- libswresample-dev | ||
- libswscale-dev | ||
- libavutil-dev | ||
|
||
cache: | ||
directories: | ||
- '$HOME/.sonar/cache' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(SDL_kitchensink C) | ||
include(GNUInstallDirs) | ||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) | ||
|
||
set(KIT_VERSION_MAJOR "0") | ||
set(KIT_VERSION_MINOR "0") | ||
set(KIT_VERSION_PATCH "7") | ||
set(KIT_VERSION ${KIT_VERSION_MAJOR}.${KIT_VERSION_MINOR}.${KIT_VERSION_PATCH}) | ||
add_definitions( | ||
-DKIT_VERSION_MAJOR=${KIT_VERSION_MAJOR} | ||
-DKIT_VERSION_MINOR=${KIT_VERSION_MINOR} | ||
-DKIT_VERSION_PATCH=${KIT_VERSION_PATCH} | ||
) | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") | ||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -Werror -fno-omit-frame-pointer -Wno-deprecated-declarations") | ||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ggdb -O2 -fno-omit-frame-pointer -DNDEBUG") | ||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -DNDEBUG") | ||
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -Os -DNDEBUG") | ||
|
||
option(BUILD_EXAMPLES "Build examples" OFF) | ||
option(BUILD_TESTS "Build unittests" OFF) | ||
option(USE_DYNAMIC_LIBASS "Use dynamically loaded libass" ON) | ||
option(USE_ASAN "Use AddressSanitizer" OFF) | ||
|
||
find_package(SDL2) | ||
find_package(ffmpeg COMPONENTS avcodec avformat avutil swscale swresample) | ||
|
||
set(LIBRARIES | ||
${SDL2_LIBRARIES} | ||
${FFMPEG_LIBRARIES} | ||
) | ||
set(INCLUDES | ||
include/ | ||
${SDL2_INCLUDE_DIRS} | ||
${FFMPEG_INCLUDE_DIRS} | ||
) | ||
|
||
if(BUILD_TESTS) | ||
add_subdirectory(tests) | ||
endif() | ||
|
||
if(USE_DYNAMIC_LIBASS) | ||
if(WIN32 OR MINGW OR MSYS) | ||
set(DYNAMIC_LIBASS_NAME "\"libass-9.dll\"") | ||
else() | ||
set(DYNAMIC_LIBASS_NAME "\"libass.so\"") | ||
endif() | ||
add_definitions(-DUSE_DYNAMIC_LIBASS) | ||
add_definitions(-DDYNAMIC_LIBASS_NAME=${DYNAMIC_LIBASS_NAME}) | ||
else() | ||
find_package(ass) | ||
set(LIBRARIES ${LIBRARIES} ${ASS_LIBRARIES}) | ||
set(INCLUDES ${INCLUDES} ${ASS_INCLUDE_DIRS}) | ||
endif() | ||
|
||
FILE(GLOB_RECURSE SOURCES "src/*.c") | ||
FILE(GLOB INSTALL_HEADERS "include/kitchensink/*.h") | ||
|
||
add_library(SDL_kitchensink SHARED ${SOURCES}) | ||
add_library(SDL_kitchensink_static STATIC ${SOURCES}) | ||
|
||
set_target_properties(SDL_kitchensink PROPERTIES VERSION ${KIT_VERSION}) | ||
set_target_properties(SDL_kitchensink PROPERTIES SOVERSION ${KIT_VERSION_MAJOR}) | ||
|
||
set_target_properties(SDL_kitchensink PROPERTIES DEBUG_POSTFIX "d") | ||
set_target_properties(SDL_kitchensink_static PROPERTIES DEBUG_POSTFIX "d") | ||
|
||
target_compile_definitions(SDL_kitchensink PRIVATE "KIT_DLL;KIT_DLL_EXPORTS") | ||
target_compile_options(SDL_kitchensink PRIVATE "-fvisibility=hidden") | ||
|
||
set_property(TARGET SDL_kitchensink PROPERTY C_STANDARD 99) | ||
set_property(TARGET SDL_kitchensink_static PROPERTY C_STANDARD 99) | ||
|
||
if(USE_ASAN) | ||
set(LIBRARIES asan ${LIBRARIES}) | ||
target_compile_options(SDL_kitchensink PRIVATE "-fsanitize=address") | ||
message(STATUS "DEVELOPMENT: AddressSanitizer enabled!") | ||
endif() | ||
|
||
include_directories(${INCLUDES}) | ||
target_link_libraries(SDL_kitchensink ${LIBRARIES}) | ||
|
||
set(PKG_CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/SDL_kitchensink.pc") | ||
|
||
configure_file( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/pkg-config.pc.in" | ||
${PKG_CONFIG_FILE} | ||
@ONLY | ||
) | ||
|
||
if(BUILD_EXAMPLES) | ||
add_executable(exampleaudio examples/example_audio.c) | ||
add_executable(examplevideo examples/example_video.c) | ||
add_executable(examplecustvideo examples/example_cust_video.c) | ||
|
||
if(MINGW) | ||
target_link_libraries(exampleaudio mingw32) | ||
target_link_libraries(examplevideo mingw32) | ||
target_link_libraries(examplecustvideo mingw32) | ||
endif() | ||
|
||
set_property(TARGET exampleaudio PROPERTY C_STANDARD 99) | ||
set_property(TARGET examplevideo PROPERTY C_STANDARD 99) | ||
set_property(TARGET examplecustvideo PROPERTY C_STANDARD 99) | ||
|
||
target_link_libraries(exampleaudio SDL_kitchensink_static ${LIBRARIES}) | ||
target_link_libraries(examplevideo SDL_kitchensink_static ${LIBRARIES}) | ||
target_link_libraries(examplecustvideo SDL_kitchensink_static ${LIBRARIES}) | ||
endif() | ||
|
||
# Installation | ||
install(FILES ${PKG_CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) | ||
install(FILES ${INSTALL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/kitchensink) | ||
INSTALL(TARGETS SDL_kitchensink SDL_kitchensink_static | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Tuomas Virtanen | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# SDL_kitchensink | ||
|
||
[![Build Status](https://travis-ci.org/katajakasa/SDL_kitchensink.svg?branch=master)](https://travis-ci.org/katajakasa/SDL_kitchensink) | ||
[![Quality Gate](https://sonarcloud.io/api/badges/gate?key=sdl_kitchensink)](https://sonarcloud.io/dashboard?id=sdl_kitchensink) | ||
|
||
FFmpeg and SDL2 based library for audio and video playback, written in C99. | ||
|
||
Features: | ||
* Decoding video, audio and subtitles via FFmpeg | ||
* Dumping video and subtitle data on SDL_textures/SDL_Surfaces | ||
* Dumping audio data in the usual mono/stereo interleaved formats | ||
* Automatic audio and video conversion to SDL2 friendly formats | ||
* Synchronizing video & audio to clock | ||
* Seeking forwards and backwards | ||
* Bitmap, text and SSA/ASS subtitle support | ||
|
||
Note! Master branch is for the development of v1.0.0 series. v0 can be found in the | ||
rel-kitchensink-0 branch. v0 is no longer in active development and only bug- and security-fixes | ||
are accepted. | ||
|
||
## 1. Library requirements | ||
|
||
Build requirements: | ||
* CMake (>=3.0) | ||
* GCC (C99 support required) | ||
|
||
Library requirements: | ||
* SDL2 (>=2.0.5) | ||
* FFmpeg (>=3.0) | ||
* libass (optional, supports runtime linking via SDL_LoadSO) | ||
* CUnit (optional, for unittests) | ||
|
||
Note that Clang might work, but is not tested. Older SDL2 and FFmpeg library versions | ||
may or may not work; versions noted here are the only ones tested. | ||
|
||
### 1.1. Debian / Ubuntu | ||
|
||
``` | ||
sudo apt-get install libsdl2-dev libavcodec-dev libavdevice-dev libavfilter-dev \ | ||
libavformat-dev libavresample-dev libavutil-dev libswresample-dev libswscale-dev \ | ||
libpostproc-dev libass-dev | ||
``` | ||
|
||
### 1.2. MSYS2 64bit | ||
|
||
These are for x86_64. For 32bit installation, just change the package names a bit . | ||
``` | ||
pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-ffmpeg mingw-w64-x86_64-libass | ||
``` | ||
|
||
## 2. Compiling | ||
|
||
By default, both static and dynamic libraries are built. | ||
* Dynamic library is called libSDL_kitchensink.dll or .so | ||
* Static library is called libSDL_kitchensink_static.a | ||
* If you build in debug mode (```-DCMAKE_BUILD_TYPE=Debug```), libraries will be postfixed with 'd'. | ||
|
||
Change CMAKE_INSTALL_PREFIX as necessary to change the installation path. The files will be installed to | ||
* CMAKE_INSTALL_PREFIX/lib for libraries (.dll.a, .a, etc.) | ||
* CMAKE_INSTALL_PREFIX/bin for binaries (.dll, .so) | ||
* CMAKE_INSTALL_PREFIX/include for headers | ||
|
||
### 2.1. Building the libraries on Debian/Ubuntu | ||
|
||
1. ```mkdir build && cd build``` | ||
2. ```cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..``` | ||
3. ```make -j``` | ||
4. ```sudo make install``` | ||
|
||
### 2.2. Building the libraries on MSYS2 | ||
|
||
1. ```mkdir build && cd build``` | ||
2. ```cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..``` | ||
3. ```make``` | ||
4. ```make install``` | ||
|
||
### 2.3. Building examples | ||
|
||
Just add ```-DBUILD_EXAMPLES=1``` to cmake arguments and rebuild. | ||
|
||
### 2.4. Building unittests | ||
|
||
Make sure CUnit is installed, then add ```-DBUILD_UNITTESTS=1``` to the cmake arguments and rebuild. | ||
|
||
You can run unittests by running ```make unittest```. | ||
|
||
## 3. License | ||
|
||
MIT. Please see ```LICENSE``` for details. | ||
|
||
Note that FFmpeg has a rather complex license. Please take a look at [FFmpeg Legal page](http://ffmpeg.org/legal.html) | ||
for details. | ||
|
||
## 4. Why SDL_kitchensink | ||
|
||
Because pulling major blob of library code like ffmpeg feels like bringing in a whole house with its | ||
kitchensink and everything to the project. Also, it sounded funny. Also, SDL_ffmpeg is already reserved :( | ||
|
||
## 5. Examples | ||
|
||
Please see examples directory. You can also take a look at unittests for some help. | ||
Note that examples are NOT meant for any kind of real life use; they are only meant to | ||
show simple use cases for the library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# A Simple SDL2 Finder. | ||
# (c) Tuomas Virtanen 2016 (Licensed under MIT license) | ||
# Usage: | ||
# find_package(SDL2) | ||
# | ||
# Declares: | ||
# * SDL2_FOUND | ||
# * SDL2_INCLUDE_DIRS | ||
# * SDL2_LIBRARIES | ||
# | ||
|
||
set(SDL2_SEARCH_PATHS | ||
/usr/local/ | ||
/usr/ | ||
/opt | ||
) | ||
|
||
find_path(SDL2_INCLUDE_DIR SDL2/SDL.h | ||
HINTS | ||
PATH_SUFFIXES include | ||
PATHS ${SDL2_SEARCH_PATHS} | ||
) | ||
|
||
find_library(SDL2_LIBRARY | ||
NAMES SDL2 | ||
HINTS | ||
PATH_SUFFIXES lib | ||
PATHS ${SDL2_SEARCH_PATHS} | ||
) | ||
|
||
if(MINGW) | ||
find_library(SDL2MAIN_LIBRARY | ||
NAMES SDL2main | ||
HINTS | ||
PATH_SUFFIXES lib | ||
PATHS ${SDL2_SEARCH_PATHS} | ||
) | ||
else() | ||
set(SDL2MAIN_LIBRARY "") | ||
endif() | ||
|
||
if(SDL2_INCLUDE_DIR AND SDL2_LIBRARY) | ||
set(SDL2_FOUND TRUE) | ||
endif() | ||
|
||
if(SDL2_FOUND) | ||
set(SDL2_LIBRARIES ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY}) | ||
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) | ||
message(STATUS "Found SDL2: ${SDL2_LIBRARIES}") | ||
else() | ||
message(WARNING "Could not find SDL2") | ||
endif() | ||
|
||
mark_as_advanced(SDL2MAIN_LIBRARY SDL2_LIBRARY SDL2_INCLUDE_DIR SDL2_SEARCH_PATHS) |
Oops, something went wrong.