### WebRTC Stream Proxy API Requests Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html Example cURL commands to create WebRTC stream proxies using SFU or P2P signaling. ```bash # WHIP/WHEP 模式拉流 curl -X POST "http://127.0.0.1/index/api/addStreamProxy" \ -d "secret=your_secret" \ -d "vhost=__defaultVhost__" \ -d "app=live" \ -d "stream=test" \ -d "url=webrtc://source.server.com:80/live/source_stream?signaling_protocols=0" # P2P 模式拉流 curl -X POST "http://127.0.0.1/index/api/addStreamProxy" \ -d "secret=your_secret" \ -d "vhost=__defaultVhost__" \ -d "app=live" \ -d "stream=test" \ -d "url=webrtc://signaling.server.com:3000/live/source_stream??signaling_protocols=1%26peer_room_id=target_room_id" ``` -------------------------------- ### Get WebRTC Proxy Player Info API Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html Retrieves connection information and status for WebRTC proxy players. ```APIDOC ## GET /index/api/getWebrtcProxyPlayerInfo ### Description Gets the connection information and status of WebRTC proxy players. ### Method GET ### Endpoint /index/api/getWebrtrcProxyPlayerInfo ### Parameters #### Query Parameters - **secret** (string) - Required - API access secret. - **key** (string) - Required - Identifier for the proxy player. ### Response (Success/Error response details not provided in the source text) ``` -------------------------------- ### Build Docker Image from Source Source: https://zlmediakit.github.io/ZLMediaKit Compile a custom Docker image using the provided build script. ```bash bash build_docker_images.sh ``` -------------------------------- ### Configure STUN/TURN Service Credentials Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html Set the username and password for the STUN/TURN service in the `[rtc]` section of `config.ini`. These are used for ICE authentication. ```ini #STUN/TURN 服务Ice密码 iceUfrag=ZLMediaKit icePwd=ZLMediaKit ``` -------------------------------- ### Configure WebRTC Signaling and ICE Ports Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html Configure the signaling server port, STUN/TURN server port, and whether to enable TURN services in the `[rtc]` section of `config.ini`. ```ini [rtc] #webrtc 信令服务器端口 signalingPort=3000 #STUN/TURN服务器端口 icePort=3478 #STUN/TURN端口是否使能TURN服务 enableTurn=1 ``` -------------------------------- ### Deploy ZLMediaKit via Docker Source: https://zlmediakit.github.io/ZLMediaKit Run the latest ZLMediaKit container using the master branch image. ```bash docker run -id -p 1935:1935 -p 8080:80 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 8000:8000/udp -p 9000:9000/udp zlmediakit/zlmediakit:master ``` -------------------------------- ### Push RTSP Stream to WHIP Server Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html Use this command to push an RTSP stream to a WHIP-compatible server. Ensure the secret, vhost, app, and stream parameters are correctly set. ```bash curl -X POST "http://127.0.0.1/index/api/addStreamPusherProxy" \ -d "secret=your_secret" \ -d "schema=rtsp" \ -d "vhost=__defaultVhost__" \ -d "app=live" \ -d "stream=test" \ -d "dst_url=webrtc://target.server.com:80/live/target_stream?signaling_protocols=0" ``` -------------------------------- ### Configure OBS for SRT Publishing Source: https://zlmediakit.github.io/ZLMediaKit/srt/srt.html Use this URL format in OBS to publish a stream to ZLMediaKit. ```text srt://192.168.1.105:9000?streamid=#!::r=live/test,m=publish ``` -------------------------------- ### Configure VLC for SRT Pulling Source: https://zlmediakit.github.io/ZLMediaKit/srt/srt.html Settings for VLC media player to pull an SRT stream. ```text #!::r=live/test ``` ```text srt://192.168.1.105:9000 ``` -------------------------------- ### WebRTC SFU Architecture Diagram Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html Visual representation of the SFU mode using WHIP for ingestion and WHEP for playback. ```text WebRTC SFU 模式 (WHIP/WHEP) 推流端 (WHIP) 拉流端 (WHEP) +----------------+ +-----------------+ | Encoder | | Player | | (Browser/ZLM) | | (Browser/ZLM) | +----------------+ +-----------------+ | | | WHIP Protocol | WHEP Protocol | (WebRTC ingest) | (WebRTC playback) | | v v +-------------------------------------------------------------------+ | ZLMediaKit Server | +-------------------------------------------------------------------+ - WHIP: WebRTC-HTTP Ingestion Protocol (推流) - WHEP: WebRTC-HTTP Egress Protocol (拉流) ``` -------------------------------- ### Publish SRT Stream with FFmpeg Source: https://zlmediakit.github.io/ZLMediaKit/srt/srt.html Command to push a TS file to the ZLMediaKit server via SRT. ```bash ffmpeg -re -stream_loop -1 -i test.ts -c:v copy -c:a copy -f mpegts srt://192.168.1.105:9000?streamid=#!::r=live/test,m=publish ``` -------------------------------- ### WebRTC P2P Architecture Diagram Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html Visual representation of the P2P mode using WebSocket-based signaling. ```text WebRTt WC P2P 模式 客户端 A 客户端 B +------------+ +-------------+ | Browser/ZLM| | Browser/ZLM | +------------+ +-------------+ | | | 1. 信令交换 (SDP Offer/Answer) | | 2. ICE Candidate 交换 | +---------------- -----+-----------------------+ | | | | +-----------------------+ | | | ZLMediaKit Server | | | | 信令服务器 (WebSocket) | | | | STUN 服务器 | | | | TURN 服务器 | | | +-----------------------+ | | | +-----------------------------------------------+ 直接P2P连接 ``` -------------------------------- ### Pull SRT Stream with FFplay Source: https://zlmediakit.github.io/ZLMediaKit/srt/srt.html Command to play an SRT stream from the ZLMediaKit server. ```bash ffplay -i srt://192.168.1.105:9000?streamid=#!::r=live/test ``` -------------------------------- ### WebRTC Room Management API Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html APIs for managing WebRTC rooms and their associated signaling servers. ```APIDOC ## POST /index/api/addWebrtcRoomKeeper ### Description Adds a WebRTC signaling server to maintain room connections. ### Method POST ### Endpoint /index/api/addWebrtcRoomKeeper ### Parameters #### Request Body - **secret** (string) - Required - API access key - **server_host** (string) - Required - Signaling server host address - **server_port** (integer) - Required - Signaling server port - **room_id** (string) - Required - Room ID, checked for uniqueness by the signaling server ## POST /index/api/delWebrtcRoomKeeper ### Description Deletes a specified signaling server. ### Method POST ### Endpoint /index/api/delWebrtcRoomKeeper ### Parameters #### Request Body - **secret** (string) - Required - API access key - **room_key** (string) - Required - Unique identifier of the room keeper ## POST /index/api/listWebrtcRoomKeepers ### Description Lists all configured signaling servers. ### Method POST ### Endpoint /index/api/listWebrtcRoomKeepers ### Parameters #### Request Body - **secret** (string) - Required - API access key ``` -------------------------------- ### Configure TURN Port Range and ICE Transport Policy Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html Define the port range for TURN service allocation and set the ICE transport policy (e.g., Relay only, P2P only) in the `[rtc]` section of `config.ini`. ```ini #TURN服务分配端口池 portRange=50000-65000 #ICE传输策略:0=不限制(默认),1=仅支持Relay转发,2=仅支持P2P直连 iceTransportPolicy=0 ``` -------------------------------- ### WebRTC Pusher Proxy URL Formats Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html URL schemes for configuring WebRTC push proxies in SFU and P2P modes. ```text # HTTP webrtc://target_server:port/app/stream_id?signaling_protocols=0 # HTTPS (暂未实现) webrtcs://target_server:port/app/stream_id?signaling_protocols=0 ``` ```text # WebSocket webrtc://signaling_server:port/app/stream_id?signaling_protocols=1&peer_room_id=target_room ``` -------------------------------- ### Push RTSP Stream to P2P Room Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html This command pushes an RTSP stream to a P2P room using WebSocket signaling. The `peer_room_id` parameter is crucial for specifying the target room. ```bash curl -X POST "http://127.0.0.1/index/api/addStreamPusherProxy" \ -d "secret=your_secret" \ -d "schema=rtsp" \ -d "vhost=__defaultVhost__" \ -d "app=live" \ -d "stream=test" \ -d "dst_url=webrtc://signaling.server.com:3000/live/room_stream?signaling_protocols=1%26peer_room_id=target_room_id" ``` -------------------------------- ### WebRTC Stream Proxy API Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html APIs for creating WebRTC stream proxies for pulling and pushing streams. ```APIDOC ## POST /index/api/addStreamProxy ### Description Creates a WebRTC pull stream proxy. Supports two signaling protocol modes: WHIP/WHEP (SFU) and WebSocket P2P. ### Method POST ### Endpoint /index/api/addStreamProxy ### Parameters #### Request Body - **secret** (string) - Required - API access key - **vhost** (string) - Optional - Virtual host name, defaults to `__defaultVhost__` - **app** (string) - Required - Application name - **stream** (string) - Required - Stream ID - **url** (string) - Required - WebRTC source URL. Supported formats: 1. WHIP/WHEP (SFU): `webrtc://server_host:server_port/app/stream_id?signaling_protocols=0` 2. WebSocket P2P: `webrtc://signaling_server_host:signaling_server_port/app/stream_id?signaling_protocols=1&peer_room_id=target_room_id` ### Request Example ``` # WHIP/WHEP Mode Pull curl -X POST "http://127.0.0.1/index/api/addStreamProxy" \ -d "secret=your_secret" \ -d "vhost=__defaultVhost__" \ -d "app=live" \ -d "stream=test" \ -d "url=webrtc://source.server.com:80/live/source_stream?signaling_protocols=0" # P2P Mode Pull curl -X POST "http://127.0.0.1/index/api/addStreamProxy" \ -d "secret=your_secret" \ -d "vhost=__defaultVhost__" \ -d "app=live" \ -d "stream=test" \ -d "url=webrtc://signaling.server.com:3000/live/source_stream??signaling_protocols=1%26peer_room_id=target_room_id" ``` ## POST /index/api/addStreamPusherProxy (Not Implemented) ### Description Creates a WebRTC push stream proxy. This endpoint is currently not implemented. ### Method POST ### Endpoint /index/api/addStreamPusherProxy ### Parameters #### Request Body - **secret** (string) - Required - API access key - **schema** (string) - Required - Source stream protocol (e.g., rtmp, rtsp, hls) - **vhost** (string) - Required - Virtual host name - **app** (string) - Required - Application name - **stream** (string) - Required - Source stream ID - **dst_url** (string) - Required - Destination WebRTC push URL. Supported formats: 1. WHIP Mode (SFU): `webrtc://target_server:port/app/stream_id?signaling_protocols=0` 2. WebSocket P2P Mode: `webrtc://signaling_server:port/app/stream_id?signaling_protocols=1&peer_room_id=target_room` ``` -------------------------------- ### WebRTC URL Formats for Stream Proxy Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html URL schemes for configuring WebRTC stream proxies in SFU and P2P modes. ```text # HTTP webrtc://server_host:server_port/app/stream_id?signaling_protocols=0 # HTTPS (暂未实现) webrtcs://server_host:server_port/app/stream_id?signaling_protocols=0 ``` ```text # WebSocket webrtc://signaling_server_host:signaling_server_port/app/stream_id?signaling_protocols=1&peer_room_id=target_room_id # WebSocket Secure (暂未实现) webrtcs://signaling_server_host:signaling_server_port/app/stream_id?signaling_protocols=1&peer_room_id=target_room_id ``` -------------------------------- ### Add Stream Pusher Proxy API Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html This API allows you to push RTSP streams to a WHIP server or a P2P room using WebRTC. ```APIDOC ## POST /index/api/addStreamPusherProxy ### Description Adds a stream pusher proxy to send RTSP streams to a specified destination URL, supporting both WHIP/WHEP and WebSocket P2P modes. ### Method POST ### Endpoint /index/api/addStreamPusherProxy ### Parameters #### Request Body - **secret** (string) - Required - API access secret. - **schema** (string) - Required - Schema of the source stream (e.g., "rtsp"). - **vhost** (string) - Required - Virtual host of the source stream. - **app** (string) - Required - Application name of the source stream. - **stream** (string) - Required - Stream name of the source stream. - **dst_url** (string) - Required - Destination URL for the WebRTC stream. This can be a WHIP/WHEP endpoint or a P2P room URL. ### Request Example ```json { "secret": "your_secret", "schema": "rtsp", "vhost": "__defaultVhost__", "app": "live", "stream": "test", "dst_url": "webrtc://target.server.com:80/live/target_stream?signaling_protocols=0" } ``` ### Request Example (P2P) ```json { "secret": "your_secret", "schema": "rtsp", "vhost": "__defaultVhost__", "app": "live", "stream": "test", "dst_url": "webrtc://signaling.server.com:3000/live/room_stream?signaling_protocols=1&peer_room_id=target_room_id" } ``` ### URL Parameters Description for dst_url - **signaling_protocols** (integer) - Signaling protocol type. - `0`: WHIP/WHEP mode (default). Protocol: Standard WebRTC signaling protocol based on HTTP. Use case: SFU mode, suitable for broadcasting and multi-party conferences. - `1`: WebSocket P2P mode. Protocol: Custom signaling protocol based on WebSocket. Use case: Peer-to-peer direct connection, suitable for low-latency calls and private communication. - **peer_room_id** (string) - Target room ID in P2P mode (required only for P2P mode). ### Response (Success/Error response details not provided in the source text) ``` -------------------------------- ### WebRTC Room Session Management API Source: https://zlmediakit.github.io/ZLMediaKit/webrtc/USAGE.html API for listing active WebRTC peer sessions. ```APIDOC ## POST /index/api/listWebrtcRooms ### Description Lists all active WebRTC Peer session information. ### Method POST ### Endpoint /index/api/listWebrtcRooms ### Parameters #### Request Body - **secret** (string) - Required - API access key ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.