include/AlignedFrame.h

include/AlignedFrame.h

Classes

Name
structAlignedFrame
A frame of aligned data that is passed to the rendering engine from the MediaReceiver. A DataFrame contains a time stamped frame of media, which might be video, audio and auxiliary data such as subtitles. A single DataFrame can contain one or multiple types of media. Which media types are included can be probed by nullptr-checking/size checking the data members. The struct has ownership of all data pointers included. The struct includes all logic for freeing the resources held by this struct and the user should therefore just make sure the struct itself is deallocated to ensure all resources are freed.

Types

Name
using std::shared_ptr< AlignedFrame >AlignedFramePtr

Types Documentation

using AlignedFramePtr

using AlignedFramePtr =  std::shared_ptr<AlignedFrame>;

Source code

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

#pragma once

#include <array>
#include <iostream>
#include <memory>
#include <vector>

#include <cuda_runtime_api.h>

#include "DeviceMemory.h"

struct AlignedFrame {

    typedef std::array<float, 16> AudioSampleRow;

    enum class CompressedVideoFormat {
        kAvc, // H264
        kHevc // H265
    };

    enum class PixelFormat {
        kUnknown,
        kNv12,    // 8 bit per component 4:2:0 YUV format. Y plane followed by interleaved UV plane.
        kP016,    // 16 bit per component 4:2:0 YUV format. Y plane followed by interleaved UV plane.
        kUyvy,    // 8 bit per component 4:2:2 YUV format. U-Y-V-Y bytes interleaved.
        kRgba,    // 8 bit per component RGBA, ordered as R-G-B-A-R-G.. in memory.
        kRgba64Le // 16 bit per component RGBA, ordered as R-G-B-A-R-G.. in memory with little endian words.
    };

    AlignedFrame() = default;

    ~AlignedFrame() = default;

    AlignedFrame(AlignedFrame const&) = delete;            // Copy construct
    AlignedFrame& operator=(AlignedFrame const&) = delete; // Copy assign

    int64_t mCaptureTimestamp = 0;

    int64_t mRenderingTimestamp = 0;

    // Video
    std::shared_ptr<DeviceMemory> mVideoFrame = nullptr;
    PixelFormat mPixelFormat = PixelFormat::kUnknown;
    uint32_t mFrameRateN = 0;
    uint32_t mFrameRateD = 0;
    uint32_t mWidth = 0;
    uint32_t mHeight = 0;

    // Audio
    std::vector<AudioSampleRow> mAudioData;
    uint32_t mAudioChannels = 0;
    uint32_t mAudioSamplingFrequency = 0;
};

using AlignedFramePtr = std::shared_ptr<AlignedFrame>;

Updated on 2022-11-17 at 15:40:06 +0100