DeviceMemory.hpp 2.84 KB
#ifndef __DEVICE_RGB_MEMORY_H__
#define __DEVICE_RGB_MEMORY_H__

#include<string>

#include "utiltools.hpp"

using namespace std;

class DeviceMemory{

public:
     DeviceMemory(int _channel, int _width, int _width_stride, int _height, int _height_stride, string _id, string _dev_id, bool _key_frame, unsigned long long _frame_nb, bool _isused){
        channel = _channel;
        width = _width;
        width_stride = _width_stride;
        height = _height;
        height_stride = _height_stride;
        data_size = channel * width * height;
        isused = _isused;
        id = _id;
        device_id = _dev_id;
        key_frame = _key_frame;
        frame_nb = _frame_nb;
        timestamp = UtilTools::get_cur_time_ms();
    }

    virtual ~DeviceMemory(){}

    int getSize() {
        return data_size;
    }

    void setSize(int size) {
        data_size = size;
    }
    
    bool isIsused() {
        return isused;
    }

    void setIsused(bool _isused) {
        isused = _isused;
        // 更新时间戳
        timestamp = UtilTools::get_cur_time_ms();
    }

    string getId() {
        return id;
    }

    void setId(string _id) {
        id = _id;
    }

    string getDeviceId() {
        return device_id;
    }

    void setDeviceId(string _device_id) {
        device_id = _device_id;
    }

    unsigned char* getMem(){
        return pHwRgb;
    }

    void setMem(unsigned char* _pHwRgb) {
        pHwRgb = _pHwRgb;
    }

    long long getTimesstamp(){
        return timestamp;
    }

    void setTimesstamp(long long _timestamp) {
        timestamp = _timestamp;
    }

    int getWidth(){
        return width;
    }

    void setWidth(int _width) {
        width = _width;
    }

    int getWidthStride(){
        return width_stride;
    }

    void setWidthStride(int _width_stride) {
        width_stride = _width_stride;
    }

    int getHeight(){
        return height;
    }

    void setHeight(int _height) {
        height = _height;
    }

    int getHeightStride(){
        return height_stride;
    }

    void setHeightStride(int _height_stride) {
        height_stride = _height_stride;
    }

    int getChannel(){
        return channel;
    }

    void setChannel(int _channel) {
        channel = _channel;
    }

    bool isKeyFrame(){
        return key_frame;
    }

    void setKeyFrame(bool _key_frame) {
        key_frame = _key_frame;
    }

    unsigned long long getFrameNb() {
        return frame_nb;
    }

    void setFrameNb(unsigned long long _frame_nb) {
        frame_nb = _frame_nb;
    }

public:
    int data_size;
    bool isused;
    string id;
    string device_id;
    unsigned char * pHwRgb{nullptr};
    long long timestamp;
    int width{0};
    int width_stride{0};
    int height{0};    
    int height_stride{0};
    int channel{3};
    bool key_frame;
    long index;
    unsigned long long frame_nb;
};

#endif