Skip to content

Commit df6faa8

Browse files
committed
Add SRT support to pipeline generator and update dependencies
1 parent 32c6868 commit df6faa8

File tree

6 files changed

+100
-10
lines changed

6 files changed

+100
-10
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ RUN \
102102
ubuntu-drivers-common \
103103
xxd \
104104
zip \
105-
zlib1g-dev && \
105+
zlib1g-dev \
106+
libsrt-openssl-dev && \
106107
apt-get clean && \
107108
rm -rf /var/lib/apt/lists/* /tmp/cuda-keyring_1.1-1_all.deb
108109

@@ -329,7 +330,8 @@ RUN \
329330
--extra-cflags="-march=native -fopenmp -I/usr/local/include/ -I/opt/intel/oneapi/ipp/latest/include/ipp/ -I/usr/local/cuda/include" \
330331
--extra-ldflags="-fopenmp -L/usr/local/cuda/lib64 -L/usr/lib64 -L/usr/local/lib" \
331332
--extra-libs='-lraisr -lstdc++ -lippcore -lippvm -lipps -lippi -lpthread -lm -lz -lbsd -lrdmacm -lbpf -lxdp' \
332-
--enable-cross-compile && \
333+
--enable-cross-compile \
334+
--enable-libsrt && \
333335
make -j${nproc}
334336

335337
COPY /gRPC /tmp/gRPC

build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ function install_dependencies {
200200
librdmacm-dev \
201201
zlib1g-dev \
202202
libelf-dev \
203+
libsrt-openssl-dev \
203204
git \
204205
cmake \
205206
meson \
@@ -654,7 +655,8 @@ function ffmpeg_download_patch_build {
654655
--extra-cflags="-march=native -fopenmp -I${LOCAL_INSTALL_DEPENDENCIES_DIRECTORY}/vsr/install/include/ -I/opt/intel/oneapi/ipp/latest/include/ipp/ -I/usr/local/cuda/include" \
655656
--extra-ldflags="-fopenmp -L${LOCAL_INSTALL_DEPENDENCIES_DIRECTORY}/vsr/install/lib -L/usr/local/cuda/lib64 -L/usr/lib64 -L/usr/local/lib" \
656657
--extra-libs='-lraisr -lstdc++ -lippcore -lippvm -lipps -lippi -lpthread -lm -lz -lbsd -lrdmacm -lbpf -lxdp' \
657-
--enable-cross-compile &&
658+
--enable-cross-compile \
659+
--enable-libsrt &&
658660
make -j"$(nproc)" &&
659661
sudo make install) >>$log_file 2>&1; then
660662
echo

gRPC/config_params.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ struct MCM {
5656
std::string urn;
5757
};
5858

59+
struct SRT {
60+
std::string urn;
61+
};
62+
5963
enum payload_type {
6064
video = 0,
6165
audio
@@ -70,14 +74,16 @@ struct Payload {
7074
enum stream_type {
7175
file = 0,
7276
st2110,
73-
mcm
77+
mcm,
78+
srt
7479
};
7580

7681
struct StreamType {
7782
stream_type type;
7883
File file;
7984
ST2110 st2110;
8085
MCM mcm;
86+
SRT srt;
8187
};
8288

8389
struct Stream {

gRPC/config_serialize_deserialize.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Audio, channels, sample_rate, format, packet_
1212
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(File, path, filename)
1313
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ST2110, network_interface, local_ip, remote_ip, transport, remote_port, payload_type)
1414
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MCM, conn_type, transport, transport_pixel_format, ip, port, urn)
15+
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SRT, urn)
1516
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Payload, type, video, audio)
16-
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(StreamType, type, file, st2110, mcm)
17+
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(StreamType, type, file, st2110, mcm, srt)
1718
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Stream, payload, stream_type)
1819
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Config, senders, receivers, function, multiviewer_columns, gpu_hw_acceleration, gpu_hw_acceleration_device, logging_level)
1920

gRPC/ffmpeg_pipeline_generator.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ int ffmpeg_append_stream_type(Stream &st, bool is_rx, int idx, std::string &pipe
191191
pipeline_string += " -";
192192
}
193193
break;
194+
case srt:
195+
if (is_rx) {
196+
pipeline_string += " -i ";
197+
}
198+
else {
199+
pipeline_string += " -f mpegts ";
200+
}
201+
pipeline_string += s.srt.urn;
202+
break;
194203
default:
195204
break;
196205
}
@@ -199,7 +208,7 @@ int ffmpeg_append_stream_type(Stream &st, bool is_rx, int idx, std::string &pipe
199208
}
200209

201210
int ffmpeg_combine_rx_tx(Stream &rx, Stream &tx, int idx, std::string &pipeline_string){
202-
if (ffmpeg_append_payload(rx.payload, pipeline_string) != 0) {
211+
if ((rx.stream_type.type != srt) && ffmpeg_append_payload(rx.payload, pipeline_string) != 0) {
203212
pipeline_string.clear();
204213
std::cout << "Error appending rx payload" << std::endl;
205214
return 1;
@@ -234,7 +243,7 @@ int ffmpeg_append_multiviewer_input(Stream &s, int idx, std::string &pipeline_st
234243
return 1;
235244
}
236245

237-
if(ffmpeg_append_payload(s.payload, pipeline_string) != 0){
246+
if((s.stream_type.type != srt) && ffmpeg_append_payload(s.payload, pipeline_string) != 0){
238247
pipeline_string.clear();
239248
std::cout << "Error appending rx payload" << std::endl;
240249
return 1;
@@ -386,7 +395,7 @@ int ffmpeg_append_recorder(Config &config, std::string &pipeline_string) {
386395
std::cout << "Error: recorder requires at least 2 senders" << std::endl;
387396
}
388397

389-
if (ffmpeg_append_payload(config.receivers[0].payload, pipeline_string) != 0){
398+
if ((config.receivers[0].stream_type.type != srt) && ffmpeg_append_payload(config.receivers[0].payload, pipeline_string) != 0){
390399
pipeline_string.clear();
391400
std::cout << "Error appending recorder rx payload" << std::endl;
392401
return 1;

gRPC/unit_test/ffmpeg_pipeline_generator_test.cc

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,32 @@ void fill_conf_receiver_mcm(Config &config) {
154154
}
155155
}
156156

157+
void fill_conf_receiver_srt(Config &config) {
158+
config.function = "rx";
159+
config.gpu_hw_acceleration = "none";
160+
config.logging_level = 0;
161+
162+
Payload p = get_video_payload_common();
163+
{
164+
Stream s;
165+
166+
s.payload = p;
167+
s.stream_type.type = stream_type::srt;
168+
s.stream_type.srt.urn = "srt://:20001?mode=caller";
169+
config.receivers.push_back(s);
170+
}
171+
172+
{
173+
Stream s;
174+
175+
s.payload = p;
176+
s.stream_type.type = stream_type::file;
177+
s.stream_type.file.path = "/home/test/recv";
178+
s.stream_type.file.filename = "1920x1080p10le_1.yuv";
179+
config.senders.push_back(s);
180+
}
181+
}
182+
157183
void fill_conf_multiviewer(Config &config) {
158184
config.function = "multiviewer";
159185
config.gpu_hw_acceleration = "intel";
@@ -425,12 +451,25 @@ TEST(FFmpegPipelineGeneratorTest, test_mcm_receiver) {
425451
std::string pipeline_string;
426452

427453
if (ffmpeg_generate_pipeline(conf, pipeline_string) != 0) {
428-
ASSERT_EQ(1, 0) << "Error generating receiver pipeline" << std::endl;
454+
ASSERT_EQ(1, 0) << "Error generating receiver mcm pipeline" << std::endl;
429455
}
430456
std::string expected_string = " -y -video_size 1920x1080 -pix_fmt yuv422p10le -r 30/1 -f rawvideo -f mcm -conn_type st2110 -transport st2110-20 -transport_pixel_format yuv422p10rfc4175 -ip_addr 192.168.96.10 -port 9002 -i \"0\" /home/test/recv/1920x1080p10le_1.yuv";
431457
ASSERT_EQ(pipeline_string.compare(expected_string) == 0, 1) << "Expected: " << std::endl << expected_string << std::endl << " Got: " << std::endl << pipeline_string << std::endl;
432458
}
433459

460+
TEST(FFmpegPipelineGeneratorTest, test_srt) {
461+
Config conf;
462+
fill_conf_receiver_srt(conf);
463+
464+
std::string pipeline_string;
465+
466+
if (ffmpeg_generate_pipeline(conf, pipeline_string) != 0) {
467+
ASSERT_EQ(1, 0) << "Error generating srt pipeline" << std::endl;
468+
}
469+
std::string expected_string = " -y -i srt://:20001?mode=caller /home/test/recv/1920x1080p10le_1.yuv";
470+
ASSERT_EQ(pipeline_string.compare(expected_string) == 0, 1) << "Expected: " << std::endl << expected_string << std::endl << " Got: " << std::endl << pipeline_string << std::endl;
471+
}
472+
434473
TEST(FFmpegPipelineConfigTest, serialize_deserialize_multiviewer) {
435474
Config conf_reference;
436475
fill_conf_multiviewer(conf_reference);
@@ -485,4 +524,35 @@ TEST(FFmpegPipelineConfigTest, serialize_deserialize_upscale) {
485524

486525
ASSERT_EQ(pipeline_string_reference.compare(pipeline_string_deserialized) == 0, 1) << "Expected: " << std::endl << pipeline_string_reference
487526
<< std::endl << " Got: " << std::endl << pipeline_string_deserialized << std::endl;
488-
}
527+
}
528+
529+
TEST(FFmpegPipelineConfigTest, serialize_deserialize_upscale_srt) {
530+
Config conf_reference;
531+
fill_conf_upscale(conf_reference);
532+
533+
conf_reference.receivers[0].stream_type.type = stream_type::srt;
534+
conf_reference.receivers[0].stream_type.srt.urn = "srt://:20001";
535+
536+
std::string pipeline_string_reference;
537+
538+
if (ffmpeg_generate_pipeline(conf_reference, pipeline_string_reference) != 0) {
539+
ASSERT_EQ(1, 0) << "Error generating convert pipeline" << std::endl;
540+
}
541+
542+
std::string json_conf_serialized;
543+
if(serialize_config_json(conf_reference, json_conf_serialized) != 0) {
544+
ASSERT_EQ(1, 0) << "Error serializing config" << std::endl;
545+
}
546+
547+
Config conf_deserialized;
548+
std::string pipeline_string_deserialized;
549+
if(deserialize_config_json(conf_deserialized, json_conf_serialized) != 0) {
550+
ASSERT_EQ(1, 0) << "Error serializing config" << std::endl;
551+
}
552+
if (ffmpeg_generate_pipeline(conf_deserialized, pipeline_string_deserialized) != 0) {
553+
ASSERT_EQ(1, 0) << "Error generating convert pipeline after deserialization" << std::endl;
554+
}
555+
556+
ASSERT_EQ(pipeline_string_reference.compare(pipeline_string_deserialized) == 0, 1) << "Expected: " << std::endl << pipeline_string_reference
557+
<< std::endl << " Got: " << std::endl << pipeline_string_deserialized << std::endl;
558+
}

0 commit comments

Comments
 (0)