30#include "../video_device.h"
49 std::vector<VideoSize>
getSizeList(
const std::string& channel)
const;
57 std::unique_ptr<CaptureGraphInterfaces> cInterface;
60 std::vector<VideoSize> sizeList_;
61 std::map<VideoSize, std::vector<FrameRate>> rateList_;
62 std::map<VideoSize, AM_MEDIA_TYPE*> capMap_;
65 void fail(
const std::string& error);
71 , cInterface(
new CaptureGraphInterfaces())
77VideoDeviceImpl::setup()
82 sizeList_.emplace_back(size);
99 (
void**) &cInterface->captureGraph_);
101 return fail(
"Unable to create the Filter Graph Manager");
107 (
void**) &cInterface->graph_);
109 return fail(
"Unable to add the graph builder!");
111 hr = cInterface->captureGraph_->SetFiltergraph(cInterface->graph_);
113 return fail(
"Unable to set filtergraph.");
124 if (FAILED(
hr) ||
pEnum ==
nullptr) {
186 hr = cInterface->graph_->AddFilter(cInterface->videoInputFilter_,
var.bstrVal);
188 fail(
"Unable to add filter to video device.");
192 cInterface->videoInputFilter_,
194 (
void**) &cInterface->streamConf_);
198 cInterface->videoInputFilter_,
200 (
void**) &cInterface->streamConf_);
202 fail(
"Unable to config the stream!");
214 if (FAILED(
hr) || cInterface->streamConf_ ==
NULL) {
215 fail(
"Unable to find the video device.");
220 cInterface->streamConf_->GetNumberOfCapabilities(&
piCount, &
piSize);
223 std::map<std::pair<jami::video::VideoSize, jami::video::FrameRate>,
LONG>
bitrateList;
225 cInterface->streamConf_->GetStreamCaps(
i, &
pmt, (
BYTE*) &
pSCC);
238 auto ratesIt = rateList_.find(size);
242 auto key = std::make_pair(size,
rate);
250 sizeList_.emplace_back(size);
251 rateList_[size].emplace_back(
rate);
258VideoDeviceImpl::fail(
const std::string& error)
260 throw std::runtime_error(error);
272 params.format =
"dxgigrab";
273 params.framerate = desktopFrameRate_;
296 desktopFrameRate_ =
params.framerate;
301 if (
pmt !=
nullptr) {
303 if (FAILED(cInterface->streamConf_->SetFormat(
pmt))) {
304 JAMI_ERR(
"Unable to set settings.");
310std::vector<VideoSize>
316std::vector<FrameRate>
320 return rateList_.at(size);
323std::vector<VideoSize>
330std::vector<std::string>
337 : deviceImpl_(
new VideoDeviceImpl(path))
340 name = deviceImpl_->name;
346 return deviceImpl_->getDeviceParams();
350VideoDevice::setDeviceParams(
const DeviceParams&
params)
352 return deviceImpl_->setDeviceParams(
params);
355std::vector<std::string>
358 return deviceImpl_->getChannelList();
361std::vector<VideoSize>
362VideoDevice::getSizeList(
const std::string& channel)
const
364 return deviceImpl_->getSizeList(channel);
367std::vector<FrameRate>
368VideoDevice::getRateList(
const std::string& channel,
VideoSize size)
const
370 return deviceImpl_->getRateList(channel, size);
VideoDeviceImpl(const std::string &id)
std::vector< VideoSize > getSizeList() const
std::vector< std::string > getChannelList() const
VideoDeviceImpl(const std::string &path)
std::vector< FrameRate > getRateList(const std::string &channel, VideoSize size) const
void setDeviceParams(const DeviceParams &)
DeviceParams getDeviceParams() const
std::vector< FrameRate > getRateList() const
std::vector< VideoSize > getSizeList(const std::string &channel) const
std::vector< std::string > getChannelList() const
VideoDevice(const std::string &path, const std::vector< std::map< std::string, std::string > > &devInfo)
DeviceParams getDeviceParams() const
Returns the parameters needed for actual use of the device.
static constexpr const char DEVICE_DESKTOP[]
std::pair< unsigned, unsigned > VideoSize
rational< double > FrameRate
void emitSignal(Args... args)
std::string to_string(double value)
DeviceParams Parameters used by MediaDecoder and MediaEncoder to open a LibAV device/stream.