Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
01a883df
Commit
01a883df
authored
Sep 27, 2014
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3267 from a-wi:MSMF_capture_fixes_v3
parents
047abb00
302b138a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
9 deletions
+36
-9
OpenCVFindLibsVideo.cmake
cmake/OpenCVFindLibsVideo.cmake
+1
-0
CMakeLists.txt
modules/videoio/CMakeLists.txt
+1
-0
cap_msmf.cpp
modules/videoio/src/cap_msmf.cpp
+22
-9
cap_msmf.hpp
modules/videoio/src/cap_msmf.hpp
+12
-0
No files found.
cmake/OpenCVFindLibsVideo.cmake
View file @
01a883df
...
@@ -254,6 +254,7 @@ if(WITH_DSHOW)
...
@@ -254,6 +254,7 @@ if(WITH_DSHOW)
endif
(
WITH_DSHOW
)
endif
(
WITH_DSHOW
)
# --- VideoInput/Microsoft Media Foundation ---
# --- VideoInput/Microsoft Media Foundation ---
ocv_clear_vars
(
HAVE_MSMF
)
if
(
WITH_MSMF
)
if
(
WITH_MSMF
)
check_include_file
(
Mfapi.h HAVE_MSMF
)
check_include_file
(
Mfapi.h HAVE_MSMF
)
endif
(
WITH_MSMF
)
endif
(
WITH_MSMF
)
...
...
modules/videoio/CMakeLists.txt
View file @
01a883df
...
@@ -42,6 +42,7 @@ if (WIN32 AND HAVE_DSHOW)
...
@@ -42,6 +42,7 @@ if (WIN32 AND HAVE_DSHOW)
endif
()
endif
()
if
(
WIN32 AND HAVE_MSMF
)
if
(
WIN32 AND HAVE_MSMF
)
list
(
APPEND videoio_srcs
${
CMAKE_CURRENT_LIST_DIR
}
/src/cap_msmf.hpp
)
list
(
APPEND videoio_srcs
${
CMAKE_CURRENT_LIST_DIR
}
/src/cap_msmf.cpp
)
list
(
APPEND videoio_srcs
${
CMAKE_CURRENT_LIST_DIR
}
/src/cap_msmf.cpp
)
endif
()
endif
()
...
...
modules/videoio/src/cap_msmf.cpp
View file @
01a883df
...
@@ -78,7 +78,9 @@
...
@@ -78,7 +78,9 @@
#pragma comment(lib, "mfuuid")
#pragma comment(lib, "mfuuid")
#pragma comment(lib, "Strmiids")
#pragma comment(lib, "Strmiids")
#pragma comment(lib, "Mfreadwrite")
#pragma comment(lib, "Mfreadwrite")
#if (WINVER >= 0x0602) // Available since Win 8
#pragma comment(lib, "MinCore_Downlevel")
#pragma comment(lib, "MinCore_Downlevel")
#endif
#include <mferror.h>
#include <mferror.h>
...
@@ -1469,7 +1471,6 @@ void ImageGrabber::stopGrabbing()
...
@@ -1469,7 +1471,6 @@ void ImageGrabber::stopGrabbing()
HRESULT
ImageGrabber
::
startGrabbing
(
void
)
HRESULT
ImageGrabber
::
startGrabbing
(
void
)
{
{
_ComPtr
<
IMFMediaEvent
>
pEvent
=
NULL
;
PROPVARIANT
var
;
PROPVARIANT
var
;
PropVariantInit
(
&
var
);
PropVariantInit
(
&
var
);
HRESULT
hr
=
ig_pSession
->
SetTopology
(
0
,
ig_pTopology
);
HRESULT
hr
=
ig_pSession
->
SetTopology
(
0
,
ig_pTopology
);
...
@@ -1477,6 +1478,7 @@ HRESULT ImageGrabber::startGrabbing(void)
...
@@ -1477,6 +1478,7 @@ HRESULT ImageGrabber::startGrabbing(void)
hr
=
ig_pSession
->
Start
(
&
GUID_NULL
,
&
var
);
hr
=
ig_pSession
->
Start
(
&
GUID_NULL
,
&
var
);
for
(;;)
for
(;;)
{
{
_ComPtr
<
IMFMediaEvent
>
pEvent
=
NULL
;
HRESULT
hrStatus
=
S_OK
;
HRESULT
hrStatus
=
S_OK
;
MediaEventType
met
;
MediaEventType
met
;
if
(
!
ig_pSession
)
break
;
if
(
!
ig_pSession
)
break
;
...
@@ -1509,11 +1511,13 @@ HRESULT ImageGrabber::startGrabbing(void)
...
@@ -1509,11 +1511,13 @@ HRESULT ImageGrabber::startGrabbing(void)
DebugPrintOut
(
L"IMAGEGRABBER VIDEODEVICE %i: MESessionStopped
\n
"
,
ig_DeviceID
);
DebugPrintOut
(
L"IMAGEGRABBER VIDEODEVICE %i: MESessionStopped
\n
"
,
ig_DeviceID
);
break
;
break
;
}
}
#if (WINVER >= 0x0602) // Available since Win 8
if
(
met
==
MEVideoCaptureDeviceRemoved
)
if
(
met
==
MEVideoCaptureDeviceRemoved
)
{
{
DebugPrintOut
(
L"IMAGEGRABBER VIDEODEVICE %i: MEVideoCaptureDeviceRemoved
\n
"
,
ig_DeviceID
);
DebugPrintOut
(
L"IMAGEGRABBER VIDEODEVICE %i: MEVideoCaptureDeviceRemoved
\n
"
,
ig_DeviceID
);
break
;
break
;
}
}
#endif
if
((
met
==
MEError
)
||
(
met
==
MENonFatalError
))
if
((
met
==
MEError
)
||
(
met
==
MENonFatalError
))
{
{
pEvent
->
GetStatus
(
&
hrStatus
);
pEvent
->
GetStatus
(
&
hrStatus
);
...
@@ -2455,7 +2459,7 @@ int videoDevice::findType(unsigned int size, unsigned int frameRate)
...
@@ -2455,7 +2459,7 @@ int videoDevice::findType(unsigned int size, unsigned int frameRate)
fmt
=
vd_CaptureFormats
.
find
(
size
);
fmt
=
vd_CaptureFormats
.
find
(
size
);
if
(
fmt
!=
vd_CaptureFormats
.
end
()
)
if
(
fmt
!=
vd_CaptureFormats
.
end
()
)
FRM
=
fmt
->
second
;
FRM
=
fmt
->
second
;
else
else
if
(
!
vd_CaptureFormats
.
empty
()
)
FRM
=
vd_CaptureFormats
.
rbegin
()
->
second
;
FRM
=
vd_CaptureFormats
.
rbegin
()
->
second
;
if
(
FRM
.
empty
()
)
if
(
FRM
.
empty
()
)
...
@@ -3844,18 +3848,25 @@ bool CvCaptureFile_MSMF::open(const char* filename)
...
@@ -3844,18 +3848,25 @@ bool CvCaptureFile_MSMF::open(const char* filename)
hr
=
enumerateCaptureFormats
(
videoFileSource
);
hr
=
enumerateCaptureFormats
(
videoFileSource
);
}
}
if
(
SUCCEEDED
(
hr
)
)
if
(
captureFormats
.
empty
()
)
{
{
hr
=
ImageGrabberThread
::
CreateInstance
(
&
grabberThread
,
videoFileSource
,
(
unsigned
int
)
-
2
,
true
)
;
isOpened
=
false
;
}
}
else
{
if
(
SUCCEEDED
(
hr
))
{
hr
=
ImageGrabberThread
::
CreateInstance
(
&
grabberThread
,
videoFileSource
,
(
unsigned
int
)
-
2
,
true
);
}
if
(
SUCCEEDED
(
hr
))
isOpened
=
SUCCEEDED
(
hr
);
}
if
(
isOpened
)
{
{
grabberThread
->
start
();
grabberThread
->
start
();
}
}
isOpened
=
SUCCEEDED
(
hr
);
return
isOpened
;
return
isOpened
;
}
}
...
@@ -3987,7 +3998,9 @@ HRESULT CvCaptureFile_MSMF::enumerateCaptureFormats(IMFMediaSource *pSource)
...
@@ -3987,7 +3998,9 @@ HRESULT CvCaptureFile_MSMF::enumerateCaptureFormats(IMFMediaSource *pSource)
goto
done
;
goto
done
;
}
}
MediaType
MT
=
FormatReader
::
Read
(
pType
.
Get
());
MediaType
MT
=
FormatReader
::
Read
(
pType
.
Get
());
captureFormats
.
push_back
(
MT
);
// We can capture only RGB video.
if
(
MT
.
MF_MT_SUBTYPE
==
MFVideoFormat_RGB24
)
captureFormats
.
push_back
(
MT
);
}
}
done
:
done
:
...
@@ -4112,7 +4125,7 @@ const GUID CvVideoWriter_MSMF::FourCC2GUID(int fourcc)
...
@@ -4112,7 +4125,7 @@ const GUID CvVideoWriter_MSMF::FourCC2GUID(int fourcc)
return
MFVideoFormat_DVSD
;
break
;
return
MFVideoFormat_DVSD
;
break
;
case
CV_FOURCC_MACRO
(
'd'
,
'v'
,
's'
,
'l'
):
case
CV_FOURCC_MACRO
(
'd'
,
'v'
,
's'
,
'l'
):
return
MFVideoFormat_DVSL
;
break
;
return
MFVideoFormat_DVSL
;
break
;
#if (WINVER >=
_WIN32_WINNT_WIN8
)
#if (WINVER >=
0x0602
)
case
CV_FOURCC_MACRO
(
'H'
,
'2'
,
'6'
,
'3'
):
// Available only for Win 8 target.
case
CV_FOURCC_MACRO
(
'H'
,
'2'
,
'6'
,
'3'
):
// Available only for Win 8 target.
return
MFVideoFormat_H263
;
break
;
return
MFVideoFormat_H263
;
break
;
#endif
#endif
...
...
modules/videoio/src/cap_msmf.hpp
View file @
01a883df
...
@@ -333,6 +333,7 @@ MAKE_ENUM(MediaEventType) MediaEventTypePairs[] = {
...
@@ -333,6 +333,7 @@ MAKE_ENUM(MediaEventType) MediaEventTypePairs[] = {
MAKE_ENUM_PAIR
(
MediaEventType
,
MEAudioSessionDisconnected
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MEAudioSessionDisconnected
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MEAudioSessionExclusiveModeOverride
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MEAudioSessionExclusiveModeOverride
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MESinkV1Anchor
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MESinkV1Anchor
),
#if (WINVER >= 0x0602) // Available since Win 8
MAKE_ENUM_PAIR
(
MediaEventType
,
MECaptureAudioSessionVolumeChanged
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MECaptureAudioSessionVolumeChanged
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MECaptureAudioSessionDeviceRemoved
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MECaptureAudioSessionDeviceRemoved
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MECaptureAudioSessionFormatChanged
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MECaptureAudioSessionFormatChanged
),
...
@@ -340,6 +341,7 @@ MAKE_ENUM(MediaEventType) MediaEventTypePairs[] = {
...
@@ -340,6 +341,7 @@ MAKE_ENUM(MediaEventType) MediaEventTypePairs[] = {
MAKE_ENUM_PAIR
(
MediaEventType
,
MECaptureAudioSessionExclusiveModeOverride
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MECaptureAudioSessionExclusiveModeOverride
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MECaptureAudioSessionServerShutdown
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MECaptureAudioSessionServerShutdown
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MESinkV2Anchor
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MESinkV2Anchor
),
#endif
MAKE_ENUM_PAIR
(
MediaEventType
,
METrustUnknown
),
MAKE_ENUM_PAIR
(
MediaEventType
,
METrustUnknown
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MEPolicyChanged
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MEPolicyChanged
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MEContentProtectionMessage
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MEContentProtectionMessage
),
...
@@ -361,9 +363,11 @@ MAKE_ENUM(MediaEventType) MediaEventTypePairs[] = {
...
@@ -361,9 +363,11 @@ MAKE_ENUM(MediaEventType) MediaEventTypePairs[] = {
MAKE_ENUM_PAIR
(
MediaEventType
,
METransformHaveOutput
),
MAKE_ENUM_PAIR
(
MediaEventType
,
METransformHaveOutput
),
MAKE_ENUM_PAIR
(
MediaEventType
,
METransformDrainComplete
),
MAKE_ENUM_PAIR
(
MediaEventType
,
METransformDrainComplete
),
MAKE_ENUM_PAIR
(
MediaEventType
,
METransformMarker
),
MAKE_ENUM_PAIR
(
MediaEventType
,
METransformMarker
),
#if (WINVER >= 0x0602) // Available since Win 8
MAKE_ENUM_PAIR
(
MediaEventType
,
MEByteStreamCharacteristicsChanged
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MEByteStreamCharacteristicsChanged
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MEVideoCaptureDeviceRemoved
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MEVideoCaptureDeviceRemoved
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MEVideoCaptureDevicePreempted
),
MAKE_ENUM_PAIR
(
MediaEventType
,
MEVideoCaptureDevicePreempted
),
#endif
MAKE_ENUM_PAIR
(
MediaEventType
,
MEReservedMax
)
MAKE_ENUM_PAIR
(
MediaEventType
,
MEReservedMax
)
};
};
MAKE_MAP
(
MediaEventType
)
MediaEventTypeMap
(
MediaEventTypePairs
,
MediaEventTypePairs
+
sizeof
(
MediaEventTypePairs
)
/
sizeof
(
MediaEventTypePairs
[
0
]));
MAKE_MAP
(
MediaEventType
)
MediaEventTypeMap
(
MediaEventTypePairs
,
MediaEventTypePairs
+
sizeof
(
MediaEventTypePairs
)
/
sizeof
(
MediaEventTypePairs
[
0
]));
...
@@ -1044,7 +1048,11 @@ class StreamSink :
...
@@ -1044,7 +1048,11 @@ class StreamSink :
{
{
public
:
public
:
// IUnknown methods
// IUnknown methods
#if defined(_MSC_VER) && _MSC_VER >= 1700 // '_Outptr_result_nullonfailure_' SAL is avaialable since VS 2012
STDMETHOD
(
QueryInterface
)(
REFIID
riid
,
_Outptr_result_nullonfailure_
void
**
ppv
)
STDMETHOD
(
QueryInterface
)(
REFIID
riid
,
_Outptr_result_nullonfailure_
void
**
ppv
)
#else
STDMETHOD
(
QueryInterface
)(
REFIID
riid
,
void
**
ppv
)
#endif
{
{
if
(
ppv
==
nullptr
)
{
if
(
ppv
==
nullptr
)
{
return
E_POINTER
;
return
E_POINTER
;
...
@@ -2383,7 +2391,11 @@ public:
...
@@ -2383,7 +2391,11 @@ public:
}
}
return
cRef
;
return
cRef
;
}
}
#if defined(_MSC_VER) && _MSC_VER >= 1700 // '_Outptr_result_nullonfailure_' SAL is avaialable since VS 2012
STDMETHOD
(
QueryInterface
)(
REFIID
riid
,
_Outptr_result_nullonfailure_
void
**
ppv
)
STDMETHOD
(
QueryInterface
)(
REFIID
riid
,
_Outptr_result_nullonfailure_
void
**
ppv
)
#else
STDMETHOD
(
QueryInterface
)(
REFIID
riid
,
void
**
ppv
)
#endif
{
{
if
(
ppv
==
nullptr
)
{
if
(
ppv
==
nullptr
)
{
return
E_POINTER
;
return
E_POINTER
;
...
...
Write
Preview
Markdown
is supported
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