### Build and Run EasyRTC Signal Server Source: https://context7.com/easydarwin/easyrtc/llms.txt Build the EasyRTC signal server on Ubuntu 22.04 by installing dependencies and running the build script. Execute the compiled server to start listening for WebSocket and secure WebSocket connections. ```bash # Build on Ubuntu 22.04 sudo apt-get install uuid-dev ./build.sh # Run the server ./signalserver # Server will listen on: # - ws://0.0.0.0:19000 for WebSocket connections # - wss://0.0.0.0:6689 for secure WebSocket (if SSL enabled) ``` -------------------------------- ### EasyRTC_CreateOffer / EasyRTC_CreateAnswer - SDP Negotiation Source: https://context7.com/easydarwin/easyrtc/llms.txt Creates SDP offer or answer for WebRTC signaling negotiation. Includes examples for initiating a call and handling incoming calls. ```APIDOC ## EasyRTC_CreateOffer / EasyRTC_CreateAnswer - SDP Negotiation ### Description Creates SDP offer or answer for WebRTC signaling negotiation. ### Method (Not specified, likely function calls within the EasyRTC library) ### Endpoint (Not applicable, these are library functions) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include "EasyRTCAPI.h" int onIceCandidate(void* userPtr, const int isOffer, const char* sdp) { if (isOffer) { printf("Generated SDP Offer:\n%s\n", sdp); sendToSignalingServer("offer", sdp); } else { printf("Generated SDP Answer:\n%s\n", sdp); sendToSignalingServer("answer", sdp); } return 0; } void initiateCall(EasyRTC_PeerConnection peerConn) { int ret = EasyRTC_CreateOffer(peerConn, onIceCandidate, NULL); if (ret != EASYRTC_ERROR_NO) { printf("Failed to create offer: %d\n", ret); return; } const char* answerSdp = receiveFromSignalingServer(); EasyRTC_SetRemoteDescription(peerConn, answerSdp); } void handleIncomingCall(EasyRTC_PeerConnection peerConn, const char* offerSdp) { int ret = EasyRTC_CreateAnswer(peerConn, offerSdp, onIceCandidate, NULL); if (ret != EASYRTC_ERROR_NO) { printf("Failed to create answer: %d\n", ret); } } ``` ### Response #### Success Response (EASYRTC_ERROR_NO) Indicates the SDP offer or answer was generated successfully. The callback function `onIceCandidate` will be invoked with the SDP data. #### Response Example (No explicit response body, success indicated by return code and callback invocation) ``` -------------------------------- ### EasyRTC_AddDataChannel - Create Data Channel Source: https://context7.com/easydarwin/easyrtc/llms.txt Creates a data channel for sending custom binary or text data between peers. Includes example usage for sending messages. ```APIDOC ## EasyRTC_AddDataChannel - Create Data Channel ### Description Creates a data channel for sending custom binary or text data between peers. ### Method (Not specified, likely a function call within the EasyRTC library) ### Endpoint (Not applicable, this is a library function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include "EasyRTCAPI.h" int onDataChannelCallback(void* userPtr, EASYRTC_DATACHANNEL_CALLBACK_TYPE_E type, BOOL isBinary, const char* msgData, int msgLen) { switch (type) { case EASYRTC_DATACHANNEL_CALLBACK_OPENED: printf("Data channel opened\n"); break; case EASYRTC_DATACHANNEL_CALLBACK_DATA: if (isBinary) { printf("Received binary data: %d bytes\n", msgLen); } else { printf("Received text message: %.*s\n", msgLen, msgData); } break; } return 0; } void setupDataChannel(EasyRTC_PeerConnection peerConn) { EasyRTC_DataChannel dataChannel = NULL; int ret = EasyRTC_AddDataChannel(&dataChannel, peerConn, "control", onDataChannelCallback, NULL); if (ret == EASYRTC_ERROR_NO) { printf("Data channel created\n"); const char* message = "Hello from device!"; EasyRTC_DataChannelSend(dataChannel, FALSE, message, strlen(message)); unsigned char binaryData[] = {0x01, 0x02, 0x03, 0x04}; EasyRTC_DataChannelSend(dataChannel, TRUE, (const char*)binaryData, sizeof(binaryData)); } } ``` ### Response #### Success Response (EASYRTC_ERROR_NO) Indicates the data channel was created successfully. #### Response Example (No explicit response body, success indicated by return code and subsequent operations) ``` -------------------------------- ### Create EasyRTC Device Instance Source: https://context7.com/easydarwin/easyrtc/llms.txt Initializes an EasyRTC device and connects it to a signaling server. Requires a callback function to handle events like connection status, incoming calls, and peer data. Ensure the `running` variable is managed to control the main loop. ```c #include "EasyRTCDeviceAPI.h" int dataCallback(void* userptr, const char* peerUUID, EASYRTC_DATA_TYPE_ENUM_E dataType, int codecID, int isBinary, char* data, int size, int keyframe, unsigned long long pts) { switch (dataType) { case EASYRTC_CALLBACK_TYPE_CONNECTED: printf("Connected to signaling server\n"); break; case EASYRTC_CALLBACK_TYPE_PASSIVE_CALL: printf("Incoming call from: %s\n", peerUUID); return 1; // Return 1 to auto-accept, 0 to handle manually case EASYRTC_CALLBACK_TYPE_START_VIDEO: printf("Peer %s requested video stream\n", peerUUID); // Start sending video frames break; case EASYRTC_CALLBACK_TYPE_PEER_VIDEO: printf("Received video: codec=%d, size=%d, keyframe=%d\n", codecID, size, keyframe); // Decode and display video frame break; case EASYRTC_CALLBACK_TYPE_PEER_AUDIO: // Play audio frame (PCM format) playAudio(data, size); break; case EASYRTC_CALLBACK_TYPE_PEER_CONNECTED: printf("Peer connected via %s\n", codecID == 1 ? "P2P" : "TURN relay"); break; case EASYRTC_CALLBACK_TYPE_PEER_DISCONNECT: printf("Peer disconnected\n"); break; } return 0; } int main() { EasyRTC_Device_Init(); EASYRTC_HANDLE handle = NULL; const char* serverAddr = "rts.easyrtc.cn"; int serverPort = 19000; int isSecure = 0; // 0 for ws://, 1 for wss:// const char* deviceId = "92092eea-be8d-4ec4-8ac5-123456789012"; // Create device and connect to signaling server int ret = EasyRTC_Device_Create(&handle, serverAddr, serverPort, isSecure, deviceId, dataCallback, NULL); if (ret != 0) { printf("Failed to create device: %d\n", ret); return -1; } // Set video/audio codec configuration EasyRTC_Device_SetChannelInfo(handle, EASYRTC_CODEC_H264, EASYRTC_CODEC_MULAW); // Main loop - device is now accessible by remote clients printf("Device online. Waiting for connections...\n"); while (running) { sleep(1); } // Cleanup EasyRTC_Device_Release(&handle); EasyRTC_Device_Deinit(); return 0; } ``` -------------------------------- ### Signal Server Configuration (signalserver.ini) Source: https://context7.com/easydarwin/easyrtc/llms.txt Configure the EasyRTC signal server by defining base settings, STUN/TURN server details, and SSL parameters in the signalserver.ini file. Ensure correct URLs and credentials for STUN/TURN servers. SSL configuration is optional. ```ini [base] localport = 19000 stuncount = 1 turncount = 1 supportssl = 0 [stun0] url = "stun.qq.com:3478" [turn0] url = "turn.openrelayproject.org:443?transport=tcp" username = "user1" credential = "pass1" [ssl] localport = 6689 pemcertfile = "server.crt" pemkeyfile = "server.key" keypassword = "" ``` -------------------------------- ### Initialize EasyRTC Library Source: https://context7.com/easydarwin/easyrtc/llms.txt Initializes the EasyRTC core library. This function must be called before any other EasyRTC functions. It returns an error code if initialization fails. ```c #include "EasyRTCAPI.h" int main() { // Initialize EasyRTC library int ret = EasyRTC_Init(); if (ret != EASYRTC_ERROR_NO) { printf("Failed to initialize EasyRTC: %d\n", ret); return -1; } // ... use EasyRTC functions ... // Cleanup when done EasyRTC_Deinit(); return 0; } ``` -------------------------------- ### EasyRTC_Init - Initialize the EasyRTC Library Source: https://context7.com/easydarwin/easyrtc/llms.txt Initializes the EasyRTC core library. This function must be called before any other EasyRTC functions are used. It returns an error code if initialization fails. ```APIDOC ## EasyRTC_Init - Initialize the EasyRTC Library ### Description Initializes the EasyRTC core library. Must be called before any other EasyRTC functions. ### Method N/A (C function) ### Endpoint N/A ### Parameters None ### Request Example ```c #include "EasyRTCAPI.h" int main() { // Initialize EasyRTC library int ret = EasyRTC_Init(); if (ret != EASYRTC_ERROR_NO) { printf("Failed to initialize EasyRTC: %d\n", ret); return -1; } // ... use EasyRTC functions ... // Cleanup when done EasyRTC_Deinit(); return 0; } ``` ### Response #### Success Response (0) Returns `EASYRTC_ERROR_NO` (0) on successful initialization. #### Response Example `0` (for success) #### Error Response Returns a non-zero error code on failure. ``` -------------------------------- ### SDP Negotiation with EasyRTC_CreateOffer/Answer Source: https://context7.com/easydarwin/easyrtc/llms.txt Generate SDP offers or answers for WebRTC signaling. The onIceCandidate callback is invoked with the generated SDP, which should then be sent to the remote peer via a signaling server. ```c #include "EasyRTCAPI.h" int onIceCandidate(void* userPtr, const int isOffer, const char* sdp) { if (isOffer) { printf("Generated SDP Offer:\n%s\n", sdp); // Send offer SDP to remote peer via signaling server sendToSignalingServer("offer", sdp); } else { printf("Generated SDP Answer:\n%s\n", sdp); // Send answer SDP to remote peer via signaling server sendToSignalingServer("answer", sdp); } return 0; } // Device side: Create offer and wait for answer void initiateCall(EasyRTC_PeerConnection peerConn) { // Create and send offer int ret = EasyRTC_CreateOffer(peerConn, onIceCandidate, NULL); if (ret != EASYRTC_ERROR_NO) { printf("Failed to create offer: %d\n", ret); return; } // When answer is received from signaling server const char* answerSdp = receiveFromSignalingServer(); EasyRTC_SetRemoteDescription(peerConn, answerSdp); } // Client side: Receive offer and create answer void handleIncomingCall(EasyRTC_PeerConnection peerConn, const char* offerSdp) { // Create answer from received offer int ret = EasyRTC_CreateAnswer(peerConn, offerSdp, onIceCandidate, NULL); if (ret != EASYRTC_ERROR_NO) { printf("Failed to create answer: %d\n", ret); } } ``` -------------------------------- ### Create Peer Connection with ICE Servers Source: https://context7.com/easydarwin/easyrtc/llms.txt Creates a new peer connection using EasyRTC. It requires configuration for ICE servers, including STUN and TURN servers with optional credentials. A callback function is provided to handle connection state changes. ```c #include "EasyRTCAPI.h" int onConnectionStateChange(void* userPtr, EASYRTC_PEER_CONNECTION_STATE state) { switch (state) { case EASYRTC_PEER_CONNECTION_STATE_CONNECTED: printf("Peer connection established\n"); break; case EASYRTC_PEER_CONNECTION_STATE_DISCONNECTED: printf("Peer connection disconnected\n"); break; case EASYRTC_PEER_CONNECTION_STATE_FAILED: printf("Peer connection failed\n"); break; } return 0; } int main() { EasyRTC_Init(); // Configure ICE servers EasyRTC_Configuration config = {0}; config.iceTransportPolicy = EasyRTC_ICE_TRANSPORT_POLICY_ALL; // Add STUN server strcpy(config.iceServers[0].urls, "stun:stun.qq.com:3478"); // Add TURN server with credentials strcpy(config.iceServers[1].urls, "turn:turn.example.com:443?transport=tcp"); strcpy(config.iceServers[1].username, "user1"); strcpy(config.iceServers[1].credential, "password1"); // Create peer connection EasyRTC_PeerConnection peerConnection = NULL; int ret = EasyRTC_CreatePeerConnection(&peerConnection, &config, onConnectionStateChange, NULL); if (ret != EASYRTC_ERROR_NO) { printf("Failed to create peer connection: %d\n", ret); return -1; } // ... use peer connection ... // Cleanup EasyRTC_ReleasePeerConnection(&peerConnection); EasyRTC_Deinit(); return 0; } ``` -------------------------------- ### EasyRTC_CreatePeerConnection - Create a Peer Connection Source: https://context7.com/easydarwin/easyrtc/llms.txt Creates a new peer connection object, configuring it with ICE server details for establishing WebRTC connections. It accepts a callback function for connection state changes. ```APIDOC ## EasyRTC_CreatePeerConnection - Create a Peer Connection ### Description Creates a new peer connection with ICE server configuration for establishing WebRTC connections. It takes a callback function to handle connection state changes. ### Method N/A (C function) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (configuration is passed via struct) ### Configuration Structure (`EasyRTC_Configuration`) - **iceTransportPolicy** (EasyRTC_ICE_TRANSPORT_POLICY) - Specifies the ICE transport policy (e.g., `EasyRTC_ICE_TRANSPORT_POLICY_ALL`). - **iceServers** (array of `EasyRTC_IceServer`) - An array of ICE server configurations. - **urls** (string) - The URL of the STUN or TURN server. - **username** (string) - Optional username for TURN server authentication. - **credential** (string) - Optional password for TURN server authentication. ### Request Example ```c #include "EasyRTCAPI.h" int onConnectionStateChange(void* userPtr, EASYRTC_PEER_CONNECTION_STATE state) { switch (state) { case EASYRTC_PEER_CONNECTION_STATE_CONNECTED: printf("Peer connection established\n"); break; case EASYRTC_PEER_CONNECTION_STATE_DISCONNECTED: printf("Peer connection disconnected\n"); break; case EASYRTC_PEER_CONNECTION_STATE_FAILED: printf("Peer connection failed\n"); break; } return 0; } int main() { EasyRTC_Init(); // Configure ICE servers EasyRTC_Configuration config = {0}; config.iceTransportPolicy = EasyRTC_ICE_TRANSPORT_POLICY_ALL; // Add STUN server strcpy(config.iceServers[0].urls, "stun:stun.qq.com:3478"); // Add TURN server with credentials strcpy(config.iceServers[1].urls, "turn:turn.example.com:443?transport=tcp"); strcpy(config.iceServers[1].username, "user1"); strcpy(config.iceServers[1].credential, "password1"); // Create peer connection EasyRTC_PeerConnection peerConnection = NULL; int ret = EasyRTC_CreatePeerConnection(&peerConnection, &config, onConnectionStateChange, NULL); if (ret != EASYRTC_ERROR_NO) { printf("Failed to create peer connection: %d\n", ret); return -1; } // ... use peer connection ... // Cleanup EasyRTC_ReleasePeerConnection(&peerConnection); EasyRTC_Deinit(); return 0; } ``` ### Response #### Success Response (0) Returns `EASYRTC_ERROR_NO` (0) on successful creation of the peer connection. The `peerConnection` pointer will be populated. #### Response Example `0` (for success) #### Error Response Returns a non-zero error code on failure. ``` -------------------------------- ### Create Data Channel with EasyRTC Source: https://context7.com/easydarwin/easyrtc/llms.txt Use EasyRTC_AddDataChannel to create a data channel for sending custom binary or text data between peers. The callback function handles events like channel opening and data reception. ```c #include "EasyRTCAPI.h" int onDataChannelCallback(void* userPtr, EASYRTC_DATACHANNEL_CALLBACK_TYPE_E type, BOOL isBinary, const char* msgData, int msgLen) { switch (type) { case EASYRTC_DATACHANNEL_CALLBACK_OPENED: printf("Data channel opened\n"); break; case EASYRTC_DATACHANNEL_CALLBACK_DATA: if (isBinary) { printf("Received binary data: %d bytes\n", msgLen); // Process binary data } else { printf("Received text message: %.*s\n", msgLen, msgData); } break; } return 0; } void setupDataChannel(EasyRTC_PeerConnection peerConn) { EasyRTC_DataChannel dataChannel = NULL; int ret = EasyRTC_AddDataChannel(&dataChannel, peerConn, "control", onDataChannelCallback, NULL); if (ret == EASYRTC_ERROR_NO) { printf("Data channel created\n"); // Send a text message const char* message = "Hello from device!"; EasyRTC_DataChannelSend(dataChannel, FALSE, message, strlen(message)); // Send binary data unsigned char binaryData[] = {0x01, 0x02, 0x03, 0x04}; EasyRTC_DataChannelSend(dataChannel, TRUE, (const char*)binaryData, sizeof(binaryData)); } } ``` -------------------------------- ### Connect to Remote EasyRTC Device Source: https://context7.com/easydarwin/easyrtc/llms.txt Initiates a connection to a specified remote device using its UUID. Connection status is reported via callbacks. The `EasyRTC_GetOnlineDevices` function can be used to retrieve a list of available devices. ```c #include "EasyRTCDeviceAPI.h" void connectToDevice(EASYRTC_HANDLE handle, const char* targetDeviceUUID) { printf("Connecting to device: %s\n", targetDeviceUUID); int ret = EasyRTC_Caller_Connect(handle, targetDeviceUUID); if (ret != 0) { printf("Failed to initiate connection: %d\n", ret); return; } // Connection progress will be reported via callback: // EASYRTC_CALLBACK_TYPE_PEER_CONNECTED - Connection established // EASYRTC_CALLBACK_TYPE_PEER_CONNECT_FAIL - Connection failed } // Get list of online devices void listOnlineDevices(EASYRTC_HANDLE handle) { // Callback will receive EASYRTC_CALLBACK_TYPE_ONLINE_DEVICE for each device EasyRTC_GetOnlineDevices(handle, dataCallback, NULL); } ``` -------------------------------- ### Send Custom Data via EasyRTC Device API Source: https://context7.com/easydarwin/easyrtc/llms.txt Use EasyRTC_Device_SendCustomData to send binary or text data through the data channel to a specific peer or broadcast to all peers. Ensure the handle and peerUUID are valid. For binary data, cast the buffer to const char*. ```c #include "EasyRTCDeviceAPI.h" void sendControlCommand(EASYRTC_HANDLE handle, const char* peerUUID) { // Send text message const char* textMsg = "Hello from device!"; EasyRTC_Device_SendCustomData(handle, peerUUID, 0, textMsg, strlen(textMsg)); // Send binary command unsigned char command[] = {0x01, 0x00, 0x10, 0x20}; // PTZ control command EasyRTC_Device_SendCustomData(handle, peerUUID, 1, (const char*)command, sizeof(command)); // Send to all connected peers (peerUUID = NULL or "") EasyRTC_Device_SendCustomData(handle, NULL, 0, "Broadcast message", 17); } ``` -------------------------------- ### Stream Video and Audio Frames Source: https://context7.com/easydarwin/easyrtc/llms.txt Sends captured and encoded video and audio data to connected peers. Ensure `streaming` variable controls the loop and `pts` is updated correctly for frame timing. ```c #include "EasyRTCDeviceAPI.h" // Video streaming example void streamVideoFromCamera(EASYRTC_HANDLE handle) { unsigned char* frameData; int frameSize; int isKeyFrame; unsigned long long pts = 0; while (streaming) { // Capture and encode video frame (H264) frameSize = captureAndEncode(&frameData, &isKeyFrame); if (frameSize > 0) { // Send video frame to all connected peers EasyRTC_Device_SendVideoFrame(handle, (char*)frameData, frameSize, isKeyFrame, pts); pts += 33; // 33ms per frame at 30fps } usleep(33000); } } // Audio streaming example void streamAudioFromMicrophone(EASYRTC_HANDLE handle) { char audioBuffer[320]; // 20ms of 8kHz 16-bit mono audio unsigned long long audioPts = 0; while (streaming) { // Capture audio and encode to G.711 mu-law int audioSize = captureAndEncodeAudio(audioBuffer, sizeof(audioBuffer)); if (audioSize > 0) { EasyRTC_Device_SendAudioFrame(handle, audioBuffer, audioSize, audioPts); audioPts += 20; // 20ms per audio packet } usleep(20000); } } ``` -------------------------------- ### Add Media Transceiver with EasyRTC Source: https://context7.com/easydarwin/easyrtc/llms.txt Adds a transceiver for sending/receiving audio or video streams with a specified codec. The `onTransceiverCallback` function handles incoming frames and events. ```c #include "EasyRTCAPI.h" int onTransceiverCallback(void* userPtr, EASYRTC_TRANSCEIVER_CALLBACK_TYPE_E type, EasyRTC_CODEC codecID, EasyRTC_Frame* frame, double bandwidthEstimation) { switch (type) { case EASYRTC_TRANSCEIVER_CALLBACK_VIDEO_FRAME: // Received video frame from remote peer printf("Received video frame: size=%u, keyframe=%d\n", frame->size, (frame->flags & EASYRTC_FRAME_FLAG_KEY_FRAME) != 0); // Process frame->frameData with frame->size bytes break; case EASYRTC_TRANSCEIVER_CALLBACK_AUDIO_FRAME: // Received audio frame from remote peer printf("Received audio frame: size=%u\n", frame->size); break; case EASYRTC_TRANSCEIVER_CALLBACK_KEY_FRAME_REQ: // Remote peer requests a keyframe printf("Keyframe requested\n"); break; case EASYRTC_TRANSCEIVER_CALLBACK_BANDWIDTH: printf("Bandwidth estimation: %.2f bps\n", bandwidthEstimation); break; } return 0; } void setupVideoTransceiver(EasyRTC_PeerConnection peerConn) { // Configure media stream track for H264 video EasyRTC_MediaStreamTrack track = {0}; track.codec = EasyRTC_CODEC_H264; track.kind = EasyRTC_MEDIA_STREAM_TRACK_KIND_VIDEO; strcpy(track.trackId, "video0"); strcpy(track.streamId, "stream0"); // Configure transceiver for send and receive EasyRTC_RtpTransceiverInit transceiverInit = {0}; transceiverInit.direction = EASYRTC_RTP_TRANSCEIVER_DIRECTION_SENDRECV; // Add the transceiver EasyRTC_Transceiver transceiver = NULL; int ret = EasyRTC_AddTransceiver(&transceiver, peerConn, &track, &transceiverInit, onTransceiverCallback, NULL); if (ret == EASYRTC_ERROR_NO) { printf("Video transceiver added successfully\n"); } } ``` -------------------------------- ### Send Media Frame with EasyRTC Source: https://context7.com/easydarwin/easyrtc/llms.txt Sends encoded audio or video frames to the remote peer through a transceiver. Ensure timestamps and frame properties are correctly set for accurate playback. ```c #include "EasyRTCAPI.h" void sendVideoFrame(EasyRTC_Transceiver transceiver, unsigned char* h264Data, int dataSize, int isKeyFrame, uint64_t timestamp) { EasyRTC_Frame frame = {0}; frame.version = 1; frame.frameData = h264Data; frame.size = dataSize; frame.presentationTs = timestamp * 10000; // Convert ms to 100ns units frame.decodingTs = frame.presentationTs; frame.duration = 333333; // ~30fps in 100ns units if (isKeyFrame) { frame.flags = EASYRTC_FRAME_FLAG_KEY_FRAME; } int ret = EasyRTC_SendFrame(transceiver, &frame); if (ret != EASYRTC_ERROR_NO) { printf("Failed to send frame: %d\n", ret); } } // Example usage in a capture loop void captureAndSendLoop(EasyRTC_Transceiver transceiver) { unsigned char frameBuffer[1024 * 1024]; int frameSize; int isKeyFrame; uint64_t pts = 0; while (capturing) { // Capture or encode video frame (implementation depends on your source) frameSize = captureEncodedFrame(frameBuffer, sizeof(frameBuffer), &isKeyFrame); if (frameSize > 0) { sendVideoFrame(transceiver, frameBuffer, frameSize, isKeyFrame, pts); pts += 33; // Increment by ~33ms for 30fps } usleep(33000); // ~30fps } } ``` -------------------------------- ### EasyRTC_AddTransceiver - Add Media Transceiver Source: https://context7.com/easydarwin/easyrtc/llms.txt Adds a transceiver for sending/receiving audio or video streams with specified codec. ```APIDOC ## EasyRTC_AddTransceiver - Add Media Transceiver ### Description Adds a transceiver for sending/receiving audio or video streams with specified codec. ### Method (Not specified, likely a library function call) ### Endpoint (Not applicable, this is a library function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include "EasyRTCAPI.h" int onTransceiverCallback(void* userPtr, EASYRTC_TRANSCEIVER_CALLBACK_TYPE_E type, EasyRTC_CODEC codecID, EasyRTC_Frame* frame, double bandwidthEstimation) { // Callback function implementation return 0; } void setupVideoTransceiver(EasyRTC_PeerConnection peerConn) { EasyRTC_MediaStreamTrack track = {0}; track.codec = EasyRTC_CODEC_H264; track.kind = EasyRTC_MEDIA_STREAM_TRACK_KIND_VIDEO; strcpy(track.trackId, "video0"); strcpy(track.streamId, "stream0"); EasyRTC_RtpTransceiverInit transceiverInit = {0}; transceiverInit.direction = EasyRTC_RTP_TRANSCEIVER_DIRECTION_SENDRECV; EasyRTC_Transceiver transceiver = NULL; int ret = EasyRTC_AddTransceiver(&transceiver, peerConn, &track, &transceiverInit, onTransceiverCallback, NULL); if (ret == EASYRTC_ERROR_NO) { printf("Video transceiver added successfully\n"); } } ``` ### Response #### Success Response (EASYRTC_ERROR_NO) Indicates the transceiver was added successfully. #### Response Example (No explicit response body, success indicated by return code and potential printf statements in example) ``` -------------------------------- ### EasyRTC_SendFrame - Send Media Frame Source: https://context7.com/easydarwin/easyrtc/llms.txt Sends encoded audio or video frames to the remote peer through a transceiver. ```APIDOC ## EasyRTC_SendFrame - Send Media Frame ### Description Sends encoded audio or video frames to the remote peer through a transceiver. ### Method (Not specified, likely a library function call) ### Endpoint (Not applicable, this is a library function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include "EasyRTCAPI.h" void sendVideoFrame(EasyRTC_Transceiver transceiver, unsigned char* h264Data, int dataSize, int isKeyFrame, uint64_t timestamp) { EasyRTC_Frame frame = {0}; frame.version = 1; frame.frameData = h264Data; frame.size = dataSize; frame.presentationTs = timestamp * 10000; // Convert ms to 100ns units frame.decodingTs = frame.presentationTs; frame.duration = 333333; // ~30fps in 100ns units if (isKeyFrame) { frame.flags = EASYRTC_FRAME_FLAG_KEY_FRAME; } int ret = EasyRTC_SendFrame(transceiver, &frame); if (ret != EASYRTC_ERROR_NO) { printf("Failed to send frame: %d\n", ret); } } // Example usage in a capture loop void captureAndSendLoop(EasyRTC_Transceiver transceiver) { unsigned char frameBuffer[1024 * 1024]; int frameSize; int isKeyFrame; uint64_t pts = 0; while (capturing) { // Capture or encode video frame (implementation depends on your source) frameSize = captureEncodedFrame(frameBuffer, sizeof(frameBuffer), &isKeyFrame); if (frameSize > 0) { sendVideoFrame(transceiver, frameBuffer, frameSize, isKeyFrame, pts); pts += 33; // Increment by ~33ms for 30fps } usleep(33000); // ~30fps } } ``` ### Response #### Success Response (EASYRTC_ERROR_NO) Indicates the frame was sent successfully. #### Response Example (No explicit response body, success indicated by return code and potential printf statements in example) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.