Name |
---|
AlignedData |
Name | |
---|---|
struct | AlignedData::DataFrame 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. |
// Copyright (c) 2022, Edgeware AB. All rights reserved.
#pragma once
#include <array>
#include <iostream>
#include <vector>
#include <cuda_runtime_api.h>
namespace AlignedData {
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.
};
struct DataFrame {
DataFrame() = default;
~DataFrame() {
if (mVideoDataCudaPtr) {
cudaError_t cudaStatus = cudaFree(mVideoDataCudaPtr);
mVideoDataCudaPtr = nullptr;
if (cudaStatus != cudaSuccess) {
std::cout << "AlignedData::~DataFrame: Failed to release cuda memory: " << cudaStatus << std::endl;
}
}
}
DataFrame(DataFrame const&) = delete; // Copy construct
DataFrame& operator=(DataFrame const&) = delete; // Copy assign
uint64_t mPTS;
// Video
uint8_t* mVideoDataCudaPtr = 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;
};
} // namespace AlignedData
Updated on 2022-06-22 at 16:53:25 +0200