RtspServer C++ lib. RTSP server H264 and HEVC(H265) video stream via TCP / UDP / UDP multicast

€2,000.00

The RtspServer C++ library implements RTSP server. The RtspServer library inherits interface from VStreamer.

LICENSE: We sell source code of this library as is, without future updates and technical support according to perpetual non-exclusive royalty-free license. You pay once and can use this library in your software and hardware products without limits. Please read the license agreement before purchasing: LICENSE.

The RtspServer C++ library implements RTSP server. The RtspServer library inherits interface from VStreamer.

LICENSE: We sell source code of this library as is, without future updates and technical support according to perpetual non-exclusive royalty-free license. You pay once and can use this library in your software and hardware products without limits. Please read the license agreement before purchasing: LICENSE.

Overview

The RtspServer C++ library implements RTSP server. The RtspServer library inherits interface from VStreamer. The library supports H264 and HEVC(H265) video stream via TCP / UDP / UDP multicast. User can set general RTSP server parameters such as: RTSP server port, IP, stream name, user name, password etc. Server works frame-by-frame. RtspServer accepts both RAW frame formats (such as NV12) and compressed formats H264 and HEVC(H265). If the frame is in a compressed format (H264 or HEVC), it bypasses any overlay and resizing processes and is sent directly to clients. However, if the frame is RAW, it undergoes a series of processing steps. First, resizing is performed if necessary (if input frame size differs from video stream resolution). Second, video overlay if pointer to video overlay engine is provided by user (according to VOverlay interface). Finally, the frame is encoded into a compressed format (H264 or HEVC) before being transmitted to clients (to use this functions the user must define video codec according to VCodec interface). The library relies on several dependencies: VCodec (defines video codec interface, source code included, Apache 2.0 license), VOverlay (defines video overlay interface, source code included, Apache 2.0 license), FormatConverterOpenCv (provides methods to convert pixel formats, source code included), ConfigReader (provides methods to work with JSON files, source code included, Apache 2.0 license) and OpenCV (version 4.5 and higher, video scaling functions). In additional the test application depends on VSourceFile library (provides function to capture compressed data from video file, source code included). The library compatible with Linux and Windows operating systems. The RTSP server compatible with all popular RTSP clients: ffmpeg, gstreamer, VLC, Milestone etc. The library uses part of source code from PHZ76/RtspServer (highly modified, source code included, MIT license).

Documentation

Documentation: GO TO DOCUMENTATION

Simple interface

class RtspServer : public cr::video::VStreamer
{
public:
    /// Get string of current library version.
    static std::string getVersion();

    /// Init video streamer by set of parameters.
    bool initVStreamer(cr::video::VStreamerParams &params,
                       cr::video::VCodec *codec = nullptr,
                       cr::video::VOverlay *overlay = nullptr) override;

    /// Get init status.
    bool isVStreamerInit() override;

    /// Close video streamer.
    void closeVStreamer() override;

    /// Send frame to video streamer.
    bool sendFrame(cr::video::Frame& frame) override;

    /// Set video streamer parameter.
    bool setParam(cr::video::VStreamerParam id, float value) override;

    /// Set video streamer parameter.
    bool setParam(cr::video::VStreamerParam id, std::string value) override;

    /// Get all video streamer parameters.
    void getParams(cr::video::VStreamerParams& params) override;

    /// Execute action command.
    bool executeCommand(cr::video::VStreamerCommand id) override;
};

Simple example

#include <iostream>
#include "RtspServer.h"
#include "VSourceFile.h"

using namespace std;
using namespace cr::rtsp;
using namespace cr::video;

int main(void)
{
    // Init RTSP server params for encoded frames by default params.
    VStreamerParams params;
    params.port = 7031;
    params.ip = "0.0.0.0";
    params.suffix = "live";
    params.user = ""; // No user name.
    params.password = ""; // No password.
    params.fps = 30;

    // RTSP server.
    RtspServer server;
    if(!server.initVStreamer(params))
        return -1;
    cout << "RTSP init string: rtsp://127.0.0.1:7031/live" << endl;
    
    // Set video source init string.
    string initString = "out.264;1280;720;30";

    // Init file video source.
    VSourceFile fileSource;
    if(!fileSource.openVSource(initString))
        return -1;

    // Main thread.
    Frame sourceFrame;

    while(1)
    {
        // Get new frame from video file.
        if(!fileSource.getFrame(sourceFrame, 1000))
            continue;
        
        // Send frame to RTSP server.
        if(!server.sendFrame(sourceFrame))
            cout << "Can not send frame to rtsp server" << endl;
        
    }

    return 1;
}