RtpPusher C++ lib. H.264 RTP, H.265 RTP, and JPEG RTP packet streaming with KLV metadata

€1,000.00

RtpPusher is a C++ library that providesH.264 RTP, H.265 RTP, and JPEG RTP packet sending to network.

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.

RtpPusher is a C++ library that providesH.264 RTP, H.265 RTP, and JPEG RTP packet sending to network.

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

RtpPusher is a C++ library that provides H.264 RTP, H.265 RTP, and JPEG RTP packet transmission over the network. The library internally handles NAL unit extraction and fragmentation into RTP packets sent over UDP. It includes an internal circular frame buffer (16 frames) to handle temporary network constraints, preventing frame loss when large key frames take extended time to transmit. The library depends on the Frame library (provides the video frame object declaration, source code included, Apache 2.0 license) and the UdpSocket library (provides methods to work with UDP sockets). The example application also depends on the VSourceFile library to read H.264/H.265/JPEG frames from files (source code included). To prevent network overload, the library uses output send-buffer monitoring (where available, e.g. Linux) and pauses transmission when the buffer exceeds a threshold. The library has no third-party dependencies that need to be installed in the OS. The library is compatible with Linux and Windows. Note: B-frames are not supported; input H.264/H.265 streams must contain only I-frames and P-frames.

Documentation

Documentation: GO TO DOCUMENTATION

Simple interface

namespace cr
{
namespace rtp
{
class RtpPusher
{
public:

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

    /// Class constructor.
    RtpPusher();

    /// Class destructor.
    ~RtpPusher();

    /// Initialize the video streamer with the specified parameters.
    bool init(std::string ip, uint16_t port,
              int maxPayloadSize = 1420, uint16_t metadataPort = 0, int fps = 30);

    /// Get the initialization status.
    bool isInit();

    /// Close the video streamer and release resources.
    void close();

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

Simple example

#include <iostream>
#include <thread>
#include <chrono>
#include "VSourceFile.h"
#include "RtpPusher.h"

int main()
{
    // Init video source.
    cr::video::VSourceFile source;
    std::string initString = "test.h264";
    if (!source.openVSource(initString)) // Default 1280x720, 30 FPS.
        return -1;
    
    std::cout << "Enter IP address: ";
    std::string ip = "127.0.0.1";
    std::cin >> ip;

    std::cout << "Enter port number: ";
    int port = 7032;
    std::cin >> port;

    // Init streamer.
    cr::rtp::RtpPusher rtpPusher;
    if (!rtpPusher.init(ip, port))
        return -1;

    // Main loop.
    cr::video::Frame sourceFrame;
    while (true)
    {
        // Get an H.264 frame from the video source. We wait for a new frame for 1 sec.
        if (!source.getFrame(sourceFrame, 1000))
            continue;

        // Send frame.
        if (!rtpPusher.sendFrame(sourceFrame))
            continue;

        std::cout << "Frame : " << sourceFrame.frameId << std::endl;

        // Wait to control the frame rate (30 FPS = ~33ms between frames).
        std::this_thread::sleep_for(std::chrono::milliseconds(33));
    }
    return 1;
}

}