How xroier/sharprtmp works
Project Type and Purpose
• Project Type: It is a framework/library for building RTMP servers with extension points for handling streaming protocols, controller logic (for live and record streams), and integration with WebSocket for FLV streaming.
• Purpose: The core engine supports receiving video/audio streams (e.g., via ffmpeg pushing to an RTMP endpoint) and distributing them over protocols (RTMP for ffplay and WebSocket/FLV for web players like flv.js). It also provides extensibility (via Startup and DI with Autofac) so developers can register their custom controllers and services.
File Structure
• Top-level separation:
• SharpRtmp: Contains the core framework code including subdirectories for Buffers, Controllers (with separate folders for Living, Record, etc.), Hosting (server setup, options, startup interfaces), Networking (divided further among AMF processing, FLV handling, RTMP messaging, and WebSocket sessions), Rpc, and Service layers.
• SharpRtmp.Example: A demonstration application that shows how to configure and run the server (using Program.cs and Startup.cs).
• SharpRtmp.UnitTests: Contains tests for AMF readers/writers, buffer management, etc.
• docs and samples: Provide API documentation and sample media files for testing AMF serialization.
• Architectural Clues:
• There’s an obvious layering: Hosting (server bootstrapping), Networking (protocol management and message processing), Controllers (handling application logic for streams), and Services (e.g., record and publisher session management).
• Use of Dependency Injection (via Autofac) in Startup and an explicit chainable RtmpServerBuilder indicating a pluggable and modular architecture.
Elements to Include (for clarity and granularity)
• Use clear labels for each module/component such as “Hosting (RtmpServer, RtmpServerBuilder, Options)”, “Networking – RTMP (Handshake, Message Streams, ChunkStream)”, “Networking – AMF Serialization (AMF0, AMF3)” and so on.
• Optionally, include annotations that capture design patterns like the builder pattern, the layered architecture, and the use of dependency injection.