FindFFMPEG.cmake (used only for frontend for now).
authorStepan777 <stepik-777@mail.ru>
Thu, 09 Aug 2012 01:24:38 +0400
changeset 7528 f8cf277dca36
parent 7525 5c840e221993
child 7531 0adcad8714c4
FindFFMPEG.cmake (used only for frontend for now). +fix for linux (older version of Qt)
QTfrontend/CMakeLists.txt
QTfrontend/ui/dialog/upload_video.cpp
QTfrontend/util/libav_iteraction.cpp
cmake_modules/FindFFMPEG.cmake
hedgewars/CMakeLists.txt
--- a/QTfrontend/CMakeLists.txt	Thu Aug 09 01:01:06 2012 +0400
+++ b/QTfrontend/CMakeLists.txt	Thu Aug 09 01:24:38 2012 +0400
@@ -28,6 +28,7 @@
 # Configure for SDL
 find_package(SDL REQUIRED)
 find_package(SDL_mixer REQUIRED)
+find_package(FFMPEG REQUIRED)
 
 include_directories(.)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/model)
@@ -39,6 +40,7 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util)
 include_directories(${SDL_INCLUDE_DIR})
 include_directories(${SDLMIXER_INCLUDE_DIR})
+include_directories(${FFMPEG_INCLUDE_DIR})
 include_directories(${CMAKE_SOURCE_DIR}/misc/quazip)
 if(UNIX)
     # HACK: in freebsd cannot find iconv.h included via SDL.h
@@ -156,9 +158,6 @@
     endif()
 endif()
 
-IF (WIN32)
-    link_directories(${CMAKE_SOURCE_DIR}/misc/winutils/lib)
-ENDIF()
 
 add_executable(hedgewars WIN32
     ${hwfr_src}
@@ -170,12 +169,10 @@
 
 set(HW_LINK_LIBS
     quazip
-    avformat
-    avcodec
-    avutil
     ${QT_LIBRARIES}
     ${SDL_LIBRARY}
     ${SDLMIXER_LIBRARY}
+    ${FFMPEG_LIBRARIES}
     ${HW_LINK_LIBS}
     )
 
--- a/QTfrontend/ui/dialog/upload_video.cpp	Thu Aug 09 01:01:06 2012 +0400
+++ b/QTfrontend/ui/dialog/upload_video.cpp	Thu Aug 09 01:24:38 2012 +0400
@@ -38,7 +38,8 @@
 #include "hwconsts.h"
 
 // User-agent string used in http requests.
-static const QByteArray UserAgent = ("Hedgewars-QtFrontend/" + *cVersionString).toAscii();
+// Don't make it a global varibale - crash on linux because of cVersionString
+#define USER_AGENT ("Hedgewars-QtFrontend/" + *cVersionString).toAscii()
 
 // This is developer key obtained from http://code.google.com/apis/youtube/dashboard/
 // If you are reusing this code outside Hedgewars, don't use this developer key,
@@ -105,7 +106,7 @@
 
     leTitle = new QLineEdit(this);
     leTitle->setText(filename);
-    leTitle->setValidator(new QRegExpValidator(rx));
+    leTitle->setValidator(new QRegExpValidator(rx, leTitle));
     layout->addWidget(leTitle, row++, 1);
 
     lbLabel = new QLabel(this);
@@ -122,7 +123,7 @@
     leTags = new QLineEdit(this);
     leTags->setText("hedgewars");
     leTags->setMaxLength(500);
-    leTags->setValidator(new QRegExpValidator(rx));
+    leTags->setValidator(new QRegExpValidator(rx, leTags));
     layout->addWidget(leTags, row++, 1);
 
     cbPrivate = new QCheckBox(this);
@@ -170,7 +171,7 @@
     // Documentation is at https://developers.google.com/youtube/2.0/developers_guide_protocol_clientlogin#ClientLogin_Authentication
     QNetworkRequest request;
     request.setUrl(QUrl("https://www.google.com/accounts/ClientLogin"));
-    request.setRawHeader("User-Agent", UserAgent);
+    request.setRawHeader("User-Agent", USER_AGENT);
     request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
 
     QString account(QUrl::toPercentEncoding(leAccount->text()));
@@ -250,7 +251,7 @@
 
     QNetworkRequest request;
     request.setUrl(QUrl("http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads"));
-    request.setRawHeader("User-Agent", UserAgent);
+    request.setRawHeader("User-Agent", USER_AGENT);
     request.setRawHeader("Authorization", auth);
     request.setRawHeader("GData-Version", "2");
     request.setRawHeader("X-GData-Key", "key=" + devKey);
--- a/QTfrontend/util/libav_iteraction.cpp	Thu Aug 09 01:01:06 2012 +0400
+++ b/QTfrontend/util/libav_iteraction.cpp	Thu Aug 09 01:24:38 2012 +0400
@@ -286,7 +286,7 @@
 
     int s = float(pContext->duration)/AV_TIME_BASE;
     QString desc = QString(tr("Duration: %1m %2s\n")).arg(s/60).arg(s%60);
-    for (int i = 0; i < pContext->nb_streams; i++)
+    for (int i = 0; i < (int)pContext->nb_streams; i++)
     {
         AVStream* pStream = pContext->streams[i];
         if (!pStream)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmake_modules/FindFFMPEG.cmake	Thu Aug 09 01:24:38 2012 +0400
@@ -0,0 +1,87 @@
+# - Try to find libxml++-2.6
+# Once done this will define
+#
+#  FFMPEG_FOUND - system has libxml++
+#  FFMPEG_INCLUDE_DIRS - the libxml++ include directory
+#  FFMPEG_LIBRARIES - Link these to use libxml++
+#  FFMPEG_DEFINITIONS - Compiler switches required for using libxml++
+#
+#  Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
+#  Modified for other libraries by Lasse Kärkkäinen <tronic>
+#  Modified for Hedgewars by Stepik777
+#
+#  Redistribution and use is allowed according to the terms of the New
+#  BSD license.
+#
+
+if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIRS)
+  # in cache already
+  set(FFMPEG_FOUND TRUE)
+else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIRS)
+  # use pkg-config to get the directories and then use these values
+  # in the FIND_PATH() and FIND_LIBRARY() calls
+  find_package(PkgConfig)
+  if (PKG_CONFIG_FOUND)
+    pkg_check_modules(_FFMPEG_AVCODEC libavcodec)
+    pkg_check_modules(_FFMPEG_AVFORMAT libavformat)
+    pkg_check_modules(_FFMPEG_AVUTIL libavutil)
+  endif (PKG_CONFIG_FOUND)
+
+  find_path(FFMPEG_AVCODEC_INCLUDE_DIR
+    NAMES avcodec.h
+    PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
+    PATH_SUFFIXES ffmpeg libavcodec
+  )
+
+  find_path(FFMPEG_AVFORMAT_INCLUDE_DIR
+    NAMES avformat.h
+    PATHS ${_FFMPEG_AVFORMAT_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
+    PATH_SUFFIXES ffmpeg libavformat
+  )
+
+  find_library(FFMPEG_AVCODEC_LIBRARY
+    NAMES avcodec
+    PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+  )
+
+  find_library(FFMPEG_AVFORMAT_LIBRARY
+    NAMES avformat
+    PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+  )
+
+  find_library(FFMPEG_AVUTIL_LIBRARY
+    NAMES avutil
+    PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+  )
+
+  if (FFMPEG_AVCODEC_LIBRARY AND FFMPEG_AVFORMAT_LIBRARY)
+    set(FFMPEG_FOUND TRUE)
+  endif (FFMPEG_AVCODEC_LIBRARY AND FFMPEG_AVFORMAT_LIBRARY)
+
+  if (FFMPEG_FOUND)
+
+    set(FFMPEG_INCLUDE_DIR
+      ${FFMPEG_AVCODEC_INCLUDE_DIR}
+      ${FFMPEG_AVFORMAT_INCLUDE_DIR}
+    )
+
+    set(FFMPEG_LIBRARIES
+      ${FFMPEG_AVCODEC_LIBRARY}
+      ${FFMPEG_AVFORMAT_LIBRARY}
+      ${FFMPEG_AVUTIL_LIBRARY}
+    )
+
+  endif (FFMPEG_FOUND)
+
+  if (FFMPEG_FOUND)
+    if (NOT FFMPEG_FIND_QUIETLY)
+      message(STATUS "Found FFMPEG: ${FFMPEG_LIBRARIES}")
+    endif (NOT FFMPEG_FIND_QUIETLY)
+  else (FFMPEG_FOUND)
+    if (FFMPEG_FIND_REQUIRED)
+      message(FATAL_ERROR "Could not find FFMPEG libavcodec, libavformat or libswscale")
+    endif (FFMPEG_FIND_REQUIRED)
+  endif (FFMPEG_FOUND)
+
+endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIRS)
+
--- a/hedgewars/CMakeLists.txt	Thu Aug 09 01:01:06 2012 +0400
+++ b/hedgewars/CMakeLists.txt	Thu Aug 09 01:24:38 2012 +0400
@@ -3,6 +3,7 @@
 find_package(SDL_net)
 find_package(SDL_ttf)
 find_package(SDL_mixer)
+find_package(FFMPEG)
 
 include(${CMAKE_MODULE_PATH}/FindSDL_Extras.cmake)