mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[feat] add new classes EncodedFrame/DecodedFrame/ReceivedFrame for video frame module
This commit is contained in:
61
src/frame/decoded_frame.h
Normal file
61
src/frame/decoded_frame.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* @Author: DI JUNKUN
|
||||
* @Date: 2025-03-19
|
||||
* Copyright (c) 2025 by DI JUNKUN, All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _DECODED_FRAME_H_
|
||||
#define _DECODED_FRAME_H_
|
||||
|
||||
#include "video_frame.h"
|
||||
|
||||
class DecodedFrame : public VideoFrame {
|
||||
public:
|
||||
DecodedFrame(const uint8_t *buffer, size_t size, uint32_t width,
|
||||
uint32_t height)
|
||||
: VideoFrame(buffer, size, width, height) {}
|
||||
DecodedFrame(size_t size, uint32_t width, uint32_t height)
|
||||
: VideoFrame(size, width, height) {}
|
||||
DecodedFrame(const uint8_t *buffer, size_t size) : VideoFrame(buffer, size) {}
|
||||
DecodedFrame() = default;
|
||||
~DecodedFrame() = default;
|
||||
|
||||
int64_t ReceivedTimestamp() const { return received_timestamp_us_; }
|
||||
|
||||
void SetReceivedTimestamp(int64_t received_timestamp_us) {
|
||||
received_timestamp_us_ = received_timestamp_us;
|
||||
}
|
||||
|
||||
int64_t CapturedTimestamp() const { return captured_timestamp_us_; }
|
||||
|
||||
void SetCapturedTimestamp(int64_t captured_timestamp_us) {
|
||||
captured_timestamp_us_ = captured_timestamp_us;
|
||||
}
|
||||
|
||||
int64_t DecodedTimestamp() const { return decoded_timestamp_us_; }
|
||||
|
||||
void SetDecodedTimestamp(int64_t decoded_timestamp_us) {
|
||||
decoded_timestamp_us_ = decoded_timestamp_us;
|
||||
}
|
||||
|
||||
uint32_t DecodedWidth() const { return decoded_width_; }
|
||||
|
||||
void SetDecodedWidth(uint32_t decoded_width) {
|
||||
decoded_width_ = decoded_width;
|
||||
}
|
||||
|
||||
uint32_t decodedHeight() const { return decoded_height_; }
|
||||
|
||||
void SetdecodedHeight(uint32_t decoded_height) {
|
||||
decoded_height_ = decoded_height;
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t received_timestamp_us_ = 0;
|
||||
int64_t captured_timestamp_us_ = 0;
|
||||
int64_t decoded_timestamp_us_ = 0;
|
||||
uint32_t decoded_width_ = 0;
|
||||
uint32_t decoded_height_ = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
59
src/frame/encoded_frame.h
Normal file
59
src/frame/encoded_frame.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* @Author: DI JUNKUN
|
||||
* @Date: 2025-03-19
|
||||
* Copyright (c) 2025 by DI JUNKUN, All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _ENCODED_FRAME_H_
|
||||
#define _ENCODED_FRAME_H_
|
||||
|
||||
#include "video_frame.h"
|
||||
|
||||
class EncodedFrame : public VideoFrame {
|
||||
public:
|
||||
EncodedFrame(const uint8_t *buffer, size_t size, uint32_t width,
|
||||
uint32_t height)
|
||||
: VideoFrame(buffer, size, width, height) {}
|
||||
EncodedFrame(size_t size, uint32_t width, uint32_t height)
|
||||
: VideoFrame(size, width, height) {}
|
||||
EncodedFrame(const uint8_t *buffer, size_t size) : VideoFrame(buffer, size) {}
|
||||
EncodedFrame() = default;
|
||||
~EncodedFrame() = default;
|
||||
|
||||
int64_t CapturedTimestamp() const { return captured_timestamp_us_; }
|
||||
|
||||
void SetCapturedTimestamp(int64_t captured_timestamp_us) {
|
||||
captured_timestamp_us_ = captured_timestamp_us;
|
||||
}
|
||||
|
||||
int64_t EncodedTimestamp() const { return encoded_timestamp_us_; }
|
||||
|
||||
void SetEncodedTimestamp(int64_t encoded_timestamp_us) {
|
||||
encoded_timestamp_us_ = encoded_timestamp_us;
|
||||
}
|
||||
|
||||
VideoFrameType FrameType() const { return frame_type_; }
|
||||
|
||||
void SetFrameType(VideoFrameType frame_type) { frame_type_ = frame_type; }
|
||||
|
||||
uint32_t EncodedWidth() const { return encoded_width_; }
|
||||
|
||||
void SetEncodedWidth(uint32_t encoded_width) {
|
||||
encoded_width_ = encoded_width;
|
||||
}
|
||||
|
||||
uint32_t EncodedHeight() const { return encoded_height_; }
|
||||
|
||||
void SetEncodedHeight(uint32_t encoded_height) {
|
||||
encoded_height_ = encoded_height;
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t captured_timestamp_us_ = 0;
|
||||
int64_t encoded_timestamp_us_ = 0;
|
||||
VideoFrameType frame_type_ = VideoFrameType::kVideoFrameDelta;
|
||||
uint32_t encoded_width_ = 0;
|
||||
uint32_t encoded_height_ = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
36
src/frame/received_frame.h
Normal file
36
src/frame/received_frame.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* @Author: DI JUNKUN
|
||||
* @Date: 2025-03-19
|
||||
* Copyright (c) 2025 by DI JUNKUN, All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RECEIVED_FRAME_H_
|
||||
#define _RECEIVED_FRAME_H_
|
||||
|
||||
#include "video_frame.h"
|
||||
|
||||
class ReceivedFrame : public VideoFrame {
|
||||
public:
|
||||
ReceivedFrame(const uint8_t *buffer, size_t size)
|
||||
: VideoFrame(buffer, size) {}
|
||||
ReceivedFrame() = default;
|
||||
~ReceivedFrame() = default;
|
||||
|
||||
int64_t ReceivedTimestamp() const { return received_timestamp_us_; }
|
||||
|
||||
void SetReceivedTimestamp(int64_t received_timestamp_us) {
|
||||
received_timestamp_us_ = received_timestamp_us;
|
||||
}
|
||||
|
||||
int64_t CapturedTimestamp() const { return captured_timestamp_us_; }
|
||||
|
||||
void SetCapturedTimestamp(int64_t captured_timestamp_us) {
|
||||
captured_timestamp_us_ = captured_timestamp_us;
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t received_timestamp_us_ = 0;
|
||||
int64_t captured_timestamp_us_ = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -10,6 +10,12 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
enum VideoFrameType {
|
||||
kEmptyFrame = 0,
|
||||
kVideoFrameKey = 3,
|
||||
kVideoFrameDelta = 4,
|
||||
};
|
||||
|
||||
class VideoFrame {
|
||||
public:
|
||||
VideoFrame();
|
||||
@@ -26,10 +32,10 @@ class VideoFrame {
|
||||
~VideoFrame();
|
||||
|
||||
public:
|
||||
const uint8_t *Buffer() { return buffer_; }
|
||||
size_t Size() { return size_; }
|
||||
uint32_t Width() { return width_; }
|
||||
uint32_t Height() { return height_; }
|
||||
const uint8_t *Buffer() const { return buffer_; }
|
||||
size_t Size() const { return size_; }
|
||||
uint32_t Width() const { return width_; }
|
||||
uint32_t Height() const { return height_; }
|
||||
|
||||
void SetSize(size_t size) { size_ = size; }
|
||||
void SetWidth(uint32_t width) { width_ = width; }
|
||||
|
||||
@@ -9,44 +9,56 @@
|
||||
|
||||
#include "video_frame.h"
|
||||
|
||||
enum VideoFrameType {
|
||||
kEmptyFrame = 0,
|
||||
kVideoFrameKey = 3,
|
||||
kVideoFrameDelta = 4,
|
||||
};
|
||||
|
||||
class VideoFrameWrapper : public VideoFrame {
|
||||
public:
|
||||
VideoFrameWrapper(const uint8_t *buffer, size_t size, uint32_t width,
|
||||
uint32_t height)
|
||||
: VideoFrame(buffer, size, width, height) {}
|
||||
VideoFrameWrapper() = delete;
|
||||
VideoFrameWrapper(size_t size, uint32_t width, uint32_t height)
|
||||
: VideoFrame(size, width, height) {}
|
||||
VideoFrameWrapper(const uint8_t *buffer, size_t size)
|
||||
: VideoFrame(buffer, size) {}
|
||||
VideoFrameWrapper() = default;
|
||||
~VideoFrameWrapper() = default;
|
||||
|
||||
int64_t CaptureTimestamp() { return capture_timestamp_us_; }
|
||||
int64_t CapturedTimestamp() const { return captured_timestamp_us_; }
|
||||
|
||||
void SetCaptureTimestamp(int64_t capture_timestamp_us) {
|
||||
capture_timestamp_us_ = capture_timestamp_us;
|
||||
void SetCapturedTimestamp(int64_t captured_timestamp_us) {
|
||||
captured_timestamp_us_ = captured_timestamp_us;
|
||||
}
|
||||
|
||||
VideoFrameType FrameType() { return frame_type_; }
|
||||
int64_t ReceivedTimestamp() const { return received_timestamp_us_; }
|
||||
|
||||
void SetReceivedTimestamp(int64_t received_timestamp_us) {
|
||||
received_timestamp_us_ = received_timestamp_us;
|
||||
}
|
||||
|
||||
int64_t DecodedTimestamp() const { return decoded_timestamp_us_; }
|
||||
|
||||
void SetDecodedTimestamp(int64_t decoded_timestamp_us) {
|
||||
decoded_timestamp_us_ = decoded_timestamp_us;
|
||||
}
|
||||
|
||||
VideoFrameType FrameType() const { return frame_type_; }
|
||||
|
||||
void SetFrameType(VideoFrameType frame_type) { frame_type_ = frame_type; }
|
||||
|
||||
uint32_t EncodedWidth() { return encoded_width_; }
|
||||
uint32_t EncodedWidth() const { return encoded_width_; }
|
||||
|
||||
void SetEncodedWidth(uint32_t encoded_width) {
|
||||
encoded_width_ = encoded_width;
|
||||
}
|
||||
|
||||
uint32_t EncodedHeight() { return encoded_height_; }
|
||||
uint32_t EncodedHeight() const { return encoded_height_; }
|
||||
|
||||
void SetEncodedHeight(uint32_t encoded_height) {
|
||||
encoded_height_ = encoded_height;
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t capture_timestamp_us_ = 0;
|
||||
int64_t captured_timestamp_us_ = 0;
|
||||
int64_t received_timestamp_us_ = 0;
|
||||
int64_t decoded_timestamp_us_ = 0;
|
||||
VideoFrameType frame_type_ = VideoFrameType::kVideoFrameDelta;
|
||||
uint32_t encoded_width_ = 0;
|
||||
uint32_t encoded_height_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user