Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kala13x committed Jan 23, 2024
1 parent e6d1d52 commit 10dc1f8
Show file tree
Hide file tree
Showing 40 changed files with 5,812 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Full Build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ cmake make
sudo apt-get install -y libavcodec-dev libavformat-dev
sudo apt-get install -y libavutil-dev libswscale-dev libavdevice-dev
- name: Checkout SMake
uses: actions/checkout@v3
with:
repository: 'kala13x/smake'
submodules: recursive
path: 'smake'

- name: Checkout libxutils
uses: actions/checkout@v3
with:
repository: 'kala13x/libxutils'
path: 'libxutils'

- name: Install SMake
run: cd smake && ./build.sh --install && smake -V

- name: Install libxutils
run: cd libxutils && ./build.sh --install && xutils

- name: Build with SMake
run: ./build.sh --tool=smake --example

- name: Build with CMAKE
run: ./build.sh --tool=cmake --example

- name: Build with Makefile
run: ./build.sh --tool=make --example
42 changes: 42 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CMake

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Checkout libxutils
uses: actions/checkout@v3
with:
repository: 'kala13x/libxutils'
path: 'libxutils'

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ cmake make
sudo apt-get install -y libavcodec-dev libavformat-dev
sudo apt-get install -y libavutil-dev libswscale-dev libavdevice-dev
- name: Check versions
run: |
gcc --version
cmake --version
- name: Build and install libxutils
run: cd libxutils && ./build.sh --tool=cmake --install

- name: Make build
run: |
mkdir build
cd build
cmake ..
make
34 changes: 34 additions & 0 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: C/C++ CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ make
sudo apt-get install -y libavcodec-dev libavformat-dev
sudo apt-get install -y libavutil-dev libswscale-dev libavdevice-dev
- name: Checkout libxutils
uses: actions/checkout@v3
with:
repository: 'kala13x/libxutils'
path: 'libxutils'

- name: Build and install libxutils
run: cd libxutils && ./build.sh --install

- name: Build Project
run: make
44 changes: 44 additions & 0 deletions .github/workflows/smake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: SMake

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Checkout SMake
uses: actions/checkout@v3
with:
repository: 'kala13x/smake'
submodules: recursive
path: 'smake'

- name: Checkout libxutils
uses: actions/checkout@v3
with:
repository: 'kala13x/libxutils'
path: 'libxutils'

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ cmake make
sudo apt-get install -y libavcodec-dev libavformat-dev
sudo apt-get install -y libavutil-dev libswscale-dev libavdevice-dev
- name: Build and install SMake
run: cd smake && ./build.sh --install

- name: Build and install libxutils
run: cd libxutils && ./build.sh --install

- name: Build with SMake
run: smake && make
34 changes: 34 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"files.associations": {
"xstd.h": "c",
"encoder.h": "c",
"stdinc.h": "c",
"cmath": "c",
"array": "c",
"string_view": "c",
"initializer_list": "c",
"numbers": "c",
"xstr.h": "c",
"random": "c",
"deque": "c",
"string": "c",
"unordered_map": "c",
"vector": "c",
"system_error": "c",
"decoder.h": "c",
"array.h": "c",
"meta.h": "c",
"compare": "c",
"functional": "c",
"tuple": "c",
"type_traits": "c",
"utility": "c",
"nalu.h": "c",
"frame.h": "c",
"version.h": "c",
"stream.h": "c",
"status.h": "c",
"xtime.h": "c",
"avformat.h": "c"
}
}
37 changes: 37 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
cmake_minimum_required(VERSION 3.10)

project(xmedia)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -Wall -D_XUTILS_DEBUG")

include_directories(${PROJECT_SOURCE_DIR}/src)

set(SOURCES
${PROJECT_SOURCE_DIR}/src/codec.c
${PROJECT_SOURCE_DIR}/src/decoder.c
${PROJECT_SOURCE_DIR}/src/encoder.c
${PROJECT_SOURCE_DIR}/src/frame.c
${PROJECT_SOURCE_DIR}/src/meta.c
${PROJECT_SOURCE_DIR}/src/mpegts.c
${PROJECT_SOURCE_DIR}/src/nalu.c
${PROJECT_SOURCE_DIR}/src/status.c
${PROJECT_SOURCE_DIR}/src/stream.c
${PROJECT_SOURCE_DIR}/src/version.c
)

add_library(${PROJECT_NAME} STATIC ${SOURCES})
SET(DST_DIR "/usr/local/include/xmedia")

target_link_libraries(${PROJECT_NAME}
xutils
pthread
avutil
avcodec
avformat
avdevice
swscale
swresample
)

install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION /usr/local/lib)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/ DESTINATION ${DST_DIR} FILES_MATCHING PATTERN "*.h")
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Sandro Kalatozishvili (s.kalatoz@gmail.com)

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.
45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
####################################
# Automatically generated by SMake #
# /~https://github.com/kala13x/smake #
####################################

CFLAGS = -g -O2 -Wall -D_XUTILS_DEBUG
CFLAGS += -I./src
LIBS = -lxutils -lpthread -lavutil -lavcodec -lavformat -lavdevice -lswscale -lswresample
NAME = libxmedia.a
ODIR = ./build
OBJ = o

OBJS = codec.$(OBJ) \
decoder.$(OBJ) \
encoder.$(OBJ) \
frame.$(OBJ) \
meta.$(OBJ) \
mpegts.$(OBJ) \
nalu.$(OBJ) \
status.$(OBJ) \
stream.$(OBJ) \
version.$(OBJ)

OBJECTS = $(patsubst %,$(ODIR)/%,$(OBJS))
INSTALL_INC = /usr/local/include/xmedia
INSTALL_BIN = /usr/local/lib
VPATH = ./src

.c.$(OBJ):
@test -d $(ODIR) || mkdir -p $(ODIR)
$(CC) $(CFLAGS) -c -o $(ODIR)/$@ $< $(LIBS)

$(NAME):$(OBJS)
$(AR) rcs -o $(ODIR)/$(NAME) $(OBJECTS)

.PHONY: install
install:
@test -d $(INSTALL_BIN) || mkdir -p $(INSTALL_BIN)
install -m 0755 $(ODIR)/$(NAME) $(INSTALL_BIN)/
@test -d $(INSTALL_INC) || mkdir -p $(INSTALL_INC)
cp -r ./src/*.h $(INSTALL_INC)/

.PHONY: clean
clean:
$(RM) $(ODIR)/$(NAME) $(OBJECTS)
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[![MIT License](https://img.shields.io/badge/License-MIT-brightgreen.svg?)](/~https://github.com/kala13x/libxmedia/blob/main/LICENSE)
[![C/C++ CI](/~https://github.com/kala13x/libxmedia/actions/workflows/make.yml/badge.svg)](/~https://github.com/kala13x/libxmedia/actions/workflows/make.yml)
[![CMake](/~https://github.com/kala13x/libxmedia/actions/workflows/cmake.yml/badge.svg)](/~https://github.com/kala13x/libxmedia/actions)
[![SMake](/~https://github.com/kala13x/libxmedia/actions/workflows/smake.yml/badge.svg)](/~https://github.com/kala13x/libxmedia/actions/workflows/smake.yml)

# libxmedia
Implementation of audio/video transmuxing functionality based on FFMPEG API with a fully functional example.

### Installation
There are several ways to build and install the project but at first, the [libxutils](/~https://github.com/kala13x/libxutils) library and the `FFMPEG` development packages must be installed on the system.

#### Using included script
The simplest way to build and install a project is to use the included build script:

```bash
git clone /~https://github.com/kala13x/libxmedia.git && ./libxmedia/build.sh --install
```

List options that build script supports:

- `--tool=<tool>` Specify `Makefile` generation tool or use included `Makefile`.
- `--install` Install library and the tools after the build.
- `--cleanup` Cleanup object files after build/installation.
- `--example` Include example in the build.

You can either choose `cmake`, `smake` or `make` as the tool argument, but `cmake` is recommended on platforms other than the Linux.
If the tool will not be specified the script will use `make` (included Makefile) as default.

#### Using CMake
If you have a `CMake` tool installed in your operating system, here is how project can be built and installed using `cmake`:

```bash
git clone /~https://github.com/kala13x/libxmedia.git
cd libxmedia
cmake . && make
sudo make install
```

#### Using SMake
[SMake](/~https://github.com/kala13x/smake) is a simple Makefile generator tool for the Linux/Unix operating systems:

```bash
git clone /~https://github.com/kala13x/libxmedia.git
cd libxmedia
smake && make
sudo make install
```

#### Using Makefile
The project can also be built with a pre-generated `Makefile` for the Linux.

```bash
git clone /~https://github.com/kala13x/libxmedia.git
cd libxmedia
make
sudo make install
```
Loading

0 comments on commit 10dc1f8

Please sign in to comment.