From 01f3b21057b3c118c710602949248b5c9f62731d Mon Sep 17 00:00:00 2001
From: Raghav Gururajan <raghavgururajan@disroot.org>
Date: Sun, 29 Mar 2020 04:55:23 -0400
Subject: [PATCH 14/14] gnu: packages: linphone: Add mediastreamer

* gnu/packages/linphone.scm (mediastreamer): New variable.
---
 gnu/packages/linphone.scm | 147 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 147 insertions(+)

diff --git a/gnu/packages/linphone.scm b/gnu/packages/linphone.scm
index 074665af03..62be01d43e 100644
--- a/gnu/packages/linphone.scm
+++ b/gnu/packages/linphone.scm
@@ -19,16 +19,29 @@
 
 (define-module (gnu packages linphone)
   #:use-module (gnu packages)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages audio)
   #:use-module (gnu packages base)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages documentation)
+  #:use-module (gnu packages gl)
+  #:use-module (gnu packages gnome)
   #:use-module (gnu packages graphviz)
+  #:use-module (gnu packages image)
   #:use-module (gnu packages java)
   #:use-module (gnu packages ncurses)
+  #:use-module (gnu packages linux)
+  #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages pth)
+  #:use-module (gnu packages python)
   #:use-module (gnu packages sqlite)
+  #:use-module (gnu packages telephony)
   #:use-module (gnu packages tls)
+  #:use-module (gnu packages version-control)
+  #:use-module (gnu packages video)
+  #:use-module (gnu packages xiph)
   #:use-module (gnu packages xml)
+  #:use-module (gnu packages xorg)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
@@ -307,3 +320,137 @@ protocol, written in C.  It is fully portable and can be executed on many
 platforms including both ARM and x86.")
  (home-page "https://gitlab.linphone.org/BC/public/bzrtp")
  (license license:gpl2+)))
+
+(define-public mediastreamer
+ (package
+  (name "mediastreamer")
+   (version "2.16.1")
+   (source
+    (origin
+     (method url-fetch)
+     (uri
+      (string-append "https://www.linphone.org/releases/sources/" name
+                     "/" name "-" version ".tar.gz"))
+     (sha256
+      (base32 "0whpqr69wz0pnzvragkpfblxhd0rds8k06c3mw5a0ag216a1yd9k"))
+     (patches
+      (list
+       ;; For srtp2 compatibility.
+       (origin
+        (method url-fetch)
+        (uri
+         (string-append "https://gitlab.linphone.org/BC/public/mediastreamer2/commit/"
+                        "97903498364ae2596e790cb2c2ce9ac76c04d64a.diff"))
+        (file-name "srtp.patch")
+        (sha256
+         (base32 "1k1cj72gyzb05ann6amc54gim19mwqz84y36kk5sb77p5qwg50hf")))
+       ;; For fixing definitions.
+       (origin
+        (method url-fetch)
+        (uri
+         (string-append "https://gitlab.linphone.org/BC/public/mediastreamer2/commit/"
+                        "de3a24b795d7a78e78eab6b974e7ec5abf2259ac.diff"))
+        (file-name "msfactory.patch")
+        (sha256
+         (base32 "18lsn9fc9di8bzr12ck3h9k9h8xvvhjzgkimbj9p4vmxxwhjaxn2")))))))
+ (build-system cmake-build-system)
+ (arguments
+  `(#:tests? #f ; No test target
+    #:configure-flags
+     (list
+      ;; To detect the required directory.
+      (string-append "-DSRTP_INCLUDE_DIRS="
+       (string-append (assoc-ref %build-inputs "srtp") "/include"))
+      ;; To detect the required directory.
+      (string-append "-DSRTP_LIBRARIES="
+       (string-append (assoc-ref %build-inputs "srtp") "/lib"))
+      ;; *** Generic ***
+      "-DENABLE_SHARED=YES"
+      "-DENABLE_STATIC=YES"
+      "-DENABLE_DEBUG_LOGS=YES"
+      "-DENABLE_DOC=YES"
+      "-DENABLE_NON_FREE_CODECS=NO" ; XXX-Hazardous-XXX
+      "-DENABLE_PCAP=YES"
+      "-DENABLE_STRICT=YES"
+      "-DENABLE_RELATIVE_PREFIX=YES"
+      "-DENABLE_TOOLS=YES"
+      "-DENABLE_UNIT_TESTS=YES"
+      ;; *** Encryption ***
+      "-DENABLE_SRTP=NO" ; Undefined references
+      "-DENABLE_ZRTP=YES"
+      ;; *** Audio ***
+      "-DENABLE_SOUND=YES"
+      "-DENABLE_ALSA=YES"
+      "-DENABLE_ANDROIDSND=NO" ; Not compatible
+      "-DENABLE_ARTSC=NO" ; Not available
+      "-DENABLE_MACSND=NO" ; Not compatible
+      "-DENABLE_MACAQSND=NO" ; Not compatible
+      "-DENABLE_QSA=NO" ; Not available
+      "-DENABLE_OSS=NO" ; Deprecated
+      "-DENABLE_PORTAUDIO=NO" ; Parsing errors
+      "-DENABLE_PULSEAUDIO=YES"
+      ;; *** Standards ***
+      "-DENABLE_G726=YES"
+      "-DENABLE_GSM=NO" ; Need recompilation with -fPIC
+      "-DENABLE_BV16=NO" ; Not available
+      "-DENABLE_OPUS=YES"
+      "-DENABLE_SPEEX_CODEC=YES"
+      "-DENABLE_SPEEX_DSP=YES"
+      "-DENABLE_G729=YES"
+      "-DENABLE_G729B_CNG=YES"
+      "-DENABLE_RESAMPLE=YES"
+      ;; *** Video ***
+      "-DENABLE_VIDEO=YES"
+      "-DENABLE_FFMPEG=YES"
+      "-DENABLE_GL=YES"
+      "-DENABLE_GLX=YES"
+      "-DENABLE_SDL=YES"
+      "-DENABLE_V4L=YES"
+      "-DENABLE_X11=YES"
+      "-DENABLE_XV=YES"
+      "-DENABLE_THEORA=YES"
+      "-DENABLE_VPX=YES"
+      ;; *** Formats ***
+      "-DENABLE_MKV=YES"
+      "-DENABLE_QNX=NO" ; Not available
+      "-DENABLE_VT_H264=NO" ; Not available
+      "-DENABLE_JPEG=YES")))
+ (native-inputs
+  `(("dot" ,graphviz)
+    ("doxygen" ,doxygen)
+    ("python" ,python)))
+ (inputs
+  `(("alsa" ,alsa-lib)
+    ("ffmpeg" ,ffmpeg)
+    ("glew" ,glew)
+    ("glu" ,glu)
+    ("glx" ,mesa-utils)
+    ("gsm" ,gsm)
+    ("opengl" ,mesa)
+    ("opus" ,opus)
+    ("pcap" ,libpcap)
+    ("portaudio" ,portaudio)
+    ("pulseaudio" ,pulseaudio)
+    ("spandsp" ,spandsp)
+    ("speex" ,speex)
+    ("speexdsp" ,speexdsp)
+    ("srtp" ,libsrtp)
+    ("theora" ,libtheora)
+    ("turbojpeg" ,libjpeg-turbo)
+    ("v4l" ,v4l-utils)
+    ("vpx" ,libvpx)
+    ("x11" ,libx11)
+    ("xv" ,libxv)))
+ (propagated-inputs
+  `(("bcg729" ,bcg729)
+    ("bcmatroska2" ,bcmatroska2)
+    ("bctoolbox" ,bctoolbox)
+    ("zrtp", bzrtp)
+    ("ortp" ,ortp)))
+ (synopsis "Belledonne Communications Streaming Engine")
+ (description "Mediastreamer is a powerful and lightweight streaming
+engine for telephony applications.  This media processing and streaming toolkit
+is responsible for receiving and sending all multimedia streams in Linphone,
+including media capture, encoding and decoding, and rendering.")
+ (home-page "https://gitlab.linphone.org/BC/public/mediastreamer2")
+ (license license:gpl2+)))
-- 
2.26.0

