Commit ff0aaa6b authored by Ghislain MARY's avatar Ghislain MARY

Add V4L support when building with CMake.

parent 33cce2e7
......@@ -78,6 +78,7 @@ option(ENABLE_VIDEO "Build mediastreamer2 with video support." YES)
cmake_dependent_option(ENABLE_FFMPEG "Build mediastreamer2 with ffmpeg video support." YES "ENABLE_VIDEO" NO)
cmake_dependent_option(ENABLE_GLX "Enable X11+OpenGL rendering support (requires glx and glew)." ${ENABLE_GLX_DEFAULT_VALUE} "ENABLE_VIDEO;UNIX" NO)
cmake_dependent_option(ENABLE_SDL "Enable SDL support." NO "ENABLE_FFMPEG" NO)
cmake_dependent_option(ENABLE_V4L "Enable Video4Linux support." YES "ENABLE_VIDEO;LINUX_OR_BSD" NO)
cmake_dependent_option(ENABLE_X11 "Enable X11 support." ${ENABLE_X11_DEFAULT_VALUE} "ENABLE_FFMPEG;UNIX" NO)
cmake_dependent_option(ENABLE_XV "Enable XV support." ${ENABLE_X11_DEFAULT_VALUE} "ENABLE_FFMPEG;UNIX" NO)
cmake_dependent_option(ENABLE_THEORA "Enable theora video codec support." YES "ENABLE_VIDEO" NO)
......@@ -180,6 +181,12 @@ if(ENABLE_FFMPEG)
else()
add_definitions(-DNO_FFMPEG)
endif()
if(ENABLE_V4L)
find_package(V4L)
if(NOT V4L_FOUND)
message(FATAL_ERROR "Missing V4L. It is highly recommended to build with libv4l2 headers and library. Many camera will won't work or will crash your application if libv4l2 is not installed. If you know what you are doing, you can use -DENABLE_V4L=0 to disable this check.")
endif()
endif()
if(ENABLE_X11)
find_package(X11)
if(NOT X11_FOUND)
......@@ -254,6 +261,9 @@ endif()
if(FFMPEG_FOUND)
include_directories(${FFMPEG_INCLUDE_DIRS})
endif()
if(V4L_FOUND)
include_directories(${V4L_INCLUDE_DIRS})
endif()
if(X11_FOUND)
include_directories(${X11_INCLUDE_DIRS})
endif()
......
############################################################################
# FindV4L.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
#
# - Find the V4L include file and library
#
# V4L_FOUND - system has V4L
# V4L_INCLUDE_DIRS - the V4L include directory
# V4L_LIBRARIES - The libraries needed to use V4L
set(_V4L_ROOT_PATHS
${WITH_V4L}
${CMAKE_INSTALL_PREFIX}
)
find_path(V4L1_INCLUDE_DIRS
NAMES linux/videodev.h
HINTS _V4L_ROOT_PATHS
PATH_SUFFIXES include
)
if(V4L1_INCLUDE_DIRS)
set(HAVE_LINUX_VIDEODEV_H 1)
endif()
find_path(V4L2_INCLUDE_DIRS
NAMES linux/videodev2.h
HINTS _V4L_ROOT_PATHS
PATH_SUFFIXES include
)
if(V4L2_INCLUDE_DIRS)
set(HAVE_LINUX_VIDEODEV2_H 1)
endif()
find_library(V4L1_LIBRARIES
NAMES v4l1
HINTS _V4L_ROOT_PATHS
PATH_SUFFIXES bin lib
)
find_library(V4L2_LIBRARIES
NAMES v4l2
HINTS _V4L_ROOT_PATHS
PATH_SUFFIXES bin lib
)
find_library(V4LCONVERT_LIBRARIES
NAMES v4lconvert
HINTS _V4L_ROOT_PATHS
PATH_SUFFIXES bin lib
)
set(V4L_INCLUDE_DIRS )
if(V4L1_INCLUDE_DIRS})
list(APPEND V4L_INCLUDE_DIRS ${V4L1_INCLUDE_DIRS})
endif()
if(V4L2_INCLUDE_DIRS)
list(APPEND V4L_INCLUDE_DIRS ${V4L2_INCLUDE_DIRS})
endif()
set(V4L_LIBRARIES )
if(V4L1_LIBRARIES)
list(APPEND V4L_LIBRARIES ${V4L1_LIBRARIES})
endif()
if(V4L2_LIBRARIES)
list(APPEND V4L_LIBRARIES ${V4L2_LIBRARIES})
endif()
if(V4LCONVERT_LIBRARIES)
list(APPEND V4L_LIBRARIES ${V4LCONVERT_LIBRARIES})
endif()
list(REMOVE_DUPLICATES V4L_INCLUDE_DIRS)
list(REMOVE_DUPLICATES V4L_LIBRARIES)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(V4L
DEFAULT_MSG
V4L_INCLUDE_DIRS V4L_LIBRARIES
)
mark_as_advanced(V4L_INCLUDE_DIRS V4L_LIBRARIES)
......@@ -259,6 +259,14 @@ if(ENABLE_VIDEO)
if(THEORA_FOUND)
list(APPEND VOIP_SOURCE_FILES videofilters/theora.c)
endif()
if(V4L_FOUND)
if(HAVE_LINUX_VIDEODEV_H)
list(APPEND VOIP_SOURCE_FILES videofilters/msv4l.c)
endif()
if(HAVE_LINUX_VIDEODEV2_H)
list(APPEND VOIP_SOURCE_FILES videofilters/msv4l2.c)
endif()
endif()
if(VPX_FOUND)
list(APPEND VOIP_SOURCE_FILES
videofilters/vp8.c
......@@ -305,7 +313,7 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yuv2rgb.vs.h
-DINPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
-DSOURCE_FILE="yuv2rgb.vs"
-P ${CMAKE_CURRENT_SOURCE_DIR}/generate_yuv2rgb_header.cmake)
endif(UNIX)
endif()
set_source_files_properties(${VOIP_GENERATED_SOURCE_FILES} PROPERTIES GENERATED TRUE)
......@@ -357,6 +365,9 @@ if(FFMPEG_FOUND)
add_definitions(-Dinline=__inline)
endif()
endif()
if(V4L_FOUND)
list(APPEND VOIP_LIBS ${V4L_LIBRARIES})
endif()
if(X11_FOUND)
list(APPEND VOIP_LIBS ${X11_LIBRARIES})
endif()
......
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