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

Add MCM transport handling and corresponding unit tests #64

Merged
merged 2 commits into from
Feb 20, 2025
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
67 changes: 54 additions & 13 deletions gRPC/ffmpeg_pipeline_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,33 @@ int ffmpeg_append_st2110_transport(std::string &transport, std::string &pipeline
return 0;
}

int ffmpeg_append_stream_type(StreamType &s, bool is_rx, int idx, std::string &pipeline_string) {
int ffmpeg_append_mcm_transport(Payload &p, std::string &pipeline_string) {
switch (p.type) {
case video:
pipeline_string += " -f mcm";
break;
case audio:
if(p.audio.format == "s16be" || p.audio.format == "s16le" || p.audio.format == "u16be" || p.audio.format == "u16le"){
pipeline_string += " -f mcm_audio_pcm16";
break;
}
else if(p.audio.format == "s24be" || p.audio.format == "s24le" || p.audio.format == "u24be" || p.audio.format == "u24le"){
pipeline_string += " -f mcm_audio_pcm24";
break;
}
else{
std::cout << "Error: audio format " << p.audio.format << " not supported yet" << std::endl;
return 1;
}
default:
std::cout << "Error: unknown mcm payload type" << std::endl;
return 1;
}
return 0;
}

int ffmpeg_append_stream_type(Stream &st, bool is_rx, int idx, std::string &pipeline_string) {
auto s = st.stream_type;
switch (s.type) {
case file:
{
Expand Down Expand Up @@ -144,12 +170,27 @@ int ffmpeg_append_stream_type(StreamType &s, bool is_rx, int idx, std::string &p
else {
pipeline_string += " -";
}


break;
case mcm:
std::cout << "Error: mcm not supported yet" << std::endl;
return 1;
if (ffmpeg_append_mcm_transport(st.payload, pipeline_string) != 0) {
pipeline_string.clear();
std::cout << "Error appending mcm transport" << std::endl;
return 1;
}
pipeline_string += " -conn_type " + s.mcm.conn_type;
pipeline_string += " -transport " + s.mcm.transport;
if (s.mcm.transport == "st2110-20") {
pipeline_string += " -transport_pixel_format " + s.mcm.transport_pixel_format;
}
pipeline_string += " -ip_addr " + s.mcm.ip;
pipeline_string += " -port " + std::to_string(s.mcm.port);
if(is_rx) {
pipeline_string += " -i \"" + std::to_string(idx) + "\"";
}
else {
pipeline_string += " -";
}
break;
default:
break;
}
Expand All @@ -164,7 +205,7 @@ int ffmpeg_combine_rx_tx(Stream &rx, Stream &tx, int idx, std::string &pipeline_
return 1;
}

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

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

if(ffmpeg_append_stream_type(s.stream_type, true/*is_rx*/, idx, pipeline_string) != 0){
if(ffmpeg_append_stream_type(s, true/*is_rx*/, idx, pipeline_string) != 0){
pipeline_string.clear();
std::cout << "Error appending rx stream type" << std::endl;
return 1;
Expand Down Expand Up @@ -272,7 +313,7 @@ int ffmpeg_append_split_process(std::vector<Stream> &senders, uint32_t intel_gpu
if(senders[i].payload.video.video_type != "rawvideo") {
pipeline_string += " -c:v " + senders[i].payload.video.video_type;
}
ffmpeg_append_stream_type(senders[i].stream_type, false /*is_rx*/, i, pipeline_string);
ffmpeg_append_stream_type(senders[i], false /*is_rx*/, i, pipeline_string);
}
return 0;
}
Expand Down Expand Up @@ -324,7 +365,7 @@ int ffmpeg_append_multiviewer(Config &config, std::string &pipeline_string) {
std::cout << "Error appending multiviewer process" << std::endl;
return 1;
}
if (ffmpeg_append_stream_type(config.senders[0].stream_type, false /*is_rx*/, 0, pipeline_string) != 0) {
if (ffmpeg_append_stream_type(config.senders[0], false /*is_rx*/, 0, pipeline_string) != 0) {
pipeline_string.clear();
std::cout << "Error appending multiviewer tx stream" << std::endl;
return 1;
Expand All @@ -350,7 +391,7 @@ int ffmpeg_append_recorder(Config &config, std::string &pipeline_string) {
std::cout << "Error appending recorder rx payload" << std::endl;
return 1;
}
if (ffmpeg_append_stream_type(config.receivers[0].stream_type, true /*is_rx*/, 0, pipeline_string) != 0) {
if (ffmpeg_append_stream_type(config.receivers[0], true /*is_rx*/, 0, pipeline_string) != 0) {
pipeline_string.clear();
std::cout << "Error appending recorder rx stream" << std::endl;
return 1;
Expand Down Expand Up @@ -384,13 +425,13 @@ int ffmpeg_append_upscale(Config &config, std::string &pipeline_string) {
std::cout << "Error appending upscale rx payload" << std::endl;
return 1;
}
if(ffmpeg_append_stream_type(config.receivers[0].stream_type, true /*is_rx*/, 0, pipeline_string) != 0){
if(ffmpeg_append_stream_type(config.receivers[0], true /*is_rx*/, 0, pipeline_string) != 0){
pipeline_string.clear();
std::cout << "Error appending upscale rx stream" << std::endl;
return 1;
}
pipeline_string += " -vf \"format=yuv420p,hwupload,raisr_opencl,hwdownload,format=yuv420p,format=yuv422p10le\"";
if(ffmpeg_append_stream_type(config.senders[0].stream_type, false /*is_rx*/, 0, pipeline_string) != 0){
if(ffmpeg_append_stream_type(config.senders[0], false /*is_rx*/, 0, pipeline_string) != 0){
pipeline_string.clear();
std::cout << "Error appending upscale tx stream" << std::endl;
return 1;
Expand Down
90 changes: 90 additions & 0 deletions gRPC/unit_test/ffmpeg_pipeline_generator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,70 @@ void fill_conf_receiver(Config &config) {
}
}

void fill_conf_sender_mcm(Config &config) {
config.function = "tx";
config.gpu_hw_acceleration = "none";
config.logging_level = 0;

Payload p = get_video_payload_common();
{
Stream s;

s.payload = p;
s.stream_type.type = stream_type::file;
s.stream_type.file.path = "/home/test";
s.stream_type.file.filename = "1920x1080p10le_1.yuv";
config.receivers.push_back(s);
}

{
Stream s;

s.payload = p;
s.stream_type.type = stream_type::mcm;
s.stream_type.mcm.conn_type = "st2110";
s.stream_type.mcm.transport = "st2110-20";
s.stream_type.mcm.transport_pixel_format = "yuv422p10rfc4175";
s.stream_type.mcm.ip = "192.168.96.11";
s.stream_type.mcm.port = 9002;
s.stream_type.mcm.urn = "abc";

config.senders.push_back(s);
}
}

void fill_conf_receiver_mcm(Config &config) {
config.function = "rx";
config.gpu_hw_acceleration = "none";
config.logging_level = 0;

Payload p = get_video_payload_common();
{
Stream s;

s.payload = p;
s.stream_type.type = stream_type::file;
s.stream_type.file.path = "/home/test/recv";
s.stream_type.file.filename = "1920x1080p10le_1.yuv";
config.senders.push_back(s);
}

{
Stream s;

s.payload = p;
s.stream_type.type = stream_type::mcm;
s.stream_type.mcm.conn_type = "st2110";
s.stream_type.mcm.transport = "st2110-20";
s.stream_type.mcm.transport_pixel_format = "yuv422p10rfc4175";
s.stream_type.mcm.ip = "192.168.96.10";
s.stream_type.mcm.port = 9002;
s.stream_type.mcm.urn = "abc";

config.receivers.push_back(s);
}
}

void fill_conf_multiviewer(Config &config) {
config.function = "multiviewer";
config.gpu_hw_acceleration = "intel";
Expand Down Expand Up @@ -341,6 +405,32 @@ TEST(FFmpegPipelineGeneratorTest, test_upscale) {
ASSERT_EQ(pipeline_string.compare(expected_string) == 0, 1) << "Expected: " << std::endl << expected_string << std::endl << " Got: " << std::endl << pipeline_string << std::endl;
}

TEST(FFmpegPipelineGeneratorTest, test_mcm_sender) {
Config conf;
fill_conf_sender_mcm(conf);

std::string pipeline_string;

if (ffmpeg_generate_pipeline(conf, pipeline_string) != 0) {
ASSERT_EQ(1, 0) << "Error generating sender pipeline" << std::endl;
}
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 -";
ASSERT_EQ(pipeline_string.compare(expected_string) == 0, 1) << "Expected: " << std::endl << expected_string << std::endl << " Got: " << std::endl << pipeline_string << std::endl;
}

TEST(FFmpegPipelineGeneratorTest, test_mcm_receiver) {
Config conf;
fill_conf_receiver_mcm(conf);

std::string pipeline_string;

if (ffmpeg_generate_pipeline(conf, pipeline_string) != 0) {
ASSERT_EQ(1, 0) << "Error generating receiver pipeline" << std::endl;
}
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";
ASSERT_EQ(pipeline_string.compare(expected_string) == 0, 1) << "Expected: " << std::endl << expected_string << std::endl << " Got: " << std::endl << pipeline_string << std::endl;
}

TEST(FFmpegPipelineConfigTest, serialize_deserialize_multiviewer) {
Config conf_reference;
fill_conf_multiviewer(conf_reference);
Expand Down
2 changes: 1 addition & 1 deletion versions.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FFMPEG_COMMIT_ID=n7.0.2
XDP_VER=d7edea3590052581c5fda5f8cfa40ae7be94f05c
BPF_VER=42065ea6627ff6e1ab4c65e51042a70fbf30ff7c
MTL_VER=v24.09
MCM_VER=24.09
MCM_VER=25.03-rc2
JPEG_XS_COMMIT_ID=e0940acc5cd0ec239233fe5a065cffcdb29b2db4
DPDK_VER=23.11
FFNVCODED_VER=1889e62e2d35ff7aa9baca2bceb14f053785e6f1
Expand Down
Loading