Skip to content

Commit

Permalink
ossrf: Add existing developed code
Browse files Browse the repository at this point in the history
  • Loading branch information
massis08 committed Sep 6, 2024
1 parent 254356d commit 1f2fdae
Show file tree
Hide file tree
Showing 138 changed files with 9,046 additions and 6 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/cmake-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: Ubuntu pipeline

# on:
# pull_request:
# branches:
# - main

env:
BUILD_TYPE: Release

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Clang Check
run: ./scripts/cipipeline/clang-test.sh

- name: Setup
run: ./scripts/setup.sh

- name: Build & Test
run: ./scripts/build.sh

8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@
*.swp
*~
.DS_Store

/build
/dist
/install
/CMakeUserPresets.json
/.vscode
/volumes
/.user
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.16)

project(ossrf LANGUAGES CXX VERSION 0.1.0)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cpp/config/cmake")
include(StandardProjectSettings)
include(PreventInSourceBuilds)

enable_testing()

# Link this 'library' to set the c++ standard / compile-time options requested
add_library(project_options INTERFACE)
target_compile_features(project_options INTERFACE cxx_std_20)
add_library(bisect::project_options ALIAS project_options)

# Link this 'library' to use the warnings specified in CompilerWarnings.cmake
add_library(project_warnings INTERFACE)
add_library(bisect::project_warnings ALIAS project_warnings)

# Standard compiler warnings
include(CompilerWarnings)
set_project_warnings(project_warnings FALSE)
add_library(project_warnings_c INTERFACE)
add_library(bisect::project_warnings_c ALIAS project_warnings_c)

add_subdirectory(cpp)

103 changes: 97 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,102 @@
# \[Work In Progress\] AMWA NMOS Sender Receiver Framework
# ossrf

[![Lint Status](https://github.com/AMWA-TV/nmos-sender-receiver-framework/workflows/Lint/badge.svg)](https://github.com/AMWA-TV/nmos-sender-receiver-framework/actions?query=workflow%3ALint)
[![Render Status](https://github.com/AMWA-TV/nmos-sender-receiver-framework/workflows/Render/badge.svg)](https://github.com/AMWA-TV/nmos-sender-receiver-framework/actions?query=workflow%3ARender)
## Overview

Developing OSSRF for AWMA by Bisect.

<!-- INTRO-START -->
## Platforms

Currently, only Linux is supported.

## Requirements

Conan >= 2.0

CMake >= 3.16

## Code

Clone the repository:

`git clone [email protected]:bisect-pt/ossrf.git`

or

`git clone https://github.com/bisect-pt/ossrf.git`

## Setup Docker Containers

This will create the docker containers base on the docker compose:

docker compose -f images/docker-compose-x86-development.yml build

One of the containers is the ossrf-dev where you can find the development container.
The other is nmos-registry where will launch the NVIDIA NMOS Commissioning Controller

## Run Docker Containers

This will run the docker containers:

docker compose -f images/docker-compose-x86-development.yml up -d

## Access the Development Container

### Using VSCode

Install `ms-vscode-remote.remote-ssh` extension on vscode and enter on the container.

### Using SSH

First you need to check you IP address. You can do it by running:

hostname -i

Once you know your ip address you enter the container by doing:

ssh -p 55555 bisect@{your-ip-address} -XY

## Access NVIDIA NMOS Commissioning Controller Container

### Access the NVIDIA NMOS Commissioning Controller UI

You can access the UI by opening your favorite browser and go to this link:

http://localhost:8010/admin/

## Build

### Prepare Conan

If you have not used Conan before:

- create a directory:

`mkdir ~/.conan2`

- confirm that the Conan version is suitable

conan --version

- set the default Conan profile, e.g.

conan profile detect --force

### Install the dependencies using Conan

This only has to be done at the first time or after any of the dependencies change:

./scripts/setup.sh

### Build using CMake

./scripts/build.sh

### Demo ossrf-nmos-api
This example showcases the creation of one video/raw receiver and two video/raw senders, both on the NMOS and GStreamer sides. The receiver can be connected to either sender, allowing you to observe the different outputs.
While it is possible to create NMOS audio resources, GStreamer support for audio is not yet implemented.

To run the demo:

`./build/Debug/cpp/demos/ossrf-nmos-api/ossrf-nmos-api -f ./cpp/demos/ossrf-nmos-api/config/nmos_config.json`

This repo and site will be used for AMWA's forthcoming open-source NMOS Sender Receiver Framework.

<!-- INTRO-END -->
18 changes: 18 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from conan import ConanFile
from conan.tools.cmake import cmake_layout

class OSSRFRecipe(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"

def requirements(self):
self.requires("nmos-cpp/cci.20240223")
self.requires("gtest/1.14.0")
self.requires("fmt/9.1.0")
self.requires("nlohmann_json/3.11.3")

def build_requirements(self):
pass

def layout(self):
cmake_layout(self)
25 changes: 25 additions & 0 deletions cpp/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BasedOnStyle: LLVM
Language: Cpp
ColumnLimit: 120
IndentWidth: 4
BreakBeforeBraces: Custom
BraceWrapping:
AfterEnum: true
AfterStruct: true
AfterClass: true
AfterControlStatement: true
AfterFunction: true
AfterNamespace: true
BeforeCatch: true
BeforeElse: true
SplitEmptyFunction: true
NamespaceIndentation: All
PointerAlignment: Left
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: InlineOnly
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignTrailingComments: true
SpaceBeforeParens: Never
SortIncludes: false
12 changes: 12 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version.txt" "${PROJECT_VERSION}")

add_subdirectory(demos)
add_subdirectory(libs)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VENDOR "BISECT LDA")

include(CPack)
90 changes: 90 additions & 0 deletions cpp/config/cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# from here:
#
# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md

function(set_project_warnings project_name is_c)
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" TRUE)

set(MSVC_WARNINGS
/W4 # Baseline reasonable warnings
/w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss of data
/w14254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
/w14263 # 'function': member function does not override any base class virtual member function
/w14265 # 'classname': class has virtual functions, but destructor is not virtual instances of this class may not
# be destructed correctly
/w14287 # 'operator': unsigned/negative constant mismatch
/we4289 # nonstandard extension used: 'variable': loop control variable declared in the for-loop is used outside
# the for-loop scope
/w14296 # 'operator': expression is always 'boolean_value'
/w14311 # 'variable': pointer truncation from 'type1' to 'type2'
/w14545 # expression before comma evaluates to a function which is missing an argument list
/w14546 # function call before comma missing argument list
/w14547 # 'operator': operator before comma has no effect; expected operator with side-effect
/w14549 # 'operator': operator before comma has no effect; did you intend 'operator'?
/w14555 # expression has no effect; expected expression with side- effect
/w14619 # pragma warning: there is no warning number 'number'
/w14640 # Enable warning on thread un-safe static member initialization
/w14826 # Conversion from 'type1' to 'type_2' is sign-extended. This may cause unexpected runtime behavior.
/w14905 # wide string literal cast to 'LPSTR'
/w14906 # string literal cast to 'LPWSTR'
/w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied
/permissive- # standards conformance mode for MSVC compiler.
)

set(CLANG_WARNINGS
-Wall
-Wextra # reasonable and standard
-Wshadow # warn the user if a variable declaration shadows one from a parent context
# catch hard to track down memory errors
-Wcast-align # warn for potential performance problem casts
-Wunused # warn on anything being unused
-Wpedantic # warn if non-standard C++ is used
-Wconversion # warn on type conversions that may lose data
-Wsign-conversion # warn on sign conversions
-Wnull-dereference # warn if a null dereference is detected
-Wdouble-promotion # warn if float is implicit promoted to double
-Wformat=2 # warn on security issues around functions that format output (ie printf)
)

if (!is_c)
set(CLANG_WARNINGS
${CLANG_WARNINGS}
-Wnon-virtual-dtor # warn the user if a class with virtual functions has a non-virtual destructor. This helps
-Wold-style-cast # warn for c-style casts
-Woverloaded-virtual # warn if you overload (not override) a virtual function
)
endif ()

if (WARNINGS_AS_ERRORS)
set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
endif ()

set(GCC_WARNINGS
${CLANG_WARNINGS}
-Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist
-Wduplicated-cond # warn if if / else chain has duplicated conditions
-Wduplicated-branches # warn if if / else branches have duplicated code
-Wlogical-op # warn about logical operations being used where bitwise were probably wanted
)

if (!is_c)
set(GCC_WARNINGS
${GCC_WARNINGS}
-Wuseless-cast # warn if you perform a cast to the same type
)
endif ()

if (MSVC)
set(PROJECT_WARNINGS ${MSVC_WARNINGS})
elseif (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
set(PROJECT_WARNINGS ${CLANG_WARNINGS})
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(PROJECT_WARNINGS ${GCC_WARNINGS})
else ()
message(AUTHOR_WARNING "No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
endif ()

target_compile_options(${project_name} INTERFACE ${PROJECT_WARNINGS})

endfunction()
18 changes: 18 additions & 0 deletions cpp/config/cmake/PreventInSourceBuilds.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# This function will prevent in-source builds
function(AssureOutOfSourceBuilds)
# make sure the user doesn't play dirty with symlinks
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)

# disallow in-source builds
if ("${srcdir}" STREQUAL "${bindir}")
message("######################################################")
message("Warning: in-source builds are disabled")
message("Please create a separate build directory and run cmake from there")
message("######################################################")
message(FATAL_ERROR "Quitting configuration")
endif ()
endfunction()

assureoutofsourcebuilds()
42 changes: 42 additions & 0 deletions cpp/config/cmake/StandardProjectSettings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Set a default build type if none was specified
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE
RelWithDebInfo
CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui, ccmake
set_property(
CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS
"Debug"
"Release"
"MinSizeRel"
"RelWithDebInfo")
endif ()

# Generate compile_commands.json to make it easier to work with clang based tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(ENABLE_IPO "Enable Interprocedural Optimization, aka Link Time Optimization (LTO)" OFF)

if (ENABLE_IPO)
include(CheckIPOSupported)
check_ipo_supported(
RESULT
result
OUTPUT
output)
if (result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else ()
message(SEND_ERROR "IPO is not supported: ${output}")
endif ()
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
add_compile_options(-fcolor-diagnostics)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
else ()
message(STATUS "No colored compiler diagnostic set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
endif ()

3 changes: 3 additions & 0 deletions cpp/demos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_subdirectory(nmos-cpp-node)
add_subdirectory(ossrf-nmos-api)
add_subdirectory(gst-sender)
Loading

0 comments on commit 1f2fdae

Please sign in to comment.