mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
Gstreamer 1.0 on windows.
This commit is contained in:
parent
8e67f0ba84
commit
46ec9c386b
@ -169,7 +169,7 @@ OCV_OPTION(WITH_NVCUVID "Include NVidia Video Decoding library support"
|
||||
OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" ON IF (NOT WINRT) )
|
||||
OCV_OPTION(WITH_VFW "Include Video for Windows support" ON IF WIN32 )
|
||||
OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (NOT ANDROID) )
|
||||
OCV_OPTION(WITH_GSTREAMER_0_10 "Enable Gstreamer 0.10 support (instead of 1.x)" OFF )
|
||||
OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_GTK_2_X "Use GTK version 2" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
|
139
cmake/FindGstreamerWindows.cmake
Normal file
139
cmake/FindGstreamerWindows.cmake
Normal file
@ -0,0 +1,139 @@
|
||||
FILE(TO_CMAKE_PATH "$ENV{GSTREAMER_DIR}" TRY1_DIR)
|
||||
FILE(TO_CMAKE_PATH "${GSTREAMER_DIR}" TRY2_DIR)
|
||||
FILE(GLOB GSTREAMER_DIR ${TRY1_DIR} ${TRY2_DIR})
|
||||
|
||||
FIND_PATH(GSTREAMER_gst_INCLUDE_DIR gst/gst.h
|
||||
PATHS ${GSTREAMER_DIR}/include/gstreamer-1.0 ${GSTREAMER_DIR}/include /usr/local/include/gstreamer-1.0 /usr/include/gstreamer-1.0
|
||||
ENV INCLUDE DOC "Directory containing gst/gst.h include file")
|
||||
|
||||
FIND_PATH(GSTREAMER_glib_INCLUDE_DIR glib.h
|
||||
PATHS ${GSTREAMER_DIR}/include/glib-2.0/
|
||||
ENV INCLUDE DOC "Directory containing glib.h include file")
|
||||
|
||||
FIND_PATH(GSTREAMER_glibconfig_INCLUDE_DIR glibconfig.h
|
||||
PATHS ${GSTREAMER_DIR}/lib/glib-2.0/include
|
||||
ENV INCLUDE DOC "Directory containing glibconfig.h include file")
|
||||
|
||||
FIND_PATH(GSTREAMER_gstconfig_INCLUDE_DIR gst/gstconfig.h
|
||||
PATHS ${GSTREAMER_DIR}/lib/gstreamer-1.0/include ${GSTREAMER_DIR}/include ${GSTREAMER_DIR}/lib/include /usr/local/include/gstreamer-1.0 /usr/include/gstreamer-1.0 /usr/local/lib/include/gstreamer-1.0 /usr/lib/include/gstreamer-1.0
|
||||
ENV INCLUDE DOC "Directory containing gst/gstconfig.h include file")
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstaudio_LIBRARY NAMES gstaudio libgstaudio-1.0 gstaudio-1.0
|
||||
PATHS ${GSTREMAER_DIR}/lib ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstaudio library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstapp_LIBRARY NAMES gstapp libgstapp-1.0 gstapp-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstapp library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstbase_LIBRARY NAMES gstbase libgstbase-1.0 gstbase-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstbase library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GLIB_gstcdda_LIBRARY NAMES gstcdda libgstcdda-1.0 gstcdda-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstcdda library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstcontroller_LIBRARY NAMES gstcontroller libgstcontroller-1.0 gstcontroller-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstcontroller library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstnet_LIBRARY NAMES gstnet libgstnet-1.0 gstnet-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstnet library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstpbutils_LIBRARY NAMES gstpbutils libgstpbutils-1.0 gstpbutils-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstpbutils library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstreamer_LIBRARY NAMES gstreamer libgstreamer-1.0 gstreamer-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstreamer library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstriff_LIBRARY NAMES gstriff libgstriff-1.0 gstriff-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstriff library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstrtp_LIBRARY NAMES gstrtp libgstrtp-1.0 gstrtp-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstrtp library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstrtsp_LIBRARY NAMES gstrtsp libgstrtsp-1.0 gstrtsp-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstrtsp library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstsdp_LIBRARY NAMES gstsdp libgstsdp-1.0 gstsdp-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstsdp library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gsttag_LIBRARY NAMES gsttag libgsttag-1.0 gsttag-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gsttag library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GSTREAMER_gstvideo_LIBRARY NAMES gstvideo libgstvideo-1.0 gstvideo-1.0
|
||||
PATHS ${GSTREAMER_DIR}/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/bin ${GSTREAMER_DIR}/bin/bin C:/gstreamer/bin ${GSTREAMER_DIR}/lib ${GSTREAMER_DIR}/win32/lib /usr/local/lib /usr/lib
|
||||
ENV LIB
|
||||
DOC "gstvideo library to link with"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GLIB_LIBRARY NAMES libglib-2.0 glib-2.0
|
||||
PATHS ${GSTREAMER_DIR}/lib
|
||||
ENV LIB
|
||||
DOC "Glib library"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
FIND_LIBRARY(GOBJECT_LIBRARY NAMES libobject-2.0 gobject-2.0
|
||||
PATHS ${GSTREAMER_DIR}/lib
|
||||
ENV LIB
|
||||
DOC "Glib library"
|
||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||
|
||||
IF (GSTREAMER_gst_INCLUDE_DIR AND GSTREAMER_gstconfig_INCLUDE_DIR AND
|
||||
GSTREAMER_gstaudio_LIBRARY AND GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstcontroller_LIBRARY AND GSTREAMER_gstnet_LIBRARY
|
||||
AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstreamer_LIBRARY AND
|
||||
GSTREAMER_gstriff_LIBRARY AND GSTREAMER_gstrtp_LIBRARY AND GSTREAMER_gstrtsp_LIBRARY AND GSTREAMER_gstsdp_LIBRARY AND
|
||||
GSTREAMER_gsttag_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GLIB_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GOBJECT_LIBRARY)
|
||||
SET(GSTREAMER_INCLUDE_DIR ${GSTREAMER_gst_INCLUDE_DIR} ${GSTREAMER_gstconfig_INCLUDE_DIR} ${GSTREAMER_glib_INCLUDE_DIR} ${GSTREAMER_glibconfig_INCLUDE_DIR})
|
||||
|
||||
list(REMOVE_DUPLICATES GSTREAMER_INCLUDE_DIR)
|
||||
SET(GSTREAMER_LIBRARIES ${GSTREAMER_gstaudio_LIBRARY} ${GSTREAMER_gstbase_LIBRARY}
|
||||
${GSTREAMER_gstcontroller_LIBRARY} ${GSTREAMER_gstdataprotocol_LIBRARY} ${GSTREAMER_gstinterfaces_LIBRARY}
|
||||
${GSTREAMER_gstnet_LIBRARY} ${GSTREAMER_gstpbutils_LIBRARY}
|
||||
${GSTREAMER_gstreamer_LIBRARY} ${GSTREAMER_gstriff_LIBRARY} ${GSTREAMER_gstrtp_LIBRARY}
|
||||
${GSTREAMER_gstrtsp_LIBRARY} ${GSTREAMER_gstsdp_LIBRARY} ${GSTREAMER_gsttag_LIBRARY} ${GSTREAMER_gstvideo_LIBRARY} ${GLIB_LIBRARY}
|
||||
${GSTREAMER_gstapp_LIBRARY} ${GOBJECT_LIBRARY})
|
||||
|
||||
list(REMOVE_DUPLICATES GSTREAMER_LIBRARIES)
|
||||
SET(GSTREAMER_FOUND TRUE)
|
||||
ENDIF (GSTREAMER_gst_INCLUDE_DIR AND GSTREAMER_gstconfig_INCLUDE_DIR AND
|
||||
GSTREAMER_gstaudio_LIBRARY AND GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstcontroller_LIBRARY
|
||||
AND GSTREAMER_gstnet_LIBRARY AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstreamer_LIBRARY AND
|
||||
GSTREAMER_gstriff_LIBRARY AND GSTREAMER_gstrtp_LIBRARY AND GSTREAMER_gstrtsp_LIBRARY AND GSTREAMER_gstsdp_LIBRARY AND
|
||||
GSTREAMER_gsttag_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GLIB_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GOBJECT_LIBRARY)
|
@ -14,22 +14,35 @@ endif(WITH_VFW)
|
||||
ocv_clear_vars(HAVE_GSTREAMER)
|
||||
# try to find gstreamer 1.x first if 0.10 was not requested
|
||||
if(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
|
||||
CHECK_MODULE(gstreamer-base-1.0 HAVE_GSTREAMER_BASE)
|
||||
CHECK_MODULE(gstreamer-video-1.0 HAVE_GSTREAMER_VIDEO)
|
||||
CHECK_MODULE(gstreamer-app-1.0 HAVE_GSTREAMER_APP)
|
||||
CHECK_MODULE(gstreamer-riff-1.0 HAVE_GSTREAMER_RIFF)
|
||||
CHECK_MODULE(gstreamer-pbutils-1.0 HAVE_GSTREAMER_PBUTILS)
|
||||
if(WIN32)
|
||||
SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_LIST_DIR}")
|
||||
FIND_PACKAGE(GstreamerWindows)
|
||||
IF(GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstriff_LIBRARY)
|
||||
set(HAVE_GSTREAMER TRUE)
|
||||
set(GSTREAMER_BASE_VERSION 1.0)
|
||||
set(GSTREAMER_VIDEO_VERSION 1.0)
|
||||
set(GSTREAMER_APP_VERSION 1.0)
|
||||
set(GSTREAMER_RIFF_VERSION 1.0)
|
||||
set(GSTREAMER_PBUTILS_VERSION 1.0)
|
||||
ENDIF(GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstriff_LIBRARY)
|
||||
|
||||
if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
|
||||
else(WIN32)
|
||||
CHECK_MODULE(gstreamer-base-1.0 HAVE_GSTREAMER_BASE)
|
||||
CHECK_MODULE(gstreamer-video-1.0 HAVE_GSTREAMER_VIDEO)
|
||||
CHECK_MODULE(gstreamer-app-1.0 HAVE_GSTREAMER_APP)
|
||||
CHECK_MODULE(gstreamer-riff-1.0 HAVE_GSTREAMER_RIFF)
|
||||
CHECK_MODULE(gstreamer-pbutils-1.0 HAVE_GSTREAMER_PBUTILS)
|
||||
|
||||
if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
|
||||
set(HAVE_GSTREAMER TRUE)
|
||||
set(GSTREAMER_BASE_VERSION ${ALIASOF_gstreamer-base-1.0_VERSION})
|
||||
set(GSTREAMER_VIDEO_VERSION ${ALIASOF_gstreamer-video-1.0_VERSION})
|
||||
set(GSTREAMER_APP_VERSION ${ALIASOF_gstreamer-app-1.0_VERSION})
|
||||
set(GSTREAMER_RIFF_VERSION ${ALIASOF_gstreamer-riff-1.0_VERSION})
|
||||
set(GSTREAMER_PBUTILS_VERSION ${ALIASOF_gstreamer-pbutils-1.0_VERSION})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endif()
|
||||
endif(WIN32)
|
||||
endif(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
|
||||
|
||||
# if gstreamer 1.x was not found, or we specified we wanted 0.10, try to find it
|
||||
if(WITH_GSTREAMER AND NOT HAVE_GSTREAMER OR WITH_GSTREAMER_0_10)
|
||||
|
@ -92,6 +92,10 @@ if(HAVE_DC1394)
|
||||
endif(HAVE_DC1394)
|
||||
|
||||
if(HAVE_GSTREAMER)
|
||||
IF(WIN32)
|
||||
INCLUDE_DIRECTORIES(${GSTREAMER_INCLUDE_DIR})
|
||||
list(APPEND VIDEOIO_LIBRARIES ${GSTREAMER_LIBRARIES})
|
||||
ENDIF(WIN32)
|
||||
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_gstreamer.cpp)
|
||||
endif(HAVE_GSTREAMER)
|
||||
|
||||
|
@ -48,7 +48,9 @@
|
||||
* \brief Use GStreamer to read/write video
|
||||
*/
|
||||
#include "precomp.hpp"
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/gstbuffer.h>
|
||||
@ -84,6 +86,14 @@
|
||||
#define COLOR_ELEM_NAME COLOR_ELEM
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
void toFraction(double decimal, double &numerator, double &denominator);
|
||||
void handleMessage(GstElement * pipeline);
|
||||
|
||||
@ -590,9 +600,20 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
|
||||
// else, we might have a file or a manual pipeline.
|
||||
// if gstreamer cannot parse the manual pipeline, we assume we were given and
|
||||
// ordinary file path.
|
||||
if(!gst_uri_is_valid(filename))
|
||||
if (!gst_uri_is_valid(filename))
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
uri = new char[2048];
|
||||
DWORD pathSize = GetFullPathName(filename, 2048, uri, NULL);
|
||||
struct stat buf;
|
||||
if (pathSize == 0 || stat(uri, &buf) != 0)
|
||||
{
|
||||
delete uri;
|
||||
uri = NULL;
|
||||
}
|
||||
#else
|
||||
uri = realpath(filename, NULL);
|
||||
#endif
|
||||
stream = false;
|
||||
if(uri)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user