Skip to content

Commit 86bd394

Browse files
authored
Add MCM transport handling and corresponding unit tests (#64)
* Add MCM transport handling and corresponding unit tests Signed-off-by: Tomasz Szumski <[email protected]> * Update MCM version to 25.03-rc2 --------- Signed-off-by: Tomasz Szumski <[email protected]>
1 parent 75969ec commit 86bd394

File tree

3 files changed

+145
-14
lines changed

3 files changed

+145
-14
lines changed

gRPC/ffmpeg_pipeline_generator.cc

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,33 @@ int ffmpeg_append_st2110_transport(std::string &transport, std::string &pipeline
104104
return 0;
105105
}
106106

107-
int ffmpeg_append_stream_type(StreamType &s, bool is_rx, int idx, std::string &pipeline_string) {
107+
int ffmpeg_append_mcm_transport(Payload &p, std::string &pipeline_string) {
108+
switch (p.type) {
109+
case video:
110+
pipeline_string += " -f mcm";
111+
break;
112+
case audio:
113+
if(p.audio.format == "s16be" || p.audio.format == "s16le" || p.audio.format == "u16be" || p.audio.format == "u16le"){
114+
pipeline_string += " -f mcm_audio_pcm16";
115+
break;
116+
}
117+
else if(p.audio.format == "s24be" || p.audio.format == "s24le" || p.audio.format == "u24be" || p.audio.format == "u24le"){
118+
pipeline_string += " -f mcm_audio_pcm24";
119+
break;
120+
}
121+
else{
122+
std::cout << "Error: audio format " << p.audio.format << " not supported yet" << std::endl;
123+
return 1;
124+
}
125+
default:
126+
std::cout << "Error: unknown mcm payload type" << std::endl;
127+
return 1;
128+
}
129+
return 0;
130+
}
131+
132+
int ffmpeg_append_stream_type(Stream &st, bool is_rx, int idx, std::string &pipeline_string) {
133+
auto s = st.stream_type;
108134
switch (s.type) {
109135
case file:
110136
{
@@ -144,12 +170,27 @@ int ffmpeg_append_stream_type(StreamType &s, bool is_rx, int idx, std::string &p
144170
else {
145171
pipeline_string += " -";
146172
}
147-
148-
149173
break;
150174
case mcm:
151-
std::cout << "Error: mcm not supported yet" << std::endl;
152-
return 1;
175+
if (ffmpeg_append_mcm_transport(st.payload, pipeline_string) != 0) {
176+
pipeline_string.clear();
177+
std::cout << "Error appending mcm transport" << std::endl;
178+
return 1;
179+
}
180+
pipeline_string += " -conn_type " + s.mcm.conn_type;
181+
pipeline_string += " -transport " + s.mcm.transport;
182+
if (s.mcm.transport == "st2110-20") {
183+
pipeline_string += " -transport_pixel_format " + s.mcm.transport_pixel_format;
184+
}
185+
pipeline_string += " -ip_addr " + s.mcm.ip;
186+
pipeline_string += " -port " + std::to_string(s.mcm.port);
187+
if(is_rx) {
188+
pipeline_string += " -i \"" + std::to_string(idx) + "\"";
189+
}
190+
else {
191+
pipeline_string += " -";
192+
}
193+
break;
153194
default:
154195
break;
155196
}
@@ -164,7 +205,7 @@ int ffmpeg_combine_rx_tx(Stream &rx, Stream &tx, int idx, std::string &pipeline_
164205
return 1;
165206
}
166207

167-
if (ffmpeg_append_stream_type(rx.stream_type, true/*is_rx*/, idx, pipeline_string) != 0) {
208+
if (ffmpeg_append_stream_type(rx, true/*is_rx*/, idx, pipeline_string) != 0) {
168209
pipeline_string.clear();
169210
std::cout << "Error appending rx stream type" << std::endl;
170211
return 1;
@@ -178,7 +219,7 @@ int ffmpeg_combine_rx_tx(Stream &rx, Stream &tx, int idx, std::string &pipeline_
178219
}
179220
}
180221

181-
if (ffmpeg_append_stream_type(tx.stream_type, false/*is_rx*/, idx, pipeline_string) != 0) {
222+
if (ffmpeg_append_stream_type(tx, false/*is_rx*/, idx, pipeline_string) != 0) {
182223
pipeline_string.clear();
183224
std::cout << "Error appending tx stream type" << std::endl;
184225
return 1;
@@ -199,7 +240,7 @@ int ffmpeg_append_multiviewer_input(Stream &s, int idx, std::string &pipeline_st
199240
return 1;
200241
}
201242

202-
if(ffmpeg_append_stream_type(s.stream_type, true/*is_rx*/, idx, pipeline_string) != 0){
243+
if(ffmpeg_append_stream_type(s, true/*is_rx*/, idx, pipeline_string) != 0){
203244
pipeline_string.clear();
204245
std::cout << "Error appending rx stream type" << std::endl;
205246
return 1;
@@ -272,7 +313,7 @@ int ffmpeg_append_split_process(std::vector<Stream> &senders, uint32_t intel_gpu
272313
if(senders[i].payload.video.video_type != "rawvideo") {
273314
pipeline_string += " -c:v " + senders[i].payload.video.video_type;
274315
}
275-
ffmpeg_append_stream_type(senders[i].stream_type, false /*is_rx*/, i, pipeline_string);
316+
ffmpeg_append_stream_type(senders[i], false /*is_rx*/, i, pipeline_string);
276317
}
277318
return 0;
278319
}
@@ -324,7 +365,7 @@ int ffmpeg_append_multiviewer(Config &config, std::string &pipeline_string) {
324365
std::cout << "Error appending multiviewer process" << std::endl;
325366
return 1;
326367
}
327-
if (ffmpeg_append_stream_type(config.senders[0].stream_type, false /*is_rx*/, 0, pipeline_string) != 0) {
368+
if (ffmpeg_append_stream_type(config.senders[0], false /*is_rx*/, 0, pipeline_string) != 0) {
328369
pipeline_string.clear();
329370
std::cout << "Error appending multiviewer tx stream" << std::endl;
330371
return 1;
@@ -350,7 +391,7 @@ int ffmpeg_append_recorder(Config &config, std::string &pipeline_string) {
350391
std::cout << "Error appending recorder rx payload" << std::endl;
351392
return 1;
352393
}
353-
if (ffmpeg_append_stream_type(config.receivers[0].stream_type, true /*is_rx*/, 0, pipeline_string) != 0) {
394+
if (ffmpeg_append_stream_type(config.receivers[0], true /*is_rx*/, 0, pipeline_string) != 0) {
354395
pipeline_string.clear();
355396
std::cout << "Error appending recorder rx stream" << std::endl;
356397
return 1;
@@ -384,13 +425,13 @@ int ffmpeg_append_upscale(Config &config, std::string &pipeline_string) {
384425
std::cout << "Error appending upscale rx payload" << std::endl;
385426
return 1;
386427
}
387-
if(ffmpeg_append_stream_type(config.receivers[0].stream_type, true /*is_rx*/, 0, pipeline_string) != 0){
428+
if(ffmpeg_append_stream_type(config.receivers[0], true /*is_rx*/, 0, pipeline_string) != 0){
388429
pipeline_string.clear();
389430
std::cout << "Error appending upscale rx stream" << std::endl;
390431
return 1;
391432
}
392433
pipeline_string += " -vf \"format=yuv420p,hwupload,raisr_opencl,hwdownload,format=yuv420p,format=yuv422p10le\"";
393-
if(ffmpeg_append_stream_type(config.senders[0].stream_type, false /*is_rx*/, 0, pipeline_string) != 0){
434+
if(ffmpeg_append_stream_type(config.senders[0], false /*is_rx*/, 0, pipeline_string) != 0){
394435
pipeline_string.clear();
395436
std::cout << "Error appending upscale tx stream" << std::endl;
396437
return 1;

gRPC/unit_test/ffmpeg_pipeline_generator_test.cc

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,70 @@ void fill_conf_receiver(Config &config) {
9090
}
9191
}
9292

93+
void fill_conf_sender_mcm(Config &config) {
94+
config.function = "tx";
95+
config.gpu_hw_acceleration = "none";
96+
config.logging_level = 0;
97+
98+
Payload p = get_video_payload_common();
99+
{
100+
Stream s;
101+
102+
s.payload = p;
103+
s.stream_type.type = stream_type::file;
104+
s.stream_type.file.path = "/home/test";
105+
s.stream_type.file.filename = "1920x1080p10le_1.yuv";
106+
config.receivers.push_back(s);
107+
}
108+
109+
{
110+
Stream s;
111+
112+
s.payload = p;
113+
s.stream_type.type = stream_type::mcm;
114+
s.stream_type.mcm.conn_type = "st2110";
115+
s.stream_type.mcm.transport = "st2110-20";
116+
s.stream_type.mcm.transport_pixel_format = "yuv422p10rfc4175";
117+
s.stream_type.mcm.ip = "192.168.96.11";
118+
s.stream_type.mcm.port = 9002;
119+
s.stream_type.mcm.urn = "abc";
120+
121+
config.senders.push_back(s);
122+
}
123+
}
124+
125+
void fill_conf_receiver_mcm(Config &config) {
126+
config.function = "rx";
127+
config.gpu_hw_acceleration = "none";
128+
config.logging_level = 0;
129+
130+
Payload p = get_video_payload_common();
131+
{
132+
Stream s;
133+
134+
s.payload = p;
135+
s.stream_type.type = stream_type::file;
136+
s.stream_type.file.path = "/home/test/recv";
137+
s.stream_type.file.filename = "1920x1080p10le_1.yuv";
138+
config.senders.push_back(s);
139+
}
140+
141+
{
142+
Stream s;
143+
144+
s.payload = p;
145+
s.stream_type.type = stream_type::mcm;
146+
s.stream_type.mcm.conn_type = "st2110";
147+
s.stream_type.mcm.transport = "st2110-20";
148+
s.stream_type.mcm.transport_pixel_format = "yuv422p10rfc4175";
149+
s.stream_type.mcm.ip = "192.168.96.10";
150+
s.stream_type.mcm.port = 9002;
151+
s.stream_type.mcm.urn = "abc";
152+
153+
config.receivers.push_back(s);
154+
}
155+
}
156+
93157
void fill_conf_multiviewer(Config &config) {
94158
config.function = "multiviewer";
95159
config.gpu_hw_acceleration = "intel";
@@ -341,6 +405,32 @@ TEST(FFmpegPipelineGeneratorTest, test_upscale) {
341405
ASSERT_EQ(pipeline_string.compare(expected_string) == 0, 1) << "Expected: " << std::endl << expected_string << std::endl << " Got: " << std::endl << pipeline_string << std::endl;
342406
}
343407

408+
TEST(FFmpegPipelineGeneratorTest, test_mcm_sender) {
409+
Config conf;
410+
fill_conf_sender_mcm(conf);
411+
412+
std::string pipeline_string;
413+
414+
if (ffmpeg_generate_pipeline(conf, pipeline_string) != 0) {
415+
ASSERT_EQ(1, 0) << "Error generating sender pipeline" << std::endl;
416+
}
417+
std::string expected_string = " -y -video_size 1920x1080 -pix_fmt yuv422p10le -r 30/1 -f rawvideo -i /home/test/1920x1080p10le_1.yuv -f mcm -conn_type st2110 -transport st2110-20 -transport_pixel_format yuv422p10rfc4175 -ip_addr 192.168.96.11 -port 9002 -";
418+
ASSERT_EQ(pipeline_string.compare(expected_string) == 0, 1) << "Expected: " << std::endl << expected_string << std::endl << " Got: " << std::endl << pipeline_string << std::endl;
419+
}
420+
421+
TEST(FFmpegPipelineGeneratorTest, test_mcm_receiver) {
422+
Config conf;
423+
fill_conf_receiver_mcm(conf);
424+
425+
std::string pipeline_string;
426+
427+
if (ffmpeg_generate_pipeline(conf, pipeline_string) != 0) {
428+
ASSERT_EQ(1, 0) << "Error generating receiver pipeline" << std::endl;
429+
}
430+
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";
431+
ASSERT_EQ(pipeline_string.compare(expected_string) == 0, 1) << "Expected: " << std::endl << expected_string << std::endl << " Got: " << std::endl << pipeline_string << std::endl;
432+
}
433+
344434
TEST(FFmpegPipelineConfigTest, serialize_deserialize_multiviewer) {
345435
Config conf_reference;
346436
fill_conf_multiviewer(conf_reference);

versions.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ FFMPEG_COMMIT_ID=n7.0.2
88
XDP_VER=d7edea3590052581c5fda5f8cfa40ae7be94f05c
99
BPF_VER=42065ea6627ff6e1ab4c65e51042a70fbf30ff7c
1010
MTL_VER=v24.09
11-
MCM_VER=24.09
11+
MCM_VER=25.03-rc2
1212
JPEG_XS_COMMIT_ID=e0940acc5cd0ec239233fe5a065cffcdb29b2db4
1313
DPDK_VER=23.11
1414
FFNVCODED_VER=1889e62e2d35ff7aa9baca2bceb14f053785e6f1

0 commit comments

Comments
 (0)