pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/multimedia/ffmpeg4



Module Name:    pkgsrc
Committed By:   nia
Date:           Fri Mar 20 21:19:54 UTC 2020

Modified Files:
        pkgsrc/multimedia/ffmpeg4: Makefile distinfo
        pkgsrc/multimedia/ffmpeg4/patches: patch-configure
Added Files:
        pkgsrc/multimedia/ffmpeg4/patches: patch-doc_general.texi
            patch-doc_indevs.texi patch-doc_outdevs.texi
            patch-libavdevice_Makefile patch-libavdevice_alldevices.c
            patch-libavdevice_sunau.c patch-libavdevice_sunau.h
            patch-libavdevice_sunau__dec.c patch-libavdevice_sunau__enc.c

Log Message:
ffmpeg4: Add native Solaris/NetBSD audio support.

Work by Yorick Hardy and myself.

Also submitted to ffmpeg-devel, but they didn't take much notice.

To record audio:

$ ffmpeg4 -f sunau -i /dev/audio0 recording.wav

To play audio:

$ ffmpeg4 -i recording.wav -f sunau /dev/audio0

Bump PKGREVISION


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 pkgsrc/multimedia/ffmpeg4/Makefile
cvs rdiff -u -r1.13 -r1.14 pkgsrc/multimedia/ffmpeg4/distinfo
cvs rdiff -u -r1.3 -r1.4 pkgsrc/multimedia/ffmpeg4/patches/patch-configure
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/multimedia/ffmpeg4/patches/patch-doc_general.texi \
    pkgsrc/multimedia/ffmpeg4/patches/patch-doc_indevs.texi \
    pkgsrc/multimedia/ffmpeg4/patches/patch-doc_outdevs.texi \
    pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_Makefile \
    pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_alldevices.c \
    pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau.c \
    pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau.h \
    pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau__dec.c \
    pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau__enc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/multimedia/ffmpeg4/Makefile
diff -u pkgsrc/multimedia/ffmpeg4/Makefile:1.23 pkgsrc/multimedia/ffmpeg4/Makefile:1.24
--- pkgsrc/multimedia/ffmpeg4/Makefile:1.23     Tue Mar 10 22:10:38 2020
+++ pkgsrc/multimedia/ffmpeg4/Makefile  Fri Mar 20 21:19:54 2020
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.23 2020/03/10 22:10:38 wiz Exp $
+# $NetBSD: Makefile,v 1.24 2020/03/20 21:19:54 nia Exp $
 
 PKGNAME=       ${DISTNAME:S/ffmpeg/ffmpeg4/}
-PKGREVISION=   3
+PKGREVISION=   4
 MAINTAINER=    pkgsrc-users%NetBSD.org@localhost
 HOMEPAGE=      http://ffmpeg.mplayerhq.hu/
 COMMENT=       Decoding, encoding and streaming software (v4.x)

Index: pkgsrc/multimedia/ffmpeg4/distinfo
diff -u pkgsrc/multimedia/ffmpeg4/distinfo:1.13 pkgsrc/multimedia/ffmpeg4/distinfo:1.14
--- pkgsrc/multimedia/ffmpeg4/distinfo:1.13     Thu Jan  2 10:26:31 2020
+++ pkgsrc/multimedia/ffmpeg4/distinfo  Fri Mar 20 21:19:54 2020
@@ -1,12 +1,21 @@
-$NetBSD: distinfo,v 1.13 2020/01/02 10:26:31 adam Exp $
+$NetBSD: distinfo,v 1.14 2020/03/20 21:19:54 nia Exp $
 
 SHA1 (ffmpeg-4.2.2.tar.xz) = 2557ec7d1dee31169980a8a10404129f94bd5809
 RMD160 (ffmpeg-4.2.2.tar.xz) = 2f1ff99e3a2db7a17bb6b692dd394e6f3afd803d
 SHA512 (ffmpeg-4.2.2.tar.xz) = 381cd6732fa699eb89000621cf34256920596ed1f9de3c2194dbad35fdf2165269eb7d3a147a0eb75dc18fbb6d601382b5801750e09fc63547766842f84208e3
 Size (ffmpeg-4.2.2.tar.xz) = 9094140 bytes
 SHA1 (patch-Makefile) = 2d27f218ee49179fdea14bb5c86c506dfb64dbd6
-SHA1 (patch-configure) = 5f9acc5a62fe20774e63e8f4d2367174104f2774
+SHA1 (patch-configure) = 4c4290dacc0fb19b6001f1a5778580bb76dd0e60
 SHA1 (patch-doc_Makefile) = 3b86307323fa565f9ad19c5bcb6ea71d323062fc
+SHA1 (patch-doc_general.texi) = 4fd158cb76a6a9fec24d3dae5edb32c0531153a2
+SHA1 (patch-doc_indevs.texi) = 066a6ead2132ec05796bdcc000071dfca76d220c
+SHA1 (patch-doc_outdevs.texi) = 0a6930b835fb24e0008adeeb6c34990db1e16fc1
+SHA1 (patch-libavdevice_Makefile) = 526efd20021068245d8904c0d55508a540ae4054
+SHA1 (patch-libavdevice_alldevices.c) = 8f835f8ec7b057ddcd6303bc2178cdb6f4541e2a
+SHA1 (patch-libavdevice_sunau.c) = 44dba866c58d508c0f873ffdd9ad8d25c059cc8a
+SHA1 (patch-libavdevice_sunau.h) = 2678d87f81e7b3faa42b5cc9814e373c4ad812f6
+SHA1 (patch-libavdevice_sunau__dec.c) = d2fc01e941c68ab8b6f5e0b98ee536a32cc56bdc
+SHA1 (patch-libavdevice_sunau__enc.c) = efe765b99ad6379d0237c619ac0dce41306431be
 SHA1 (patch-libavformat_sctp.c) = 22bad9c7dc152aec3c60e0009899af241f495535
 SHA1 (patch-libavutil_common.h) = d0f1093bc82567807b39dde990ee347f90a082c9
 SHA1 (patch-libavutil_x86_asm.h) = 8f48f9e8ec08b5176bb40fc0021f3bb913dbef22

Index: pkgsrc/multimedia/ffmpeg4/patches/patch-configure
diff -u pkgsrc/multimedia/ffmpeg4/patches/patch-configure:1.3 pkgsrc/multimedia/ffmpeg4/patches/patch-configure:1.4
--- pkgsrc/multimedia/ffmpeg4/patches/patch-configure:1.3       Tue Nov  6 19:31:09 2018
+++ pkgsrc/multimedia/ffmpeg4/patches/patch-configure   Fri Mar 20 21:19:54 2020
@@ -1,12 +1,23 @@
-$NetBSD: patch-configure,v 1.3 2018/11/06 19:31:09 adam Exp $
+$NetBSD: patch-configure,v 1.4 2020/03/20 21:19:54 nia Exp $
+
+Sun audio support.
 
 Enable PIC on NetBSD, even on i386 to avoid text relocations.
 Do not use 'rsync'.
+
 Portability fixes.
 
---- configure.orig     2018-11-05 23:22:33.000000000 +0000
+--- configure.orig     2020-03-20 20:53:47.977808652 +0000
 +++ configure
-@@ -2203,7 +2203,6 @@ TOOLCHAIN_FEATURES="
+@@ -2119,6 +2119,7 @@ HEADERS_LIST="
+     sys_resource_h
+     sys_select_h
+     sys_soundcard_h
++    sys_audioio_h
+     sys_time_h
+     sys_un_h
+     sys_videoio_h
+@@ -2257,7 +2258,6 @@ TOOLCHAIN_FEATURES="
      inline_asm_labels
      inline_asm_nonlocal_labels
      pragma_deprecated
@@ -14,7 +25,16 @@ Portability fixes.
      symver_asm_label
      symver_gnu_asm
      vfp_args
-@@ -4844,9 +4843,9 @@ elif enabled mips; then
+@@ -3336,6 +3336,8 @@ opengl_outdev_deps="opengl"
+ opengl_outdev_suggest="sdl2"
+ oss_indev_deps_any="sys_soundcard_h"
+ oss_outdev_deps_any="sys_soundcard_h"
++sunau_indev_deps_any="sys_audioio_h"
++sunau_outdev_deps_any="sys_audioio_h"
+ pulse_indev_deps="libpulse"
+ pulse_outdev_deps="libpulse"
+ sdl2_outdev_deps="sdl2"
+@@ -4950,9 +4952,9 @@ elif enabled mips; then
                  disable mipsdsp
                  disable mipsdspr2
                  # When gcc version less than 5.3.0, add -fno-expensive-optimizations flag.
@@ -26,7 +46,7 @@ Portability fixes.
                          expensive_optimization_flag=""
                      else
                          expensive_optimization_flag="-fno-expensive-optimizations"
-@@ -5140,6 +5139,7 @@ case $target_os in
+@@ -5247,6 +5249,7 @@ case $target_os in
          ;;
      netbsd)
          disable symver
@@ -34,7 +54,7 @@ Portability fixes.
          oss_indev_extralibs="-lossaudio"
          oss_outdev_extralibs="-lossaudio"
          enabled gcc || check_ldflags -Wl,-zmuldefs
-@@ -5526,10 +5526,13 @@ done
+@@ -5639,10 +5642,13 @@ done
  check_cc pragma_deprecated "" '_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")'
  
  # The global variable ensures the bits appear unchanged in the object file.
@@ -51,7 +71,15 @@ Portability fixes.
  
  check_cc const_nan math.h "struct { double d; } static const bar[] = { { NAN } }"
  
-@@ -6299,7 +6302,6 @@ enabled makeinfo \
+@@ -6021,6 +6027,7 @@ check_headers libcrystalhd/libcrystalhd_
+ check_headers malloc.h
+ check_headers net/udplite.h
+ check_headers poll.h
++check_headers sys/audioio.h
+ check_headers sys/param.h
+ check_headers sys/resource.h
+ check_headers sys/select.h
+@@ -6427,7 +6434,6 @@ enabled makeinfo \
  disabled makeinfo_html && texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html
  perl -v            > /dev/null 2>&1 && enable perl      || disable perl
  pod2man --help     > /dev/null 2>&1 && enable pod2man   || disable pod2man

Added files:

Index: pkgsrc/multimedia/ffmpeg4/patches/patch-doc_general.texi
diff -u /dev/null pkgsrc/multimedia/ffmpeg4/patches/patch-doc_general.texi:1.1
--- /dev/null   Fri Mar 20 21:19:54 2020
+++ pkgsrc/multimedia/ffmpeg4/patches/patch-doc_general.texi    Fri Mar 20 21:19:54 2020
@@ -0,0 +1,12 @@
+$NetBSD: patch-doc_general.texi,v 1.1 2020/03/20 21:19:54 nia Exp $
+
+--- doc/general.texi.orig      2019-12-31 21:35:22.000000000 +0000
++++ doc/general.texi
+@@ -1354,6 +1354,7 @@ performance on systems without hardware 
+ @item OSS               @tab X      @tab X
+ @item PulseAudio        @tab X      @tab X
+ @item SDL               @tab        @tab X
++@item Sun Audio         @tab        @tab X
+ @item Video4Linux2      @tab X      @tab X
+ @item VfW capture       @tab X      @tab
+ @item X11 grabbing      @tab X      @tab
Index: pkgsrc/multimedia/ffmpeg4/patches/patch-doc_indevs.texi
diff -u /dev/null pkgsrc/multimedia/ffmpeg4/patches/patch-doc_indevs.texi:1.1
--- /dev/null   Fri Mar 20 21:19:54 2020
+++ pkgsrc/multimedia/ffmpeg4/patches/patch-doc_indevs.texi     Fri Mar 20 21:19:54 2020
@@ -0,0 +1,40 @@
+$NetBSD: patch-doc_indevs.texi,v 1.1 2020/03/20 21:19:54 nia Exp $
+
+--- doc/indevs.texi.orig       2019-12-31 21:35:22.000000000 +0000
++++ doc/indevs.texi
+@@ -1282,6 +1282,35 @@ Set the number of channels. Default is 2
+ 
+ @end table
+ 
++@section sunau
++
++Solaris/NetBSD audio input device.
++
++The filename to provide to the input device is the device node
++representing the Sun input device, and is usually set to
++@file{/dev/audio0}.
++
++For example to grab from @file{/dev/audio0} using @command{ffmpeg} use the
++command:
++@example
++ffmpeg -f sunau -i /dev/audio0 /tmp/oss.wav
++@end example
++
++@subsection Options
++
++@table @option
++
++@item buffer_samples
++Set the size of the audio buffer in samples. Default is 32.
++
++@item sample_rate
++Set the sample rate in Hz. Default is 48000.
++
++@item channels
++Set the number of channels. Default is 2.
++
++@end table
++
+ @section video4linux2, v4l2
+ 
+ Video4Linux2 input video device.
Index: pkgsrc/multimedia/ffmpeg4/patches/patch-doc_outdevs.texi
diff -u /dev/null pkgsrc/multimedia/ffmpeg4/patches/patch-doc_outdevs.texi:1.1
--- /dev/null   Fri Mar 20 21:19:54 2020
+++ pkgsrc/multimedia/ffmpeg4/patches/patch-doc_outdevs.texi    Fri Mar 20 21:19:54 2020
@@ -0,0 +1,22 @@
+$NetBSD: patch-doc_outdevs.texi,v 1.1 2020/03/20 21:19:54 nia Exp $
+
+--- doc/outdevs.texi.orig      2019-12-31 21:35:22.000000000 +0000
++++ doc/outdevs.texi
+@@ -393,6 +393,17 @@ ffmpeg -i INPUT -c:v rawvideo -pix_fmt y
+ 
+ sndio audio output device.
+ 
++@section sunau
++
++Solaris/NetBSD audio output device.
++
++@subsection Options
++@table @option
++
++@item buffer_samples
++Set the size of the audio buffer in samples. Default is 32.
++@end table
++
+ @section v4l2
+ 
+ Video4Linux2 output device.
Index: pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_Makefile
diff -u /dev/null pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_Makefile:1.1
--- /dev/null   Fri Mar 20 21:19:54 2020
+++ pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_Makefile        Fri Mar 20 21:19:54 2020
@@ -0,0 +1,15 @@
+$NetBSD: patch-libavdevice_Makefile,v 1.1 2020/03/20 21:19:54 nia Exp $
+
+Sun audio support.
+
+--- libavdevice/Makefile.orig  2019-12-31 21:35:24.000000000 +0000
++++ libavdevice/Makefile
+@@ -43,6 +43,8 @@ OBJS-$(CONFIG_PULSE_OUTDEV)             
+ OBJS-$(CONFIG_SDL2_OUTDEV)               += sdl2.o
+ OBJS-$(CONFIG_SNDIO_INDEV)               += sndio_dec.o sndio.o
+ OBJS-$(CONFIG_SNDIO_OUTDEV)              += sndio_enc.o sndio.o
++OBJS-$(CONFIG_SUNAU_INDEV)               += sunau_dec.o sunau.o
++OBJS-$(CONFIG_SUNAU_OUTDEV)              += sunau_enc.o sunau.o
+ OBJS-$(CONFIG_V4L2_INDEV)                += v4l2.o v4l2-common.o timefilter.o
+ OBJS-$(CONFIG_V4L2_OUTDEV)               += v4l2enc.o v4l2-common.o
+ OBJS-$(CONFIG_VFWCAP_INDEV)              += vfwcap.o
Index: pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_alldevices.c
diff -u /dev/null pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_alldevices.c:1.1
--- /dev/null   Fri Mar 20 21:19:54 2020
+++ pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_alldevices.c    Fri Mar 20 21:19:54 2020
@@ -0,0 +1,15 @@
+$NetBSD: patch-libavdevice_alldevices.c,v 1.1 2020/03/20 21:19:54 nia Exp $
+
+Sun audio support.
+
+--- libavdevice/alldevices.c.orig      2019-12-31 21:35:24.000000000 +0000
++++ libavdevice/alldevices.c
+@@ -49,6 +49,8 @@ extern AVOutputFormat ff_pulse_muxer;
+ extern AVOutputFormat ff_sdl2_muxer;
+ extern AVInputFormat  ff_sndio_demuxer;
+ extern AVOutputFormat ff_sndio_muxer;
++extern AVInputFormat  ff_sunau_demuxer;
++extern AVOutputFormat ff_sunau_muxer;
+ extern AVInputFormat  ff_v4l2_demuxer;
+ extern AVOutputFormat ff_v4l2_muxer;
+ extern AVInputFormat  ff_vfwcap_demuxer;
Index: pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau.c
diff -u /dev/null pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau.c:1.1
--- /dev/null   Fri Mar 20 21:19:54 2020
+++ pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau.c Fri Mar 20 21:19:54 2020
@@ -0,0 +1,109 @@
+$NetBSD: patch-libavdevice_sunau.c,v 1.1 2020/03/20 21:19:54 nia Exp $
+
+Sun audio support.
+
+--- libavdevice/sunau.c.orig   2020-03-20 20:53:01.554485424 +0000
++++ libavdevice/sunau.c
+@@ -0,0 +1,102 @@
++/*
++ * Solaris/NetBSD play and grab interface
++ * Copyright (c) 2020 Yorick Hardy
++ * Copyright (c) 2020 Nia Alarie <nia%NetBSD.org@localhost>
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#include "config.h"
++
++#include <string.h>
++
++#include <unistd.h>
++#include <fcntl.h>
++#include <sys/audioio.h>
++#include <sys/ioctl.h>
++
++#include "libavutil/log.h"
++
++#include "libavcodec/avcodec.h"
++#include "avdevice.h"
++
++#include "sunau.h"
++
++int ff_sunau_audio_open(AVFormatContext *s1, int is_output,
++                          const char *audio_device)
++{
++    SunAudioData *s = s1->priv_data;
++    struct audio_info info;
++    struct audio_prinfo *prinfo;
++    int audio_fd, err;
++
++    audio_fd = avpriv_open(audio_device, is_output ? O_WRONLY : O_RDONLY);
++    if (audio_fd < 0) {
++        av_log(s1, AV_LOG_ERROR, "%s: %s\n", audio_device, av_err2str(AVERROR(errno)));
++        return AVERROR(EIO);
++    }
++
++    AUDIO_INITINFO(&info);
++
++#ifdef AUMODE_PLAY /* BSD extension */
++    info.mode = is_output ? AUMODE_PLAY : AUMODE_RECORD;
++#endif
++
++    prinfo = is_output ? &info.play : &info.record;
++
++    prinfo->encoding = AUDIO_ENCODING_LINEAR;
++    prinfo->precision = 16;
++    prinfo->sample_rate = s->sample_rate;
++    prinfo->channels = s->channels;
++
++    if ((err = ioctl(audio_fd, AUDIO_SETINFO, &info)) < 0) {
++        av_log(s1, AV_LOG_ERROR, "AUDIO_SETINFO: %s\n", av_err2str(AVERROR(errno)));
++        goto fail;
++    }
++
++    if ((err = ioctl(audio_fd, AUDIO_GETINFO, &info)) < 0) {
++        av_log(s1, AV_LOG_ERROR, "AUDIO_GETINFO: %s\n", av_err2str(AVERROR(errno)));
++        goto fail;
++    }
++
++    s->fd = audio_fd;
++#if HAVE_BIGENDIAN
++    s->codec_id = AV_CODEC_ID_PCM_S16BE;
++#else
++    s->codec_id = AV_CODEC_ID_PCM_S16LE;
++#endif
++    s->precision = prinfo->precision;
++    s->sample_rate = prinfo->sample_rate;
++    s->channels = prinfo->channels;
++    s->blocksize = s->buffer_samples * prinfo->precision * prinfo->channels;
++
++    if ((s->buffer = malloc(s->blocksize)) == NULL) {
++        av_log(s1, AV_LOG_ERROR, "malloc: %s\n", av_err2str(AVERROR(errno)));
++        goto fail;
++    }
++
++    return 0;
++ fail:
++    close(audio_fd);
++    return AVERROR(EIO);
++}
++
++int ff_sunau_audio_close(SunAudioData *s)
++{
++    close(s->fd);
++    return 0;
++}
Index: pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau.h
diff -u /dev/null pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau.h:1.1
--- /dev/null   Fri Mar 20 21:19:54 2020
+++ pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau.h Fri Mar 20 21:19:54 2020
@@ -0,0 +1,55 @@
+$NetBSD: patch-libavdevice_sunau.h,v 1.1 2020/03/20 21:19:54 nia Exp $
+
+Sun audio support.
+
+--- libavdevice/sunau.h.orig   2020-03-20 20:53:01.579839153 +0000
++++ libavdevice/sunau.h
+@@ -0,0 +1,48 @@
++/*
++ * Solaris/NetBSD play and grab interface
++ * Copyright (c) 2020 Yorick Hardy
++ * Copyright (c) 2020 Nia Alarie <nia%NetBSD.org@localhost>
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#ifndef AVDEVICE_SUNAU_H
++#define AVDEVICE_SUNAU_H
++
++#include "libavcodec/avcodec.h"
++
++#include "libavformat/avformat.h"
++
++typedef struct SunAudioData {
++    AVClass *class;
++    int fd;
++    int buffer_samples;
++    unsigned int sample_rate;
++    unsigned int channels;
++    unsigned int precision;
++    size_t blocksize;
++    enum AVCodecID codec_id;
++    uint8_t *buffer;
++    size_t buffer_ptr;
++} SunAudioData;
++
++int ff_sunau_audio_open(AVFormatContext *s1, int is_output,
++                        const char *audio_device);
++
++int ff_sunau_audio_close(SunAudioData *s);
++
++#endif /* AVDEVICE_SUNAU_H */
Index: pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau__dec.c
diff -u /dev/null pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau__dec.c:1.1
--- /dev/null   Fri Mar 20 21:19:54 2020
+++ pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau__dec.c    Fri Mar 20 21:19:54 2020
@@ -0,0 +1,145 @@
+$NetBSD: patch-libavdevice_sunau__dec.c,v 1.1 2020/03/20 21:19:54 nia Exp $
+
+Sun audio support.
+
+--- libavdevice/sunau_dec.c.orig       2020-03-20 20:53:01.607986932 +0000
++++ libavdevice/sunau_dec.c
+@@ -0,0 +1,138 @@
++/*
++ * Solaris/NetBSD play and grab interface
++ * Copyright (c) 2020 Yorick Hardy
++ * Copyright (c) 2020 Nia Alarie <nia%NetBSD.org@localhost>
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#include "config.h"
++
++#include <stdint.h>
++
++#include <unistd.h>
++#include <fcntl.h>
++#include <poll.h>
++#include <sys/audioio.h>
++#include <sys/ioctl.h>
++
++#include "libavutil/internal.h"
++#include "libavutil/opt.h"
++#include "libavutil/time.h"
++
++#include "libavcodec/avcodec.h"
++
++#include "avdevice.h"
++#include "libavformat/internal.h"
++
++#include "sunau.h"
++
++static int audio_read_header(AVFormatContext *s1)
++{
++    SunAudioData *s = s1->priv_data;
++    AVStream *st;
++
++    st = avformat_new_stream(s1, NULL);
++    if (!st) {
++        return AVERROR(ENOMEM);
++    }
++
++    if (ff_sunau_audio_open(s1, 0, s1->url) < 0) {
++        return AVERROR(EIO);
++    }
++
++    /* take real parameters */
++    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
++    st->codecpar->codec_id = s->codec_id;
++    st->codecpar->sample_rate = s->sample_rate;
++    st->codecpar->channels = s->channels;
++
++    avpriv_set_pts_info(st, 64, 1, 1000000);  /* 64 bits pts in us */
++
++    return 0;
++}
++
++static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
++{
++    SunAudioData *s = s1->priv_data;
++    struct audio_info info;
++    int ret;
++    long bdelay;
++    int64_t cur_time;
++
++    if ((ret = av_new_packet(pkt, s->blocksize)) < 0)
++        return ret;
++
++    ret = read(s->fd, pkt->data, pkt->size);
++    if (ret <= 0) {
++        av_packet_unref(pkt);
++        pkt->size = 0;
++        return ret < 0 ? AVERROR(errno) : AVERROR_EOF;
++    }
++
++    /* compute pts of the start of the packet */
++    cur_time = av_gettime();
++    bdelay = ret;
++
++#ifdef AUDIO_GETBUFINFO /* BSD extension */
++    if (ioctl(s->fd, AUDIO_GETBUFINFO, &info) == 0) {
++        bdelay += info.record.seek;
++    }
++#endif
++
++    /* subtract time represented by the number of bytes in the audio fifo */
++    cur_time -= (bdelay * 1000000LL) / (s->sample_rate * s->channels * s->precision);
++
++    /* convert to wanted units */
++    pkt->pts = cur_time;
++
++    return 0;
++}
++
++static int audio_read_close(AVFormatContext *s1)
++{
++    SunAudioData *s = s1->priv_data;
++
++    ff_sunau_audio_close(s);
++    return 0;
++}
++
++static const AVOption options[] = {
++    { "buffer_samples", "", offsetof(SunAudioData, buffer_samples), AV_OPT_TYPE_INT, {.i64 = 32},    1,     INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
++    { "sample_rate",    "", offsetof(SunAudioData, sample_rate),    AV_OPT_TYPE_INT, {.i64 = 48000}, 1000,  192000,  AV_OPT_FLAG_DECODING_PARAM },
++    { "channels",       "", offsetof(SunAudioData, channels),       AV_OPT_TYPE_INT, {.i64 = 2},     1,     12,      AV_OPT_FLAG_DECODING_PARAM },
++    { NULL },
++};
++
++static const AVClass sunau_demuxer_class = {
++    .class_name     = "Sun/NetBSD audio demuxer",
++    .item_name      = av_default_item_name,
++    .option         = options,
++    .version        = LIBAVUTIL_VERSION_INT,
++    .category       = AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT,
++};
++
++AVInputFormat ff_sunau_demuxer = {
++    .name           = "sunau",
++    .long_name      = NULL_IF_CONFIG_SMALL("Sun/NetBSD audio capture"),
++    .priv_data_size = sizeof(SunAudioData),
++    .read_header    = audio_read_header,
++    .read_packet    = audio_read_packet,
++    .read_close     = audio_read_close,
++    .flags          = AVFMT_NOFILE,
++    .priv_class     = &sunau_demuxer_class,
++};
Index: pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau__enc.c
diff -u /dev/null pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau__enc.c:1.1
--- /dev/null   Fri Mar 20 21:19:54 2020
+++ pkgsrc/multimedia/ffmpeg4/patches/patch-libavdevice_sunau__enc.c    Fri Mar 20 21:19:54 2020
@@ -0,0 +1,121 @@
+$NetBSD: patch-libavdevice_sunau__enc.c,v 1.1 2020/03/20 21:19:54 nia Exp $
+
+Sun audio support.
+
+--- libavdevice/sunau_enc.c.orig       2020-03-20 20:53:01.636938971 +0000
++++ libavdevice/sunau_enc.c
+@@ -0,0 +1,114 @@
++/*
++ * Solaris/NetBSD play and grab interface
++ * Copyright (c) 2020 Yorick Hardy
++ * Copyright (c) 2020 Nia Alarie <nia%NetBSD.org@localhost>
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#include "config.h"
++
++#include <unistd.h>
++#include <fcntl.h>
++#include <sys/audioio.h>
++#include <sys/ioctl.h>
++
++#include "libavutil/internal.h"
++
++#include "libavcodec/avcodec.h"
++
++#include "avdevice.h"
++#include "libavformat/internal.h"
++
++#include "sunau.h"
++
++static int audio_write_header(AVFormatContext *s1)
++{
++    SunAudioData *s = s1->priv_data;
++    AVStream *st;
++
++    st = s1->streams[0];
++    s->sample_rate = st->codecpar->sample_rate;
++    s->channels = st->codecpar->channels;
++    s->codec_id = st->codecpar->codec_id;
++    return ff_sunau_audio_open(s1, 1, s1->url) < 0 ? AVERROR(EIO) : 0;
++}
++
++static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
++{
++    SunAudioData *s = s1->priv_data;
++    unsigned int len, size = pkt->size;
++    uint8_t *buf = pkt->data;
++    int ret;
++
++    while (size > 0) {
++        len = FFMIN(s->blocksize - s->buffer_ptr, size);
++        memcpy(s->buffer + s->buffer_ptr, buf, len);
++        s->buffer_ptr += len;
++        if (s->buffer_ptr >= s->blocksize) {
++            for (;;) {
++                ret = write(s->fd, s->buffer, s->blocksize);
++                if (ret > 0)
++                    break;
++                if (ret < 0 && (errno != EAGAIN && errno != EINTR))
++                    return AVERROR(EIO);
++            }
++            s->buffer_ptr = 0;
++        }
++        buf += len;
++        size -= len;
++    }
++    return 0;
++}
++
++static int audio_write_trailer(AVFormatContext *s1)
++{
++    SunAudioData *s = s1->priv_data;
++
++    ff_sunau_audio_close(s);
++    return 0;
++}
++
++static const AVOption options[] = {
++    { "buffer_samples", "", offsetof(SunAudioData, buffer_samples), AV_OPT_TYPE_INT, {.i64 = 32}, 1, 192000, AV_OPT_FLAG_DECODING_PARAM },
++    { NULL },
++};
++
++static const AVClass sunau_muxer_class = {
++    .class_name     = "Sun/NetBSD audio muxer",
++    .item_name      = av_default_item_name,
++    .option         = options,
++    .version        = LIBAVUTIL_VERSION_INT,
++    .category       = AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT,
++};
++
++AVOutputFormat ff_sunau_muxer = {
++    .name           = "sunau",
++    .long_name      = NULL_IF_CONFIG_SMALL("Sun/NetBSD audio playback"),
++    .priv_data_size = sizeof(SunAudioData),
++    /* XXX: we may need to support higher precisions in the future, but
++       right now this is what the kernel can handle natively */
++    /* XXX: find better solution with "preinit" method, needed also in
++       other formats */
++    .audio_codec    = AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE),
++    .video_codec    = AV_CODEC_ID_NONE,
++    .write_header   = audio_write_header,
++    .write_packet   = audio_write_packet,
++    .write_trailer  = audio_write_trailer,
++    .flags          = AVFMT_NOFILE,
++    .priv_class     = &sunau_muxer_class,
++};



Home | Main Index | Thread Index | Old Index