Rtspvideoplugin -

Client (Plugin) Server (Camera) |--- OPTIONS ---------------->| |<--- 200 OK -----------------| |--- DESCRIBE --------------->| |<--- SDP (Session Description)| |--- SETUP (client_port)----->| |<--- 200 OK (server_port)----| |--- PLAY ------------------->| |<--- 200 OK -----------------| |<--- RTP/UDP Stream ---------| 3.1 Minimal RTSP Client Core // RTSPClient.h #include <string> #include <functional> #include <thread> #include <cstring> #include <sys/socket.h> #include <arpa/inet.h> #include <unistd.h> class RTSPVideoPlugin public: using FrameCallback = std::function<void(uint8_t* data, int width, int height, int stride)>;

public class RTSPVideoSource : MonoBehaviour [DllImport("RTSPPlugin")] private static extern System.IntPtr CreateRTSPPlayer(); [DllImport("RTSPPlugin")] private static extern bool OpenStream(System.IntPtr player, string url); private System.IntPtr player; private Texture2D videoTexture; rtspvideoplugin

public: bool open(const char* rtspUrl) avformat_network_init(); AVDictionary* opts = nullptr; av_dict_set(&opts, "rtsp_transport", "tcp", 0); // TCP for reliability av_dict_set(&opts, "max_delay", "500000", 0); Send OPTIONS, DESCRIBE, SETUP, PLAY (see full code

bool connect(const std::string& url, FrameCallback callback) m_callback = callback; m_url = url; // 1. Parse URL (rtsp://ip:port/path) // 2. Open TCP socket to server:554 // 3. Send OPTIONS, DESCRIBE, SETUP, PLAY (see full code in repo) // 4. Start receive thread m_running = true; m_thread = std::thread(&RTSPVideoPlugin::receiveLoop, this); return true; m_thread = std::thread(&RTSPVideoPlugin::receiveLoop

RTSPVideoPlugin() = default; ~RTSPVideoPlugin() stop();

Запомнить меня
X