Unverified Commit c13f8abb authored by Luke Granger-Brown's avatar Luke Granger-Brown Committed by GitHub
Browse files

libajantv2: 16.2-bugfix5 -> 17.1.0 (#367135)

parents 4e1d4f49 270a8431
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
diff --git a/ajantv2/src/ntv2devicescanner.cpp b/ajantv2/src/ntv2devicescanner.cpp
index 448e48d372..6b46f9f69d 100644
--- a/ajantv2/src/ntv2devicescanner.cpp
+++ b/ajantv2/src/ntv2devicescanner.cpp
@@ -137,7 +137,7 @@
 		}
 	#endif	//	!defined(NTV2_DEPRECATE_16_3)
 
-NTV2DeviceInfoList	GetDeviceInfoList (void)
+NTV2DeviceInfoList	CNTV2DeviceScanner::GetDeviceInfoList (void)
 {
 	AJAAutoLock tmpLock(&sDevInfoListLock);
 	return sDevInfoList;
+27 −11
Original line number Diff line number Diff line
@@ -5,21 +5,25 @@
  cmake,
  ninja,
  pkg-config,
  mbedtls,
  udev,
  linuxPackages,
}:

# Warning: We are aware that the upstream changed and there are new releases,
# this got initally packaged for obs-studio which appears to fail to build even upstream with the new version.
# https://github.com/NixOS/nixpkgs/pull/296191 / https://github.com/obsproject/obs-studio/pull/10037
stdenv.mkDerivation rec {
  pname = "libajantv2";
  version = "16.2-bugfix5";
  version = "17.1.0";

  src = fetchFromGitHub {
    owner = "aja-video";
    repo = "ntv2";
    rev = "v${version}";
    sha256 = "sha256-h5PKWMwqTeI5/EaTWkjYojuvDU0FyMpzIjWB98UOJwc=";
    repo = "libajantv2";
    rev = "ntv2_${builtins.replaceStrings [ "." ] [ "_" ] version}";
    hash = "sha256-n9j98r1E9E0hv5gA8jCg/eQyqGuyU9JlZYm/zlcTQOo=";
  };
  patches = [
    ./use-system-mbedtls.patch
    ./device-info-list.patch
  ];

  outputs = [
    "out"
@@ -31,27 +35,39 @@ stdenv.mkDerivation rec {
    ninja
    pkg-config
  ];
  buildInputs = [
    mbedtls
    udev
  ];

  cmakeFlags = [
    (lib.cmakeBool "AJANTV2_BUILD_SHARED" true)
  ];

  postInstall = ''
    mkdir -p "$out/lib/pkgconfig"
    cat >"$out/lib/pkgconfig/libajantv2.pc" <<EOF
    prefix=$out
    libdir=\''${prefix}/lib
    includedir=\''${prefix}/include/ajalibraries
    includedir=\''${prefix}/include/libajantv2

    Name: libajantv2
    Description: Library for controlling AJA NTV2 video devices
    Version: ${version}
    Libs: -L\''${libdir} -lajantv2
    Cflags: -I\''${includedir} -I\''${includedir}/ajantv2/includes
    Cflags: -I\''${includedir} -I\''${includedir}/ajantv2/includes -I\''${includedir}/ajantv2/src/lin -DAJALinux -DAJA_LINUX -DAJA_USE_CPLUSPLUS11 -DNDEBUG -DNTV2_USE_CPLUSPLUS11
    EOF
  '';

  passthru.tests = {
    inherit (linuxPackages) ajantv2;
  };

  meta = with lib; {
    description = "AJA NTV2 Open Source Static Libs and Headers for building applications that only wish to statically link against";
    homepage = "https://github.com/aja-video/ntv2";
    homepage = "https://github.com/aja-video/libajantv2";
    license = with licenses; [ mit ];
    maintainers = [ ];
    maintainers = [ lib.maintainers.lukegb ];
    platforms = platforms.linux;
  };
}
+86 −0
Original line number Diff line number Diff line
Commit ID: 1aeee534119a22e717ce3d0e9f62c8791cd825b9
Change ID: pzyrusopmyvtvnwnruvrltqtpqtzxrpo
Author: Luke Granger-Brown <git@lukegb.com> (2024-12-20 18:03:16)
Committer: Luke Granger-Brown <git@lukegb.com> (2024-12-20 18:03:25)

    Use system mbedtls, rather than downloading from a random Git branch...

diff --git a/ajantv2/CMakeLists.txt b/ajantv2/CMakeLists.txt
index ffa572e9c8..74c23e8e4e 100644
--- a/ajantv2/CMakeLists.txt
+++ b/ajantv2/CMakeLists.txt
@@ -52,49 +52,13 @@
 else()
     message(STATUS "NTV2 SDK will load signed 3rd-party plugins")
 
-    set(MBEDTLS_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/mbedtls-install)
-    set(MBEDTLS_INCLUDE_DIR ${MBEDTLS_INSTALL_DIR}/include)
-    set(MBEDTLS_LIBRARY_DIR ${MBEDTLS_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR})
-
-    if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
-        set(MBEDTLS_LIBRARY ${MBEDTLS_LIBRARY_DIR}/mbedtls.lib)
-        set(MBEDX509_LIBRARY ${MBEDTLS_LIBRARY_DIR}/mbedx509.lib)
-        set(MBEDCRYPTO_LIBRARY ${MBEDTLS_LIBRARY_DIR}/mbedcrypto.lib)
-        set(MBEDTLS_EXTRA_CONFIG_FLAGS
-                "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON"
-                "-DMSVC_STATIC_RUNTIME=ON"
-                "-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}")
-    elseif (CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin)$")
-        set(MBEDTLS_LIBRARY ${MBEDTLS_LIBRARY_DIR}/libmbedtls.a)
-        set(MBEDX509_LIBRARY ${MBEDTLS_LIBRARY_DIR}/libmbedx509.a)
-        set(MBEDCRYPTO_LIBRARY ${MBEDTLS_LIBRARY_DIR}/libmbedcrypto.a)
-        set(MBEDTLS_C_FLAGS -fPIC)
-    endif()
-
-    # BUILD_BYPRODUCTS informing CMake where the .a files are located is required to make Ninja build work
-    ExternalProject_Add(
-        mbedtls
-        GIT_REPOSITORY https://github.com/aja-video/mbedtls.git
-        GIT_TAG fix-win-dll-cmake
-        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${MBEDTLS_INSTALL_DIR}
-                    -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-                    -DENABLE_TESTING=OFF 
-                    -DENABLE_PROGRAMS=OFF
-                    -DCMAKE_C_FLAGS=${MBEDTLS_C_FLAGS}
-                    -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
-                    -DUSE_STATIC_MBEDTLS_LIBRARY=ON
-                    -DUSE_SHARED_MBEDTLS_LIBRARY=OFF
-                    ${MBEDTLS_EXTRA_CONFIG_FLAGS}
-        BUILD_ALWAYS TRUE
-        BUILD_BYPRODUCTS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY}
-    )
+    find_package(PkgConfig REQUIRED)
+    pkg_check_modules(MBEDTLS REQUIRED mbedtls mbedcrypto mbedx509)
 
     list(APPEND TARGET_INCLUDE_DIRS
             ${MBEDTLS_INCLUDE_DIR})
     list(APPEND MBEDTLS_LINK_LIBS
-            ${MBEDTLS_LIBRARY}
-            ${MBEDCRYPTO_LIBRARY}
-            ${MBEDX509_LIBRARY})
+	    ${MBEDTLS_LIBRARIES})
 endif()
 
 
@@ -668,10 +632,6 @@
         aja_ntv2_log_build_info()
 
         add_library(${PROJECT_NAME} SHARED ${TARGET_SOURCES})
-        
-        if (NOT AJANTV2_DISABLE_PLUGIN_LOAD)
-            add_dependencies(${PROJECT_NAME} mbedtls)
-        endif()
 
         target_compile_definitions(${PROJECT_NAME} PUBLIC
             ${TARGET_COMPILE_DEFS_DYNAMIC}
@@ -687,10 +647,6 @@
 
         add_library(${PROJECT_NAME} STATIC ${TARGET_SOURCES})
 
-        if (NOT AJANTV2_DISABLE_PLUGIN_LOAD)
-            add_dependencies(${PROJECT_NAME} mbedtls)
-        endif()
-
         target_compile_definitions(${PROJECT_NAME} PUBLIC
             ${TARGET_COMPILE_DEFS_STATIC}
             ${AJANTV2_TARGET_COMPILE_DEFS})
+11 −2
Original line number Diff line number Diff line
{ lib
, stdenv
, fetchurl
, fetchpatch
, substituteAll
, meson
, ninja
@@ -46,6 +47,7 @@
, flite
, gsm
, json-glib
, ajaSupport ? lib.meta.availableOn stdenv.hostPlatform libajantv2
, libajantv2
, libaom
, libdc1394
@@ -129,6 +131,12 @@ stdenv.mkDerivation rec {
      src = ./fix-paths.patch;
      inherit (addDriverRunpath) driverLink;
    })
    # Add support for newer AJA SDK from next GStreamer release
    (fetchpatch {
      url = "https://github.com/GStreamer/gstreamer/commit/d68ac0db571f44cae42b57c876436b3b09df616b.patch";
      hash = "sha256-ZXwlHzuPT8kUKt5+HkqFH5tzL9l5NusDXImabj4fBbI=";
      relative = "subprojects/${pname}";
    })
  ];

  nativeBuildInputs = [
@@ -214,6 +222,8 @@ stdenv.mkDerivation rec {
    libmicrodns
  ] ++ lib.optionals openh264Support [
    openh264
  ] ++ lib.optionals ajaSupport [
    libajantv2
  ] ++ lib.optionals (gst-plugins-base.waylandEnabled && stdenv.hostPlatform.isLinux) [
    libva # vaapi requires libva -> libdrm -> libpciaccess, which is Linux-only in nixpkgs
    wayland
@@ -224,7 +234,6 @@ stdenv.mkDerivation rec {

    chromaprint
    flite
    libajantv2
    libdrm
    libgudev
    sbc
@@ -300,7 +309,7 @@ stdenv.mkDerivation rec {
    "-Donnx=disabled" # depends on `libonnxruntime` not packaged in nixpkgs as of writing
    "-Dopenaptx=enabled" # since gstreamer-1.20.1 `libfreeaptx` is supported for circumventing the dubious license conflict with `libopenaptx`
    "-Dopencv=${if opencvSupport then "enabled" else "disabled"}" # Reduces rebuild size when `config.cudaSupport = true`
    "-Daja=disabled" # should pass libajantv2 via aja-sdk-dir instead
    "-Daja=${if ajaSupport then "enabled" else "disabled"}"
    "-Dmicrodns=${if microdnsSupport then "enabled" else "disabled"}"
    "-Dbluez=${if bluezSupport then "enabled" else "disabled"}"
    (lib.mesonEnable "openh264" openh264Support)
+41 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  kernel,
  libajantv2,
}:
stdenv.mkDerivation {
  name = "ajantv2-module-${libajantv2.version}-${kernel.version}";

  inherit (libajantv2) src;
  sourceRoot = "source/driver/linux";

  hardeningDisable = [ "pic" ];

  nativeBuildInputs = kernel.moduleBuildDependencies;

  preBuild = ''
    chmod -R +w ../../
  '';

  enableParallelBuilding = true;

  buildFlags = [
    "KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
  ];

  installPhase = ''
    install -D ajantv2.ko $out/lib/modules/${kernel.modDirVersion}/misc/ajantv2.ko
    install -D ajardma.ko $out/lib/modules/${kernel.modDirVersion}/misc/ajardma.ko
  '';

  meta = {
    inherit (libajantv2.meta) license homepage maintainers;
    platforms = [
      "x86_64-linux"
      "aarch64-linux"
    ];
    description = "AJA video driver";
  };
}
Loading