RtspServerLive555 C++ lib. RTSP server (H264, HEVC and JPEG) C++ library for Linux

€2,000.00

The RtspServerLive555 is a C++ library provides RTSP server with H264, HEVC and JPEG support. The library based on popular opensource library Live555 and provides simple interface to include in any C++ project.

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 RtspServerLive555 is a C++ library provides RTSP server with H264, HEVC and JPEG support. The library based on popular opensource library Live555 and provides simple interface to include in any C++ project.

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 RtspServerLive555 is a C++ library that implements an RTSP server. The library is based on the popular open-source library Live555 (source code not included, just linked). It provides a simple interface according to the VStreamer interface class and can be included in any C++ project. It allows developers to create an RTSP server without the complexity of the Live555 library. Users can set general RTSP server parameters: RTSP server port, IP, stream name, user name, and password. The server works frame-by-frame: users provide video frames. RtspServerLive555 accepts both raw pixel formats and compressed formats like H264, HEVC, or JPEG. If the frame is in a compressed format (H264, HEVC, or JPEG), 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, followed by the application of any required overlay. Finally, the processed frame is encoded into a compressed format before being transmitted to clients (to use these functions the user must define video codec and video overlay implementations according to VCodec and VOverlay interfaces). 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), FormatConverter (provides methods to convert pixel formats, source code included), ImageResizer (provides methods to resize images, source code included) and ConfigReader (provides methods to work with JSON files, source code included, Apache 2.0 license). It has been specifically tested and verified for functionality on the Linux operating system. It uses the C++17 standard. The RTSP server provided by the library is compatible with all popular RTSP clients: ffmpeg, gstreamer, VLC, Milestone etc.

Documentation

Documentation: GO TO DOCUMENTATION

Simple interface

namespace cr
{
namespace video
{
class RtspServerLive555 : public VStreamer
{
public:

    /// Class constructor.
    RtspServerLive555();

    /// Class destructor.
    ~RtspServerLive555();

    /// Get string of current library version.
    static std::string getVersion();

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

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

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

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

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

    /// Execute action command.
    bool executeCommand(VStreamerCommand id) override;

    /// Send frame to video streamer.
    bool sendFrame(cr::video::Frame& frame, uint8_t* userData = nullptr, int userDataSize = 0) override;

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

Simple example

#include <iostream>
#include <atomic>
#include <csignal>
#include "RtspServerLive555.h"
#include "VSourceFile.h"

using namespace std;
using namespace cr::video;

/// Flag to indicate when to finish the streaming.
std::atomic<bool> g_finishFlag{false};

/// Ctrl+C handler
void signalHandler(int signum)
{
    g_finishFlag.store(true);
}

int main()
{
    cout << "RtspServerLive555 v" << RtspServerLive555::getVersion() << endl;
    cout << endl;

    // Register signal.
    signal(SIGINT, signalHandler);

    // Init RTSP server params for encoded frames by default params.
    VStreamerParams params;
    params.rtspPort = 8554;
    params.ip = "127.0.0.1";
    params.suffix = "live";
    params.user = ""; // No user name.
    params.password = ""; // No password.
    params.fps = 30;

    // RTSP server.
    RtspServerLive555 server;
    if(!server.initVStreamer(params))
    {
        cout << "Can't init RTSP server" << endl;
        return -1;
    }
    cout << "RTSP init string: rtsp://" << params.ip << ":" << params.rtspPort
         << "/" << params.suffix << endl;
    
    // Set video source init string.
    string initString = "out.h264;1920;1080;30";

    // Init file video source.
    VSourceFile fileSource;
    if(!fileSource.openVSource(initString))
    {
        cout << "Can't open source file" << endl;
        return -1;
    }

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

    server.closeVStreamer();
    cout << "RTSP server closed" << endl;
    return 0;
}