Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ossrf: Add previously developed code #1

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

114 changes: 108 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,113 @@
# \[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.
#### Configuration file
Open `cpp/demos/ossrf-nmos-api/config/nmos_config.json` and adjust the following parameters:

- `host_addresses`
- `registry_address`
- `system_address`
- `interface_address`
- `system_address`

This must be the address of the primary data interface.
***

#### To run:

`./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()
Loading