Skip to content

Commit

Permalink
Add nmos and grpc communication for ffmpeg pipeline (#35)
Browse files Browse the repository at this point in the history
* Add nmos and grpc communication for ffmpeg
* Run ffmpeg client as process and pass params via args
*It requires to pre-compile Intel-Tiber-Broadcast-Suite/gRPC code in order to use executable file.
Run:
$ cd Intel-Tiber-Broadcast-Suite/gRPC && ./compile.sh
$ ./build/Ffmpeg_wrapper_service localhost 50051
And then build and start nmos client using script nmos/docker/run.sh
  • Loading branch information
Magda-Pytel authored Jan 13, 2025
1 parent ec0c309 commit f003e63
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 56 deletions.
20 changes: 10 additions & 10 deletions gRPC/cmd_pass_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@
*/

#include "FFmpeg_wrapper_client.h"
#include <iostream>
#include <utility>
#include <vector>

int main(int argc, char* argv[]) {

if(argc != 3) {
std::cout << "client sample app only takes two argument 1) interface 2) port" << std::endl;
if (argc != 5) {
std::cout << "client sample app requires the following arguments: 1) interface, 2) port, 3) source_ip, 4) destination_port" << std::endl;
return 1;
}

std::vector<std::pair<std::string, std::string>> vec1 = {};
std::vector<std::pair<std::string, std::string>> vec2 = {{"key3", "val3"}, {"key4", "val4"}};
std::vector<std::pair<std::string, std::string>> vec3 = {{"key5", "val5"}, {"key6", "val6"}};
std::string interface = argv[1];//"localhost";
std::string port = argv[2];//"50051";
std::string source_ip = argv[3];
std::string destination_port = argv[4];

std::string interface = "localhost";
std::string port = "50051";
// Populate the connection_info vector with the provided values
std::vector<std::pair<std::string, std::string>> connection_info = {{"ip_addr", source_ip}, {"port", destination_port}};

CmdPassClient obj(interface, port);

// Send multiple asynchronous requests
obj.FFmpegCmdExec(vec1);
obj.FFmpegCmdExec(vec2);
obj.FFmpegCmdExec(vec3);
obj.FFmpegCmdExec(connection_info);

// Wait for all asynchronous operations to complete
obj.WaitForAllRequests();
Expand Down
4 changes: 3 additions & 1 deletion nmos/docker/node.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
"frame_width": 1920,
"frame_height": 1080,
"video_type": "video/jxsv",
"domain": "local"
"domain": "local",
"ffmpeg_grpc_server_address": "<ip_of_ffmpeg_grpc_server>",
"ffmpeg_grpc_server_port": "50051"
}
13 changes: 12 additions & 1 deletion nmos/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ BUILD=false
# Enable/disable to apply patches to 3rd party submodules nmos-cpp and build-nmos-cpp
APPLY_PATCHES=false
# Run script but without running containers
PREPARE=false
PREPARE=true

while [[ "$#" -gt 0 ]]; do
case $1 in
Expand Down Expand Up @@ -112,6 +112,17 @@ fi
echo "Copying files to build directory..."
cp "${SOURCE_DIR}/Development/nmos-cpp-node/node_implementation.cpp" "${BUILD_DIR}/"
cp "${SOURCE_DIR}/Development/nmos-cpp-node/main.cpp" "${BUILD_DIR}/"
cp -r ../../gRPC/ "${BUILD_DIR}/"

# Build grpc client that is necessary for NMOS node and ffmpeg pipeline communication
echo "Building grpc client that is necessary for NMOS node and ffmpeg pipeline communication..."
cd "${BUILD_DIR}/gRPC" || exit
./compile.sh

if [ $? -ne 0 ]; then
echo "Error: ./compile.sh failed. Check if all necesarry packages are installed"
exit 1
fi

# Build NMOS registry and controller
if [[ "${BUILD}" == true ]]; then
Expand Down
4 changes: 3 additions & 1 deletion nmos/k8s/bcs/nmos-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ data:
"frame_width": 1920,
"frame_height": 1080,
"video_type": "video/jxsv",
"domain": "local"
"domain": "default.svc.cluster.local",
"ffmpeg_grpc_server_address": "<ip_of_ffmpeg_grpc_server>",
"ffmpeg_grpc_server_port": "50051"
}
---
Expand Down
43 changes: 36 additions & 7 deletions nmos/patches/build-nmos-cpp.patch
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
diff --git a/Dockerfile b/Dockerfile
index f24a67a..792777f 100644
index f24a67a..a9d04f8 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -28,10 +28,14 @@ RUN cd /home && mkdir certs && git config --global http.sslVerify false && \
@@ -8,6 +8,7 @@ ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get install -y --no-install-recommends \
g++ build-essential \
+ autoconf libtool pkg-config clang libc++-dev \
openssl libssl-dev git wget gnupg curl ca-certificates nano \
python3 python3-pip python3-setuptools rdma-core && \
# Avahi: dbus avahi-daemon libavahi-compat-libdnssd-dev libnss-mdns AND NOT make \
@@ -28,10 +29,17 @@ RUN cd /home && mkdir certs && git config --global http.sslVerify false && \

## Get source for Sony nmos-cpp
## Commit 0fb6b51 corresponds to Conan package nmos-cpp/cci.20221203
Expand All @@ -14,11 +22,14 @@ index f24a67a..792777f 100644
+# FOR NMOS-CPP-CLIENT-NODE in BCS
+COPY ./node_implementation.cpp /home/nmos-cpp/Development/nmos-cpp-node/node_implementation.cpp
+COPY ./main.cpp /home/nmos-cpp/Development/nmos-cpp-node/main.cpp
+
+# Install BCS gRPC client
+COPY ./gRPC/build/ /home/gRPC/build/
+
## You should use either Avahi or Apple mDNS - DO NOT use both
##
## mDNSResponder 878.260.1 Build and install
@@ -42,10 +46,17 @@ RUN cd /home/ && curl --output - -s -k https://codeload.github.com/apple-oss-dis
@@ -42,10 +50,17 @@ RUN cd /home/ && curl --output - -s -k https://codeload.github.com/apple-oss-dis
patch -d mDNSResponder/ -p1 <nmos-cpp/Development/third_party/mDNSResponder/poll-rather-than-select.patch && \
cd /home/mDNSResponder/mDNSPosix && make os=linux && make os=linux install

Expand All @@ -38,7 +49,7 @@ index f24a67a..792777f 100644
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE:STRING="MinSizeRel" \
-DCMAKE_CONFIGURATION_TYPES:STRING="MinSizeRel" \
@@ -88,8 +99,9 @@ RUN cd /home/nmos-js/Development && \
@@ -88,12 +103,13 @@ RUN cd /home/nmos-js/Development && \
cp -rf /home/nmos-js/Development/build/* /home/admin

## Move executables, libraries and clean up container as much as possible
Expand All @@ -50,6 +61,22 @@ index f24a67a..792777f 100644
cd /home && rm -rf .git nmos-cpp nmos-js

## Re-build container for optimised runtime environment using clean Ubuntu Bionic release
-FROM ubuntu:focal
+FROM ubuntu:jammy

##Copy required files from build container
COPY --from=stage1-build /home /home
@@ -105,8 +121,8 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get install -
cd /home/mDNSResponder/mDNSPosix && make os=linux install && \
cd /home && rm -rf /home/mDNSResponder /etc/nsswitch.conf.pre-mdns && \
curl -sS -k "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x77b7346a59027b33c10cafe35e64e954262c4500" | apt-key add - && \
- echo "deb http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu focal main" | tee /etc/apt/sources.list.d/mosquitto.list && \
- apt-get update && apt-get install -y --no-install-recommends mosquitto && \
+ echo "deb http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu jammy main" | tee /etc/apt/sources.list.d/mosquitto.list && \
+ apt-get update && apt-get install -y --no-install-recommends mosquitto libc6 && \
apt-get remove --purge -y make gnupg && \
apt-get autoremove -y && \
apt-get clean -y --no-install-recommends && \
diff --git a/Makefile b/Makefile
index f04cb04..afdb54c 100644
--- a/Makefile
Expand All @@ -68,10 +95,10 @@ index f04cb04..afdb54c 100644

start: run
diff --git a/node.json b/node.json
index 6d36960..9e28c30 100644
index 6d36960..cf97d42 100644
--- a/node.json
+++ b/node.json
@@ -1,7 +1,17 @@
@@ -1,7 +1,19 @@
{
-"logging_level": 0,
-"http_port": 11000,
Expand All @@ -93,7 +120,9 @@ index 6d36960..9e28c30 100644
+ "frame_width": 1920,
+ "frame_height": 1080,
+ "video_type": "video/jxsv",
+ "domain": "local"
+ "domain": "local",
+ "ffmpeg_grpc_server_address": "<ip_of_ffmpeg_grpc_server>",
+ "ffmpeg_grpc_server_port": "50051"
+}
\ No newline at end of file
diff --git a/registry.json b/registry.json
Expand Down
Loading

0 comments on commit f003e63

Please sign in to comment.