How jimm98y/sharprtsptowebrtc works
Main Components
• Frontend Client (React App)
• Located in the “ClientApp” directory inside src/RTSPtoWebRTCGateway.
• Contains key elements like index.html and components (CameraViewer.js, NavMenu.js, etc.) that are responsible for rendering the WebRTC video stream and handling user interactions.
• Backend API / Gateway (ASP.NET Core App)
• Found in src/RTSPtoWebRTCGateway with Controllers, Pages, Program.cs, and configuration (appsettings.json).
• Contains the WebRTCController that exposes REST endpoints (e.g., get offer, set answer, add ICE candidate) for signaling between clients and the WebRTC proxy service.
• RTSP to WebRTC Proxy Service
• This part of the system actually bridges the RTSP stream with WebRTC functionality and is implemented by the code in the SharpRTSPtoWebRTC project (e.g., RTSPtoWebRTCProxyService, RTSPtoWebRTCProxy.cs).
• External RTSP Streams
• These are not part of the repository but are external sources that the system connects to (e.g., cameras streaming H264/H265 content).
• Supporting Libraries/Frameworks
• sipsorcery for the WebRTC implementation.
• SharpRTSP for RTSP client functionality.
• Concentus and SharpJaad for handling audio transcoding.
Relationships and Interactions
• Client Browser → Frontend (React App)
• The browser loads the static files and uses the client-side JavaScript to render the camera view (using the CameraViewer component) and initiate WebRTC signaling.
• React App → Backend API (WebRTC Signaling)
• API calls made from the client (using endpoints exposed by WebRTCController) to begin a session – these include obtaining the offer, sending the answer back, and exchanging ICE candidates.
• Backend API → RTSP to WebRTC Proxy Service
• The controller leverages the RTSPtoWebRTCProxyService (registered in Startup/Program) to manage the RTSP session and conversion.
• RTSP to WebRTC Proxy Service → External RTSP Stream
• Handles the inbound RTSP stream from a camera and manages the session (without video transcoding, but with AAC to Opus audio transcoding when needed).
Architectural Patterns and Design Principles
• Layered Architecture:
• The system is clearly separated between the Frontend (client) and the Backend (API and service layers).
• API-Driven Communication:
• The RESTful endpoints in WebRTCController indicate a service that acts as a mediator between the browser and the WebRTC proxy service.
• Modular Microservice-like Segmentation:
• Although the code is encapsulated in one solution (with different projects and directories) it logically separates concerns (UI vs server-side processing vs proxy logic).
Relevant Technologies
• ASP.NET Core (for backend service and API endpoints)
• C# and .NET (for the core logic, including the RTSPtoWebRTC gateway)
• React (for the client-side application in the ClientApp folder)
• WebRTC (for real-time communication)
• Additional libraries: sipsorcery, SharpRTSP, concentus, and SharpJaad.
Specific Elements
• Client Browser: label it “React WebRTC Viewer” and include components such as CameraViewer.
• Backend API: label it “ASP.NET Core Gateway” that includes the WebRTCController and related components.
• RTSPtoWebRTC Proxy Service: encapsulated as a separate service/module within the backend.
• Data flows from the browser to the API (e.g., signaling messages, API calls).
• API to the RTSP proxy service to demonstrate control flow (e.g., obtaining offers, transmitting the media stream).
• Inversely, show the return path from the RTSP stream/Proxy Service back to the browser.
• Components with the primary libraries they use (e.g., “Uses sipsorcery for WebRTC”).