Skip to content

Commit 7b0997f

Browse files
Merge pull request #61 from OpenHD/codex/fix-internal-data-stream-error
Improve debug sample decoder fallback
2 parents 6b51913 + 50a2e7c commit 7b0997f

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

display_host_main.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <stdlib.h>
88
#include <string.h>
99
#include <string>
10+
#include <sstream>
1011
#include <sys/types.h>
1112
#include <sys/wait.h>
1213
#include <thread>
@@ -494,12 +495,22 @@ int main(int argc, char **argv) {
494495
setenv("FPVUE_RESERVED_PLANE_IDS", reserved_planes, 1);
495496
}
496497

497-
std::string pipeline_command =
498-
std::string("gst-launch-1.0 -q filesrc location=") + debug_sample_path +
499-
" ! qtdemux name=demux demux.video_0 ! h264parse config-interval=1 "
500-
"! video/x-h264,stream-format=byte-stream,alignment=au ! queue ! omxh264dec ! "
501-
"videoconvert ! video/x-raw,format=NV12,width=1280,height=720 ! queue ! fdsink fd=1 sync=false | "
502-
"fpvue --screen-mode 1280x720@60 --stdin-nv12";
498+
// Attempt to use platform-specific hardware decoders first and fall back to a
499+
// software decoder if negotiation keeps failing.
500+
std::ostringstream pipeline_builder;
501+
pipeline_builder << "run_decoder() {\n"
502+
<< " decoder=\"$1\";\n"
503+
<< " echo \"Attempting debug decode with $decoder\" >&2;\n"
504+
<< " gst-launch-1.0 -q filesrc location=" << debug_sample_path
505+
<< " ! qtdemux name=demux demux.video_0 ! h264parse config-interval=1"
506+
<< " ! video/x-h264,stream-format=byte-stream,alignment=au ! queue ! \"$decoder\""
507+
<< " ! videoconvert ! video/x-raw,format=NV12,width=1280,height=720 ! queue ! fdsink fd=1 sync=false;\n"
508+
<< "}\n"
509+
<< "(run_decoder omxh264dec || run_decoder mppvideodec || run_decoder avdec_h264)";
510+
511+
std::string pipeline_command = "(";
512+
pipeline_command += pipeline_builder.str();
513+
pipeline_command += ") | fpvue --screen-mode 1280x720@60 --stdin-nv12";
503514

504515
execlp("sh", "sh", "-c", pipeline_command.c_str(), (char *)NULL);
505516
perror("execlp sample video pipeline");

0 commit comments

Comments
 (0)