summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--multimedia/ffmpeg/Makefile47
-rw-r--r--multimedia/ffmpeg/distinfo5
-rw-r--r--multimedia/ffmpeg/files/bktr.diff22
-rw-r--r--multimedia/ffmpeg/files/ffmpeg.1.diff61
-rw-r--r--multimedia/ffmpeg/files/grab_bsdbktr.c325
-rw-r--r--multimedia/ffmpeg/patches/patch-ad24
-rw-r--r--multimedia/ffmpeg/patches/patch-ag194
7 files changed, 663 insertions, 15 deletions
diff --git a/multimedia/ffmpeg/Makefile b/multimedia/ffmpeg/Makefile
index 23df7cd697c..0744231ec2d 100644
--- a/multimedia/ffmpeg/Makefile
+++ b/multimedia/ffmpeg/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.8 2004/07/26 23:53:49 xtraeme Exp $
+# $NetBSD: Makefile,v 1.9 2004/08/29 22:43:50 wiz Exp $
DISTNAME= ffmpeg-0.4.8
-PKGREVISION= 1
+PKGREVISION= 2
CATEGORIES= multimedia net
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=ffmpeg/}
@@ -22,15 +22,25 @@ MAKE_ENV+= EXTRA_LIBS="${LIBGETOPT}" \
FFSERVER_CONF=${PKG_SYSCONFDIR}/ffserver.conf \
LOCALBASE="${LOCALBASE}"
-CONFIGURE_ARGS= --cc=${CC} --disable-grab --prefix=${PREFIX}
+CONFIGURE_ARGS= --cc=${CC} --prefix=${PREFIX}
CONFIGURE_ARGS+= --enable-pp --disable-vhook --disable-debug
+PKG_OPTIONS_VAR= PKG_OPTIONS.ffmpeg
+PKG_SUPPORTED_OPTIONS= bktr lame mmx vorbis
+
+.include "../../mk/bsd.options.mk"
+
+.include "../../mk/bsd.prefs.mk"
+
+.if !empty(USE_MMX:M[Yy][Ee][Ss])
+PKG_DEFAULT_OPTIONS+= mmx
+.endif
+
.include "../../mk/compiler.mk"
.if !empty(MACHINE_ARCH:Mi386)
-BUILD_DEFS+= USE_MMX
-. if !empty(USE_MMX:M[Yy][Ee][Ss]) && !empty(CC_VERSION:Mgcc*)
-CFLAGS+= -fomit-frame-pointer
+. if !empty(PKG_OPTIONS:Mmmx) && !empty(CC_VERSION:Mgcc*)
+CFLAGS+= -fomit-frame-pointer
. else
CONFIGURE_ARGS+= --disable-mmx
. endif
@@ -38,6 +48,15 @@ CONFIGURE_ARGS+= --disable-mmx
CONFIGURE_ARGS+= --disable-mmx
.endif
+.if !empty(PKG_OPTIONS:Mbktr)
+post-extract:
+ ${CP} ${FILESDIR}/grab_bsdbktr.c ${WRKSRC}/libavformat
+
+post-patch:
+ ${PATCH} --quiet -d ${WRKSRC} < ${FILESDIR}/bktr.diff
+ ${PATCH} --quiet -d ${WRKSRC} < ${FILESDIR}/ffmpeg.1.diff
+.endif
+
post-install:
${INSTALL_DATA_DIR} ${PREFIX}/share/examples/ffmpeg \
${PREFIX}/share/doc/ffmpeg \
@@ -56,5 +75,19 @@ post-install:
${PREFIX}/include/ffmpeg/libpostproc
.include "../../devel/libgetopt/buildlink3.mk"
-.include "../../mk/ossaudio.buildlink3.mk"
+
+.if !empty(PKG_OPTIONS:Mlame)
+CONFIGURE_ARGS+= --enable-mp3lame
+.include "../../audio/lame/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-mp3lame
+.endif
+
+.if !empty(PKG_OPTIONS:Mvorbis)
+CONFIGURE_ARGS+= --enable-vorbis
+.include "../../audio/libvorbis/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-vorbis
+.endif
+
.include "../../mk/bsd.pkg.mk"
diff --git a/multimedia/ffmpeg/distinfo b/multimedia/ffmpeg/distinfo
index d514bf10419..495161973b8 100644
--- a/multimedia/ffmpeg/distinfo
+++ b/multimedia/ffmpeg/distinfo
@@ -1,10 +1,11 @@
-$NetBSD: distinfo,v 1.5 2004/08/06 11:01:53 drochner Exp $
+$NetBSD: distinfo,v 1.6 2004/08/29 22:43:50 wiz Exp $
SHA1 (ffmpeg-0.4.8.tar.gz) = 629a0f8f4daa3da1dedd8ba58bfdec4c47581bb4
Size (ffmpeg-0.4.8.tar.gz) = 1352874 bytes
SHA1 (patch-aa) = ed0dadc9112d8ae1cdcb30bc08f7e8c27195e027
SHA1 (patch-ab) = f596db3c555ab772eae2da5b8144c23fb4f2eaa0
SHA1 (patch-ac) = 6f137ca14131e00c2db89cbe44657f32f3513e98
-SHA1 (patch-ad) = 38ce2de4fd721ed0832669ffb9e30f4a909e10b2
+SHA1 (patch-ad) = e058ddcb0ad4211c16d2f4c5fe0859723316b3a8
SHA1 (patch-ae) = 7223978301c95de96d19610afb332f10764c4de0
SHA1 (patch-af) = 6e245cee0c49bc9a829bc9caf5fad5f887da8e3c
+SHA1 (patch-ag) = 975f7dac2488f367083cf4375b862fe8e3f4daf6
diff --git a/multimedia/ffmpeg/files/bktr.diff b/multimedia/ffmpeg/files/bktr.diff
new file mode 100644
index 00000000000..690204aa74b
--- /dev/null
+++ b/multimedia/ffmpeg/files/bktr.diff
@@ -0,0 +1,22 @@
+--- libavformat/Makefile.orig 2004-08-14 14:51:47.000000000 +0200
++++ libavformat/Makefile 2004-08-14 14:52:43.000000000 +0200
+@@ -32,7 +32,7 @@
+ OBJS+= framehook.o
+
+ ifeq ($(CONFIG_VIDEO4LINUX),yes)
+-OBJS+= grab.o
++OBJS+= grab_bsdbktr.o
+ endif
+
+ ifeq ($(CONFIG_DV1394),yes)
+--- configure.org 2004-07-31 17:12:40.000000000 +0200
++++ configure 2004-07-31 17:12:54.000000000 +0200
+@@ -231,6 +231,8 @@
+ *) ;;
+ esac
+
++v4l="yes"
++
+ # From mplayer configure. We need TARGET_OS available
+ # to the Makefile, so it can distinguish between flavors
+ # of AltiVec on PowerPC
diff --git a/multimedia/ffmpeg/files/ffmpeg.1.diff b/multimedia/ffmpeg/files/ffmpeg.1.diff
new file mode 100644
index 00000000000..8e2ae71e9bb
--- /dev/null
+++ b/multimedia/ffmpeg/files/ffmpeg.1.diff
@@ -0,0 +1,61 @@
+--- doc/ffmpeg.1.orig 2004-08-29 12:38:34.000000000 +0200
++++ doc/ffmpeg.1 2004-08-29 13:03:08.000000000 +0200
+@@ -505,21 +505,49 @@
+ tell that the raw codec data must be copied as is.
+ .Sh "Audio/Video grab options"
+ .IX Subsection "Audio/Video grab options"
+-.IP "\fB\-vd device\fR" 4
+-.IX Item "-vd device"
+-set video grab device (e.g. \fI/dev/video0\fR)
+-.IP "\fB\-vc channel\fR" 4
+-.IX Item "-vc channel"
+-set video grab channel (\s-1DV1394\s0 only)
+ .IP "\fB\-tvstd standard\fR" 4
+ .IX Item "-tvstd standard"
+ set television standard (\s-1NTSC\s0, \s-1PAL\s0 (\s-1SECAM\s0))
+-.IP "\fB\-dv1394\fR" 4
+-.IX Item "-dv1394"
+-set \s-1DV1394\s0 grab
+ .IP "\fB\-ad device\fR" 4
+ .IX Item "-ad device"
+ set audio device (e.g. \fI/dev/dsp\fR)
++.PP
++This build of ffmpeg includes NetBSD-specific patches that change the
++video-grabbing semantics. Recording from bktr(4) can be controlled via the
++following environment variables:
++.PP
++.RS
++.B BKTR_DEV
++(0\-4): which of the devices on the bktr should provide the signal (tuner,
++video-in,...)
++.PP
++.B BKTR_FORMAT
++(1\-6): TV format, 1 PAL 2 NTSC 3 SECAM 4 PALN 5 PALM 6 NTSCJ
++.PP
++.B BKTR_FREQUENCY
++(float): frequency to which the tuner should be set.
++.PP
++.B BKTR_CHANNEL
++(int): channel to which the tuner should be set, overrides BKTR_FREQUENCY
++.RE
++.PP
++If you set the channel or frequency with a different program such as xawtv
++or fxtv you might not get audio; try to use the environment variables in
++that case. Do not forget to set the following mixerctl variables to useful
++values:
++.PP
++.RS
++record.source=line
++.PP
++record.volume=255,255
++.PP
++inputs.line=255,255
++.RE
++.PP
++One possible command line would then be:
++.PP
++ffmpeg -y -intra -tvstd pal -vcodec mpeg2video -s 768x576 -b 9600 -ab 128 -ad
++/dev/audio -ac 2 -ar 44100 /tmp/file.mpg
+ .Sh "Advanced options"
+ .IX Subsection "Advanced options"
+ .IP "\fB\-map file:stream\fR" 4
diff --git a/multimedia/ffmpeg/files/grab_bsdbktr.c b/multimedia/ffmpeg/files/grab_bsdbktr.c
new file mode 100644
index 00000000000..8932d6364f9
--- /dev/null
+++ b/multimedia/ffmpeg/files/grab_bsdbktr.c
@@ -0,0 +1,325 @@
+/*
+ * FreeBSD video grab interface
+ * Copyright (c) 2002 Steve O'Hara-Smith
+ * based on
+ * Linux video grab interface
+ * Copyright (c) 2000,2001 Gerard Lantau.
+ * and
+ * simple_grab.c Copyright (c) 1999 Roger Hardiman
+ *
+ * GPL virus inherited:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include "avformat.h"
+#include <dev/ic/bt8xx.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <signal.h>
+
+typedef struct {
+ int fd;
+ int tuner_fd;
+ int frame_format; /* see VIDEO_PALETTE_xxx */
+ int width, height;
+ int frame_rate;
+ int frame_rate_base;
+ int64_t per_frame;
+} VideoData;
+
+const char *video_device = "/dev/bktr0";
+
+#define PAL 1
+#define PALBDGHI 1
+#define NTSC 2
+#define NTSCM 2
+#define SECAM 3
+#define PALN 4
+#define PALM 5
+#define NTSCJ 6
+
+/* PAL is 768 x 576. NTSC is 640 x 480 */
+#define PAL_HEIGHT 576
+#define SECAM_HEIGHT 576
+#define NTSC_HEIGHT 480
+
+#ifndef VIDEO_FORMAT
+#define VIDEO_FORMAT NTSC
+#endif
+
+static int bktr_dev[] = { METEOR_DEV0, METEOR_DEV1, METEOR_DEV2,
+ METEOR_DEV3, METEOR_DEV_SVIDEO };
+
+static u_int8_t *video_buf;
+static int nsignals = 0;
+static void catchsignal(int signal)
+{
+ nsignals++;
+ return;
+}
+
+static int bktr_init (const char *video_device, int width, int height,
+ int format, u_int8_t **video_buf, int *video_fd, int *tuner_fd,
+ int idev, double frequency)
+{
+ struct meteor_geomet geo;
+ int h_max;
+ long ioctl_frequency;
+ char *arg;
+ int c;
+ int channel = 0;
+ struct sigaction act,old;
+
+ if (idev < 0 || idev > 4)
+ {
+ arg = getenv ("BKTR_DEV");
+ if (arg)
+ idev = atoi (arg);
+ if (idev < 0 || idev > 4)
+ idev = 0;
+ }
+
+ if (format < 1 || format > 6)
+ {
+ arg = getenv ("BKTR_FORMAT");
+ if (arg)
+ format = atoi (arg);
+ if (format < 1 || format > 6)
+ format = VIDEO_FORMAT;
+ }
+
+ if (frequency <= 0)
+ {
+ arg = getenv ("BKTR_FREQUENCY");
+ if (arg)
+ frequency = atof (arg);
+ if (frequency <= 0)
+ frequency = 0.0;
+ }
+
+ arg = getenv ("BKTR_CHANNEL");
+ if (arg)
+ channel = atoi (arg);
+ if (channel < 0)
+ channel = 0;
+
+ memset(&act,0,sizeof(act));
+ sigemptyset(&act.sa_mask);
+ act.sa_handler = catchsignal;
+ sigaction(SIGUSR1,&act,&old);
+
+ *tuner_fd = open ("/dev/tuner0", O_RDONLY);
+ if (*tuner_fd < 0) {
+ perror("Warning: Tuner not opened continuing");
+ }
+
+ *video_fd = open (video_device, O_RDONLY);
+ if (*video_fd < 0) {
+ perror (video_device);
+ return -1;
+ }
+
+ geo.rows = height;
+ geo.columns = width;
+ geo.frames = 1;
+// geo.oformat = METEOR_GEO_YUV_422 | METEOR_GEO_YUV_12;
+ geo.oformat = METEOR_GEO_YUV_PACKED;
+
+ switch (format) {
+ case PAL: h_max = PAL_HEIGHT; c = BT848_IFORM_F_PALBDGHI; break;
+ case PALN: h_max = PAL_HEIGHT; c = BT848_IFORM_F_PALN; break;
+ case PALM: h_max = PAL_HEIGHT; c = BT848_IFORM_F_PALM; break;
+ case SECAM: h_max = SECAM_HEIGHT; c = BT848_IFORM_F_SECAM; break;
+ case NTSC: h_max = NTSC_HEIGHT; c = BT848_IFORM_F_NTSCM; break;
+ case NTSCJ: h_max = NTSC_HEIGHT; c = BT848_IFORM_F_NTSCJ; break;
+ default: h_max = PAL_HEIGHT; c = BT848_IFORM_F_PALBDGHI; break;
+ }
+ if (height <= h_max/2) {
+ geo.oformat |= METEOR_GEO_EVEN_ONLY;
+ }
+
+ if (ioctl(*video_fd, METEORSETGEO, &geo) < 0) {
+ perror ("METEORSETGEO");
+ return -1;
+ }
+
+ if (ioctl(*video_fd, BT848SFMT, &c) < 0) {
+ perror ("BT848SFMT");
+ return -1;
+ }
+
+ c = bktr_dev[idev];
+ if (ioctl(*video_fd, METEORSINPUT, &c) < 0) {
+ perror ("METEORSINPUT");
+ return -1;
+ }
+ *video_buf = (u_int8_t *) mmap((caddr_t)0, width*height*2,
+ PROT_READ, MAP_SHARED, *video_fd, (off_t) 0);
+ if (*video_buf == MAP_FAILED) {
+ perror ("mmap");
+ return -1;
+ }
+ if (frequency != 0.0) {
+ ioctl_frequency = (unsigned long)(frequency*16);
+ if (ioctl(*tuner_fd, TVTUNER_SETFREQ, &ioctl_frequency)<0)
+ perror("TVTUNER_SETFREQ");
+ }
+ if (channel != 0) {
+ if (ioctl(*tuner_fd, TVTUNER_SETCHNL, &channel) < 0)
+ perror("TVTUNER_SETCHNL");
+ }
+ c = METEOR_CAP_CONTINOUS;
+ ioctl(*video_fd, METEORCAPTUR, &c);
+ c = SIGUSR1;
+ ioctl (*video_fd, METEORSSIGNAL, &c);
+ return 0;
+}
+
+static void bktr_getframe(u_int64_t per_frame)
+{
+ u_int64_t curtime;
+ static u_int64_t last_frame_time = 0;
+
+ curtime = av_gettime();
+ if (!last_frame_time
+ || ((last_frame_time + per_frame) > curtime)) {
+ if (!usleep (last_frame_time + per_frame + per_frame/8 - curtime)) {
+ if (!nsignals)
+ printf ("\nSLEPT NO signals - %d microseconds late\n",
+ (int) (av_gettime() - last_frame_time - per_frame));
+ }
+ }
+ nsignals = 0;
+
+ last_frame_time = curtime;
+}
+
+void bf_memcpy (char *dest, char *src, int size)
+{
+ while (size -= 2)
+ {
+ dest[0] = src[1];
+ dest[1] = src[0];
+ dest += 2;
+ src += 2;
+ }
+}
+
+/* note: we support only one picture read at a time */
+static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
+{
+ VideoData *s = s1->priv_data;
+ int size, halfsize;
+
+ size = s->width * s->height;
+ halfsize = size << 1;
+
+// if (av_new_packet(pkt, size + halfsize) < 0)
+ if (av_new_packet(pkt, size + size) < 0)
+ return -EIO;
+
+ bktr_getframe (s->per_frame);
+ pkt->pts = av_gettime() & ((1LL << 48) - 1);
+ bf_memcpy (pkt->data, video_buf, size + size);
+// bf_memcpy (pkt->data, video_buf, size + halfsize);
+
+// return size + halfsize;
+ return size + size;
+}
+
+static int grab_read_header (AVFormatContext *s1, AVFormatParameters *ap)
+{
+ VideoData *s = s1->priv_data;
+ AVStream *st;
+ int width, height;
+ int frame_rate;
+ int frame_rate_base;
+ int format = -1;
+
+ if (!ap || ap->width <= 0 || ap->height <= 0 || ap->frame_rate <= 0)
+ return -1;
+
+ width = ap->width;
+ height = ap->height;
+ frame_rate = ap->frame_rate;
+ frame_rate_base = ap->frame_rate_base;
+
+ st = av_new_stream(s1, 0);
+ if (!st)
+ return -ENOMEM;
+
+ s->width = width;
+ s->height = height;
+ s->frame_rate = frame_rate;
+ s->frame_rate_base = frame_rate_base;
+ s->per_frame = ((int64_t)1000000 * s->frame_rate_base) / s->frame_rate;
+
+ st->codec.codec_type = CODEC_TYPE_VIDEO;
+// st->codec.pix_fmt = PIX_FMT_YUV420P;
+ st->codec.pix_fmt = PIX_FMT_YUV422;
+ st->codec.codec_id = CODEC_ID_RAWVIDEO;
+ st->codec.width = width;
+ st->codec.height = height;
+ st->codec.frame_rate = frame_rate;
+ st->codec.frame_rate_base = frame_rate_base;
+
+ av_set_pts_info(s1, 48, 1, 1000000); /* 48 bits pts in use */
+
+ if (ap->standard) {
+ if (!strcasecmp(ap->standard, "pal"))
+ format = PAL;
+ if (!strcasecmp(ap->standard, "secam"))
+ format = SECAM;
+ if (!strcasecmp(ap->standard, "ntsc"))
+ format = NTSC;
+ }
+
+ if (bktr_init (video_device, width, height, format, &video_buf,
+ &(s->fd), &(s->tuner_fd), -1, 0.0) < 0)
+ return -EIO;
+ return 0;
+}
+
+static int grab_read_close (AVFormatContext *s1)
+{
+ VideoData *s = s1->priv_data;
+
+ int c = METEOR_CAP_STOP_CONT;
+ ioctl(s->fd, METEORCAPTUR, &c);
+ close(s->fd);
+ close(s->tuner_fd);
+ av_free(s);
+ return 0;
+}
+
+AVInputFormat video_grab_device_format = {
+ "video4linux",
+ "video grab",
+ sizeof(VideoData),
+ NULL,
+ grab_read_header,
+ grab_read_packet,
+ grab_read_close,
+ flags: AVFMT_NOFILE,
+};
+
+int video_grab_init(void)
+{
+ av_register_input_format(&video_grab_device_format);
+ return 0;
+}
diff --git a/multimedia/ffmpeg/patches/patch-ad b/multimedia/ffmpeg/patches/patch-ad
index 48746f87ca4..08bff48b34d 100644
--- a/multimedia/ffmpeg/patches/patch-ad
+++ b/multimedia/ffmpeg/patches/patch-ad
@@ -1,8 +1,20 @@
-$NetBSD: patch-ad,v 1.2 2004/05/25 21:49:26 wiz Exp $
+$NetBSD: patch-ad,v 1.3 2004/08/29 22:43:50 wiz Exp $
--- libavformat/Makefile.orig 2003-09-28 17:26:40.000000000 +0200
-+++ libavformat/Makefile
-@@ -69,12 +69,14 @@ endif
++++ libavformat/Makefile 2004-08-14 14:50:54.000000000 +0200
+@@ -60,6 +60,11 @@
+
+ ifeq ($(CONFIG_VORBIS),yes)
+ OBJS+= ogg.o
++EXTRALIBS+= -lvorbis -lvorbisenc
++endif
++
++ifeq ($(CONFIG_MP3LAME),yes)
++EXTRALIBS += -lmp3lame
+ endif
+
+ LIB= $(LIBPREF)avformat$(LIBSUF)
+@@ -69,12 +74,14 @@
SRCS := $(OBJS:.o=.c) $(PPOBJS:.o=.cpp)
@@ -15,11 +27,11 @@ $NetBSD: patch-ad,v 1.2 2004/05/25 21:49:26 wiz Exp $
rm -f $@
- $(AR) rc $@ $(OBJS) $(PPOBJS)
- $(RANLIB) $@
-+ $(LIBTOOL) --mode=link $(CC) -o $(LIB:.a=.la) $(OBJS:.o=.lo) $(PPOBJS:.o=.lo) -rpath $(prefix)/lib $(LIBOSSAUDIO)
++ $(LIBTOOL) --mode=link $(CC) -o $(LIB:.a=.la) $(OBJS:.o=.lo) $(PPOBJS:.o=.lo) -rpath $(prefix)/lib $(LIBOSSAUDIO) $(EXTRALIBS)
$(SLIB): $(OBJS)
ifeq ($(CONFIG_WIN32),yes)
-@@ -84,9 +86,6 @@ else
+@@ -84,9 +91,6 @@
$(CC) $(SHFLAGS) -o $@ $(OBJS) $(PPOBJS) $(EXTRALIBS)
endif
@@ -29,7 +41,7 @@ $NetBSD: patch-ad,v 1.2 2004/05/25 21:49:26 wiz Exp $
ifeq ($(BUILD_SHARED),yes)
install: all install-headers
ifeq ($(CONFIG_WIN32),yes)
-@@ -112,11 +111,11 @@ install-headers:
+@@ -112,11 +116,11 @@
"$(prefix)/include/ffmpeg"
%.o: %.c
diff --git a/multimedia/ffmpeg/patches/patch-ag b/multimedia/ffmpeg/patches/patch-ag
new file mode 100644
index 00000000000..14a3ec05a98
--- /dev/null
+++ b/multimedia/ffmpeg/patches/patch-ag
@@ -0,0 +1,194 @@
+$NetBSD: patch-ag,v 1.1 2004/08/29 22:43:50 wiz Exp $
+
+--- libavformat/audio.c.orig 2003-09-28 17:26:40.000000000 +0200
++++ libavformat/audio.c
+@@ -18,10 +18,19 @@
+ */
+ #include "avformat.h"
+
++#ifdef __NetBSD__
++#define USE_SUNAUDIO
++#endif
++
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
++#ifndef USE_SUNAUDIO
+ #include <sys/soundcard.h>
++#else
++#include <sys/types.h>
++#include <sys/audioio.h>
++#endif
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <sys/ioctl.h>
+@@ -47,9 +56,18 @@ static int audio_open(AudioData *s, int
+ int tmp, err;
+ char *flip = getenv("AUDIO_FLIP_LEFT");
+
++#ifdef USE_SUNAUDIO
++ audio_info_t info;
++ struct audio_prinfo *settings;
++ int mixer_fd;
++
++ if (!audio_device)
++ audio_device = "/dev/audio";
++#else
+ /* open linux audio device */
+ if (!audio_device)
+ audio_device = "/dev/dsp";
++#endif
+
+ if (is_output)
+ audio_fd = open(audio_device, O_WRONLY);
+@@ -77,6 +95,7 @@ static int audio_open(AudioData *s, int
+ }
+ #endif
+
++#ifndef USE_SUNAUDIO
+ /* select format : favour native format */
+ err = ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &tmp);
+
+@@ -124,14 +143,114 @@ static int audio_open(AudioData *s, int
+ }
+ if (tmp)
+ s->channels = 2;
++#else /* USE_SUNAUDIO */
++ AUDIO_INITINFO(&info);
++ if (!is_output) {
++ info.mode = AUMODE_RECORD;
++ settings = &info.record;
++ } else {
++ info.mode = AUMODE_PLAY;
++ settings = &info.play;
++ }
++
++ /* select format */
++ /* Try native 16 bit format first */
++#ifdef WORDS_BIGENDIAN
++ settings->encoding = AUDIO_ENCODING_SLINEAR_BE;
++ s->codec_id = CODEC_ID_PCM_S16BE;
++#else
++ settings->encoding = AUDIO_ENCODING_SLINEAR_LE;
++ s->codec_id = CODEC_ID_PCM_S16LE;
++#endif
++ settings->precision = 16;
++ err = ioctl(audio_fd, AUDIO_SETINFO, &info);
++ if (err < 0) {
++ fprintf(stderr, "Soundcard does not support signed 16 bit sample format\n");
++ close(audio_fd);
++ return -EIO;
++ }
+
++ /* set channels */
++ AUDIO_INITINFO(&info);
++ settings->channels = s->channels;
++ err = ioctl(audio_fd, AUDIO_SETINFO, &info);
++ if (err < 0) {
++ fprintf(stderr, "stereo not supported, using mono");
++ }
++
++ /* set gain */
++ AUDIO_INITINFO(&info);
++ settings->gain = AUDIO_MAX_GAIN;
++ err = ioctl(audio_fd, AUDIO_SETINFO, &info);
++ if (err < 0) {
++ fprintf(stderr, "setting gain to %d failed", AUDIO_MAX_GAIN);
++ }
++
++#ifndef MIXER_DEVICE
++#define MIXER_DEVICE "/dev/mixer"
++#endif
++ if ((mixer_fd=open(MIXER_DEVICE, O_RDONLY)) == -1)
++ fprintf(stderr, "can't open %s\n", MIXER_DEVICE);
++ else {
++ int n;
++ mixer_devinfo_t mdt;
++ /* get debuggin information about all mixer devices */
++ mdt.index = n = 0;
++ while (ioctl(mixer_fd, AUDIO_MIXER_DEVINFO, &mdt) != -1) {
++ if (strcasecmp(mdt.label.name, "inputs") == 0) {
++ while (mdt.next != -1) {
++ printf("Mixer device %d: `%s' has type %d, class %d\n",
++ mdt.index, mdt.label.name, mdt.type,
++ mdt.mixer_class);
++ mdt.index = mdt.next;
++ if (ioctl(mixer_fd, AUDIO_MIXER_DEVINFO, &mdt) == -1) {
++ fprintf(stderr, "getting next mixer device "
++ "failed (%d)", mdt.index);
++ break;
++ }
++ printf("next device: ");
++ }
++ printf("Mixer device %d: `%s' has type %d, class %d\n",
++ mdt.index, mdt.label.name, mdt.type,
++ mdt.mixer_class);
++ }
++ n++;
++ mdt.index = n;
++ }
++ /* set input to line-in */
++ AUDIO_INITINFO(&info);
++ settings->port = AUDIO_LINE_IN;
++ err = ioctl(audio_fd, AUDIO_SETINFO, &info);
++ if (err < 0) {
++ fprintf(stderr, "setting input to line-in failed");
++ }
++ }
++ close(mixer_fd);
++#endif
++
++#ifndef USE_SUNAUDIO
+ tmp = s->sample_rate;
+ err = ioctl(audio_fd, SNDCTL_DSP_SPEED, &tmp);
+ if (err < 0) {
+ perror("SNDCTL_DSP_SPEED");
+ goto fail;
+ }
++
+ s->sample_rate = tmp; /* store real sample rate */
++#else
++ AUDIO_INITINFO(&info);
++ settings->sample_rate = s->sample_rate;
++ err = ioctl(audio_fd, AUDIO_SETINFO, &info);
++ if (err < 0) {
++ fprintf(stderr, "setting sample rate to %d failed", s->sample_rate);
++ err = ioctl(audio_fd, AUDIO_GETINFO, &info);
++ if (err < 0) {
++ perror("AUDIO_GETINFO");
++ goto fail;
++ }
++ s->sample_rate = settings->sample_rate;
++ }
++#endif
+ s->fd = audio_fd;
+
+ return 0;
+@@ -239,7 +358,11 @@ static int audio_read_packet(AVFormatCon
+ AudioData *s = s1->priv_data;
+ int ret, bdelay;
+ int64_t cur_time;
++#ifndef USE_SUNAUDIO
+ struct audio_buf_info abufi;
++#else
++ audio_info_t info;
++#endif
+
+ if (av_new_packet(pkt, s->frame_size) < 0)
+ return -EIO;
+@@ -274,9 +397,15 @@ static int audio_read_packet(AVFormatCon
+ /* compute pts of the start of the packet */
+ cur_time = av_gettime();
+ bdelay = ret;
++#ifndef USE_SUNAUDIO
+ if (ioctl(s->fd, SNDCTL_DSP_GETISPACE, &abufi) == 0) {
+ bdelay += abufi.bytes;
+ }
++#else
++ if (ioctl(s->fd, AUDIO_GETINFO, &info) == 0) {
++ bdelay += info.record.seek * (info.record.precision/8);
++ }
++#endif
+ /* substract time represented by the number of bytes in the audio fifo */
+ cur_time -= (bdelay * 1000000LL) / (s->sample_rate * s->channels);
+