备份最新边缘设备程序
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
|
||||
class RtspFrameGrabber {
|
||||
public:
|
||||
explicit RtspFrameGrabber(const std::string &rtsp_url);
|
||||
~RtspFrameGrabber();
|
||||
|
||||
bool start();
|
||||
|
||||
void stop();
|
||||
|
||||
bool capture_jpeg(const std::string &filename);
|
||||
|
||||
bool is_ready() const;
|
||||
|
||||
const std::string &get_rtsp_url() const { return rtsp_url_; }
|
||||
|
||||
private:
|
||||
void decode_loop();
|
||||
|
||||
private:
|
||||
std::string rtsp_url_;
|
||||
std::thread worker_;
|
||||
std::atomic<bool> running_{false};
|
||||
std::atomic<bool> ready_{false};
|
||||
mutable std::mutex frame_mutex_;
|
||||
void *opaque_impl_ = nullptr;
|
||||
};
|
||||
|
||||
class RtspManager {
|
||||
public:
|
||||
RtspManager() = default;
|
||||
~RtspManager();
|
||||
|
||||
void configure(const std::unordered_map<int, std::string> &side_sources);
|
||||
|
||||
void shutdown();
|
||||
|
||||
std::string capture_side_frame(int source_id);
|
||||
|
||||
bool is_ready(int source_id) const;
|
||||
|
||||
private:
|
||||
std::unordered_map<int, std::unique_ptr<RtspFrameGrabber>> side_grabbers_;
|
||||
|
||||
mutable std::mutex mgr_mutex_;
|
||||
};
|
||||
Reference in New Issue
Block a user