Add a GStreamer element that provides a video sink that draws directly on QWidget.
[qtgstreamer:qtgstreamer.git] / cmake / modules / FindGStreamerPlugins.cmake
1 # - Try to find GStreamer_Plugins
2 # Once done this will define
3 #
4 #  GSTREAMERPLUGINSBASE_FOUND - system has GStreamer_Plugins
5 #  GSTREAMERPLUGINSBASE_INCLUDE_DIRS - the GStreamer_Plugins include directories
6 #  GSTREAMERPLUGINSBASE_LIBRARIES - the libraries needed to use GStreamer_Plugins
7 #
8 # The following variables are set for each plugin PLUGINNAME:
9 #
10 #  GSTREAMER_PLUGIN_PLUGINNAME_FOUND - plugin is found
11 #  GSTREAMER_PLUGIN_PLUGINNAME_INCLUDE_DIR - plugin include directory
12 #  GSTREAMER_PLUGIN_PLUGINNAME_LIBRARY - the library needed to use plugin
13 #
14 #  (c)2009 Nokia Corporation
15 #  (c)2010 Yury G. Kudryashov <urkud@ya.ru>
16
17 FIND_PACKAGE(PkgConfig REQUIRED)
18
19 IF (NOT WIN32)
20    # don't make this check required - otherwise you can't use macro_optional_find_package on this one
21    PKG_CHECK_MODULES( PKG_GSTREAMER_PLUGINSBASE gstreamer-plugins-base-0.10 )
22 ENDIF (NOT WIN32)
23
24 MACRO(MACRO_FIND_GSTREAMER_PLUGIN _plugin _header)
25    STRING(TOUPPER ${_plugin} _upper)
26    IF (NOT WIN32)
27       # don't make this check required - otherwise you can't use macro_optional_find_package on this one
28       PKG_CHECK_MODULES( PKG_GSTREAMER_${_upper} gstreamer-${_plugin}-0.10 )
29    ENDIF (NOT WIN32)
30
31    FIND_LIBRARY(GSTREAMER_PLUGIN_${_upper}_LIBRARY NAMES gst${_plugin}-0.10
32       PATHS
33       ${PKG_GSTREAMER_PLUGINSBASE_LIBRARY_DIRS}
34       ${PKG_GSTREAMER_${_upper}_LIBRARY_DIRS}
35       )
36
37    FIND_PATH(GSTREAMER_PLUGIN_${_upper}_INCLUDE_DIR
38        NAMES gst/${_plugin}/${_header}
39        PATHS
40        ${PKG_GSTREAMER_PLUGINSBASE_INCLUDE_DIRS}
41        ${PKG_GSTREAMER_${_upper}_INCLUDE_DIRS}
42        )
43
44    IF(GSTREAMER_PLUGIN_${_upper}_LIBRARY AND GSTREAMER_PLUGIN_${_upper}_INCLUDE_DIR)
45       SET(GSTREAMER_PLUGIN_${_upper}_FOUND TRUE)
46       LIST(APPEND GSTREAMERPLUGINSBASE_INCLUDE_DIRS GSTREAMER_${_upper}_INCLUDE_DIR)
47       LIST(APPEND GSTREAMERPLUGINSBASE_LIBRARIES GSTREAMER_${_upper}_LIBRARY)
48    ELSE(GSTREAMER_PLUGIN_${_upper}_LIBRARY AND GSTREAMER_PLUGIN_${_upper}_INCLUDE_DIR)
49       MESSAGE(STATUS "Could not find ${_plugin} plugin")
50       MESSAGE(STATUS "${_upper} library: ${GSTREAMER_${_upper}_LIBRARY}")
51       MESSAGE(STATUS "${_upper} include dir: ${GSTREAMER_${_upper}_INCLUDE_DIR}")
52       SET(GSTREAMER_PLUGIN_${_upper}_FOUND FALSE)
53       SET(GSTREAMER_PLUGIN_${_upper}_LIBRARY GSTREAMER_${_upper}_LIBRARY-NOTFOUND)
54       SET(GSTREAMER_PLUGIN_${_upper}_INCLUDE_DIR GSTREAMER_${_upper}_INCLUDE_DIR-NOTFOUND)
55       SET(GSTREAMERPLUGINSBASE_FOUND FALSE)
56    ENDIF(GSTREAMER_PLUGIN_${_upper}_LIBRARY AND GSTREAMER_PLUGIN_${_upper}_INCLUDE_DIR)
57
58    MARK_AS_ADVANCED(GSTREAMER_PLUGIN_${_upper}_LIBRARY
59       GSTREAMER_PLUGIN_${_upper}_INCLUDE_DIR)
60 ENDMACRO(MACRO_FIND_GSTREAMER_PLUGIN)
61
62 #
63 # Base plugins:
64 #  audio
65 #  cdda
66 #  netbuffer
67 #  pbutils
68 #  riff
69 #  rtp
70 #  rtsp
71 #  sdp
72 #  tag
73 #  video
74 #
75 # The gstinterfaces-0.10 library is found by FindGStreamer.cmake
76 #
77
78 SET(GSTREAMER_PLUGINSBASE_FOUND TRUE)
79 MACRO_FIND_GSTREAMER_PLUGIN(audio audio.h)
80 MACRO_FIND_GSTREAMER_PLUGIN(cdda gstcddabasesrc.h)
81 MACRO_FIND_GSTREAMER_PLUGIN(netbuffer gstnetbuffer.h)
82 MACRO_FIND_GSTREAMER_PLUGIN(pbutils pbutils.h)
83 MACRO_FIND_GSTREAMER_PLUGIN(riff riff-ids.h)
84 MACRO_FIND_GSTREAMER_PLUGIN(rtp gstrtpbuffer.h)
85 MACRO_FIND_GSTREAMER_PLUGIN(rtsp gstrtspdefs.h)
86 MACRO_FIND_GSTREAMER_PLUGIN(sdp gstsdp.h)
87 MACRO_FIND_GSTREAMER_PLUGIN(tag tag.h)
88 MACRO_FIND_GSTREAMER_PLUGIN(video video.h)
89
90 IF (GSTREAMERPLUGINSBASE_FOUND)
91    LIST(REMOVE_DUPLICATES GSTREAMERPLUGINSBASE_LIBRARIES)
92    LIST(REMOVE_DUPLICATES GSTREAMERPLUGINSBASE_INCLUDE_DIRS)
93    IF (NOT GStreamer_Plugins_FIND_QUIETLY)
94       MESSAGE(STATUS "Found GStreamer Plugins:
95     ${GSTREAMER_PLUGIN_AUDIO_LIBRARIES}
96     ${GSTREAMER_PLUGIN_CDDA_LIBRARIES}
97     ${GSTREAMER_PLUGIN_NETBUFFER_LIBRARIES}
98     ${GSTREAMER_PLUGIN_PBUTILS_LIBRARIES}
99     ${GSTREAMER_PLUGIN_RIFF_LIBRARIES}
100     ${GSTREAMER_PLUGIN_RTP_LIBRARIES}
101     ${GSTREAMER_PLUGIN_RTSP_LIBRARIES}
102     ${GSTREAMER_PLUGIN_SDP_LIBRARIES}
103     ${GSTREAMER_PLUGIN_TAG_LIBRARIES}
104     ${GSTREAMER_PLUGIN_VIDEO_LIBRARIES}")
105    ENDIF (NOT GStreamer_Plugins_FIND_QUIETLY)
106 ELSE (GSTREAMERPLUGINSBASE_FOUND)
107    SET(GSTREAMERPLUGINSBASE_LIBRARIES GSTREAMERPLUGINSBASE_LIBRARIES-NOTFOUND)
108    SET(GSTREAMERPLUGINSBASE_INCLUDE_DIRS GSTREAMERPLUGINSBASE_INCLUDE_DIRS-NOTFOUND)
109    IF (GStreamer_Plugins_FIND_REQUIRED)
110       MESSAGE(SEND_ERROR "Could NOT find GStreamer Plugins")
111    ENDIF (GStreamer_Plugins_FIND_REQUIRED)
112 ENDIF (GSTREAMERPLUGINSBASE_FOUND)