Browse Source

chore: Make building for FreeBSD easier

Add some patches from https://svnweb.freebsd.org/ports/head/net-im/qTox/
and make some things more platform independent.
sudden6 4 years ago
parent
commit
8d320ca3be
5 changed files with 25 additions and 12 deletions
  1. 12 0
      qtox.pro
  2. 2 1
      src/platform/camera/v4l2.cpp
  3. 2 2
      src/platform/camera/v4l2.h
  4. 8 8
      src/video/cameradevice.cpp
  5. 1 1
      test-pr.sh

+ 12 - 0
qtox.pro

@@ -260,6 +260,18 @@ macx {
     LIBPATH += /usr/local/lib
 }
 
+unix {
+    target.path  = $$PREFIX/bin
+
+    desktop.files = qTox.desktop
+    desktop.path = $$PREFIX/share/applications
+
+    icon.files = img/qtox.png
+    icon.path = $$PREFIX/share/pixmaps
+
+    INSTALLS = target desktop icon
+}
+
 RESOURCES += res.qrc
 
 !contains(SMILEYS, NO) {

+ 2 - 1
src/platform/camera/v4l2.cpp

@@ -29,6 +29,7 @@
 #include <linux/videodev2.h>
 #include <dirent.h>
 #include <map>
+#include <QDebug>
 
 /**
  * Most of this file is adapted from libavdevice's v4l2.c,
@@ -201,7 +202,7 @@ QString v4l2::getPixelFormatString(uint32_t pixel_format)
 {
     if (pixFmtToName.find(pixel_format) == pixFmtToName.end())
     {
-        printf("BAD!\n");
+        qWarning() << "Pixel format not found";
         return QString("unknown");
     }
     return pixFmtToName.at(pixel_format);

+ 2 - 2
src/platform/camera/v4l2.h

@@ -24,8 +24,8 @@
 #include <QPair>
 #include "video/videomode.h"
 
-#ifndef Q_OS_LINUX
-#error "This file is only meant to be compiled for Linux targets"
+#if !(defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD))
+#error "This file is only meant to be compiled for Linux or FreeBSD targets"
 #endif
 
 namespace v4l2

+ 8 - 8
src/video/cameradevice.cpp

@@ -31,7 +31,7 @@ extern "C" {
 #ifdef Q_OS_WIN
 #include "platform/camera/directshow.h"
 #endif
-#ifdef Q_OS_LINUX
+#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
 #include "platform/camera/v4l2.h"
 #endif
 #ifdef Q_OS_OSX
@@ -150,7 +150,7 @@ CameraDevice* CameraDevice::open(QString devName, VideoMode mode)
 
     AVDictionary* options = nullptr;
     if (!iformat);
-#ifdef Q_OS_LINUX
+#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
     else if (devName.startsWith("x11grab#"))
     {
         QSize screen;
@@ -359,7 +359,7 @@ QVector<QPair<QString, QString>> CameraDevice::getDeviceList()
     else if (iformat->name == QString("dshow"))
         devices += DirectShow::getDeviceList();
 #endif
-#ifdef Q_OS_LINUX
+#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
     else if (iformat->name == QString("video4linux2,v4l2"))
         devices += v4l2::getDeviceList();
 #endif
@@ -467,7 +467,7 @@ QVector<VideoMode> CameraDevice::getVideoModes(QString devName)
     else if (iformat->name == QString("dshow"))
         return DirectShow::getDeviceModes(devName);
 #endif
-#ifdef Q_OS_LINUX
+#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
     else if (iformat->name == QString("video4linux2,v4l2"))
         return v4l2::getDeviceModes(devName);
 #endif
@@ -488,7 +488,7 @@ QVector<VideoMode> CameraDevice::getVideoModes(QString devName)
  */
 QString CameraDevice::getPixelFormatString(uint32_t pixel_format)
 {
-#ifdef Q_OS_LINUX
+#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
     return v4l2::getPixelFormatString(pixel_format);
 #else
     return QString("unknown");
@@ -504,7 +504,7 @@ QString CameraDevice::getPixelFormatString(uint32_t pixel_format)
  */
 bool CameraDevice::betterPixelFormat(uint32_t a, uint32_t b)
 {
-#ifdef Q_OS_LINUX
+#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
 	return v4l2::betterPixelFormat(a, b);
 #else
 	return false;
@@ -524,7 +524,7 @@ bool CameraDevice::getDefaultInputFormat()
     avdevice_register_all();
 
     // Desktop capture input formats
-#ifdef Q_OS_LINUX
+#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
     idesktopFormat = av_find_input_format("x11grab");
 #endif
 #ifdef Q_OS_WIN
@@ -532,7 +532,7 @@ bool CameraDevice::getDefaultInputFormat()
 #endif
 
     // Webcam input formats
-#ifdef Q_OS_LINUX
+#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
     if ((iformat = av_find_input_format("v4l2")))
         return true;
 #endif

+ 1 - 1
test-pr.sh

@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 #    Copyright © 2016 Zetok Zalbavar <zetok@openmailbox.org>
 #