代码拉取完成,页面将自动刷新
同步操作将从 ZVision/UVCCapture 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* Copyright (c) 2016, Roman Meyta <theshrodingerscat@gmail.com>
* Copyright (c) 2020-2021 https://gitee.com/fsfzp888
* All rights reserved
*/
#ifndef VIDEO_DEVICE_H
#define VIDEO_DEVICE_H
#include <string>
#include <vector>
#include "SampleGrabber.h"
#include "VideoCaptureCallback.h"
struct IBaseFilter;
struct IFilterGraph2;
class VideoCapture;
class VideoDevice;
/**
* @brief Video device
*/
class VideoDevice
{
public:
/**
* @brief Video device properties
*/
struct Properties
{
/**
* @brief Constructor
*/
Properties() : mediaType(), width(0), height(0), pixelFormat(), isFlippedHorizontal(false), isFlippedVertical(false) {}
/**
* @brief Media type structure
*/
AM_MEDIA_TYPE mediaType;
/**
* @brief Frame width
*/
LONG width;
/**
* @brief Frame height
*/
LONG height;
/**
* @brief Frame pixel format
*/
GUID pixelFormat;
/**
* @brief Frame per second
*/
double fps;
/**
* @brief Necessity of horizontal flipping
*/
bool isFlippedHorizontal;
/**
* @brief Necessity of vertical flipping
*/
bool isFlippedVertical;
};
/**
* @brief Constructor
*/
VideoDevice();
/**
* @brief Destructor
*/
~VideoDevice();
/**
* @brief Get device id
*
* @return int
*/
int getId() const;
/**
* @brief Get device name
*
* @return std::wstring
*/
std::wstring getFriendlyName() const;
/**
* @brief Get device name
*
* @return std::wstring
*/
std::vector<VideoDevice::Properties> getPropertiesList() const;
/**
* @brief Get current frame properties
*
* @return Properties
*/
VideoDevice::Properties getCurrentProperties() const;
/**
* @brief Set current frame properties
*
* @param properties
* @return bool
*/
bool setCurrentProperties(const VideoDevice::Properties &properties);
/**
* @brief Set function that process video frames
*
* @param callback
* @return bool
*/
void setCallback(VideoCaptureCallback &callback);
/**
* @brief Set function that process still frame
*
* @param callback
* @return bool
*/
void setStillCallback(VideoCaptureCallback &callback);
/**
* @brief Delete still related filter.
*/
void RemoveStillRelatedFilter();
/**
* @brief Start capturing
*
* @return bool
*/
bool start();
/**
* @brief Stop capturing
*
* @return bool
*/
bool stop();
/**
* @brief Check if active
*
* @return bool
*/
bool isActive() const;
private:
/**
* @brief Device id
*/
int m_id;
/**
* @brief Device name
*/
std::wstring m_friendlyName;
/**
* @brief Filter name
*/
std::wstring m_filterName;
/**
* @brief List of properties
*/
std::vector<VideoDevice::Properties> m_propertiesList;
/**
* @brief Current properties
*/
VideoDevice::Properties m_currentProperties;
/**
* @brief Source filter
*/
IBaseFilter *m_sourceFilter;
/**
* @brief Grab filter
*/
IBaseFilter *m_sampleGrabberFilter;
/**
* @brief Still filter
*/
IBaseFilter *m_sampleStillFilter;
/**
* @brief Null renderer
*/
IBaseFilter *m_nullRenderer;
IBaseFilter *m_nullRenderer2;
/**
* @brief Sample grabber
*/
ISampleGrabber *m_sampleGrabber;
/**
* @brief Sample still grabber
*/
ISampleGrabber *m_sampleStill;
/**
* @brief IFilterGraph2 interface
*/
IFilterGraph2 *m_graph;
/**
* @brief IAMStreamConfig interface
*/
IAMStreamConfig *m_config;
/**
* @brief Alive flag
*/
bool m_isActive;
/**
* @brief Callback handler
*/
class CallbackHandler : public ISampleGrabberCB
{
public:
/**
* @brief Constructor
*
* @param device
*/
CallbackHandler(VideoDevice *device);
/**
* @brief Destructor
*/
virtual ~CallbackHandler();
/**
* @brief Set function that process video frames
*
* @param callback
*/
void SetCallback(VideoCaptureCallback &callback);
/**
* @overload
*/
virtual HRESULT STDMETHODCALLTYPE SampleCB(double time, IMediaSample *sample);
/**
* @overload
*/
virtual HRESULT STDMETHODCALLTYPE BufferCB(double time, BYTE *buffer, long len);
/**
* @overload
*/
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv);
/**
* @overload
*/
virtual ULONG STDMETHODCALLTYPE AddRef();
/**
* @overload
*/
virtual ULONG STDMETHODCALLTYPE Release();
private:
/**
* @brief Callback function
*/
VideoCaptureCallback m_callback;
/**
* @brief Parent device
*/
VideoDevice *m_device;
};
CallbackHandler *m_callbackHandler;
CallbackHandler *m_stillCallbackHandler;
friend class VideoCapture;
};
#endif // VIDEO_DEVICE_H
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。