From e39c31ff306e2a9772850ac310604ccef9533835 Mon Sep 17 00:00:00 2001 From: gtxaspec Date: Sun, 3 Mar 2024 17:17:48 -0800 Subject: [PATCH] update osd logic --- README.md | 13 ++++++++++ src/Encoder.cpp | 63 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 20 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..318f0f4 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# prudynt-t + +**prudynt-t** is a video server based on the **[prudynt-v3](https://git.i386.io/wyze/prudynt-v3)** project originally for the Wyzecam v3. It extends the functionality of the original project while expanding compatibility with modern Ingenic hardware. + +## Features + +- **Video Compression**: Supports both H264 and H265 codecs for efficient video compression and streaming. +- **Expanded Configuration**: Integrated support for **[libimp_control](https://github.com/gtxaspec/libimp_control)**. +- **Thingino Integration**: Seamlessly integrates with **[thingino](https://github.com/themactep/thingino-firmware)**, enhancing connectivity and control options. + +## Contributing + +Contributions to prudynt-t are welcome! If you have improvements, bug fixes, or new features, please feel free to submit a pull request or open an issue. diff --git a/src/Encoder.cpp b/src/Encoder.cpp index 076bdae..69ea9fc 100644 --- a/src/Encoder.cpp +++ b/src/Encoder.cpp @@ -38,26 +38,47 @@ bool Encoder::init() { return true; } - ret = osd.init(); - if (ret) { - LOG_ERROR("OSD Init Failed"); - return true; - } + if (Config::singleton()->OSDEnabled == 0) { + // If OSD is not enabled, initialize without OSD and bind FrameSource directly to Encoder + ret = osd.init(); + if (ret) { + LOG_ERROR("OSD Init Failed"); + return true; + } + + IMPCell fs = { DEV_ID_FS, 0, 0 }; + IMPCell enc = { DEV_ID_ENC, 0, 0 }; + // Framesource -> ENC + ret = IMP_System_Bind(&fs, &enc); + if (ret < 0) { + LOG_ERROR("IMP_System_Bind(FS, ENC) == " << ret); + return true; + } + + } else { + // If OSD is enabled, initialize OSD and bind FrameSource to OSD, then OSD to Encoder + ret = osd.init(); + if (ret) { + LOG_ERROR("OSD Init Failed"); + return true; + } + + IMPCell fs = { DEV_ID_FS, 0, 0 }; + IMPCell osd_cell = { DEV_ID_OSD, 0, 0 }; + IMPCell enc = { DEV_ID_ENC, 0, 0 }; + // Framesource -> OSD + ret = IMP_System_Bind(&fs, &osd_cell); + if (ret < 0) { + LOG_ERROR("IMP_System_Bind(FS, OSD) == " << ret); + return true; + } + // OSD -> Encoder + ret = IMP_System_Bind(&osd_cell, &enc); + if (ret < 0) { + LOG_ERROR("IMP_System_Bind(OSD, ENC) == " << ret); + return true; + } - IMPCell fs = { DEV_ID_FS, 0, 0 }; - IMPCell osd_cell = { DEV_ID_OSD, 0, 0 }; - IMPCell enc = { DEV_ID_ENC, 0, 0 }; - //Framesource -> OSD - ret = IMP_System_Bind(&fs, &osd_cell); - if (ret < 0) { - LOG_ERROR("IMP_System_Bind(FS, OSD) == " << ret); - return true; - } - //OSD -> Encoder - ret = IMP_System_Bind(&osd_cell, &enc); - if (ret < 0) { - LOG_ERROR("IMP_System_Bind(OSD, ENC) == " << ret); - return true; } ret = IMP_FrameSource_EnableChn(0); @@ -194,7 +215,9 @@ void Encoder::run() { } } } - osd.update(); + if (Config::singleton()->OSDEnabled == 1) { + osd.update(); + } IMP_Encoder_ReleaseStream(0, &stream); last_nal_ts = nal_ts; std::this_thread::yield();