Rtspvideoplugin Work Site

add_library(rtsp_plugin SHARED src/plugin.cpp) target_include_directories(rtsp_plugin PRIVATE $FFMPEG_INCLUDE_DIRS) target_link_libraries(rtsp_plugin $FFMPEG_LIBRARIES) target_compile_definitions(rtsp_plugin PRIVATE -DPLUGIN_EXPORTS)

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); rtspvideoplugin

struct obs_source_info rtsp_source = .id = "rtsp_video_source", .type = OBS_SOURCE_TYPE_INPUT, .output_flags = OBS_SOURCE_VIDEO, .get_name = rtsp_name, .create = rtsp_create, .destroy = rtsp_destroy, .video_render = rtsp_video_render, .get_properties = rtsp_properties, .update = rtsp_update ; static void rtsp_video_render(void* data, gs_effect_t* effect) struct rtsp_data rtsp = (struct rtsp_data )data; if (rtsp->texture) obs_source_draw(rtsp->texture, 0, 0, 0, 0, false); add_library(rtsp_plugin SHARED src/plugin

; 4.1 Unity Plugin (C++ -> C#) Expose C functions: AVDictionary* opts = nullptr

__declspec(dllexport) void UpdateTexture(void* player, void* texturePtr, int width, int height) uint8_t* rgbData; ((FFmpegRTSPDecoder*)player)->readFrame(&rgbData, &width, &height); // Copy to Unity Texture2D native pointer memcpy(texturePtr, rgbData, width * height * 3);

void Start() player = CreateRTSPPlayer(); OpenStream(player, "rtsp://192.168.1.100/stream"); videoTexture = new Texture2D(1920, 1080, TextureFormat.RGB24, false); GetComponent<Renderer>().material.mainTexture = videoTexture;