Commit 6648735a authored by Edric Milaret's avatar Edric Milaret Committed by gerrit2

video: add screen sharing for windows

- add gdigrab as indev in ffmepg
- link to gdi32
- add method to init gdigrab

Refs #74614

Change-Id: I8fc1ea510a23a567c0cba7c4f646dfb9d78732cc
parent 3ab37d7a
......@@ -80,6 +80,7 @@ FFMPEGCONF += \
FFMPEGCONF += \
--enable-indev=dshow \
--enable-indev=gdigrab \
--enable-dxva2
DEPS_ffmpeg = iconv zlib x264 vpx opus speex $(DEPS_vpx)
......
......@@ -48,6 +48,9 @@
namespace ring { namespace video {
static constexpr unsigned default_grab_width = 640;
static constexpr unsigned default_grab_height = 480;
VideoInput::VideoInput()
: VideoGenerator::VideoGenerator()
, sink_ {Manager::instance().createSinkClient("local")}
......@@ -241,8 +244,32 @@ VideoInput::initX11(std::string display)
} else {
decOpts_.input = display;
//decOpts_.video_size = "vga";
decOpts_.width = 640;
decOpts_.height = 480;
decOpts_.width = default_grab_width;
decOpts_.height = default_grab_height;
}
return true;
}
bool
VideoInput::initGdiGrab(std::string params)
{
size_t space = params.find(' ');
clearOptions();
decOpts_.format = "gdigrab";
decOpts_.input = "desktop";
decOpts_.framerate = 30;
if (space != std::string::npos) {
std::istringstream iss(params.substr(space + 1));
char sep;
unsigned w, h;
iss >> w >> sep >> h;
decOpts_.width = round2pow(w, 3);
decOpts_.height = round2pow(h, 3);
} else {
decOpts_.width = default_grab_width;
decOpts_.height = default_grab_height;
}
return true;
......@@ -325,7 +352,11 @@ VideoInput::switchInput(const std::string& resource)
valid = initCamera(suffix);
} else if (prefix == "display") {
/* X11 display name */
#ifndef _WIN32
valid = initX11(suffix);
#else
valid = initGdiGrab(suffix);
#endif
} else if (prefix == "file") {
/* Pathname */
valid = initFile(suffix);
......
......@@ -92,6 +92,7 @@ private:
bool initCamera(const std::string& device);
bool initX11(std::string display);
bool initFile(std::string path);
bool initGdiGrab(std::string params);
// for ThreadLoop
bool setup();
......
......@@ -8,4 +8,4 @@ libwinvideo_la_SOURCES = \
AM_OBJCXXFLAGS = -std=c++11
libwinvideo_la_LIBADD = -ldxguid -lole32 -luuid -lstrmiids -loleaut32
\ No newline at end of file
libwinvideo_la_LIBADD = -ldxguid -lole32 -luuid -lstrmiids -loleaut32 -lgdi32
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment