include/MediaStreamer.h

include/MediaStreamer.h

Classes

Name
classMediaStreamer
MediaStreamer is a class that can take a single stream of uncompressed video and/or audio frames and encode and output it in some way to some interface. This interface 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.
structMediaStreamer::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) 2022, Edgeware AB. All rights reserved.

#pragma once

#include <memory>

#include <ISystemControllerInterface.h>

#include "AlignedFrame.h"

class MediaStreamer final {
public:
    struct Configuration {
        // Video
        AlignedFrame::PixelFormat mIncomingPixelFormat = AlignedFrame::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
    };

    MediaStreamer();

    ~MediaStreamer();

    bool configure(const std::shared_ptr<ISystemControllerInterface>& controllerInterface);

    bool setInputFormatAndStart(const Configuration& configuration);

    bool stopAndResetFormat();

    [[nodiscard]] bool hasFormatAndIsRunning() const;

    [[nodiscard]] bool hasOpenOutputStream() const;

    bool outputData(const AlignedFramePtr& frame);

    static std::string getVersion();

    static std::string getBuildInfo();

private:
    class Impl;
    std::unique_ptr<Impl> pImpl;
};

Updated on 2023-06-13 at 17:00:17 +0200