提交代码。

This commit is contained in:
amass 2025-03-17 18:34:08 +08:00
parent d54ffd6541
commit 854140e323
5 changed files with 22 additions and 8 deletions

View File

@ -1,6 +1,7 @@
#include "Camera.h" #include "Camera.h"
#include "Core/Logger.h" #include "Core/Logger.h"
#include "sensorsdk_api.h" #include "sensorsdk_api.h"
#include <thread>
Camera::Camera() { Camera::Camera() {
SensorSDK_CameraLens cameraLens = {}; SensorSDK_CameraLens cameraLens = {};
@ -12,6 +13,7 @@ Camera::Camera() {
int status = SensorSdk_Init(7, boardLine, lensType, autoLensParmPath, &cameraLens); int status = SensorSdk_Init(7, boardLine, lensType, autoLensParmPath, &cameraLens);
if (status == 0) { if (status == 0) {
LOG(info) << "SensorSdk_Init() successed."; LOG(info) << "SensorSdk_Init() successed.";
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
} else { } else {
LOG(info) << "SensorSdk_Init() failed."; LOG(info) << "SensorSdk_Init() failed.";
} }

View File

@ -1,4 +1,6 @@
#include "RtspServer.h" #include "RtspServer.h"
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>
#include <chrono> #include <chrono>
#include <cstring> #include <cstring>
#include <mk_common.h> #include <mk_common.h>
@ -12,21 +14,23 @@ lowLatency=1
)"; )";
class RtspServerPrivate { class RtspServerPrivate {
public: public:
RtspServerPrivate(boost::asio::io_context &ioContext) : strand{ioContext.get_executor()} {
}
boost::asio::strand<boost::asio::io_context::executor_type> strand;
mk_media media; mk_media media;
mk_h264_splitter splitter; mk_h264_splitter splitter;
}; };
static void on_h264_frame(void *user_data, mk_h264_splitter splitter, const char *data, int size) { static void on_h264_frame(void *user_data, mk_h264_splitter splitter, const char *data, int size) {
using namespace std::chrono;
using namespace std::chrono_literals; using namespace std::chrono_literals;
std::this_thread::sleep_for(40ms); int pts = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
static int dts = 0; mk_frame frame = mk_frame_create(MKCodecH264, pts, pts, data, size, NULL, NULL);
mk_frame frame = mk_frame_create(MKCodecH264, dts, dts, data, size, NULL, NULL);
dts += 40;
mk_media_input_frame((mk_media)user_data, frame); mk_media_input_frame((mk_media)user_data, frame);
mk_frame_unref(frame); mk_frame_unref(frame);
} }
RtspServer::RtspServer() : m_d(new RtspServerPrivate()) { RtspServer::RtspServer(boost::asio::io_context &ioContext) : m_d(new RtspServerPrivate(ioContext)) {
mk_config config; mk_config config;
std::memset(&config, 0, sizeof(mk_config)); std::memset(&config, 0, sizeof(mk_config));
config.ini = iniConfig; config.ini = iniConfig;
@ -58,5 +62,7 @@ RtspServer::~RtspServer() {
} }
void RtspServer::push(const uint8_t *data, uint32_t size) { void RtspServer::push(const uint8_t *data, uint32_t size) {
mk_h264_splitter_input_data(m_d->splitter, reinterpret_cast<const char *>(data), size); boost::asio::post(m_d->strand, [this, frame = std::vector<uint8_t>(data, data + size)]() {
mk_h264_splitter_input_data(m_d->splitter, reinterpret_cast<const char *>(frame.data()), frame.size());
});
} }

View File

@ -3,11 +3,16 @@
#include <string> #include <string>
namespace boost {
namespace asio {
class io_context;
}
} // namespace boost
class RtspServerPrivate; class RtspServerPrivate;
class RtspServer { class RtspServer {
public: public:
RtspServer(); RtspServer(boost::asio::io_context &ioContext);
~RtspServer(); ~RtspServer();
/** /**

View File

@ -21,7 +21,7 @@ int main(int argc, char const *argv[]) {
try { try {
auto camera = Singleton<Camera>::construct(); auto camera = Singleton<Camera>::construct();
auto ioContext = Singleton<IoContext>::construct(std::thread::hardware_concurrency()); auto ioContext = Singleton<IoContext>::construct(std::thread::hardware_concurrency());
auto rtsp = std::make_shared<RtspServer>(); auto rtsp = std::make_shared<RtspServer>(*ioContext->ioContext());
auto streamer = std::make_shared<Streamer>(*ioContext->ioContext()); auto streamer = std::make_shared<Streamer>(*ioContext->ioContext());
streamer->start("amass.fun", 443); streamer->start("amass.fun", 443);

View File

@ -64,6 +64,7 @@ function init() {
ssh danki "mkdir -p /data/sdcard/PassengerStatistics/lib" ssh danki "mkdir -p /data/sdcard/PassengerStatistics/lib"
echo "put /opt/aarch64-v01c01-linux-gnu-gcc/lib/gdb-10.2/bin/gdbserver /system/bin" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP} echo "put /opt/aarch64-v01c01-linux-gnu-gcc/lib/gdb-10.2/bin/gdbserver /system/bin" | sftp -i resources/ssh_host_rsa_key_ok root@${TARGET_IP}
echo "put 3rdparty/rw_mpp/lib/librw_mpp.so /data/sdcard/PassengerStatistics/lib" | sftp danki echo "put 3rdparty/rw_mpp/lib/librw_mpp.so /data/sdcard/PassengerStatistics/lib" | sftp danki
echo "put 3rdparty/fsan_sensorsdk/libs/libsensorsdk.so /data/sdcard/PassengerStatistics/lib" | sftp danki
echo "put 3rdparty/ds_pedestrian_mot_hisi/libs/libds_pedestrian_mot_Hi3516DV500.so /data/sdcard/PassengerStatistics/lib" | sftp danki echo "put 3rdparty/ds_pedestrian_mot_hisi/libs/libds_pedestrian_mot_Hi3516DV500.so /data/sdcard/PassengerStatistics/lib" | sftp danki
echo "put /opt/aarch64-v01c01-linux-gnu-gcc/lib/openssl-3.4.1/lib/libssl.so.3 /data/sdcard/PassengerStatistics/lib" | sftp danki echo "put /opt/aarch64-v01c01-linux-gnu-gcc/lib/openssl-3.4.1/lib/libssl.so.3 /data/sdcard/PassengerStatistics/lib" | sftp danki
echo "put /opt/aarch64-v01c01-linux-gnu-gcc/lib/openssl-3.4.1/lib/libcrypto.so.3 /data/sdcard/PassengerStatistics/lib" | sftp danki echo "put /opt/aarch64-v01c01-linux-gnu-gcc/lib/openssl-3.4.1/lib/libcrypto.so.3 /data/sdcard/PassengerStatistics/lib" | sftp danki