Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
99d1356c
Commit
99d1356c
authored
Jun 28, 2019
by
Andreas Traczyk
Committed by
Adrien Béraud
Jul 03, 2019
Browse files
videodevices: don't enumerate video devices asynchronously
Change-Id: I0fca87622f15942d526524e4ebd5f53896461417
parent
d9ffa092
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/media/video/winvideo/video_device_impl.cpp
View file @
99d1356c
...
...
@@ -77,11 +77,7 @@ VideoDeviceImpl::VideoDeviceImpl(const std::string& path)
void
VideoDeviceImpl
::
setup
()
{
HRESULT
hr
=
CoInitializeEx
(
nullptr
,
COINIT_MULTITHREADED
);
if
(
FAILED
(
hr
))
return
fail
(
"Could not initialize video device."
);
hr
=
CoCreateInstance
(
HRESULT
hr
=
CoCreateInstance
(
CLSID_CaptureGraphBuilder2
,
nullptr
,
CLSCTX_INPROC_SERVER
,
...
...
src/media/video/winvideo/video_device_monitor_impl.cpp
View file @
99d1356c
...
...
@@ -52,7 +52,6 @@ private:
void
run
();
HRESULT
enumerateVideoInputDevices
(
IEnumMoniker
**
ppEnum
);
std
::
vector
<
std
::
string
>
enumerateVideoInputDevices
();
std
::
thread
thread_
;
...
...
@@ -68,6 +67,11 @@ VideoDeviceMonitorImpl::VideoDeviceMonitorImpl(VideoDeviceMonitor* monitor)
void
VideoDeviceMonitorImpl
::
start
()
{
// Enumerate the initial capture device list.
auto
captureDeviceList
=
enumerateVideoInputDevices
();
for
(
auto
node
:
captureDeviceList
)
{
monitor_
->
addDevice
(
node
);
}
thread_
=
std
::
thread
(
&
VideoDeviceMonitorImpl
::
run
,
this
);
}
...
...
@@ -244,12 +248,6 @@ VideoDeviceMonitorImpl::WinProcCallback(HWND hWnd, UINT message, WPARAM wParam,
void
VideoDeviceMonitorImpl
::
run
()
{
// Enumerate the initial capture device list.
auto
captureDeviceList
=
enumerateVideoInputDevices
();
for
(
auto
node
:
captureDeviceList
)
{
monitor_
->
addDevice
(
node
);
}
// Create a dummy window with the sole purpose to receive device change messages.
static
const
char
*
className
=
"Message"
;
WNDCLASSEX
wx
=
{};
...
...
@@ -275,35 +273,13 @@ VideoDeviceMonitorImpl::run()
}
}
HRESULT
VideoDeviceMonitorImpl
::
enumerateVideoInputDevices
(
IEnumMoniker
**
ppEnum
)
{
ICreateDevEnum
*
pDevEnum
;
HRESULT
hr
=
CoCreateInstance
(
CLSID_SystemDeviceEnum
,
NULL
,
CLSCTX_INPROC_SERVER
,
IID_PPV_ARGS
(
&
pDevEnum
));
if
(
SUCCEEDED
(
hr
))
{
hr
=
pDevEnum
->
CreateClassEnumerator
(
CLSID_VideoInputDeviceCategory
,
ppEnum
,
0
);
if
(
hr
==
S_FALSE
)
{
hr
=
VFW_E_NOT_FOUND
;
}
pDevEnum
->
Release
();
}
return
hr
;
}
std
::
vector
<
std
::
string
>
VideoDeviceMonitorImpl
::
enumerateVideoInputDevices
()
{
HRESULT
hr
=
CoInitializeEx
(
NULL
,
COINIT_MULTITHREADED
);
if
(
FAILED
(
hr
))
{
return
{};
}
std
::
vector
<
std
::
string
>
deviceList
;
ICreateDevEnum
*
pDevEnum
;
hr
=
CoCreateInstance
(
CLSID_SystemDeviceEnum
,
NULL
,
HRESULT
hr
=
CoCreateInstance
(
CLSID_SystemDeviceEnum
,
NULL
,
CLSCTX_INPROC_SERVER
,
IID_PPV_ARGS
(
&
pDevEnum
));
if
(
FAILED
(
hr
))
{
...
...
@@ -312,7 +288,11 @@ VideoDeviceMonitorImpl::enumerateVideoInputDevices()
}
IEnumMoniker
*
pEnum
=
nullptr
;
hr
=
enumerateVideoInputDevices
(
&
pEnum
);
hr
=
pDevEnum
->
CreateClassEnumerator
(
CLSID_VideoInputDeviceCategory
,
&
pEnum
,
0
);
if
(
hr
==
S_FALSE
)
{
hr
=
VFW_E_NOT_FOUND
;
}
pDevEnum
->
Release
();
if
(
FAILED
(
hr
)
||
pEnum
==
nullptr
)
{
JAMI_ERR
()
<<
"No webcam found"
;
return
{};
...
...
@@ -351,7 +331,6 @@ VideoDeviceMonitorImpl::enumerateVideoInputDevices()
deviceID
++
;
}
pEnum
->
Release
();
CoUninitialize
();
return
deviceList
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment