include/IMediaStreamer.h

include/IMediaStreamer.h

Classes

Name
classIMediaStreamer
IMediaStreamer is an interface class for MediaStreamers, that can take a single stream of uncompressed video and/or audio frames and encode and output it in some way. This output can either be a stream to a network or writing down the data to a file on the hard drive. This class is configured from two interfaces. The input configuration (input video resolution, frame rate, pixel format, number of audio channels…) is made through this C++ API. The output stream is then started from the System Controller. Any of these configurations can be made first. The actual stream to output will start once the first call to.
structIMediaStreamer::Settings
Settings used when creating a new MediaStreamer.
structIMediaStreamer::Configuration
The input configuration of the frames that will be sent to this MediaStreamer. The output stream configuration is made from the System controller via the ISystemControllerInterface.

Source code

// Copyright (c) 2024, Edgeware AB. All rights reserved.

#pragma once

#include <memory>

#include <ISystemControllerInterface.h>
#include <cuda.h>

#include "AlignedFrame.h"

class IMediaStreamer {
public:
    struct Settings {
        std::string mName; // Human-readable name, presented in the REST API
    };

    struct Configuration {
        // Video
        PixelFormat mIncomingPixelFormat = PixelFormat::kUnknown;
        uint32_t mWidth = 0;      // Width of the incoming video frames in pixels
        uint32_t mHeight = 0;     // Height of the incoming video frames in pixels
        uint32_t mFrameRateN = 0; // Frame rate numerator of the incoming video frames
        uint32_t mFrameRateD = 0; // Frame rate denominator of the incoming video frames

        // Audio
        uint32_t mAudioSampleRate = 0;  // Audio sample rate of the incoming frames in Hz
        uint32_t mNumAudioChannels = 0; // Number of audio channels in the incoming frames
    };

    virtual ~IMediaStreamer() = default;

    virtual bool configure(const std::string& uuid, const Settings& settings, CUcontext cudaContext) = 0;

    virtual bool setInputFormatAndStart(const Configuration& configuration) = 0;

    virtual bool stopAndResetFormat() = 0;

    [[nodiscard]] virtual bool hasFormatAndIsRunning() const = 0;

    [[nodiscard]] virtual bool hasOpenOutputStream() const = 0;

    virtual bool outputData(const AlignedFramePtr& frame) = 0;
};

Updated on 2024-04-08 at 15:15:27 +0200