From: yomguy <> Date: Tue, 13 Jul 2010 22:13:46 +0000 (+0000) Subject: add libedcast X-Git-Tag: 1.0~169 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=84ccb3bb72477c58e323142d4c3295cd4ce95b35;p=telecaster-server.git add libedcast --- diff --git a/tools/edcast-jack/libedcast/.deps/Socket.Po b/tools/edcast-jack/libedcast/.deps/Socket.Po new file mode 100644 index 0000000..6bcaf31 --- /dev/null +++ b/tools/edcast-jack/libedcast/.deps/Socket.Po @@ -0,0 +1,143 @@ +Socket.o: Socket.cpp //usr/include/stdio.h //usr/include/features.h \ + //usr/include/bits/predefs.h //usr/include/sys/cdefs.h \ + //usr/include/bits/wordsize.h //usr/include/gnu/stubs.h \ + //usr/include/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stddef.h \ + //usr/include/bits/types.h //usr/include/bits/typesizes.h \ + //usr/include/libio.h //usr/include/_G_config.h //usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stdarg.h \ + //usr/include/bits/stdio_lim.h //usr/include/bits/sys_errlist.h \ + //usr/include/bits/stdio.h //usr/include/bits/stdio2.h \ + libedcast_socket.h //usr/include/sys/types.h //usr/include/time.h \ + //usr/include/endian.h //usr/include/bits/endian.h \ + //usr/include/bits/byteswap.h //usr/include/sys/select.h \ + //usr/include/bits/select.h //usr/include/bits/sigset.h \ + //usr/include/bits/time.h //usr/include/sys/sysmacros.h \ + //usr/include/bits/pthreadtypes.h //usr/include/sys/socket.h \ + //usr/include/sys/uio.h //usr/include/bits/uio.h \ + //usr/include/bits/socket.h //usr/include/bits/sockaddr.h \ + //usr/include/asm/socket.h //usr/include/asm-generic/socket.h \ + //usr/include/asm/sockios.h //usr/include/asm-generic/sockios.h \ + //usr/include/bits/socket2.h //usr/include/netinet/in.h \ + //usr/include/stdint.h //usr/include/bits/wchar.h \ + //usr/include/bits/in.h //usr/include/unistd.h \ + //usr/include/bits/posix_opt.h //usr/include/bits/environments.h \ + //usr/include/bits/confname.h //usr/include/getopt.h \ + //usr/include/bits/unistd.h //usr/include/string.h \ + //usr/include/xlocale.h //usr/include/bits/string3.h \ + //usr/include/netdb.h //usr/include/rpc/netdb.h \ + //usr/include/bits/siginfo.h //usr/include/bits/netdb.h + +//usr/include/stdio.h: + +//usr/include/features.h: + +//usr/include/bits/predefs.h: + +//usr/include/sys/cdefs.h: + +//usr/include/bits/wordsize.h: + +//usr/include/gnu/stubs.h: + +//usr/include/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stddef.h: + +//usr/include/bits/types.h: + +//usr/include/bits/typesizes.h: + +//usr/include/libio.h: + +//usr/include/_G_config.h: + +//usr/include/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stdarg.h: + +//usr/include/bits/stdio_lim.h: + +//usr/include/bits/sys_errlist.h: + +//usr/include/bits/stdio.h: + +//usr/include/bits/stdio2.h: + +libedcast_socket.h: + +//usr/include/sys/types.h: + +//usr/include/time.h: + +//usr/include/endian.h: + +//usr/include/bits/endian.h: + +//usr/include/bits/byteswap.h: + +//usr/include/sys/select.h: + +//usr/include/bits/select.h: + +//usr/include/bits/sigset.h: + +//usr/include/bits/time.h: + +//usr/include/sys/sysmacros.h: + +//usr/include/bits/pthreadtypes.h: + +//usr/include/sys/socket.h: + +//usr/include/sys/uio.h: + +//usr/include/bits/uio.h: + +//usr/include/bits/socket.h: + +//usr/include/bits/sockaddr.h: + +//usr/include/asm/socket.h: + +//usr/include/asm-generic/socket.h: + +//usr/include/asm/sockios.h: + +//usr/include/asm-generic/sockios.h: + +//usr/include/bits/socket2.h: + +//usr/include/netinet/in.h: + +//usr/include/stdint.h: + +//usr/include/bits/wchar.h: + +//usr/include/bits/in.h: + +//usr/include/unistd.h: + +//usr/include/bits/posix_opt.h: + +//usr/include/bits/environments.h: + +//usr/include/bits/confname.h: + +//usr/include/getopt.h: + +//usr/include/bits/unistd.h: + +//usr/include/string.h: + +//usr/include/xlocale.h: + +//usr/include/bits/string3.h: + +//usr/include/netdb.h: + +//usr/include/rpc/netdb.h: + +//usr/include/bits/siginfo.h: + +//usr/include/bits/netdb.h: diff --git a/tools/edcast-jack/libedcast/.deps/cbuffer.Po b/tools/edcast-jack/libedcast/.deps/cbuffer.Po new file mode 100644 index 0000000..8995ee3 --- /dev/null +++ b/tools/edcast-jack/libedcast/.deps/cbuffer.Po @@ -0,0 +1,78 @@ +cbuffer.o: cbuffer.c //usr/include/stdlib.h //usr/include/features.h \ + //usr/include/bits/predefs.h //usr/include/sys/cdefs.h \ + //usr/include/bits/wordsize.h //usr/include/gnu/stubs.h \ + //usr/include/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stddef.h \ + //usr/include/bits/waitflags.h //usr/include/bits/waitstatus.h \ + //usr/include/endian.h //usr/include/bits/endian.h \ + //usr/include/bits/byteswap.h //usr/include/xlocale.h \ + //usr/include/sys/types.h //usr/include/bits/types.h \ + //usr/include/bits/typesizes.h //usr/include/time.h \ + //usr/include/sys/select.h //usr/include/bits/select.h \ + //usr/include/bits/sigset.h //usr/include/bits/time.h \ + //usr/include/sys/sysmacros.h //usr/include/bits/pthreadtypes.h \ + //usr/include/alloca.h //usr/include/bits/stdlib.h cbuffer.h \ + //usr/include/pthread.h //usr/include/sched.h //usr/include/bits/sched.h \ + //usr/include/bits/setjmp.h + +//usr/include/stdlib.h: + +//usr/include/features.h: + +//usr/include/bits/predefs.h: + +//usr/include/sys/cdefs.h: + +//usr/include/bits/wordsize.h: + +//usr/include/gnu/stubs.h: + +//usr/include/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stddef.h: + +//usr/include/bits/waitflags.h: + +//usr/include/bits/waitstatus.h: + +//usr/include/endian.h: + +//usr/include/bits/endian.h: + +//usr/include/bits/byteswap.h: + +//usr/include/xlocale.h: + +//usr/include/sys/types.h: + +//usr/include/bits/types.h: + +//usr/include/bits/typesizes.h: + +//usr/include/time.h: + +//usr/include/sys/select.h: + +//usr/include/bits/select.h: + +//usr/include/bits/sigset.h: + +//usr/include/bits/time.h: + +//usr/include/sys/sysmacros.h: + +//usr/include/bits/pthreadtypes.h: + +//usr/include/alloca.h: + +//usr/include/bits/stdlib.h: + +cbuffer.h: + +//usr/include/pthread.h: + +//usr/include/sched.h: + +//usr/include/bits/sched.h: + +//usr/include/bits/setjmp.h: diff --git a/tools/edcast-jack/libedcast/.deps/libedcast.Po b/tools/edcast-jack/libedcast/.deps/libedcast.Po new file mode 100644 index 0000000..a19975d --- /dev/null +++ b/tools/edcast-jack/libedcast/.deps/libedcast.Po @@ -0,0 +1,239 @@ +libedcast.o: libedcast.cpp //usr/include/fcntl.h //usr/include/features.h \ + //usr/include/bits/predefs.h //usr/include/sys/cdefs.h \ + //usr/include/bits/wordsize.h //usr/include/gnu/stubs.h \ + //usr/include/gnu/stubs-64.h //usr/include/bits/fcntl.h \ + //usr/include/sys/types.h //usr/include/bits/types.h \ + //usr/include/bits/typesizes.h //usr/include/time.h \ + /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stddef.h \ + //usr/include/endian.h //usr/include/bits/endian.h \ + //usr/include/bits/byteswap.h //usr/include/sys/select.h \ + //usr/include/bits/select.h //usr/include/bits/sigset.h \ + //usr/include/bits/time.h //usr/include/sys/sysmacros.h \ + //usr/include/bits/pthreadtypes.h //usr/include/bits/uio.h \ + //usr/include/bits/stat.h //usr/include/bits/fcntl2.h \ + //usr/include/sys/stat.h //usr/include/string.h //usr/include/xlocale.h \ + //usr/include/bits/string3.h //usr/include/stdio.h //usr/include/libio.h \ + //usr/include/_G_config.h //usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stdarg.h \ + //usr/include/bits/stdio_lim.h //usr/include/bits/sys_errlist.h \ + //usr/include/bits/stdio.h //usr/include/bits/stdio2.h \ + //usr/include/stdlib.h //usr/include/bits/waitflags.h \ + //usr/include/bits/waitstatus.h //usr/include/alloca.h \ + //usr/include/bits/stdlib.h //usr/include/sys/timeb.h \ + //usr/include/vorbis/vorbisenc.h //usr/include/vorbis/codec.h \ + //usr/include/ogg/ogg.h //usr/include/ogg/os_types.h \ + //usr/include/ogg/config_types.h libedcast.h //usr/include/pthread.h \ + //usr/include/sched.h //usr/include/bits/sched.h \ + //usr/include/bits/setjmp.h cbuffer.h libedcast_socket.h \ + //usr/include/sys/socket.h //usr/include/sys/uio.h \ + //usr/include/bits/socket.h //usr/include/bits/sockaddr.h \ + //usr/include/asm/socket.h //usr/include/asm-generic/socket.h \ + //usr/include/asm/sockios.h //usr/include/asm-generic/sockios.h \ + //usr/include/bits/socket2.h //usr/include/netinet/in.h \ + //usr/include/stdint.h //usr/include/bits/wchar.h \ + //usr/include/bits/in.h //usr/include/unistd.h \ + //usr/include/bits/posix_opt.h //usr/include/bits/environments.h \ + //usr/include/bits/confname.h //usr/include/getopt.h \ + //usr/include/bits/unistd.h //usr/include/netdb.h \ + //usr/include/rpc/netdb.h //usr/include/bits/siginfo.h \ + //usr/include/bits/netdb.h libedcast_resample.h \ + //usr/include/lame/lame.h //usr/include/sys/ioctl.h \ + //usr/include/bits/ioctls.h //usr/include/asm/ioctls.h \ + //usr/include/asm-generic/ioctls.h //usr/include/linux/ioctl.h \ + //usr/include/asm/ioctl.h //usr/include/asm-generic/ioctl.h \ + //usr/include/bits/ioctl-types.h //usr/include/sys/ttydefaults.h \ + //usr/include/errno.h //usr/include/bits/errno.h \ + //usr/include/linux/errno.h //usr/include/asm/errno.h \ + //usr/include/asm-generic/errno.h //usr/include/asm-generic/errno-base.h + +//usr/include/fcntl.h: + +//usr/include/features.h: + +//usr/include/bits/predefs.h: + +//usr/include/sys/cdefs.h: + +//usr/include/bits/wordsize.h: + +//usr/include/gnu/stubs.h: + +//usr/include/gnu/stubs-64.h: + +//usr/include/bits/fcntl.h: + +//usr/include/sys/types.h: + +//usr/include/bits/types.h: + +//usr/include/bits/typesizes.h: + +//usr/include/time.h: + +/usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stddef.h: + +//usr/include/endian.h: + +//usr/include/bits/endian.h: + +//usr/include/bits/byteswap.h: + +//usr/include/sys/select.h: + +//usr/include/bits/select.h: + +//usr/include/bits/sigset.h: + +//usr/include/bits/time.h: + +//usr/include/sys/sysmacros.h: + +//usr/include/bits/pthreadtypes.h: + +//usr/include/bits/uio.h: + +//usr/include/bits/stat.h: + +//usr/include/bits/fcntl2.h: + +//usr/include/sys/stat.h: + +//usr/include/string.h: + +//usr/include/xlocale.h: + +//usr/include/bits/string3.h: + +//usr/include/stdio.h: + +//usr/include/libio.h: + +//usr/include/_G_config.h: + +//usr/include/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stdarg.h: + +//usr/include/bits/stdio_lim.h: + +//usr/include/bits/sys_errlist.h: + +//usr/include/bits/stdio.h: + +//usr/include/bits/stdio2.h: + +//usr/include/stdlib.h: + +//usr/include/bits/waitflags.h: + +//usr/include/bits/waitstatus.h: + +//usr/include/alloca.h: + +//usr/include/bits/stdlib.h: + +//usr/include/sys/timeb.h: + +//usr/include/vorbis/vorbisenc.h: + +//usr/include/vorbis/codec.h: + +//usr/include/ogg/ogg.h: + +//usr/include/ogg/os_types.h: + +//usr/include/ogg/config_types.h: + +libedcast.h: + +//usr/include/pthread.h: + +//usr/include/sched.h: + +//usr/include/bits/sched.h: + +//usr/include/bits/setjmp.h: + +cbuffer.h: + +libedcast_socket.h: + +//usr/include/sys/socket.h: + +//usr/include/sys/uio.h: + +//usr/include/bits/socket.h: + +//usr/include/bits/sockaddr.h: + +//usr/include/asm/socket.h: + +//usr/include/asm-generic/socket.h: + +//usr/include/asm/sockios.h: + +//usr/include/asm-generic/sockios.h: + +//usr/include/bits/socket2.h: + +//usr/include/netinet/in.h: + +//usr/include/stdint.h: + +//usr/include/bits/wchar.h: + +//usr/include/bits/in.h: + +//usr/include/unistd.h: + +//usr/include/bits/posix_opt.h: + +//usr/include/bits/environments.h: + +//usr/include/bits/confname.h: + +//usr/include/getopt.h: + +//usr/include/bits/unistd.h: + +//usr/include/netdb.h: + +//usr/include/rpc/netdb.h: + +//usr/include/bits/siginfo.h: + +//usr/include/bits/netdb.h: + +libedcast_resample.h: + +//usr/include/lame/lame.h: + +//usr/include/sys/ioctl.h: + +//usr/include/bits/ioctls.h: + +//usr/include/asm/ioctls.h: + +//usr/include/asm-generic/ioctls.h: + +//usr/include/linux/ioctl.h: + +//usr/include/asm/ioctl.h: + +//usr/include/asm-generic/ioctl.h: + +//usr/include/bits/ioctl-types.h: + +//usr/include/sys/ttydefaults.h: + +//usr/include/errno.h: + +//usr/include/bits/errno.h: + +//usr/include/linux/errno.h: + +//usr/include/asm/errno.h: + +//usr/include/asm-generic/errno.h: + +//usr/include/asm-generic/errno-base.h: diff --git a/tools/edcast-jack/libedcast/.deps/resample.Po b/tools/edcast-jack/libedcast/.deps/resample.Po new file mode 100644 index 0000000..cbf8936 --- /dev/null +++ b/tools/edcast-jack/libedcast/.deps/resample.Po @@ -0,0 +1,106 @@ +resample.o: resample.c //usr/include/math.h //usr/include/features.h \ + //usr/include/bits/predefs.h //usr/include/sys/cdefs.h \ + //usr/include/bits/wordsize.h //usr/include/gnu/stubs.h \ + //usr/include/gnu/stubs-64.h //usr/include/bits/huge_val.h \ + //usr/include/bits/huge_valf.h //usr/include/bits/huge_vall.h \ + //usr/include/bits/inf.h //usr/include/bits/nan.h \ + //usr/include/bits/mathdef.h //usr/include/bits/mathcalls.h \ + //usr/include/bits/mathinline.h //usr/include/stdlib.h \ + /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stddef.h \ + //usr/include/bits/waitflags.h //usr/include/bits/waitstatus.h \ + //usr/include/endian.h //usr/include/bits/endian.h \ + //usr/include/bits/byteswap.h //usr/include/xlocale.h \ + //usr/include/sys/types.h //usr/include/bits/types.h \ + //usr/include/bits/typesizes.h //usr/include/time.h \ + //usr/include/sys/select.h //usr/include/bits/select.h \ + //usr/include/bits/sigset.h //usr/include/bits/time.h \ + //usr/include/sys/sysmacros.h //usr/include/bits/pthreadtypes.h \ + //usr/include/alloca.h //usr/include/bits/stdlib.h \ + //usr/include/string.h //usr/include/bits/string.h \ + //usr/include/bits/string2.h //usr/include/bits/string3.h \ + /usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stdarg.h \ + //usr/include/assert.h libedcast_resample.h + +//usr/include/math.h: + +//usr/include/features.h: + +//usr/include/bits/predefs.h: + +//usr/include/sys/cdefs.h: + +//usr/include/bits/wordsize.h: + +//usr/include/gnu/stubs.h: + +//usr/include/gnu/stubs-64.h: + +//usr/include/bits/huge_val.h: + +//usr/include/bits/huge_valf.h: + +//usr/include/bits/huge_vall.h: + +//usr/include/bits/inf.h: + +//usr/include/bits/nan.h: + +//usr/include/bits/mathdef.h: + +//usr/include/bits/mathcalls.h: + +//usr/include/bits/mathinline.h: + +//usr/include/stdlib.h: + +/usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stddef.h: + +//usr/include/bits/waitflags.h: + +//usr/include/bits/waitstatus.h: + +//usr/include/endian.h: + +//usr/include/bits/endian.h: + +//usr/include/bits/byteswap.h: + +//usr/include/xlocale.h: + +//usr/include/sys/types.h: + +//usr/include/bits/types.h: + +//usr/include/bits/typesizes.h: + +//usr/include/time.h: + +//usr/include/sys/select.h: + +//usr/include/bits/select.h: + +//usr/include/bits/sigset.h: + +//usr/include/bits/time.h: + +//usr/include/sys/sysmacros.h: + +//usr/include/bits/pthreadtypes.h: + +//usr/include/alloca.h: + +//usr/include/bits/stdlib.h: + +//usr/include/string.h: + +//usr/include/bits/string.h: + +//usr/include/bits/string2.h: + +//usr/include/bits/string3.h: + +/usr/lib/gcc/x86_64-linux-gnu/4.4.4/include/stdarg.h: + +//usr/include/assert.h: + +libedcast_resample.h: diff --git a/tools/edcast-jack/libedcast/Makefile b/tools/edcast-jack/libedcast/Makefile new file mode 100644 index 0000000..6fadad6 --- /dev/null +++ b/tools/edcast-jack/libedcast/Makefile @@ -0,0 +1,558 @@ +# Makefile.in generated by automake 1.10 from Makefile.am. +# libedcast/Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + + + +pkgdatadir = $(datadir)/edcast-jack +pkglibdir = $(libdir)/edcast-jack +pkgincludedir = $(includedir)/edcast-jack +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = x86_64-unknown-linux-gnu +host_triplet = x86_64-unknown-linux-gnu +subdir = libedcast +DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/lame.m4 $(top_srcdir)/m4/mad.m4 \ + $(top_srcdir)/m4/ogg.m4 $(top_srcdir)/m4/vorbis.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" +libLIBRARIES_INSTALL = $(INSTALL_DATA) +LIBRARIES = $(lib_LIBRARIES) +ARFLAGS = cru +libedcast_a_AR = $(AR) $(ARFLAGS) +libedcast_a_LIBADD = +am_libedcast_a_OBJECTS = libedcast.$(OBJEXT) resample.$(OBJEXT) \ + cbuffer.$(OBJEXT) Socket.$(OBJEXT) +libedcast_a_OBJECTS = $(am_libedcast_a_OBJECTS) +DEFAULT_INCLUDES = -I. +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libedcast_a_SOURCES) +DIST_SOURCES = $(libedcast_a_SOURCES) +includeHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(include_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = ${SHELL} /home/telecaster/dev/telecaster/trunk/tools/edcast-jack/missing --run aclocal-1.10 +AMTAR = ${SHELL} /home/telecaster/dev/telecaster/trunk/tools/edcast-jack/missing --run tar +AR = ar +AUTOCONF = ${SHELL} /home/telecaster/dev/telecaster/trunk/tools/edcast-jack/missing --run autoconf +AUTOHEADER = ${SHELL} /home/telecaster/dev/telecaster/trunk/tools/edcast-jack/missing --run autoheader +AUTOMAKE = ${SHELL} /home/telecaster/dev/telecaster/trunk/tools/edcast-jack/missing --run automake-1.10 +AWK = gawk +CC = gcc +CCDEPMODE = depmode=gcc3 +CFLAGS = -g -O20 -ffast-math -fsigned-char -D_REENTRANT -D_GNU_SOURCE -DHAVE_FAAC -INONE/include +CPP = gcc -E +CPPFLAGS = +CXX = g++ +CXXCPP = g++ -E +CXXDEPMODE = depmode=gcc3 +CXXFLAGS = -O20 -ffast-math -fsigned-char -D_REENTRANT -D_GNU_SOURCE -INONE/include -INONE/include +CYGPATH_W = echo +DEBUG = -g -Wall -fsigned-char -D_REENTRANT -D_GNU_SOURCE +DEFS = -DPACKAGE_NAME=\"edcast-jack\" -DPACKAGE_TARNAME=\"edcast-jack\" -DPACKAGE_VERSION=\"3.1.7\" -DPACKAGE_STRING=\"edcast-jack\ 3.1.7\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"edcast-jack\" -DVERSION=\"3.1.7\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DSTDC_HEADERS=1 -DHAVE_JACK_JACK_H=1 -DHAVE_OGG=1 -DHAVE_STRUCT_OVECTL_RATEMANAGE_ARG=1 -DHAVE_VORBIS=1 -DHAVE_MAD_H=1 -DHAVE_LIBMAD=1 -DHAVE_LAME=1 +DEPDIR = .deps +ECHO = echo +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = /bin/grep -E +EXEEXT = +F77 = +FAAC_CFLAGS = -DHAVE_FAAC +FAAC_LIBS = -lfaac -lm +FFLAGS = +GREP = /bin/grep +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +JACK_LIBS = -ljack -ldl +LAME_CFLAGS = +LAME_LIBS = -lmp3lame -lm +LDFLAGS = +LIBFLAC_CFLAGS = -INONE/include +LIBFLAC_LIBS = -lFLAC -lm -lFLAC -lm +LIBOBJS = +LIBS = -lpthread -logg -lvorbis -lmad -lmp3lame -lm -lvorbisenc -lvorbisfile -lfaac -lm -lFLAC -lm -lFLAC -lm +LIBTOOL = $(SHELL) $(top_builddir)/libtool +LN_S = ln -s +LTLIBOBJS = +MAD_CFLAGS = +MAD_LIBS = -lmad +MAKEINFO = ${SHELL} /home/telecaster/dev/telecaster/trunk/tools/edcast-jack/missing --run makeinfo +MKDIR_P = /bin/mkdir -p +OBJEXT = o +OGG_CFLAGS = +OGG_LDFLAGS = +OGG_LIBS = -logg +OGG_PREFIX = +PACKAGE = edcast-jack +PACKAGE_BUGREPORT = +PACKAGE_NAME = edcast-jack +PACKAGE_STRING = edcast-jack 3.1.7 +PACKAGE_TARNAME = edcast-jack +PACKAGE_VERSION = 3.1.7 +PATH_SEPARATOR = : +RANLIB = ranlib +SET_MAKE = +SHELL = /bin/bash +STRIP = strip +VERSION = 3.1.7 +VORBISENC_LIBS = -lvorbisenc +VORBISFILE_LIBS = -lvorbisfile +VORBIS_CFLAGS = +VORBIS_LDFLAGS = +VORBIS_LIBS = -lvorbis +VORBIS_PREFIX = +abs_builddir = /home/telecaster/dev/telecaster/trunk/tools/edcast-jack/libedcast +abs_srcdir = /home/telecaster/dev/telecaster/trunk/tools/edcast-jack/libedcast +abs_top_builddir = /home/telecaster/dev/telecaster/trunk/tools/edcast-jack +abs_top_srcdir = /home/telecaster/dev/telecaster/trunk/tools/edcast-jack +ac_ct_CC = gcc +ac_ct_CXX = g++ +ac_ct_F77 = +am__include = include +am__leading_dot = . +am__quote = +am__tar = ${AMTAR} chof - "$$tardir" +am__untar = ${AMTAR} xf - +bindir = ${exec_prefix}/bin +build = x86_64-unknown-linux-gnu +build_alias = +build_cpu = x86_64 +build_os = linux-gnu +build_vendor = unknown +builddir = . +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host = x86_64-unknown-linux-gnu +host_alias = +host_cpu = x86_64 +host_os = linux-gnu +host_vendor = unknown +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = $(SHELL) /home/telecaster/dev/telecaster/trunk/tools/edcast-jack/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = /bin/mkdir -p +oldincludedir = /usr/include +pdfdir = ${docdir} +prefix = /usr/local +program_transform_name = s,x,x, +psdir = ${docdir} +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = ${prefix}/etc +target_alias = +top_builddir = .. +top_srcdir = .. +AUTOMAKE_OPTIONS = foreign 1.6 +lib_LIBRARIES = libedcast.a +#libedcast_la_LDFLAGS = -version-info 3:0:0 +include_HEADERS = libedcast.h libedcast_resample.h libedcast_socket.h +libedcast_a_SOURCES = libedcast.cpp \ + resample.c \ + cbuffer.c \ + Socket.cpp + +EXTRA_DIST = \ + cbuffer.h \ + enc_if.h \ + libedcast.dsp \ + libedcast.h \ + libedcast_resample.h \ + libedcast_socket.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libedcast/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libedcast/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-libLIBRARIES: $(lib_LIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(libLIBRARIES_INSTALL) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ + $(libLIBRARIES_INSTALL) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ + else :; fi; \ + done + @$(POST_INSTALL) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + p=$(am__strip_dir) \ + echo " $(RANLIB) '$(DESTDIR)$(libdir)/$$p'"; \ + $(RANLIB) "$(DESTDIR)$(libdir)/$$p"; \ + else :; fi; \ + done + +uninstall-libLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(libdir)/$$p'"; \ + rm -f "$(DESTDIR)$(libdir)/$$p"; \ + done + +clean-libLIBRARIES: + -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) +libedcast.a: $(libedcast_a_OBJECTS) $(libedcast_a_DEPENDENCIES) + -rm -f libedcast.a + $(libedcast_a_AR) libedcast.a $(libedcast_a_OBJECTS) $(libedcast_a_LIBADD) + $(RANLIB) libedcast.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +include ./$(DEPDIR)/Socket.Po +include ./$(DEPDIR)/cbuffer.Po +include ./$(DEPDIR)/libedcast.Po +include ./$(DEPDIR)/resample.Po + +.c.o: + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c $< + +.c.obj: + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: + $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +# source='$<' object='$@' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(LTCOMPILE) -c -o $@ $< + +.cpp.o: + $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: + $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: + $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +# source='$<' object='$@' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" + @list='$(include_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \ + $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \ + rm -f "$(DESTDIR)$(includedir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libLIBRARIES clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-includeHEADERS + +install-dvi: install-dvi-am + +install-exec-am: install-libLIBRARIES + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-includeHEADERS uninstall-libLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libLIBRARIES clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-includeHEADERS install-info \ + install-info-am install-libLIBRARIES install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-includeHEADERS \ + uninstall-libLIBRARIES + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/tools/edcast-jack/libedcast/Makefile.am b/tools/edcast-jack/libedcast/Makefile.am new file mode 100644 index 0000000..3a71d20 --- /dev/null +++ b/tools/edcast-jack/libedcast/Makefile.am @@ -0,0 +1,21 @@ +AUTOMAKE_OPTIONS = foreign 1.6 + +lib_LIBRARIES = libedcast.a +#libedcast_la_LDFLAGS = -version-info 3:0:0 + +include_HEADERS = libedcast.h libedcast_resample.h libedcast_socket.h +libedcast_a_SOURCES = libedcast.cpp \ + resample.c \ + cbuffer.c \ + Socket.cpp + +EXTRA_DIST = \ + cbuffer.h \ + enc_if.h \ + libedcast.dsp \ + libedcast.h \ + libedcast_resample.h \ + libedcast_socket.h + +LIBS = @LIBS@ @OGG_LIBS@ @VORBIS_LIBS@ @MAD_LIBS@ @LAME_LIBS@ @VORBISENC_LIBS@ @VORBISFILE_LIBS@ @FAAC_LIBS@ @LIBFLAC_LIBS@ +CFLAGS = -g @CFLAGS@ @OGG_CFLAGS@ @VORBIS_CFLAGS@ @MAD_CFLAGS@ @LAME_CFLAGS@ @FAAC_CFLAGS@ @LIBFLAC_CFLAGS@ diff --git a/tools/edcast-jack/libedcast/Makefile.in b/tools/edcast-jack/libedcast/Makefile.in new file mode 100644 index 0000000..f08876f --- /dev/null +++ b/tools/edcast-jack/libedcast/Makefile.in @@ -0,0 +1,558 @@ +# Makefile.in generated by automake 1.10 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = libedcast +DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/lame.m4 $(top_srcdir)/m4/mad.m4 \ + $(top_srcdir)/m4/ogg.m4 $(top_srcdir)/m4/vorbis.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" +libLIBRARIES_INSTALL = $(INSTALL_DATA) +LIBRARIES = $(lib_LIBRARIES) +ARFLAGS = cru +libedcast_a_AR = $(AR) $(ARFLAGS) +libedcast_a_LIBADD = +am_libedcast_a_OBJECTS = libedcast.$(OBJEXT) resample.$(OBJEXT) \ + cbuffer.$(OBJEXT) Socket.$(OBJEXT) +libedcast_a_OBJECTS = $(am_libedcast_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libedcast_a_SOURCES) +DIST_SOURCES = $(libedcast_a_SOURCES) +includeHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(include_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = -g @CFLAGS@ @OGG_CFLAGS@ @VORBIS_CFLAGS@ @MAD_CFLAGS@ @LAME_CFLAGS@ @FAAC_CFLAGS@ @LIBFLAC_CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEBUG = @DEBUG@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FAAC_CFLAGS = @FAAC_CFLAGS@ +FAAC_LIBS = @FAAC_LIBS@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +JACK_LIBS = @JACK_LIBS@ +LAME_CFLAGS = @LAME_CFLAGS@ +LAME_LIBS = @LAME_LIBS@ +LDFLAGS = @LDFLAGS@ +LIBFLAC_CFLAGS = @LIBFLAC_CFLAGS@ +LIBFLAC_LIBS = @LIBFLAC_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ @OGG_LIBS@ @VORBIS_LIBS@ @MAD_LIBS@ @LAME_LIBS@ @VORBISENC_LIBS@ @VORBISFILE_LIBS@ @FAAC_LIBS@ @LIBFLAC_LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAD_CFLAGS = @MAD_CFLAGS@ +MAD_LIBS = @MAD_LIBS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +OGG_CFLAGS = @OGG_CFLAGS@ +OGG_LDFLAGS = @OGG_LDFLAGS@ +OGG_LIBS = @OGG_LIBS@ +OGG_PREFIX = @OGG_PREFIX@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +VORBISENC_LIBS = @VORBISENC_LIBS@ +VORBISFILE_LIBS = @VORBISFILE_LIBS@ +VORBIS_CFLAGS = @VORBIS_CFLAGS@ +VORBIS_LDFLAGS = @VORBIS_LDFLAGS@ +VORBIS_LIBS = @VORBIS_LIBS@ +VORBIS_PREFIX = @VORBIS_PREFIX@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = foreign 1.6 +lib_LIBRARIES = libedcast.a +#libedcast_la_LDFLAGS = -version-info 3:0:0 +include_HEADERS = libedcast.h libedcast_resample.h libedcast_socket.h +libedcast_a_SOURCES = libedcast.cpp \ + resample.c \ + cbuffer.c \ + Socket.cpp + +EXTRA_DIST = \ + cbuffer.h \ + enc_if.h \ + libedcast.dsp \ + libedcast.h \ + libedcast_resample.h \ + libedcast_socket.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libedcast/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libedcast/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-libLIBRARIES: $(lib_LIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(libLIBRARIES_INSTALL) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ + $(libLIBRARIES_INSTALL) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ + else :; fi; \ + done + @$(POST_INSTALL) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + p=$(am__strip_dir) \ + echo " $(RANLIB) '$(DESTDIR)$(libdir)/$$p'"; \ + $(RANLIB) "$(DESTDIR)$(libdir)/$$p"; \ + else :; fi; \ + done + +uninstall-libLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(libdir)/$$p'"; \ + rm -f "$(DESTDIR)$(libdir)/$$p"; \ + done + +clean-libLIBRARIES: + -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) +libedcast.a: $(libedcast_a_OBJECTS) $(libedcast_a_DEPENDENCIES) + -rm -f libedcast.a + $(libedcast_a_AR) libedcast.a $(libedcast_a_OBJECTS) $(libedcast_a_LIBADD) + $(RANLIB) libedcast.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Socket.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cbuffer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedcast.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resample.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +.cpp.o: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" + @list='$(include_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \ + $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \ + rm -f "$(DESTDIR)$(includedir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libLIBRARIES clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-includeHEADERS + +install-dvi: install-dvi-am + +install-exec-am: install-libLIBRARIES + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-includeHEADERS uninstall-libLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libLIBRARIES clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-includeHEADERS install-info \ + install-info-am install-libLIBRARIES install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-includeHEADERS \ + uninstall-libLIBRARIES + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/tools/edcast-jack/libedcast/Socket.cpp b/tools/edcast-jack/libedcast/Socket.cpp new file mode 100644 index 0000000..6932f7f --- /dev/null +++ b/tools/edcast-jack/libedcast/Socket.cpp @@ -0,0 +1,234 @@ +/* + +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +oddsock@oddsock.org +*/ +// Socket.cpp: implementation of the CMySocket class. +// +////////////////////////////////////////////////////////////////////// + +#include +#include "libedcast_socket.h" + +#define MAX_LEN 256 + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CMySocket::CMySocket() +{ + +} + +CMySocket::~CMySocket() +{ + +} + +///////////////////////////////////////////////////////////////////////////// +// +// socketErrorExit +// +// Description +// Print supplied error message and exit the program. +// +// Parameters +// szError - Error message text +// +void CMySocket::socketErrorExit(char *szError) +{ + printf("Socket error: %s\n", szError); +} + +///////////////////////////////////////////////////////////////////////////// +// +// DoSocketListen +// +// Description +// Code to create, bind and listen to socket; Originally from bzs@bu-cs.bu.edu +// +// Parameters +// portnum - local port to listen for connections +// +// Return +// Socket created on success, -1 on error. +// +#define MAXHOSTNAME 1024 +SOCKET CMySocket::DoSocketListen(unsigned short portnum) +{ + char myname[MAXHOSTNAME+1]; + SOCKET s; + struct sockaddr_in sa; + struct hostent *hp; + + memset(&sa, 0, sizeof(struct sockaddr_in)); /* clear our address */ + gethostname(myname, MAXHOSTNAME); /* who are we? */ + hp= gethostbyname(myname); /* get our address info */ + if (hp == NULL) /* we don't exist !? */ + return(-1); + sa.sin_family= hp->h_addrtype; /* this is our host address */ + sa.sin_port= htons(portnum); /* this is our port number */ + if ((s= socket(AF_INET, SOCK_STREAM, 0)) < 0) /* create socket */ + return(-1); + if (bind(s,(struct sockaddr *)&sa,sizeof(struct sockaddr_in)) < 0) { + closesocket(s); + return(-1); /* bind address to socket */ + } + + listen(s, SOMAXCONN); /* max # of queued connects */ + return(s); +} + +///////////////////////////////////////////////////////////////////////////// +// +// DoSocketAccept +// +// Description +// Performs an accept() on the supplied socket. +// +// Parameters +// s - listen()'ing socket to call accept() on. +// +// Return +// Returns the accept()'d socket on success, -1 on error. +// +SOCKET CMySocket::DoSocketAccept(SOCKET s) +{ + SOCKET t; /* socket of connection */ + int namelen = 0; + + if ((t = accept(s,NULL,NULL)) < 0) /* accept connection if there is one */ + return(-1); + +/* + memset(&connectedIP, '\000', sizeof(connectedIP)); + namelen = sizeof(connectedIP); + int ret = getpeername(t, (struct sockaddr *)&connectedIP, &namelen); + if (ret == SOCKET_ERROR) { + int error = WSAGetLastError(); + } +*/ +// MessageBox(NULL, inet_ntoa(connectedIP.sin_addr), "Connected To", MB_OK); + return(t); +} + +///////////////////////////////////////////////////////////////////////////// +// +// DoSocketConnect +// +// Description +// Performs a generic socket() and connect() +// +// Parameters +// hostname - host to connect() to. +// portnum - port number for connect(). +// +SOCKET CMySocket::DoSocketConnect(char *hostname, unsigned short portnum) +{ + struct sockaddr_in sa; + struct hostent *hp; + SOCKET s; + + + if ((hp= gethostbyname(hostname)) == NULL) { /* do we know the host's */ + +#ifdef WIN32 + SetLastError(WSAECONNREFUSED); +#else + fprintf(stderr, "cannot find host %s", hostname); +#endif + return(-1); /* no */ + } + + memset(&sa,0,sizeof(sa)); + memcpy((char *)&sa.sin_addr,hp->h_addr,hp->h_length); /* set address */ + sa.sin_family= hp->h_addrtype; + sa.sin_port= htons((u_short)portnum); + + if ((s= socket(hp->h_addrtype,SOCK_STREAM,0)) < 0) /* get socket */ + return(-1); + + int optval = 10000; + setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (const char *)&optval, sizeof(optval)); + setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (const char *)&optval, sizeof(optval)); + + if (connect(s,(struct sockaddr *)&sa,sizeof sa) < 0) { /* connect */ +#ifdef WIN32 + long err = WSAGetLastError(); +#endif + closesocket(s); + return(-1); + } + return(s); +} + +///////////////////////////////////////////////////////////////////////////// +// +// initWinsockLib +// +// Description +// Boiler-plate Winsock setup function +// +// Parameters +// +void CMySocket::initWinsockLib(void) +{ +#ifdef WIN32 + WORD wVersionRequested; + WSADATA wsaData; + int err; + + wVersionRequested = MAKEWORD( 1, 1 ); + err = WSAStartup( wVersionRequested, &wsaData ); + + if ( err != 0 ) { + socketErrorExit("cannot find winsock.dll"); + exit(1); + } + + if ( LOBYTE( wsaData.wVersion ) != 1 || + HIBYTE( wsaData.wVersion ) != 1 ) { + /* Tell the user that we couldn't find a useable */ + /* winsock.dll. */ + socketErrorExit("winsock.dll is an old version"); + exit(2); + } +#endif +} + +///////////////////////////////////////////////////////////////////////////// +// +// CheckSocketError +// +// Description +// Checks the iError input for SOCKET_ERROR, if an error exists, print +// the supplied szMessage and exit the program +// +// Parameters +// +void CMySocket::CheckSocketError(int iError, char *szMessage) +{ + char szErrMessage[MAX_LEN]; + + if (iError == SOCKET_ERROR) { + sprintf(szErrMessage, "%s\n", szMessage); + socketErrorExit(szErrMessage); + return; + } + +} + diff --git a/tools/edcast-jack/libedcast/cbuffer.c b/tools/edcast-jack/libedcast/cbuffer.c new file mode 100644 index 0000000..73b8538 --- /dev/null +++ b/tools/edcast-jack/libedcast/cbuffer.c @@ -0,0 +1,198 @@ +/* sbuffer.c - jonclegg@yahoo.com + * general use circular buffer lib + * + * 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 +#include "cbuffer.h" + +/********************************************************************************* + * Public functions + *********************************************************************************/ +int cbuffer_init(CBUFFER *buffer, unsigned long size); +void cbuffer_destroy(CBUFFER *buffer); +int cbuffer_extract(CBUFFER *buffer, char *items, unsigned long count); +int cbuffer_peek(CBUFFER *buffer, char *items, unsigned long count); +int cbuffer_insert(CBUFFER *buffer, const char *items, unsigned long count); +unsigned long cbuffer_get_free(CBUFFER *buffer); +unsigned long cbuffer_get_used(CBUFFER *buffer); +unsigned long cbuffer_get_size(CBUFFER *buffer); + + +/********************************************************************************* + * Private functions + *********************************************************************************/ +static void reset(CBUFFER *buffer); +static void increment(CBUFFER *buffer, unsigned long *index); + +int cbuffer_init2(CBUFFER *buffer, unsigned long size) +{ + if (size == 0) { + return 0; + } + if (size == 0) { + buffer->size = 0; + buffer->buf = NULL; + reset(buffer); + } else { + buffer->size = size; + buffer->buf = (char *)malloc(size); + reset(buffer); + } + + return 1; +} + +int cbuffer_init(CBUFFER *buffer, unsigned long size) +{ + if (size == 0) { + return 0; + } + if (size == 0) { + buffer->size = 0; + buffer->buf = NULL; + reset(buffer); + } else { + buffer->size = size; + buffer->buf = (char *)malloc(size); + reset(buffer); + } + + pthread_mutex_init(&(buffer->cbuffer_mutex), NULL); + + return 1; +} + +void cbuffer_destroy(CBUFFER *buffer) +{ + if (buffer->buf) + { + free(buffer->buf); + buffer->buf = NULL; + } +} + +void cbuffer_clear(CBUFFER *buffer) +{ + pthread_mutex_lock(&(buffer->cbuffer_mutex)); + cbuffer_destroy(buffer); + cbuffer_init2(buffer, buffer->size); + pthread_mutex_unlock(&(buffer->cbuffer_mutex)); +} +int cbuffer_extract(CBUFFER *buffer, char *items, unsigned long count) +{ + unsigned long i; + + pthread_mutex_lock(&(buffer->cbuffer_mutex)); + + if (buffer->buf) { + for(i = 0; i < count; i++) + { + if (buffer->item_count > 0) { + buffer->item_count--; + } + else { + pthread_mutex_unlock(&(buffer->cbuffer_mutex)); + return BUFFER_EMPTY; + } + + increment(buffer, &buffer->read_index); + items[i] = buffer->buf[buffer->read_index]; + } + } + else { + pthread_mutex_unlock(&(buffer->cbuffer_mutex)); + return 0; + } + pthread_mutex_unlock(&(buffer->cbuffer_mutex)); + return 1; +} + + +int cbuffer_peek(CBUFFER *buffer, char *items, unsigned long count) +{ + unsigned long i; + unsigned long my_read_index = buffer->read_index; + unsigned long my_item_count = buffer->item_count; + + for(i = 0; i < count; i++) + { + if (my_item_count > 0) + my_item_count--; + else + return BUFFER_EMPTY; + + increment(buffer, &my_read_index); + items[i] = buffer->buf[my_read_index]; + } + return 1; +} + + +int cbuffer_insert(CBUFFER *buffer, const char *items, unsigned long count) +{ + unsigned long i; + + pthread_mutex_lock(&(buffer->cbuffer_mutex)); + for(i = 0; i < count; i++) + { + if (buffer->item_count < cbuffer_get_size(buffer)) { + buffer->item_count++; + } + else { + pthread_mutex_unlock(&(buffer->cbuffer_mutex)); + return BUFFER_FULL; + } + + increment(buffer, &buffer->write_index); + buffer->buf[buffer->write_index] = items[i]; + } + + pthread_mutex_unlock(&(buffer->cbuffer_mutex)); + return 1; +} + +unsigned long cbuffer_get_size(CBUFFER *buffer) +{ + return buffer->size; + +} + +unsigned long cbuffer_get_free(CBUFFER *buffer) +{ + return cbuffer_get_size(buffer) - cbuffer_get_used(buffer); +} + +unsigned long cbuffer_get_used(CBUFFER *buffer) +{ + return buffer->item_count; +} + + +void increment(CBUFFER *buffer, unsigned long *index) +{ + (*index)++; + if (*index >= cbuffer_get_size(buffer)) + *index = 0; +} + +void reset(CBUFFER *buffer) +{ + buffer->read_index = buffer->write_index = cbuffer_get_size(buffer) - 1; + buffer->item_count = 0; +} + + diff --git a/tools/edcast-jack/libedcast/cbuffer.h b/tools/edcast-jack/libedcast/cbuffer.h new file mode 100644 index 0000000..83f4fbd --- /dev/null +++ b/tools/edcast-jack/libedcast/cbuffer.h @@ -0,0 +1,38 @@ +#ifndef __CBUFFER_H__ +#define __CBUFFER_H__ + +#ifdef _DMALLOC_ +#include +#endif + +#include +typedef struct CBUFFERst +{ + pthread_mutex_t cbuffer_mutex; + char *buf; + unsigned long size; + unsigned long write_index; + unsigned long read_index; + unsigned long item_count; +} CBUFFER; + +#define BUFFER_EMPTY 3 +#define BUFFER_FULL 2 +#ifdef __cplusplus +extern "C" { +#endif +int cbuffer_init(CBUFFER *buffer, unsigned long size); +void cbuffer_destroy(CBUFFER *buffer); +int cbuffer_extract(CBUFFER *buffer, char *items, unsigned long count); +int cbuffer_peek(CBUFFER *buffer, char *items, unsigned long count); +int cbuffer_insert(CBUFFER *buffer, const char *items, unsigned long count); +unsigned long cbuffer_get_free(CBUFFER *buffer); +unsigned long cbuffer_get_used(CBUFFER *buffer); +unsigned long cbuffer_get_size(CBUFFER *buffer); +void cbuffer_clear(CBUFFER *buffer); +#ifdef __cplusplus +} +#endif + +#endif //__CBUFFER_H__ + diff --git a/tools/edcast-jack/libedcast/enc_if.h b/tools/edcast-jack/libedcast/enc_if.h new file mode 100644 index 0000000..65daf32 --- /dev/null +++ b/tools/edcast-jack/libedcast/enc_if.h @@ -0,0 +1,44 @@ +/* +** enc_if.h - common encoder interface +** +** Copyright (C) 2001-2003 Nullsoft, Inc. +** +** This software is provided 'as-is', without any express or implied warranty. +** In no event will the authors be held liable for any damages arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, including commercial +** applications, and to alter it and redistribute it freely, subject to the following restrictions: +** 1. The origin of this software must not be misrepresented; you must not claim that you wrote the +** original software. If you use this software in a product, an acknowledgment in the product +** documentation would be appreciated but is not required. +** 2. Altered source versions must be plainly marked as such, and must not be misrepresented as +** being the original software. +** 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _NSV_ENC_IF_H_ +#define _NSV_ENC_IF_H_ +class VideoCoder +{ + public: + VideoCoder() { } + virtual int Encode(void *in, void *out, int *iskf)=0; // returns bytes in out + virtual ~VideoCoder() { }; +}; + +class AudioCoder +{ + public: + AudioCoder() { } + virtual int Encode(int framepos, void *in, int in_avail, int *in_used, void *out, int out_avail)=0; //returns bytes in out + virtual ~AudioCoder() { }; +}; + +// unsigned int GetAudioTypes3(int idx, char *desc); +// unsigned int GetVideoTypes3(int idx, char *desc); +// AudioCoder *CreateAudio3(int nch, int srate, int bps, unsigned int srct, unsigned int *outt, char *configfile); +// VideoCoder *CreateVideo3(int w, int h, double frt, unsigned int pixt, unsigned int *outt, char *configfile); +// HWND ConfigAudio3(HWND hwndParent, HINSTANCE hinst, unsigned int outt, char *configfile); +// HWND ConfigVideo3(HWND hwndParent, HINSTANCE hinst, unsigned int outt, char *configfile); + +#endif //_NSV_ENC_IF_H_ diff --git a/tools/edcast-jack/libedcast/libedcast.cpp b/tools/edcast-jack/libedcast/libedcast.cpp new file mode 100644 index 0000000..20b8846 --- /dev/null +++ b/tools/edcast-jack/libedcast/libedcast.cpp @@ -0,0 +1,3712 @@ +/*$T libedcast.cpp GC 1.140 10/23/05 11:32:15 */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_VORBIS +#include +#endif + +#include "libedcast.h" +#include "libedcast_socket.h" +#ifdef WIN32 +#include +#else +#ifdef HAVE_LAME +#include +#endif +#include +#endif +#ifdef HAVE_FAAC +#include +#endif +#ifndef LAME_MAXMP3BUFFER +#define LAME_MAXMP3BUFFER 16384 +#endif +#define GUINT16_TO_LE(val) ((unsigned short) (val)) +#define GUINT32_TO_LE(val) ((unsigned int) (val)) +#define GUINT16_FROM_LE(val) (GUINT16_TO_LE(val)) +#ifdef WIN32 +#pragma comment(linker, "/delayload:libfaac.dll") +#define FILE_SEPARATOR "\\" +#else +#define FILE_SEPARATOR "/" +typedef struct +{ + short wFormatTag; + short nChannels; + long nSamplesPerSec; + long nAvgBytesPerSec; + short nBlockAlign; + short wBitsPerSample; + short cbSize; +} WAVEFORMATEX; +#define WAVE_FORMAT_PCM (0x0001) +#define DWORD long +#endif +long dwDataBlockPos = 0; +long TotalWritten = 0; + + +#ifdef WIN32 +#define INT32 __int32 +#else +#define INT32 int +#endif + +#define MAX_ENCODERS 10 + +extern edcastGlobals *g[MAX_ENCODERS]; +extern edcastGlobals gMain; + +int buffer_blocksize = 0; + +#ifdef HAVE_AACP + +/* + ======================================================================================================================= + uninteresting stuff ; + for the input plugin + ======================================================================================================================= + */ +static void SAAdd(void *data, int timestamp, int csa) { +} + +static void VSAAdd(void *data, int timestamp) { +} + +static void SAVSAInit(int maxlatency_in_ms, int srate) { +} + +static void SAVSADeInit() { +} + +static void SAAddPCMData(void *PCMData, int nch, int bps, int timestamp) { +} + +static int SAGetMode() { + return 0; +} + +static int VSAGetMode(int *specNch, int *waveNch) { + return 0; +} + +static void VSAAddPCMData(void *PCMData, int nch, int bps, int timestamp) { +} + +static void VSASetInfo(int nch, int srate) { +} + +static int dsp_isactive() { + return 0; +} + +static int dsp_dosamples(short int *samples, int ns, int bps, int nch, int srate) { + return ns; +} + +static void SetInfo(int bitrate0, int srate0, int stereo, int synched) { +} +#endif +typedef struct tagConfigFileValue +{ + char_t Variable[256]; + char_t Value[256]; + char_t Description[1024]; +} configFileValue; + +static configFileValue configFileValues[100]; +static int numConfigValues = 0; + +static int greconnectFlag = 0; +char_t defaultLogFileName[1024] = "edcast.log"; + +void setDefaultLogFileName(char_t *filename) { + strcpy(defaultLogFileName, filename); +} +int getReconnectFlag(edcastGlobals *g) { + return g->gAutoReconnect; +} + +int getReconnectSecs(edcastGlobals *g) { + return g->gReconnectSec; +} + +void addVorbisComment(edcastGlobals *g, char_t *comment) { + int commentLen = strlen(comment) + 1; + + g->vorbisComments[g->numVorbisComments] = (char_t *) calloc(1, commentLen); + if (g->vorbisComments[g->numVorbisComments]) { + memset(g->vorbisComments[g->numVorbisComments], '\000', commentLen); + strcpy(g->vorbisComments[g->numVorbisComments], comment); + g->numVorbisComments++; + } +} + +void freeVorbisComments(edcastGlobals *g) { + for(int i = 0; i < g->numVorbisComments; i++) { + if(g->vorbisComments[i]) { + free(g->vorbisComments[i]); + g->vorbisComments[i] = NULL; + } + } + + g->numVorbisComments = 0; +} + +void addConfigVariable(edcastGlobals *g, char_t *variable) { + g->configVariables[g->numConfigVariables] = strdup(variable); + g->numConfigVariables++; +} +long getWritten(edcastGlobals *g) { + return g->written; +} + +void setWritten(edcastGlobals *g, long writ) { + g->written = writ; +} + +void setAutoConnect(edcastGlobals *g, int flag) { + g->autoconnect = flag; +} + +FILE *getSaveFileP(edcastGlobals *g) { + return g->gSaveFile; +} + +int getLiveRecordingSetFlag(edcastGlobals *g) { + return g->gLiveRecordingFlag; +} + +bool getLiveRecordingFlag(edcastGlobals *g) { + return g->areLiveRecording; +} + +void setLiveRecordingFlag(edcastGlobals *g, bool flag) { + g->areLiveRecording = flag; +} + +int getLiveInSamplerate(edcastGlobals *g) { + return g->gLiveInSamplerate; +} + +void setLiveInSamplerate(edcastGlobals *g, int rate) { + g->gLiveInSamplerate = rate; +} + +int getOggFlag(edcastGlobals *g) { + return g->gOggFlag; +} + +char_t *getServerDesc(edcastGlobals *g) { + return g->gServDesc; +} + +char_t *getSourceURL(edcastGlobals *g) { + return g->gSourceURL; +} + +void setSourceURL(edcastGlobals *g, char_t *url) { + strcpy(g->gSourceURL, url); +} + +int getIsConnected(edcastGlobals *g) { + return g->weareconnected; +} + +long getCurrentSamplerate(edcastGlobals *g) { + return g->currentSamplerate; +} + +int getCurrentBitrate(edcastGlobals *g) { + return g->currentBitrate; +} + +int getCurrentChannels(edcastGlobals *g) { + return g->currentChannels; +} + +void setSourceDescription(edcastGlobals *g, char_t *desc) { + strcpy(g->sourceDescription, desc); +} + +long getVUShow(edcastGlobals *g) { + return g->vuShow; +} + +void setVUShow(edcastGlobals *g, long x) { + g->vuShow = x; +} + +long getLastXWindow(edcastGlobals *g) { + return g->lastX; +} + +long getLastYWindow(edcastGlobals *g) { + return g->lastY; +} + +void setLastXWindow(edcastGlobals *g, long x) { + g->lastX = x; +} + +void setLastYWindow(edcastGlobals *g, long y) { + g->lastY = y; +} + +long getLastDummyXWindow(edcastGlobals *g) { + return g->lastDummyX; +} + +long getLastDummyYWindow(edcastGlobals *g) { + return g->lastDummyY; +} + +void setLastDummyXWindow(edcastGlobals *g, long x) { + g->lastDummyX = x; +} + +void setLastDummyYWindow(edcastGlobals *g, long y) { + g->lastDummyY = y; +} + +int getSaveAsWAV(edcastGlobals *g) { + return g->gSaveAsWAV; +} + +void setSaveAsWAV(edcastGlobals *g, int flag) { + g->gSaveAsWAV = flag; +} + +char_t *getCurrentRecordingName(edcastGlobals *g) { + return(g->gCurrentRecordingName); +} + +void setCurrentRecordingName(edcastGlobals *g, char_t *name) { + strcpy(g->gCurrentRecordingName, name); +} + +int getFrontEndType(edcastGlobals *g) { + return(g->frontEndType); +} + +void setFrontEndType(edcastGlobals *g, int x) { + g->frontEndType = x; +} + +int getReconnectTrigger(edcastGlobals *g) { + return(g->ReconnectTrigger); +} + +void setReconnectTrigger(edcastGlobals *g, int x) { + g->ReconnectTrigger = x; +} + +char_t *getLockedMetadata(edcastGlobals *g) { + return g->gManualSongTitle; +} + +void setLockedMetadata(edcastGlobals *g, char_t *buf) { + memset(g->gManualSongTitle, '\000', sizeof(g->gManualSongTitle)); + strncpy(g->gManualSongTitle, buf, sizeof(g->gManualSongTitle) - 1); +} + +int getLockedMetadataFlag(edcastGlobals *g) { + return g->gLockSongTitle; +} + +void setLockedMetadataFlag(edcastGlobals *g, int flag) { + g->gLockSongTitle = flag; +} + +void setSaveDirectory(edcastGlobals *g, char_t *saveDir) { + memset(g->gSaveDirectory, '\000', sizeof(g->gSaveDirectory)); + strncpy(g->gSaveDirectory, saveDir, sizeof(g->gSaveDirectory) - 1); +} + +char_t *getSaveDirectory(edcastGlobals *g) { + return(g->gSaveDirectory); +} + +void setSaveDirectoryFlag(edcastGlobals *g, int flag) { + g->gSaveDirectoryFlag = flag; +} + +int getSaveDirectoryFlag(edcastGlobals *g) { + return(g->gSaveDirectoryFlag); +} + +void setgLogFile(edcastGlobals *g, char_t *logFile) { + strcpy(g->gLogFile, logFile); +} + +char_t *getgLogFile(edcastGlobals *g) { + return(g->gLogFile); +} + +int resetResampler(edcastGlobals *g) { + if(g->initializedResampler) { + res_clear(&(g->resampler)); + } + + g->initializedResampler = 0; + return 1; +} + +/* Gratuitously ripped from util.c */ +static char_t base64table[64] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; + +static signed char_t base64decode[256] = { -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 62, -2, -2, -2, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -2, -2, -2, -1, -2, -2, -2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -2, -2, -2, -2, -2, -2, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2 }; + +/* + ======================================================================================================================= + This isn't efficient, but it doesn't need to be + ======================================================================================================================= + */ +char_t *util_base64_encode(char_t *data) { + int len = strlen(data); + char_t *out = (char_t *) malloc(len * 4 / 3 + 4); + char_t *result = out; + int chunk; + + while(len > 0) { + chunk = (len > 3) ? 3 : len; + *out++ = base64table[(*data & 0xFC) >> 2]; + *out++ = base64table[((*data & 0x03) << 4) | ((*(data + 1) & 0xF0) >> 4)]; + switch(chunk) { + case 3: + *out++ = base64table[((*(data + 1) & 0x0F) << 2) | ((*(data + 2) & 0xC0) >> 6)]; + *out++ = base64table[(*(data + 2)) & 0x3F]; + break; + + case 2: + *out++ = base64table[((*(data + 1) & 0x0F) << 2)]; + *out++ = '='; + break; + + case 1: + *out++ = '='; + *out++ = '='; + break; + } + + data += chunk; + len -= chunk; + } + + *out = 0; + + return result; +} + +char_t *util_base64_decode(unsigned char_t *input) { + int len = strlen((char_t *) input); + char_t *out = (char_t *) malloc(len * 3 / 4 + 5); + char_t *result = out; + signed char_t vals[4]; + + while(len > 0) { + if(len < 4) { + free(result); + return NULL; /* Invalid Base64 data */ + } + + vals[0] = base64decode[*input++]; + vals[1] = base64decode[*input++]; + vals[2] = base64decode[*input++]; + vals[3] = base64decode[*input++]; + + if(vals[0] < 0 || vals[1] < 0 || vals[2] < -1 || vals[3] < -1) { + continue; + } + + *out++ = vals[0] << 2 | vals[1] >> 4; + if(vals[2] >= 0) + *out++ = ((vals[1] & 0x0F) << 4) | (vals[2] >> 2); + else + *out++ = 0; + + if(vals[3] >= 0) + *out++ = ((vals[2] & 0x03) << 6) | (vals[3]); + else + *out++ = 0; + + len -= 4; + } + + *out = 0; + + return result; +} + +#define HEADER_TYPE 1 +#define CODEC_TYPE 2 + +void closeArchiveFile(edcastGlobals *g) { + if(g->gSaveFile) { + if(g->gSaveAsWAV) { + wav_header.length = GUINT32_TO_LE(g->written + sizeof(struct wavhead) - 8); + wav_header.data_length = GUINT32_TO_LE(g->written); + fseek(g->gSaveFile, 0, SEEK_SET); + fwrite(&wav_header, sizeof(struct wavhead), 1, g->gSaveFile); + g->written = 0; + } + + fclose(g->gSaveFile); + g->gSaveFile = 0; + } +} + +int openArchiveFile(edcastGlobals *g) { + char_t outFilename[1024] = ""; + char_t outputFile[1024] = ""; + struct tm *newtime; + time_t aclock; + + time(&aclock); + newtime = localtime(&aclock); + + sprintf(outFilename, "%s_%s", g->gServDesc, asctime(newtime)); + + memset(outputFile, '\000', sizeof(outputFile)); + + memset(outputFile, '\000', sizeof(outputFile)); + ReplaceString(outFilename, outputFile, "\"", "'"); + memset(outFilename, '\000', sizeof(outFilename)); + ReplaceString(outputFile, outFilename, FILE_SEPARATOR, ""); + memset(outputFile, '\000', sizeof(outputFile)); + ReplaceString(outFilename, outputFile, "/", ""); + memset(outFilename, '\000', sizeof(outFilename)); + ReplaceString(outputFile, outFilename, ":", ""); + memset(outputFile, '\000', sizeof(outputFile)); + ReplaceString(outFilename, outputFile, "*", ""); + memset(outFilename, '\000', sizeof(outFilename)); + ReplaceString(outputFile, outFilename, "?", ""); + memset(outputFile, '\000', sizeof(outputFile)); + ReplaceString(outFilename, outputFile, "<", ""); + memset(outFilename, '\000', sizeof(outFilename)); + ReplaceString(outputFile, outFilename, ">", ""); + memset(outputFile, '\000', sizeof(outputFile)); + ReplaceString(outFilename, outputFile, "|", ""); + memset(outFilename, '\000', sizeof(outFilename)); + ReplaceString(outputFile, outFilename, "\n", ""); + + memset(outputFile, '\000', sizeof(outputFile)); + strcpy(outputFile, outFilename); + + if(g->gSaveAsWAV) { + strcat(outputFile, ".wav"); + } + else { + if(g->gOggFlag) { + strcat(outputFile, ".ogg"); + } + + if(g->gLAMEFlag) { + strcat(outputFile, ".mp3"); + } + + if(g->gAACFlag) { + strcat(outputFile, ".aac"); + } + + if(g->gAACPFlag) { + strcat(outputFile, ".aac"); + } + } + + sprintf(outFilename, "%s%s%s", g->gSaveDirectory, FILE_SEPARATOR, outputFile); + + g->gSaveFile = fopen(outFilename, "wb"); + if(!g->gSaveFile) { + char_t buff[1024] = ""; + + sprintf(buff, "Cannot open %s", outputFile); + LogMessage(g,LOG_ERROR, buff); + return 0; + } + + if(g->gSaveAsWAV) { + int nch = 2; + int rate = 44100; + + memcpy(&wav_header.main_chunk, "RIFF", 4); + wav_header.length = GUINT32_TO_LE(0); + memcpy(&wav_header.chunk_type, "WAVE", 4); + memcpy(&wav_header.sub_chunk, "fmt ", 4); + wav_header.sc_len = GUINT32_TO_LE(16); + wav_header.format = GUINT16_TO_LE(1); + wav_header.modus = GUINT16_TO_LE(nch); + wav_header.sample_fq = GUINT32_TO_LE(rate); + wav_header.bit_p_spl = GUINT16_TO_LE(16); + wav_header.byte_p_sec = GUINT32_TO_LE(rate * wav_header.modus * (GUINT16_FROM_LE(wav_header.bit_p_spl) / 8)); + wav_header.byte_p_spl = GUINT16_TO_LE((GUINT16_FROM_LE(wav_header.bit_p_spl) / (8 / nch))); + memcpy(&wav_header.data_chunk, "data", 4); + wav_header.data_length = GUINT32_TO_LE(0); + fwrite(&wav_header, sizeof(struct wavhead), 1, g->gSaveFile); + } + + return 1; +} + +int sendToServer(edcastGlobals *g, int sd, char_t *data, int length, int type) { + int ret = 0; + int sendflags = 0; + + if(g->gSaveDirectoryFlag) { + if(!g->gSaveFile) { + openArchiveFile(g); + } + } + +#if !defined(WIN32) && !defined(__FreeBSD__) + sendflags = MSG_NOSIGNAL; +#endif + switch(type) { + case HEADER_TYPE: + ret = send(sd, data, length, sendflags); + break; + + case CODEC_TYPE: + ret = send(sd, data, length, sendflags); + if(g->gSaveDirectoryFlag) { + if(g->gSaveFile) { + if(!g->gSaveAsWAV) { + fwrite(data, length, 1, g->gSaveFile); + } + } + } + break; + } + + if(ret > 0) { + if(g->writeBytesCallback) { + g->writeBytesCallback((void *) g, (void *) ret); + } + } + + return ret; +} + +int readConfigFile(edcastGlobals *g, int readOnly) { + FILE *filep; + char_t buffer[1024]; + char_t configFile[1024] = ""; + char_t defaultConfigName[] = "edcast"; + + + numConfigValues = 0; + memset(&configFileValues, '\000', sizeof(configFileValues)); + + if(readOnly) { + sprintf(configFile, "%s", g->gConfigFileName); + } + else { + if(strlen(g->gConfigFileName) == 0) { + sprintf(configFile, "%s_%d.cfg", defaultConfigName, g->encoderNumber); + } + else { + sprintf(configFile, "%s_%d.cfg", g->gConfigFileName, g->encoderNumber); + } + } + + filep = fopen(configFile, "r"); + if(filep == 0) { + + /* + * LogMessage(g,g,LOG_ERROR, "Cannot open config file %s\n", configFile); + * strcpy(g->gConfigFileName, defaultConfigName); + */ + } + else { + while(!feof(filep)) { + char_t *p2; + + memset(buffer, '\000', sizeof(buffer)); + fgets(buffer, sizeof(buffer) - 1, filep); + p2 = strchr(buffer, '\r'); + if(p2) { + *p2 = '\000'; + } + + p2 = strchr(buffer, '\n'); + if(p2) { + *p2 = '\000'; + } + + if(buffer[0] != '#') { + char_t *p1 = strchr(buffer, '='); + + if(p1) { + strncpy(configFileValues[numConfigValues].Variable, buffer, p1 - buffer); + p1++; /* Get past the = */ + strcpy(configFileValues[numConfigValues].Value, p1); + numConfigValues++; + } + } + } + + if(filep) { + fclose(filep); + } + } + + config_read(g); + + if(!readOnly) { + writeConfigFile(g); + } + + return 1; +} + +int deleteConfigFile(edcastGlobals *g) { + char_t configFile[1024] = ""; + char_t defaultConfigName[] = "edcast"; + + if(strlen(g->gConfigFileName) == 0) { + sprintf(configFile, "%s_%d.cfg", defaultConfigName, g->encoderNumber); + } + else { + sprintf(configFile, "%s_%d.cfg", g->gConfigFileName, g->encoderNumber); + } + + unlink(configFile); + + return 1; +} + +void setConfigFileName(edcastGlobals *g, char_t *configFile) { + strcpy(g->gConfigFileName, configFile); +} + +char_t *getConfigFileName(edcastGlobals *g) { + return g->gConfigFileName; +} + +int writeConfigFile(edcastGlobals *g) { + char_t configFile[1024] = ""; + char_t defaultConfigName[] = "edcast"; + + config_write(g); + + if(strlen(g->gConfigFileName) == 0) { + sprintf(configFile, "%s_%d.cfg", defaultConfigName, g->encoderNumber); + } + else { + sprintf(configFile, "%s_%d.cfg", g->gConfigFileName, g->encoderNumber); + } + + FILE *filep = fopen(configFile, "w"); + + if(filep == 0) { + LogMessage(g,LOG_ERROR, "Cannot open config file %s\n", configFile); + return 0; + } + + for(int i = 0; i < numConfigValues; i++) { + int ok = 1; + if (g->configVariables) { + ok = 0; + for (int j=0;jnumConfigVariables;j++) { + if (!strcmp(g->configVariables[j], configFileValues[i].Variable)) { + ok = 1; + break; + } + } + } + + if (ok) { + if (strlen(configFileValues[i].Description) > 0) { + fprintf(filep, "# %s\n", configFileValues[i].Description); + } + fprintf(filep, "%s=%s\n", configFileValues[i].Variable, configFileValues[i].Value); + } + } + + fclose(filep); + + return 1; +} + +void printConfigFileValues() { +// for(int i = 0; i < numConfigValues; i++) { +// LogMessage(g,LOG_DEBUG, "(%s) = (%s)\n", configFileValues[i].Variable, configFileValues[i].Value); +// } +} + +void GetConfigVariable(edcastGlobals *g, char_t *appName, char_t *paramName, char_t *defaultvalue, char_t *destValue, int destSize, char_t *desc) { + + if (g->configVariables) { + int ok = 0; + for (int j=0;jnumConfigVariables;j++) { + if (!strcmp(g->configVariables[j], paramName)) { + ok = 1; + break; + } + } + if (!ok) { + strcpy(destValue, defaultvalue); + return; + } + } + for(int i = 0; i < numConfigValues; i++) { + if(!strcmp(paramName, configFileValues[i].Variable)) { + strcpy(destValue, configFileValues[i].Value); + if (desc) { + strcpy(configFileValues[i].Description, desc); + } + return; + } + } + + strcpy(configFileValues[numConfigValues].Variable, paramName); + strcpy(configFileValues[numConfigValues].Value, defaultvalue); + if (desc) { + strcpy(configFileValues[numConfigValues].Description, desc); + } + + strcpy(destValue, configFileValues[numConfigValues].Value); + numConfigValues++; + return; +} + +long GetConfigVariableLong(edcastGlobals *g, char_t *appName, char_t *paramName, long defaultvalue, char_t *desc) { + char_t buf[1024] = ""; + char_t defaultbuf[1024] = ""; + + sprintf(defaultbuf, "%d", defaultvalue); + + GetConfigVariable(g, appName, paramName, defaultbuf, buf, sizeof(buf), desc); + + return atol(buf); +} + +void PutConfigVariable(edcastGlobals *g, char_t *appName, char_t *paramName, char_t *destValue) { + + if (g->configVariables) { + int ok = 0; + for (int j=0;jnumConfigVariables;j++) { + if (!strcmp(g->configVariables[j], paramName)) { + ok = 1; + break; + } + } + if (!ok) { + return; + } + } + + for(int i = 0; i < numConfigValues; i++) { + if(!strcmp(paramName, configFileValues[i].Variable)) { + strcpy(configFileValues[i].Value, destValue); + return; + } + } + + strcpy(configFileValues[numConfigValues].Variable, paramName); + strcpy(configFileValues[numConfigValues].Value, destValue); + strcpy(configFileValues[numConfigValues].Description, ""); + numConfigValues++; + return; +} + +void PutConfigVariableLong(edcastGlobals *g, char_t *appName, char_t *paramName, long value) { + char_t buf[1024] = ""; + + sprintf(buf, "%d", value); + + PutConfigVariable(g, appName, paramName, buf); + + return; +} + +void restartConnection() { + ; +} + +int trimVariable(char_t *variable) { + char_t *p1; + + /* Trim off the back */ + for(p1 = variable + strlen(variable) - 1; p1 > variable; p1--) { + if((*p1 == ' ') || (*p1 == ' ')) { + *p1 = '\000'; + } + else { + break; + } + } + + /* Trim off the front */ + char_t tempVariable[1024] = ""; + + memset(tempVariable, '\000', sizeof(tempVariable)); + for(p1 = variable; p1 < variable + strlen(variable) - 1; p1++) { + if((*p1 == ' ') || (*p1 == ' ')) { + ; + } + else { + break; + } + } + + strcpy(tempVariable, p1); + strcpy(variable, tempVariable); + return 1; +} + +void setDestURLCallback(edcastGlobals *g, void (*pCallback) (void *, void *)) { + g->destURLCallback = pCallback; +} + +void setSourceURLCallback(edcastGlobals *g, void (*pCallback) (void *, void *)) { + g->sourceURLCallback = pCallback; +} + +void setServerStatusCallback(edcastGlobals *g, void (*pCallback) (void *, void *)) { + g->serverStatusCallback = pCallback; +} + +void setGeneralStatusCallback(edcastGlobals *g, void (*pCallback) (void *, void *)) { + g->generalStatusCallback = pCallback; +} + +void setWriteBytesCallback(edcastGlobals *g, void (*pCallback) (void *, void *)) { + g->writeBytesCallback = pCallback; +} + +void setServerTypeCallback(edcastGlobals *g, void (*pCallback) (void *, void *)) { + g->serverTypeCallback = pCallback; +} + +void setServerNameCallback(edcastGlobals *g, void (*pCallback) (void *, void *)) { + g->serverNameCallback = pCallback; +} + +void setStreamTypeCallback(edcastGlobals *g, void (*pCallback) (void *, void *)) { + g->streamTypeCallback = pCallback; +} + +void setBitrateCallback(edcastGlobals *g, void (*pCallback) (void *, void *)) { + g->bitrateCallback = pCallback; +} + +void setOggEncoderText(edcastGlobals *g, char_t *text) { + strcpy(g->gOggEncoderText, text); +} + +void setVUCallback(edcastGlobals *g, void (*pCallback) (int, int)) { + g->VUCallback = pCallback; +} + +void setForceStop(edcastGlobals *g, int forceStop) { + g->gForceStop = forceStop; +} + +void initializeGlobals(edcastGlobals *g) { + + /* Global variables....gotta love em... */ + g->gSCSocket = 0; + g->gSCSocket2 = 0; + g->gSCSocketControl = 0; + g->gSCFlag = 0; + g->gReconnectSec = 10; + g->gAutoCountdown = 10; + g->automaticconnect = 1; + memset(g->gServer, '\000', sizeof(g->gServer)); + memset(g->gPort, '\000', sizeof(g->gPort)); + memset(g->gPassword, '\000', sizeof(g->gPassword)); + memset(g->gIniFile, '\000', sizeof(g->gIniFile)); + memset(g->gAppName, '\000', sizeof(g->gAppName)); + memset(g->gCurrentSong, '\000', sizeof(g->gCurrentSong)); + g->gPubServ = 0; + memset(g->gServIRC, '\000', sizeof(g->gServIRC)); + memset(g->gServAIM, '\000', sizeof(g->gServAIM)); + memset(g->gServICQ, '\000', sizeof(g->gServICQ)); + memset(g->gServURL, '\000', sizeof(g->gServURL)); + memset(g->gServDesc, '\000', sizeof(g->gServDesc)); + memset(g->gMountpoint, '\000', sizeof(g->gMountpoint)); + g->gAutoReconnect = 0; + memset(g->gAutoStart, '\000', sizeof(g->gAutoStart)); + memset(g->gAutoStartSec, '\000', sizeof(g->gAutoStartSec)); + memset(g->gQuality, '\000', sizeof(g->gQuality)); + g->gOggFlag = 0; + memset(g->gIceFlag, '\000', sizeof(g->gIceFlag)); + g->gLAMEFlag = 0; + memset(g->gSaveDirectory, '\000', sizeof(g->gSaveDirectory)); + memset(g->gLogFile, '\000', sizeof(g->gLogFile)); + g->gLogLevel = LM_ERROR; + g->gSaveDirectoryFlag = 0; + memset(g->gSongTitle, '\000', sizeof(g->gSongTitle)); + memset(g->gManualSongTitle, '\000', sizeof(g->gManualSongTitle)); + g->gLockSongTitle = 0; + g->startTime = 0; + g->endTime = 0; + + g->weareconnected = 0; + pthread_mutex_init(&(g->mutex), NULL); + + memset(g->WindowsRecDevice, '\000', sizeof(g->WindowsRecDevice)); + g->LAMEJointStereoFlag = 1; + +#ifndef WIN32 +#ifdef HAVE_LAME + g->gf = NULL; +#endif +#endif + g->gCurrentlyEncoding = 0; + g->gShoutcastFlag = 0; + g->gIcecastFlag = 0; + g->gSaveFile = 0; + g->destURLCallback = NULL; + g->sourceURLCallback = NULL; + g->serverStatusCallback = NULL; + g->generalStatusCallback = NULL; + g->writeBytesCallback = NULL; + g->serverTypeCallback = NULL; + g->serverNameCallback = NULL; + g->streamTypeCallback = NULL; + g->bitrateCallback = NULL; + g->VUCallback = NULL; + + memset(g->sourceDescription, '\000', sizeof(g->sourceDescription)); + + /* OGG Stuff */ + g->oggflag = 1; + g->ice2songChange = false; + g->in_header = 0; + + /* Resampler stuff */ + g->initializedResampler = 0; + + g->gLiveRecordingFlag = 0; + + g->areLiveRecording = FALSE; + + memset(g->gOggEncoderText, '\000', sizeof(g->gOggEncoderText)); + g->gForceStop = 0; + +#ifdef HAVE_VORBIS + memset(&(g->vi), '\000', sizeof(g->vi)); +#endif + g->vuShow = 0; + + g->ReconnectTrigger = 0; + +} + +char_t *getCurrentlyPlaying(edcastGlobals *g) { + return(g->gSongTitle); +} + +int setCurrentSongTitle(edcastGlobals *g, char_t *song) { + char_t *pCurrent; + char_t modifiedSong[1024] = ""; + + if(g->gLockSongTitle) { + pCurrent = g->gManualSongTitle; + } + else { + pCurrent = song; + } + + if(strcmp(g->gSongTitle, pCurrent)) { + strcpy(g->gSongTitle, pCurrent); + updateSongTitle(g, 0); + return 1; + } + + return 0; +} + +int setCurrentSongTitleURL(edcastGlobals *g, char_t *song) { + char_t *pCurrent; + + if(g->gLockSongTitle) { + pCurrent = g->gManualSongTitle; + } + else { + pCurrent = song; + } + + if(strcmp(g->gSongTitle, pCurrent)) { + strcpy(g->gSongTitle, pCurrent); + updateSongTitle(g, 0); + return 1; + } + + return 0; +} + +void getCurrentSongTitle(edcastGlobals *g, char_t *song, char_t *artist, char_t *full) { + char_t songTitle[1024] = ""; + char_t songTitle2[1024] = ""; + + memset(songTitle2, '\000', sizeof(songTitle2)); + + char_t *pCurrent; + + if(g->gLockSongTitle) { + pCurrent = g->gManualSongTitle; + } + else { + pCurrent = g->gSongTitle; + } + + strcpy(songTitle, pCurrent); + + strcpy(full, songTitle); + + char_t *p1 = strchr(songTitle, '-'); + + if(p1) { + if(*(p1 - 1) == ' ') { + p1--; + } + + strncpy(artist, songTitle, p1 - songTitle); + p1 = strchr(songTitle, '-'); + p1++; + if(*p1 == ' ') { + p1++; + } + + strcpy(song, p1); + } + else { + strcpy(artist, ""); + strcpy(song, songTitle); + } +} + +void ReplaceString(char_t *source, char_t *dest, char_t *from, char_t *to) { + int loop = 1; + char_t *p2 = (char_t *) 1; + char_t *p1 = source; + + while(p2) { + p2 = strstr(p1, from); + if(p2) { + strncat(dest, p1, p2 - p1); + strcat(dest, to); + p1 = p2 + strlen(from); + } + else { + strcat(dest, p1); + } + } +} + +/* + ======================================================================================================================= + This function URLencodes strings for use in sending them thru ; + the Shoutcast admin.cgi interface to update song titles.. + ======================================================================================================================= + */ +void URLize(char_t *input, char_t *output, int inputlen, int outputlen) { + ReplaceString(input, output, "%", "%25"); + memset(input, '\000', inputlen); + ReplaceString(output, input, ";", "%3B"); + memset(output, '\000', outputlen); + ReplaceString(input, output, "/", "%2F"); + memset(input, '\000', inputlen); + ReplaceString(output, input, "?", "%3F"); + memset(output, '\000', outputlen); + ReplaceString(input, output, ":", "%3A"); + memset(input, '\000', inputlen); + ReplaceString(output, input, "@", "%40"); + memset(output, '\000', outputlen); + ReplaceString(input, output, "&", "%26"); + memset(input, '\000', inputlen); + ReplaceString(output, input, "=", "%3D"); + memset(output, '\000', outputlen); + ReplaceString(input, output, "+", "%2B"); + memset(input, '\000', inputlen); + ReplaceString(output, input, " ", "%20"); + memset(output, '\000', outputlen); + ReplaceString(input, output, "\"", "%22"); + memset(input, '\000', inputlen); + ReplaceString(output, input, "#", "%23"); + memset(output, '\000', outputlen); + ReplaceString(input, output, "<", "%3C"); + memset(input, '\000', inputlen); + ReplaceString(output, input, ">", "%3E"); + memset(output, '\000', outputlen); + ReplaceString(input, output, "!", "%21"); + memset(input, '\000', inputlen); + ReplaceString(output, input, "*", "%2A"); + memset(output, '\000', outputlen); + ReplaceString(input, output, "'", "%27"); + memset(input, '\000', inputlen); + ReplaceString(output, input, "(", "%28"); + memset(output, '\000', outputlen); + ReplaceString(input, output, ")", "%29"); + memset(input, '\000', inputlen); + ReplaceString(output, input, ",", "%2C"); + + memset(output, '\000', outputlen); + strcpy(output, input); +} + +int updateSongTitle(edcastGlobals *g, int forceURL) { + char_t contentString[2056] = ""; + char_t URLPassword[255] = ""; + char_t URLSong[1024] = ""; + char_t Song[1024] = ""; + + if(getIsConnected(g)) { + if((!g->gOggFlag) || (forceURL)) { + if((g->gSCFlag) || (g->gIcecastFlag) || (g->gIcecast2Flag) || forceURL) { + URLize(g->gPassword, URLPassword, sizeof(g->gPassword), sizeof(URLPassword)); + + strcpy(g->gCurrentSong, g->gSongTitle); + + URLize(g->gCurrentSong, URLSong, sizeof(g->gSongTitle), sizeof(URLSong)); + + if(g->gIcecast2Flag) { + char_t userAuth[1024] = ""; + + sprintf(userAuth, "source:%s", g->gPassword); + + char_t *puserAuthbase64 = util_base64_encode(userAuth); + + if(puserAuthbase64) { + sprintf(contentString, + "GET /admin/metadata?pass=%s&mode=updinfo&mount=%s&song=%s HTTP/1.0\r\nAuthorization: Basic %s\r\nUser-Agent: (Mozilla Compatible)\r\n\r\n", + URLPassword, + g->gMountpoint, + URLSong, + puserAuthbase64); + free(puserAuthbase64); + } + } + + if(g->gIcecastFlag) { + sprintf(contentString, + "GET /admin.cgi?pass=%s&mode=updinfo&mount=%s&song=%s HTTP/1.0\r\nUser-Agent: (Mozilla Compatible)\r\n\r\n", + URLPassword, + g->gMountpoint, + URLSong); + } + + if(g->gSCFlag) { + sprintf(contentString, + "GET /admin.cgi?pass=%s&mode=updinfo&song=%s HTTP/1.0\r\nUser-Agent: (Mozilla Compatible)\r\n\r\n", + URLPassword, + URLSong); + } + + g->gSCSocketControl = g->controlChannel.DoSocketConnect(g->gServer, atoi(g->gPort)); + if(g->gSCSocketControl != -1) { + int sent = send(g->gSCSocketControl, contentString, strlen(contentString), 0); + //int sent = sendToServer(g, g->gSCSocketControl, contentString, strlen(contentString), HEADER_TYPE); + + closesocket(g->gSCSocketControl); + } + else { + LogMessage(g,LOG_ERROR, "Cannot connect to server"); + } + } + } + else { + g->ice2songChange = true; + } + return 1; + } + return 0; +} + +/* + ======================================================================================================================= + This function does some magic in order to change the metadata ; + in a vorbis stream....Vakor helped me with this, and it's pretty ; + much all his idea anyway...and probably the reason why it actually ; + does work..:) + ======================================================================================================================= + */ +void icecast2SendMetadata(edcastGlobals *g) +{ +#ifdef HAVE_VORBIS + pthread_mutex_lock(&(g->mutex)); + vorbis_analysis_wrote(&g->vd, 0); + ogg_encode_dataout(g); + initializeencoder(g); + pthread_mutex_unlock(&(g->mutex)); +#endif +} + + +#ifdef HAVE_FLAC +extern "C" { +FLAC__StreamEncoderWriteStatus FLACWriteCallback( + const FLAC__StreamEncoder *encoder, + const FLAC__byte buffer[], + unsigned bytes, + unsigned samples, + unsigned current_frame, + void *client_data + ) { + edcastGlobals *g = (edcastGlobals *) client_data; + + int sentbytes = sendToServer(g, g->gSCSocket, (char_t *) buffer, bytes, CODEC_TYPE); + + if(sentbytes < 0) { + g->flacFailure = 1; + } + else { + g->flacFailure = 0; + } + + return FLAC__STREAM_ENCODER_WRITE_STATUS_OK; +} +} +extern "C" { +void FLACMetadataCallback(const FLAC__StreamEncoder *encoder, + const FLAC__StreamMetadata *metadata, + void *client_data) { + edcastGlobals *g = (edcastGlobals *) client_data; + + return; +} +} +#endif + +/* + ======================================================================================================================= + This function will disconnect the DSP from the server (duh) + ======================================================================================================================= + */ +int disconnectFromServer(edcastGlobals *g) { + g->weareconnected = 0; + + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (char_t *) "Disconnecting"); + } + + if(g->gCurrentlyEncoding) + { +#ifdef WIN32 + Sleep(1000); +#else + sleep(1); +#endif + } + + /* Close all open sockets */ + closesocket(g->gSCSocket); + closesocket(g->gSCSocketControl); + + /* + * Reset the Status to Disconnected, and reenable the config ; + * button + */ + g->gSCSocket = 0; + g->gSCSocketControl = 0; + +#ifdef HAVE_VORBIS + ogg_stream_clear(&g->os); + vorbis_block_clear(&g->vb); + vorbis_dsp_clear(&g->vd); + vorbis_info_clear(&g->vi); + memset(&(g->vi), '\000', sizeof(g->vi)); +#endif +#ifdef HAVE_LAME +#ifndef WIN32 + if(g->gf) { + lame_close(g->gf); + g->gf = NULL; + } +#endif +#endif + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Disconnected"); + } + + closeArchiveFile(g); + + return 1; +} + +/* + ======================================================================================================================= + This funciton will connect to a server (Shoutcast/Icecast/Icecast2) ; + and send the appropriate password info and check to make sure things ; + are connected.... + ======================================================================================================================= + */ +int connectToServer(edcastGlobals *g) { + int s_socket = 0; + char_t buffer[1024] = ""; + char_t contentString[1024] = ""; + char_t brate[25] = ""; + char_t ypbrate[25] = ""; + + LogMessage(g,LOG_DEBUG, "Connecting encoder %d", g->encoderNumber); + + sprintf(brate, "%d", g->currentBitrate); + + if(g->gOggFlag) { + if(!g->gOggBitQualFlag) { + sprintf(ypbrate, "Quality %s", g->gOggQuality); + } + else { + strcpy(ypbrate, brate); + } + } + else { + strcpy(ypbrate, brate); + } + + g->gSCFlag = 0; + + greconnectFlag = 0; + + if(g->serverStatusCallback) { + + sprintf(buffer, "Connnecting to %s:%d", g->gServer, g->gPort); + g->serverStatusCallback(g, (void *) buffer); + } + +#ifdef WIN32 + g->dataChannel.initWinsockLib(); +#endif + + /* If we are Icecast/Icecast2, then connect to specified port */ + if(g->gIcecastFlag || g->gIcecast2Flag) { + g->gSCSocket = g->dataChannel.DoSocketConnect(g->gServer, atoi(g->gPort)); + } + else { + + /* + * If we are Shoutcast, then the control socket (used for password) ; + * is port+1. + */ + g->gSCSocket = g->dataChannel.DoSocketConnect(g->gServer, atoi(g->gPort) + 1); + } + + /* Check to see if we connected okay */ + if(g->gSCSocket == -1) { + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Unable to connect to socket"); + } + + return 0; + } + + int pswdok = 1; + + /* Yup, we did. */ + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Socket connected"); + } + + char_t contentType[255] = ""; + + if(g->gOggFlag) { + strcpy(contentType, "application/ogg"); + } + else { + if(g->gAACFlag) { + strcpy(contentType, "audio/aac"); + } + else { + if(g->gAACPFlag) { + strcpy(contentType, "audio/aacp"); + } + else { + if(g->gFLACFlag) { + strcpy(contentType, "application/ogg"); + } + else { + strcpy(contentType, "audio/mpeg"); + } + } + } + } + + /* + * Here are all the variations of sending the password to ; + * a server..This if statement really is ugly...must fix. + */ + if(g->gIcecastFlag || g->gIcecast2Flag) { + + /* The Icecast/Icecast2 Way */ + if(g->gIcecastFlag) { + sprintf(contentString, + "SOURCE %s %s\r\ncontent-type: %s\r\nx-audiocast-name: %s\r\nx-audiocast-url: %s\r\nx-audiocast-genre: %s\r\nx-audiocast-bitrate: %s\r\nx-audiocast-public: %d\r\nx-audiocast-description: %s\r\n\r\n", + g->gPassword, + g->gMountpoint, + contentType, + g->gServDesc, + g->gServURL, + g->gServGenre, + brate, + g->gPubServ, + g->gServDesc); + } + + if(g->gIcecast2Flag) { + char_t audioInfo[1024] = ""; + + sprintf(audioInfo, + "ice-samplerate=%d;ice-bitrate=%s;ice-channels=%d", + getCurrentSamplerate(g), + ypbrate, + getCurrentChannels(g)); + + char_t userAuth[1024] = ""; + + sprintf(userAuth, "source:%s", g->gPassword); + + char_t *puserAuthbase64 = util_base64_encode(userAuth); + + if(puserAuthbase64) { + sprintf(contentString, + "SOURCE %s ICE/1.0\ncontent-type: %s\nAuthorization: Basic %s\nice-name: %s\nice-url: %s\nice-genre: %s\nice-bitrate: %s\nice-private: %d\nice-public: %d\nice-description: %s\nice-audio-info: %s\n\n", + g->gMountpoint, + contentType, + puserAuthbase64, + g->gServName, + g->gServURL, + g->gServGenre, + ypbrate, + !g->gPubServ, + g->gPubServ, + g->gServDesc, + audioInfo); + free(puserAuthbase64); + } + } + } + else { + + /* The Shoutcast way */ + sendToServer(g, g->gSCSocket, g->gPassword, strlen(g->gPassword), HEADER_TYPE); + sendToServer(g, g->gSCSocket, "\r\n", strlen("\r\n"), HEADER_TYPE); + + recv(g->gSCSocket, buffer, sizeof(buffer), (int) 0); + + /* + * if we get an OK, then we are not a Shoutcast server ; + * (could be live365 or other variant)..And OK2 means it's ; + * Shoutcast and we can safely send in metadata via the ; + * admin.cgi interface. + */ + if(!strncmp(buffer, "OK", strlen("OK"))) { + if(!strncmp(buffer, "OK2", strlen("OK2"))) { + g->gSCFlag = 1; + } + else { + g->gSCFlag = 0; + } + + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Password OK"); + } + } + else { + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Password Failed"); + } + + closesocket(g->gSCSocket); + return 0; + } + + memset(contentString, '\000', sizeof(contentString)); + if(strlen(g->gServICQ) == 0) { + strcpy(g->gServICQ, "N/A"); + } + + if(strlen(g->gServAIM) == 0) { + strcpy(g->gServAIM, "N/A"); + } + + if(strlen(g->gServIRC) == 0) { + strcpy(g->gServIRC, "N/A"); + } + + sprintf(contentString, + "content-type:%s\r\nicy-name:%s\r\nicy-genre:%s\r\nicy-url:%s\r\nicy-pub:%d\r\nicy-irc:%s\r\nicy-icq:%s\r\nicy-aim:%s\r\nicy-br:%s\r\n\r\n", + contentType, + g->gServName, + g->gServGenre, + g->gServURL, + g->gPubServ, + g->gServIRC, + g->gServICQ, + g->gServAIM, + brate); + } + + sendToServer(g, g->gSCSocket, contentString, strlen(contentString), HEADER_TYPE); + + if(g->gIcecastFlag) { + + /* + * Here we are checking the response from Icecast/Icecast2 ; + * from when we sent in the password...OK means we are good..if the ; + * password is bad, Icecast just disconnects the socket. + */ + if(g->gOggFlag) { + recv(g->gSCSocket, buffer, sizeof(buffer), 0); + if(!strncmp(buffer, "OK", strlen("OK"))) { + + /* I don't think this check is needed.. */ + if(!strncmp(buffer, "OK2", strlen("OK2"))) { + g->gSCFlag = 1; + } + else { + g->gSCFlag = 0; + } + + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Password OK"); + } + } + else { + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Password Failed"); + } + + closesocket(g->gSCSocket); + return 0; + } + } + } + + /* We are connected */ + char_t outFilename[1024] = ""; + char_t outputFile[1024] = ""; + struct tm *newtime; + time_t aclock; + + time(&aclock); + newtime = localtime(&aclock); + + int ret = 0; + + ret = initializeencoder(g); + g->forcedDisconnect = false; + if(ret) { + g->weareconnected = 1; + g->automaticconnect = 1; + + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Success"); + } + + /* Start up song title check */ + } + else { + disconnectFromServer(g); + if(g->serverStatusCallback) + { +#ifdef WIN32 + if(g->gLAMEFlag) { + g->serverStatusCallback(g, (void *) "error with lame_enc.dll"); + } + else { + if(g->gAACFlag) { + g->serverStatusCallback(g, (void *) "cannot find libfaac.dll"); + } + else { + g->serverStatusCallback(g, (void *) "Encoder init failed"); + } + } + +#else + g->serverStatusCallback(g, (void *) "Encoder init failed"); +#endif + } + + return 0; + } + + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Connected"); + } + + setCurrentSongTitle(g, g->gSongTitle); + updateSongTitle(g, 0); + return 1; +} + +/* + ======================================================================================================================= + These are some ogg routines that are used for Icecast2 + ======================================================================================================================= + */ +int ogg_encode_dataout(edcastGlobals *g) +{ +#ifdef HAVE_VORBIS + ogg_packet op; + ogg_page og; + int result; + int sentbytes = 0; + + if(g->in_header) { + result = ogg_stream_flush(&g->os, &og); + g->in_header = 0; + } + + while(vorbis_analysis_blockout(&g->vd, &g->vb) == 1) { + vorbis_analysis(&g->vb, NULL); + vorbis_bitrate_addblock(&g->vb); + + int packetsdone = 0; + + while(vorbis_bitrate_flushpacket(&g->vd, &op)) { + + /* Add packet to bitstream */ + ogg_stream_packetin(&g->os, &op); + packetsdone++; + + /* + * If we've gone over a page boundary, we can do actual output, so do so (for + * however many pages are available) + */ + int eos = 0; + + while(!eos) { + int result = ogg_stream_pageout(&g->os, &og); + + if(!result) break; + + int ret = 0; + + sentbytes = sendToServer(g, g->gSCSocket, (char_t *) og.header, og.header_len, CODEC_TYPE); + if(sentbytes < 0) { + return sentbytes; + } + + sentbytes += sendToServer(g, g->gSCSocket, (char_t *) og.body, og.body_len, CODEC_TYPE); + if(sentbytes < 0) { + return sentbytes; + } + + if(ogg_page_eos(&og)) { + eos = 1; + } + } + } + } + + return sentbytes; +#else + return 0; +#endif +} + +void oddsock_error_handler_function(const char_t *format, va_list ap) { + return; +} + +int initializeResampler(edcastGlobals *g, long inSampleRate, long inNCH) { + if(!g->initializedResampler) { + long in_samplerate = inSampleRate; + long out_samplerate = getCurrentSamplerate(g); + long in_nch = inNCH; + long out_nch = 2; + + if(res_init(&(g->resampler), out_nch, out_samplerate, in_samplerate, RES_END)) { + LogMessage(g,LOG_ERROR, "Error initializing resampler"); + return 0; + } + + g->initializedResampler = 1; + } + + return 1; +} + +int ocConvertAudio(edcastGlobals *g, float *in_samples, float *out_samples, int num_in_samples, int num_out_samples) { + int max_num_samples = res_push_max_input(&(g->resampler), num_out_samples); + int ret_samples = res_push_interleaved(&(g->resampler), + (SAMPLE *) out_samples, + (const SAMPLE *) in_samples, + max_num_samples); + + return ret_samples; +} + +int initializeencoder(edcastGlobals *g) { + int ret = 0; + char_t outFilename[1024] = ""; + char_t message[1024] = ""; + + resetResampler(g); + + if(g->gLAMEFlag) + { +#ifdef HAVE_LAME +#ifdef WIN32 + BE_ERR err = 0; + BE_VERSION Version = { 0, }; + BE_CONFIG beConfig = { 0, }; + + if(g->hDLL) { + FreeLibrary(g->hDLL); + } + + g->hDLL = LoadLibrary("lame_enc.dll"); + + if(g->hDLL == NULL) { + sprintf(message, + "Unable to load DLL (lame_enc.dll)\nYou have selected encoding with LAME, but apparently the plugin cannot find LAME installed. Due to legal issues, \ +edcast cannot distribute LAME directly, and so you'll have to download it \ +separately. You will need to put the LAME DLL (lame_enc.dll) into the same directory as the application in order to get it working-> To download the LAME DLL, check \ +out http://www.mp3dev.org/mp3/"); + LogMessage(g,LOG_ERROR, message); + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "can't find lame_enc.dll"); + } + + return 0; + } + + /* Get Interface functions from the DLL */ + g->beInitStream = (BEINITSTREAM) GetProcAddress(g->hDLL, TEXT_BEINITSTREAM); + g->beEncodeChunk = (BEENCODECHUNK) GetProcAddress(g->hDLL, TEXT_BEENCODECHUNK); + g->beDeinitStream = (BEDEINITSTREAM) GetProcAddress(g->hDLL, TEXT_BEDEINITSTREAM); + g->beCloseStream = (BECLOSESTREAM) GetProcAddress(g->hDLL, TEXT_BECLOSESTREAM); + g->beVersion = (BEVERSION) GetProcAddress(g->hDLL, TEXT_BEVERSION); + g->beWriteVBRHeader = (BEWRITEVBRHEADER) GetProcAddress(g->hDLL, TEXT_BEWRITEVBRHEADER); + + if + ( + !g->beInitStream + || !g->beEncodeChunk + || !g->beDeinitStream + || !g->beCloseStream + || !g->beVersion + || !g->beWriteVBRHeader + ) { + sprintf(message, "Unable to get LAME interfaces - This DLL (lame_enc.dll) doesn't appear to be LAME?!?!?"); + LogMessage(g,LOG_ERROR, message); + return 0; + } + + /* Get the version number */ + g->beVersion(&Version); + + if(Version.byMajorVersion < 3) { + sprintf(message, + "This version of edcast expects at least version 3.91 of the LAME DLL, the DLL found is at %u.%02u, please consider upgrading", + Version.byDLLMajorVersion, + Version.byDLLMinorVersion); + LogMessage(g,LOG_ERROR, message); + } + else { + if(Version.byMinorVersion < 91) { + sprintf(message, + "This version of edcast expects at least version 3.91 of the LAME DLL, the DLL found is at %u.%02u, please consider upgrading", + Version.byDLLMajorVersion, + Version.byDLLMinorVersion); + LogMessage(g,LOG_ERROR, message); + } + } + + /* Check if all interfaces are present */ + memset(&beConfig, 0, sizeof(beConfig)); /* clear all fields */ + + /* use the LAME config structure */ + beConfig.dwConfig = BE_CONFIG_LAME; + + if(g->currentChannels == 1) { + beConfig.format.LHV1.nMode = BE_MP3_MODE_MONO; + } + else { + if (g->LAMEJointStereoFlag) { + beConfig.format.LHV1.nMode = BE_MP3_MODE_JSTEREO; + } + else { + beConfig.format.LHV1.nMode = BE_MP3_MODE_STEREO; + } + } + + /* this are the default settings for testcase.wav */ + beConfig.format.LHV1.dwStructVersion = 1; + beConfig.format.LHV1.dwStructSize = sizeof(beConfig); + beConfig.format.LHV1.dwSampleRate = g->currentSamplerate; /* INPUT FREQUENCY */ + beConfig.format.LHV1.dwReSampleRate = g->currentSamplerate; /* DON"T RESAMPLE */ + + /* + * beConfig.format.LHV1.dwReSampleRate = 0; + */ + beConfig.format.LHV1.dwBitrate = g->currentBitrate; /* MINIMUM BIT RATE */ + if(g->gLAMEpreset > 0) { + beConfig.format.LHV1.nPreset = g->gLAMEpreset; + } + + beConfig.format.LHV1.dwMpegVersion = MPEG1; /* MPEG VERSION (I or II) */ + beConfig.format.LHV1.dwPsyModel = 0; /* USE DEFAULT PSYCHOACOUSTIC MODEL */ + beConfig.format.LHV1.dwEmphasis = 0; /* NO EMPHASIS TURNED ON */ + beConfig.format.LHV1.bWriteVBRHeader = TRUE; /* YES, WRITE THE XING VBR HEADER */ + + if(g->gLAMEOptions.cbrflag) { + beConfig.format.LHV1.bEnableVBR = FALSE; + } + else { + beConfig.format.LHV1.bEnableVBR = TRUE; + beConfig.format.LHV1.dwMaxBitrate = g->currentBitrateMax; + beConfig.format.LHV1.dwBitrate = g->currentBitrate; /* MINIMUM BIT RATE */ + } + + beConfig.format.LHV1.nVBRQuality = g->gLAMEOptions.quality; + + beConfig.format.LHV1.nVbrMethod = VBR_METHOD_DEFAULT; + if(!strcmp(g->gLAMEOptions.VBR_mode, "vbr_rh")) { + beConfig.format.LHV1.nVbrMethod = VBR_METHOD_OLD; + } + + if(!strcmp(g->gLAMEOptions.VBR_mode, "vbr_mtrh")) { + beConfig.format.LHV1.nVbrMethod = VBR_METHOD_MTRH; + } + + if(!strcmp(g->gLAMEOptions.VBR_mode, "vbr_abr")) { + beConfig.format.LHV1.nVbrMethod = VBR_METHOD_ABR; + } + + beConfig.format.LHV1.bNoRes = TRUE; /* No Bit resorvoir */ + + err = g->beInitStream(&beConfig, &(g->dwSamples), &(g->dwMP3Buffer), &(g->hbeStream)); + + if(err != BE_ERR_SUCCESSFUL) { + sprintf(message, "Error opening encoding stream (%lu)", err); + LogMessage(g,LOG_ERROR, message); + return 0; + } + +#else + g->gf = lame_init(); + lame_set_errorf(g->gf, oddsock_error_handler_function); + lame_set_debugf(g->gf, oddsock_error_handler_function); + lame_set_msgf(g->gf, oddsock_error_handler_function); + + lame_set_brate(g->gf, g->currentBitrate); + lame_set_quality(g->gf, g->gLAMEOptions.quality); + + lame_set_num_channels(g->gf, 2); + + if(g->currentChannels == 1) { + lame_set_mode(g->gf, MONO); + + /* + * lame_set_num_channels(g->gf, 1); + */ + } + else { + lame_set_mode(g->gf, STEREO); + } + + /* + * Make the input sample rate the same as output..i.e. don't make lame do ; + * any resampling->..cause we are handling it ourselves... + */ + lame_set_in_samplerate(g->gf, g->currentSamplerate); + lame_set_out_samplerate(g->gf, g->currentSamplerate); + lame_set_copyright(g->gf, g->gLAMEOptions.copywrite); + lame_set_strict_ISO(g->gf, g->gLAMEOptions.strict_ISO); + lame_set_disable_reservoir(g->gf, g->gLAMEOptions.disable_reservoir); + + if(!g->gLAMEOptions.cbrflag) { + if(!strcmp(g->gLAMEOptions.VBR_mode, "vbr_rh")) { + lame_set_VBR(g->gf, vbr_rh); + } + + if(!strcmp(g->gLAMEOptions.VBR_mode, "vbr_mtrh")) { + lame_set_VBR(g->gf, vbr_mtrh); + } + + if(!strcmp(g->gLAMEOptions.VBR_mode, "vbr_abr")) { + lame_set_VBR(g->gf, vbr_abr); + } + + lame_set_VBR_mean_bitrate_kbps(g->gf, g->currentBitrate); + lame_set_VBR_min_bitrate_kbps(g->gf, g->currentBitrateMin); + lame_set_VBR_max_bitrate_kbps(g->gf, g->currentBitrateMax); + } + + if(strlen(g->gLAMEbasicpreset) > 0) { + if(!strcmp(g->gLAMEbasicpreset, "r3mix")) { + + /* + * presets_set_r3mix(g->gf, g->gLAMEbasicpreset, stdout); + */ + } + else { + + /* + * presets_set_basic(g->gf, g->gLAMEbasicpreset, stdout); + */ + } + } + + if(strlen(g->gLAMEaltpreset) > 0) { + int altbitrate = atoi(g->gLAMEaltpreset); + + /* + * dm_presets(g->gf, 0, altbitrate, g->gLAMEaltpreset, "edcast"); + */ + } + + /* do internal inits... */ + lame_set_lowpassfreq(g->gf, g->gLAMEOptions.lowpassfreq); + lame_set_highpassfreq(g->gf, g->gLAMEOptions.highpassfreq); + + int lame_ret = lame_init_params(g->gf); + + if(lame_ret != 0) { + printf("Error initializing LAME"); + } +#endif +#else + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Not compiled with LAME support"); + } + + LogMessage(g,LOG_ERROR, "Not compiled with LAME support"); + return 0; +#endif + } + + if(g->gAACFlag) + { +#ifdef HAVE_FAAC + faacEncConfigurationPtr m_pConfig; + +#ifdef WIN32 + g->hFAACDLL = LoadLibrary("libfaac.dll"); + if(g->hFAACDLL == NULL) { + sprintf(message, "Unable to load AAC DLL (libfaac.dll)"); + LogMessage(g,LOG_ERROR, message); + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "can't find libfaac.dll"); + } + + return 0; + } + + FreeLibrary(g->hFAACDLL); +#endif + if(g->aacEncoder) { + faacEncClose(g->aacEncoder); + g->aacEncoder = NULL; + } + + g->aacEncoder = faacEncOpen(g->currentSamplerate, g->currentChannels, &g->samplesInput, &g->maxBytesOutput); + + if(g->faacFIFO) { + free(g->faacFIFO); + } + + g->faacFIFO = (float *) malloc(g->samplesInput * sizeof(float) * 16); + g->faacFIFOendpos = 0; + + m_pConfig = faacEncGetCurrentConfiguration(g->aacEncoder); + + m_pConfig->mpegVersion = MPEG2; + + m_pConfig->quantqual = atoi(g->gAACQuality); + + int cutoff = atoi(g->gAACCutoff); + + if(cutoff > 0) { + m_pConfig->bandWidth = cutoff; + } + + /* + * m_pConfig->bitRate = (g->currentBitrate * 1000) / g->currentChannels; + */ + m_pConfig->allowMidside = 1; + m_pConfig->useLfe = 0; + m_pConfig->useTns = 1; + m_pConfig->aacObjectType = LOW; + m_pConfig->outputFormat = 1; + m_pConfig->inputFormat = FAAC_INPUT_FLOAT; + + /* set new config */ + faacEncSetConfiguration(g->aacEncoder, m_pConfig); +#else + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Not compiled with AAC support"); + } + + LogMessage(g,LOG_ERROR, "Not compiled with AAC support"); + return 0; +#endif + } + + if(g->gAACPFlag) + { +#ifdef HAVE_AACP + +#ifdef WIN32 + g->hAACPDLL = LoadLibrary("enc_aacplus.dll"); + if(g->hAACPDLL == NULL) { + g->hAACPDLL = LoadLibrary("plugins\\enc_aacplus.dll"); + } + + if(g->hAACPDLL == NULL) { + sprintf(message, "Unable to load AAC Plus DLL (enc_aacplus.dll)"); + LogMessage(g,LOG_ERROR, message); + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "can't find enc_aacplus.dll"); + } + + return 0; + } + + g->CreateAudio3 = (CREATEAUDIO3TYPE) GetProcAddress(g->hAACPDLL, "CreateAudio3"); + if(!g->CreateAudio3) { + sprintf(message, "Invalid DLL (enc_aacplus.dll)"); + LogMessage(g,LOG_ERROR, message); + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "invalid enc_aacplus.dll"); + } + + return 0; + } + + g->GetAudioTypes3 = (GETAUDIOTYPES3TYPE) GetProcAddress(g->hAACPDLL, "GetAudioTypes3"); + *(void **) &(g->finishAudio3) = (void *) GetProcAddress(g->hAACPDLL, "FinishAudio3"); + *(void **) &(g->PrepareToFinish) = (void *) GetProcAddress(g->hAACPDLL, "PrepareToFinish"); + + /* + * FreeLibrary(g->hAACPDLL); + */ +#endif + if(g->aacpEncoder) { + delete g->aacpEncoder; + g->aacpEncoder = NULL; + } + + unsigned int outt = 1346584897; + char_t *conf_file = "edcast_aacp.ini"; /* Default ini file */ + + /* 1 - Mono 2 - Stereo 3 - Stereo Independent 4 - Parametric 5 - Dual Channel */ + char_t sampleRate[255] = ""; + char_t channelMode[255] = ""; + char_t bitrateValue[255] = ""; + char_t aacpV2Enable[255] = "1"; + long bitrateLong = g->currentBitrate * 1000; + + sprintf(bitrateValue, "%d", bitrateLong); + if(bitrateLong >= 64000) { + if(g->currentChannels == 2) { + strcpy(channelMode, "2"); + } + else { + strcpy(channelMode, "1"); + } + } + + if((bitrateLong <= 48000) && (bitrateLong >= 16000)) { + if(g->currentChannels == 2) { + strcpy(channelMode, "4"); + } + else { + strcpy(channelMode, "1"); + } + } + + if(bitrateLong <= 12000) { + strcpy(channelMode, "1"); + } + + sprintf(sampleRate, "%d", g->currentSamplerate); + + WritePrivateProfileString("audio_aacplus", "samplerate", sampleRate, conf_file); + WritePrivateProfileString("audio_aacplus", "channelmode", channelMode, conf_file); + WritePrivateProfileString("audio_aacplus", "bitrate", bitrateValue, conf_file); + WritePrivateProfileString("audio_aacplus", "v2enable", aacpV2Enable, conf_file); + WritePrivateProfileString("audio_aacplus", "bitstream", "0", conf_file); + WritePrivateProfileString("audio_aacplus", "nsignallingmode", "0", conf_file); + + g->aacpEncoder = g->CreateAudio3((int) g->currentChannels, + (int) g->currentSamplerate, + 16, + mmioFOURCC('P', 'C', 'M', ' '), + &outt, + conf_file); + if(!g->aacpEncoder) { + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Invalid AAC+ settings"); + } + + LogMessage(g,LOG_ERROR, "Invalid AAC+ settings"); + return 0; + } + +#else + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Not compiled with AAC Plus support"); + } + + LogMessage(g,LOG_ERROR, "Not compiled with AAC Plus support"); + return 0; +#endif + } + + if(g->gOggFlag) + { +#ifdef HAVE_VORBIS + /* Ogg Vorbis Initialization */ + ogg_stream_clear(&g->os); + vorbis_block_clear(&g->vb); + vorbis_dsp_clear(&g->vd); + vorbis_info_clear(&g->vi); + + int bitrate = 0; + + vorbis_info_init(&g->vi); + + int encode_ret = 0; + + if(!g->gOggBitQualFlag) { + encode_ret = vorbis_encode_setup_vbr(&g->vi, + g->currentChannels, + g->currentSamplerate, + ((float) atof(g->gOggQuality) * (float) .1)); + if(encode_ret) { + vorbis_info_clear(&g->vi); + } + } + else { + int maxbit = -1; + int minbit = -1; + + if(g->currentBitrateMax > 0) { + maxbit = g->currentBitrateMax; + } + + if(g->currentBitrateMin > 0) { + minbit = g->currentBitrateMin; + } + + encode_ret = vorbis_encode_setup_managed(&g->vi, + g->currentChannels, + g->currentSamplerate, + g->currentBitrate * 1000, + g->currentBitrate * 1000, + g->currentBitrate * 1000); + + if(encode_ret) { + vorbis_info_clear(&g->vi); + } + } + + if(encode_ret == OV_EIMPL) { + LogMessage(g,LOG_ERROR, "Sorry, but this vorbis mode is not supported currently..."); + return 0; + } + + if(encode_ret == OV_EINVAL) { + LogMessage(g,LOG_ERROR, "Sorry, but this is an illegal vorbis mode..."); + return 0; + } + + ret = vorbis_encode_setup_init(&g->vi); + + /* + * Now, set up the analysis engine, stream encoder, and other preparation before + * the encoding begins + */ + ret = vorbis_analysis_init(&g->vd, &g->vi); + ret = vorbis_block_init(&g->vd, &g->vb); + + g->serialno = 0; + srand(time(0)); + ret = ogg_stream_init(&g->os, rand()); + + /* + * Now, build the three header packets and send through to the stream output stage + * (but defer actual file output until the main encode loop) + */ + ogg_packet header_main; + ogg_packet header_comments; + ogg_packet header_codebooks; + vorbis_comment vc; + char_t title[1024] = ""; + char_t artist[1024] = ""; + char_t FullTitle[1024] = ""; + char_t SongTitle[1024] = ""; + char_t Artist[1024] = ""; + char_t Streamed[1024] = ""; + wchar_t widestring[4096]; + char tempstring[4096]; + + memset(Artist, '\000', sizeof(Artist)); + memset(SongTitle, '\000', sizeof(SongTitle)); + memset(FullTitle, '\000', sizeof(FullTitle)); + memset(Streamed, '\000', sizeof(Streamed)); + + vorbis_comment_init(&vc); + + bool bypass = false; + + if(!getLockedMetadataFlag(g)) { + if(g->numVorbisComments) { + for(int i = 0; i < g->numVorbisComments; i++) + { +#ifdef WIN32 + MultiByteToWideChar(CP_ACP, + 0, + g->vorbisComments[i], + strlen(g->vorbisComments[i]) + 1, + widestring, + 4096); + memset(tempstring, '\000', sizeof(tempstring)); + WideCharToMultiByte(CP_UTF8, + 0, + widestring, + wcslen(widestring) + 1, + tempstring, + sizeof(tempstring), + 0, + NULL); + vorbis_comment_add(&vc, tempstring); +#else + vorbis_comment_add(&vc, g->vorbisComments[i]); +#endif + } + + bypass = true; + } + } + + if(!bypass) { + getCurrentSongTitle(g, SongTitle, Artist, FullTitle); + if((strlen(SongTitle) == 0) && (strlen(Artist) == 0)) { + sprintf(title, "TITLE=%s", FullTitle); + } + else { + sprintf(title, "TITLE=%s", SongTitle); + } + +#ifdef WIN32 + MultiByteToWideChar(CP_ACP, 0, title, strlen(title) + 1, widestring, 4096); + memset(tempstring, '\000', sizeof(tempstring)); + WideCharToMultiByte(CP_UTF8, + 0, + widestring, + wcslen(widestring) + 1, + tempstring, + sizeof(tempstring), + 0, + NULL); + vorbis_comment_add(&vc, tempstring); +#else + vorbis_comment_add(&vc, title); +#endif + sprintf(artist, "ARTIST=%s", Artist); +#ifdef WIN32 + MultiByteToWideChar(CP_ACP, 0, artist, strlen(artist) + 1, widestring, 4096); + memset(tempstring, '\000', sizeof(tempstring)); + WideCharToMultiByte(CP_UTF8, + 0, + widestring, + wcslen(widestring) + 1, + tempstring, + sizeof(tempstring), + 0, + NULL); + vorbis_comment_add(&vc, tempstring); +#else + vorbis_comment_add(&vc, artist); +#endif + } + + sprintf(Streamed, "ENCODEDBY=edcast"); + vorbis_comment_add(&vc, Streamed); + if(strlen(g->sourceDescription) > 0) { + sprintf(Streamed, "TRANSCODEDFROM=%s", g->sourceDescription); + vorbis_comment_add(&vc, Streamed); + } + + /* Build the packets */ + memset(&header_main, '\000', sizeof(header_main)); + memset(&header_comments, '\000', sizeof(header_comments)); + memset(&header_codebooks, '\000', sizeof(header_codebooks)); + + vorbis_analysis_headerout(&g->vd, &vc, &header_main, &header_comments, &header_codebooks); + + ogg_stream_packetin(&g->os, &header_main); + ogg_stream_packetin(&g->os, &header_comments); + ogg_stream_packetin(&g->os, &header_codebooks); + + g->in_header = 1; + + ogg_page og; + int eos = 0; + int sentbytes = 0; + int ret = 0; + + while(!eos) { + int result = ogg_stream_flush(&g->os, &og); + + if(result == 0) break; + sentbytes += sendToServer(g, g->gSCSocket, (char *) og.header, og.header_len, CODEC_TYPE); + sentbytes += sendToServer(g, g->gSCSocket, (char *) og.body, og.body_len, CODEC_TYPE); + } + + vorbis_comment_clear(&vc); + if(g->numVorbisComments) { + freeVorbisComments(g); + } + +#else + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Not compiled with Ogg Vorbis support"); + } + + LogMessage(g,LOG_ERROR, "Not compiled with Ogg Vorbis support"); + return 0; +#endif + } + + if(g->gFLACFlag) + { +#ifdef HAVE_FLAC + char FullTitle[1024] = ""; + char SongTitle[1024] = ""; + char Artist[1024] = ""; + char Streamed[1024] = ""; + + memset(Artist, '\000', sizeof(Artist)); + memset(SongTitle, '\000', sizeof(SongTitle)); + memset(FullTitle, '\000', sizeof(FullTitle)); + memset(Streamed, '\000', sizeof(Streamed)); + + if(g->flacEncoder) { + FLAC__stream_encoder_finish(g->flacEncoder); + FLAC__stream_encoder_delete(g->flacEncoder); + FLAC__metadata_object_delete(g->flacMetadata); + g->flacEncoder = NULL; + g->flacMetadata = NULL; + } + + g->flacEncoder = FLAC__stream_encoder_new(); + g->flacMetadata = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT); + + FLAC__stream_encoder_set_streamable_subset(g->flacEncoder, false); +// FLAC__stream_encoder_set_client_data(g->flacEncoder, (void*)g); + + FLAC__stream_encoder_set_channels(g->flacEncoder, g->currentChannels); + + +/* + FLAC__stream_encoder_set_write_callback(g->flacEncoder,(FLAC__StreamEncoderWriteCallback) FLACWriteCallback, + (FLAC__StreamEncoderWriteCallback) FLACWriteCallback); + FLAC__stream_encoder_set_metadata_callback(g->flacEncoder, + (FLAC__StreamEncoderMetadataCallback) FLACMetadataCallback); + */ + srand(time(0)); + + + if(!getLockedMetadataFlag(g)) { + FLAC__StreamMetadata_VorbisComment_Entry entry; + FLAC__StreamMetadata_VorbisComment_Entry entry3; + FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "ENCODEDBY", "edcast"); + FLAC__metadata_object_vorbiscomment_append_comment(g->flacMetadata, entry, true); + if(strlen(g->sourceDescription) > 0) { + FLAC__StreamMetadata_VorbisComment_Entry entry2; + FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry2, "TRANSCODEDFROM", g->sourceDescription); + FLAC__metadata_object_vorbiscomment_append_comment(g->flacMetadata, entry2, true); + } + getCurrentSongTitle(g, SongTitle, Artist, FullTitle); + FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry3, "TITLE", FullTitle); + FLAC__metadata_object_vorbiscomment_append_comment(g->flacMetadata, entry3, true); + + } + FLAC__stream_encoder_set_ogg_serial_number(g->flacEncoder, rand()); + + FLAC__StreamEncoderInitStatus ret = FLAC__stream_encoder_init_ogg_stream(g->flacEncoder, NULL, (FLAC__StreamEncoderWriteCallback) FLACWriteCallback, NULL, NULL, (FLAC__StreamEncoderMetadataCallback) FLACMetadataCallback, (void*)g); + if(ret == FLAC__STREAM_ENCODER_INIT_STATUS_OK) { + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "FLAC initialized"); + } + } + else { + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Error Initializing FLAC"); + } + + LogMessage(g,LOG_ERROR, "Error Initializing FLAC"); + return 0; + } +#endif + } + + return 1; +} + +void addToFIFO(edcastGlobals *g, float *samples, int numsamples) { + int currentFIFO = g->faacFIFOendpos; + + for(int i = 0; i < numsamples; i++) { + g->faacFIFO[currentFIFO] = samples[i]; + currentFIFO++; + } + + g->faacFIFOendpos = currentFIFO; +} + +void FloatScale(float *destination, float *source, int numsamples, int destchannels) { + int i; + + if(destchannels == 2) { + for(i = 0; i < numsamples; i++) { + *destination++ = *source++ *32767.f; + } + } + else { + for(i = 0; i < numsamples >> 1; i++) { + *destination++ = (*source++ +*source++) * 16383.f; + } + } +} + +void ExtractFromFIFO(float *destination, float *source, int numsamples) { + for(int i = 0; i < numsamples; i++) { + *destination++ = *source++; + } +} + +int do_encoding(edcastGlobals *g, float *samples, int numsamples, int nch) { + g->gCurrentlyEncoding = 1; + + int s; + int count = 0; + unsigned char mp3buffer[LAME_MAXMP3BUFFER]; + int imp3; + short int *int_samples; + int eos = 0; + int ret = 0; + int sentbytes = 0; + char buf[255] = ""; + + g->gCurrentlyEncoding = 1; + + if(g->weareconnected) { + s = numsamples * nch; + + long leftMax = 0; + long rightMax = 0; + int samplecounter = 0; + + LogMessage(g,LOG_DEBUG, "determining left/right max..."); + for(int i = 0; i < numsamples * 2; i = i + 2) { + leftMax += abs((int) ((float) samples[i] * 32767.f)); + rightMax += abs((int) ((float) samples[i + 1] * 32767.f)); + } + + if(numsamples > 0) { + leftMax = leftMax / (numsamples * 2); + rightMax = rightMax / (numsamples * 2); + if(g->VUCallback) { + g->VUCallback(leftMax, rightMax); + } + } + + if(g->gOggFlag) + { +#ifdef HAVE_VORBIS + /* + * If a song change was detected, close the stream and resend new ; + * vorbis headers (with new comments) - all done by icecast2SendMetadata(); + */ + if(g->ice2songChange) { + LogMessage(g,LOG_DEBUG, "Song change processing..."); + g->ice2songChange = false; + icecast2SendMetadata(g); + } + + LogMessage(g,LOG_DEBUG, "vorbis_analysis_buffer..."); + + float **buffer = vorbis_analysis_buffer(&g->vd, numsamples); + int samplecount = 0; + int i; + + samplecounter = 0; + + for(i = 0; i < numsamples * 2; i = i + 2) { + buffer[0][samplecounter] = samples[i]; + if(g->currentChannels == 2) { + buffer[1][samplecounter] = samples[i + 1]; + } + + samplecounter++; + } + LogMessage(g,LOG_DEBUG, "vorbis_analysis_wrote..."); + + ret = vorbis_analysis_wrote(&g->vd, numsamples); + + pthread_mutex_lock(&(g->mutex)); + LogMessage(g,LOG_DEBUG, "ogg_encode_dataout..."); + /* Stream out what we just prepared for Vorbis... */ + sentbytes = ogg_encode_dataout(g); + LogMessage(g,LOG_DEBUG, "done ogg_ecndoe_dataout..."); + pthread_mutex_unlock(&(g->mutex)); +#endif + } + + if(g->gAACFlag) + { +#ifdef HAVE_FAAC + float *buffer = (float *) malloc(numsamples * 2 * sizeof(float)); + FloatScale(buffer, samples, numsamples * 2, g->currentChannels); + + addToFIFO(g, buffer, numsamples * g->currentChannels); + + while(g->faacFIFOendpos > (int)g->samplesInput) { + float *buffer2 = (float *) malloc(g->samplesInput * 2 * sizeof(float)); + + ExtractFromFIFO(buffer2, g->faacFIFO, g->samplesInput); + + int counter = 0; + + for(int i = g->samplesInput; i < g->faacFIFOendpos; i++) { + g->faacFIFO[counter] = g->faacFIFO[i]; + counter++; + } + + g->faacFIFOendpos = counter; + + unsigned long dwWrite = 0; + unsigned char *aacbuffer = (unsigned char *) malloc(g->maxBytesOutput); + + imp3 = faacEncEncode(g->aacEncoder, (int32_t *) buffer2, g->samplesInput, aacbuffer, g->maxBytesOutput); + + if(imp3) { + sentbytes = sendToServer(g, g->gSCSocket, (char *) aacbuffer, imp3, CODEC_TYPE); + } + + if(buffer2) { + free(buffer2); + } + + if(aacbuffer) { + free(aacbuffer); + } + } + + if(buffer) { + free(buffer); + } +#endif + } + + if(g->gAACPFlag) + { +#ifdef HAVE_AACP + static char outbuffer[32768]; + static char inbuffer[32768]; + static int inbufferused = 0; + int len = numsamples * g->currentChannels * sizeof(short); + + int_samples = (short *) malloc(len); + + int samplecount = 0; + + if(g->currentChannels == 1) { + for(int i = 0; i < numsamples * 2; i = i + 2) { + int_samples[samplecount] = (short int) (samples[i] * 32767.0); + samplecount++; + } + } + else { + for(int i = 0; i < numsamples * 2; i++) { + int_samples[i] = (short int) (samples[i] * 32767.0); + samplecount++; + } + } + + char *bufcounter = (char *) int_samples; + + for(;;) { + int in_used = 0; + + if(len <= 0) break; + + int enclen = g->aacpEncoder->Encode(in_used, bufcounter, len, &in_used, outbuffer, sizeof(outbuffer)); + + if(enclen > 0) { + sentbytes = sendToServer(g, g->gSCSocket, (char *) outbuffer, enclen, CODEC_TYPE); + } + else { + break; + } + + if(in_used > 0) { + bufcounter += in_used; + len -= in_used; + } + } + + if(int_samples) { + free(int_samples); + } +#endif + } + + if(g->gLAMEFlag) + { +#ifdef HAVE_LAME + /* Lame encoding is simple, we are passing it interleaved samples */ + int_samples = (short int *) malloc(numsamples * 2 * sizeof(short int)); + + int samplecount = 0; + + if(g->currentChannels == 1) { + for(int i = 0; i < numsamples * 2; i = i + 2) { + int_samples[samplecount] = (int) (samples[i] * 32767.0); + samplecount++; + } + } + else { + for(int i = 0; i < numsamples * 2; i++) { + int_samples[i] = (int) (samples[i] * 32767.0); + samplecount++; + } + } + +#ifdef WIN32 + unsigned long dwWrite = 0; + int err = g->beEncodeChunk(g->hbeStream, + samplecount, + (short *) int_samples, + (PBYTE) mp3buffer, + &dwWrite); + + imp3 = dwWrite; +#else + float *samples_left; + float *samples_right; + + samples_left = (float *) malloc(numsamples * (sizeof(float))); + samples_right = (float *) malloc(numsamples * (sizeof(float))); + + for(int i = 0; i < numsamples; i++) { + samples_left[i] = samples[2 * i] * 32767.0; + samples_right[i] = samples[2 * i + 1] * 32767.0; + } + + imp3 = lame_encode_buffer_float(g->gf, + (float *) samples_left, + (float *) samples_right, + numsamples, + mp3buffer, + sizeof(mp3buffer)); + if(samples_left) { + free(samples_left); + } + + if(samples_right) { + free(samples_right); + } +#endif + if(int_samples) { + free(int_samples); + } + + if(imp3 == -1) { + LogMessage(g,LOG_ERROR, "mp3 buffer is not big enough!"); + return -1; + } + + /* Send out the encoded buffer */ + sentbytes = sendToServer(g, g->gSCSocket, (char *) mp3buffer, imp3, CODEC_TYPE); +#endif + } + + if(g->gFLACFlag) + { +#ifdef HAVE_FLAC + INT32 *int32_samples; + + int32_samples = (INT32 *) malloc(numsamples * 2 * sizeof(INT32)); + + int samplecount = 0; + + if(g->currentChannels == 1) { + for(int i = 0; i < numsamples * 2; i = i + 2) { + int32_samples[samplecount] = (INT32) (samples[i] * 32767.0); + samplecount++; + } + } + else { + for(int i = 0; i < numsamples * 2; i++) { + int32_samples[i] = (INT32) (samples[i] * 32767.0); + samplecount++; + } + } + + FLAC__stream_encoder_process_interleaved(g->flacEncoder, int32_samples, numsamples); + + if(int32_samples) { + free(int32_samples); + } + + if(g->flacFailure) { + sentbytes = 0; + } + else { + sentbytes = 1; + } +#endif + } + + /* + * Generic error checking, if there are any socket problems, the trigger ; + * a disconnection handling->.. + */ + if(sentbytes < 0) { + int rret = triggerDisconnect(g); + if (rret == 0) { + return 0; + } + } + } + + g->gCurrentlyEncoding = 0; + return 1; +} + +int triggerDisconnect(edcastGlobals *g) { + char buf[2046] = ""; + + disconnectFromServer(g); + if(g->gForceStop) { + g->gForceStop = 0; + return 0; + } + + + sprintf(buf, "Disconnected from server"); + g->forcedDisconnect = true; + g->forcedDisconnectSecs = time(&(g->forcedDisconnectSecs)); + g->serverStatusCallback(g, (void *) buf); + return 1; +} +void config_read(edcastGlobals *g) { + strcpy(g->gAppName, "edcast"); + + char buf[255] = ""; + char desc[1024] = ""; + +#ifdef XMMS_PLUGIN + sprintf(desc, "This is the named pipe used to communicate with the XMMS effect plugin. Make sure it matches the settings in that plugin"); + GetConfigVariable(g, g->gAppName, "SourceURL", "/tmp/edcastFIFO", g->gSourceURL, sizeof(g->gSourceURL), desc); +#else + sprintf(desc, "The source URL for the broadcast. It must be in the form http://server:port/mountpoint. For those servers without a mountpoint (Shoutcast) use http://server:port."); + GetConfigVariable(g, g->gAppName, "SourceURL", "http://localhost/", g->gSourceURL, sizeof(g->gSourceURL), desc); +#endif + if(g->sourceURLCallback) { + g->sourceURLCallback(g, (char *) g->gSourceURL); + } + + sprintf(desc, "Destination server details (to where you are encoding). Valid server types : Shoutcast, Icecast, Icecast2"); + GetConfigVariable(g, g->gAppName, "ServerType", "Icecast2", g->gServerType, sizeof(g->gServerType), desc); +// sprintf(desc, "The server to which the stream is sent. It can be a hostname or IP (example: www.stream.com, 192.168.1.100)"); + GetConfigVariable(g, g->gAppName, "Server", "localhost", g->gServer, sizeof(g->gServer), NULL); +// sprintf(desc, "The port to which the stream is sent. Must be a number (example: 8000)"); + GetConfigVariable(g, g->gAppName, "Port", "8000", g->gPort, sizeof(g->gPort), NULL); +// sprintf(desc, "This is the encoder password for the destination server (example: hackme)"); + GetConfigVariable(g, g->gAppName, "ServerPassword", "changemenow", g->gPassword, sizeof(g->gPassword), NULL); +// sprintf(desc,"Used for Icecast/Icecast2 servers, The mountpoint must end in .ogg for Vorbis streams and have NO extention for MP3 streams. If you are sending to a Shoutcast server, this MUST be blank. (example: /mp3, /myvorbis.ogg)"); + GetConfigVariable(g, g->gAppName, "ServerMountpoint", "/stream.ogg", g->gMountpoint, sizeof(g->gMountpoint), NULL); +// sprintf(desc,"This setting tells the destination server to list on any available YP listings. Not all servers support this (Shoutcast does, Icecast2 doesn't) (example: 1 for YES, 0 for NO)"); + sprintf(desc,"YP (Stream Directory) Settings"); + g->gPubServ = GetConfigVariableLong(g, g->gAppName, "ServerPublic", 1, desc); +// sprintf(desc, "This is used in the YP listing, I think only Shoutcast supports this (example: #mystream)"); + GetConfigVariable(g, g->gAppName, "ServerIRC", "", g->gServIRC, sizeof(g->gServIRC), NULL); +// sprintf(desc, "This is used in the YP listing, I think only Shoutcast supports this (example: myAIMaccount)"); + GetConfigVariable(g, g->gAppName, "ServerAIM", "", g->gServAIM, sizeof(g->gServAIM), NULL); +// sprintf(desc, "This is used in the YP listing, I think only Shoutcast supports this (example: 332123132)"); + GetConfigVariable(g, g->gAppName, "ServerICQ", "", g->gServICQ, sizeof(g->gServICQ), NULL); +// sprintf(desc, "The URL that is associated with your stream. (example: http://www.mystream.com)"); + GetConfigVariable(g, g->gAppName, "ServerStreamURL", "http://www.oddsock.org", g->gServURL, sizeof(g->gServURL), NULL); +// sprintf(desc, "The Stream Name"); + GetConfigVariable(g, g->gAppName, "ServerName", "This is my server name", g->gServName, sizeof(g->gServName), NULL); +// sprintf(desc, "A short description of the stream (example: Stream House on Fire!)"); + GetConfigVariable(g, g->gAppName, "ServerDescription", "This is my server description", g->gServDesc, sizeof(g->gServDesc), NULL); +// sprintf(desc, "Genre of music, can be anything you want... (example: Rock)"); + GetConfigVariable(g, g->gAppName, "ServerGenre", "Rock", g->gServGenre, sizeof(g->gServGenre), NULL); +// sprintf(desc,"Wether or not edcast will reconnect if it is disconnected from the destination server (example: 1 for YES, 0 for NO)"); + sprintf(desc,"Misc encoder properties"); + g->gAutoReconnect = GetConfigVariableLong(g, g->gAppName, "AutomaticReconnect", 1, desc); + +// sprintf(desc, "How long it will wait (in seconds) between reconnect attempts. (example: 10)"); + g->gReconnectSec = GetConfigVariableLong(g, g->gAppName, "AutomaticReconnectSecs", 10, NULL); + + g->autoconnect = GetConfigVariableLong(g, g->gAppName, "AutoConnect", 0, NULL); + + + // sprintf(desc, "What format to encode to. Valid values are (OGG, LAME) (example: OGG, LAME)"); + sprintf(desc, "Output codec selection (Valid selections : MP3, OggVorbis, Ogg FLAC, AAC, AAC Plus)"); + GetConfigVariable(g, g->gAppName, "Encode", "OggVorbis", g->gEncodeType, sizeof(g->gEncodeType), desc); + if(!strncmp(g->gEncodeType, "MP3", 3)) { + /* LAME */ + g->gAACPFlag = 0; + g->gOggFlag = 0; + g->gLAMEFlag = 1; + g->gAACFlag = 0; + g->gFLACFlag = 0; + } + + if(!strncmp(g->gEncodeType, "AAC Plus", 8)) { + + /* AAC */ + g->gOggFlag = 0; + g->gLAMEFlag = 0; + g->gAACFlag = 0; + g->gAACPFlag = 1; + g->gFLACFlag = 0; + } + + if(!strcmp(g->gEncodeType, "AAC")) { + + /* AAC */ + g->gAACPFlag = 0; + g->gOggFlag = 0; + g->gLAMEFlag = 0; + g->gAACFlag = 1; + g->gFLACFlag = 0; + } + + if(!strcmp(g->gEncodeType, "OggVorbis")) { + + /* OggVorbis */ + g->gOggFlag = 1; + g->gAACPFlag = 0; + g->gLAMEFlag = 0; + g->gAACFlag = 0; + g->gFLACFlag = 0; + } + + if(!strcmp(g->gEncodeType, "Ogg FLAC")) { + + /* OggVorbis */ + g->gOggFlag = 0; + g->gAACPFlag = 0; + g->gLAMEFlag = 0; + g->gAACFlag = 0; + g->gFLACFlag = 1; + } + + if(g->streamTypeCallback) { + if(g->gOggFlag) { + g->streamTypeCallback(g, (void *) "OggVorbis"); + } + + if(g->gLAMEFlag) { + g->streamTypeCallback(g, (void *) "MP3"); + } + + if(g->gAACFlag) { + g->streamTypeCallback(g, (void *) "AAC"); + } + + if(g->gAACPFlag) { + g->streamTypeCallback(g, (void *) "AAC+"); + } + + if(g->gFLACFlag) { + g->streamTypeCallback(g, (void *) "OggFLAC"); + } + } + + if(g->destURLCallback) { + sprintf(buf, "http://%s:%s%s", g->gServer, g->gPort, g->gMountpoint); + g->destURLCallback(g, (char *) buf); + } + +// sprintf(desc, "Bitrate. This is the mean bitrate if using VBR."); + sprintf(desc, "General settings (non-codec related). Note : NumberChannels = 1 for MONO, 2 for STEREO"); + g->currentBitrate = GetConfigVariableLong(g, g->gAppName, "BitrateNominal", 128, desc); + +// sprintf(desc,"Minimum Bitrate. Used only if using Bitrate Management (not recommended) or LAME VBR(example: 64, 128)"); + g->currentBitrateMin = GetConfigVariableLong(g, g->gAppName, "BitrateMin", 128, NULL); + +// sprintf(desc,"Maximum Bitrate. Used only if using Bitrate Management (not recommended) or LAME VBR (example: 64, 128)"); + g->currentBitrateMax = GetConfigVariableLong(g, g->gAppName, "BitrateMax", 128, NULL); + +// sprintf(desc, "Number of channels. Valid values are (1, 2). 1 means Mono, 2 means Stereo (example: 2,1)"); + g->currentChannels = GetConfigVariableLong(g, g->gAppName, "NumberChannels", 2, NULL); + +// sprintf(desc, "Sample rate for the stream. Valid values depend on wether using lame or vorbis. Vorbis supports odd samplerates such as 32kHz and 48kHz, but lame appears to not.feel free to experiment (example: 44100, 22050, 11025)"); + g->currentSamplerate = GetConfigVariableLong(g, g->gAppName, "Samplerate", 44100, NULL); + +// sprintf(desc, "Vorbis Quality Level. Valid values are between -1 (lowest quality) and 10 (highest). The lower the quality the lower the output bitrate. (example: -1, 3)"); + sprintf(desc, "Ogg Vorbis specific settings. Note: Valid settings for BitrateQuality flag are (Quality, Bitrate Management)"); + GetConfigVariable(g, g->gAppName, "OggQuality", "0", g->gOggQuality, sizeof(g->gOggQuality), desc); + + +// sprintf(desc,"This flag specifies if you want Vorbis Quality or Bitrate Management. Quality is always recommended. Valid values are (Bitrate, Quality). (example: Quality, Bitrate Management)"); + GetConfigVariable(g, g->gAppName, "OggBitrateQualityFlag", "Quality", g->gOggBitQual, sizeof(g->gOggBitQual), NULL); + g->gOggBitQualFlag = 0; + if(!strncmp(g->gOggBitQual, "Q", 1)) { + + /* Quality */ + g->gOggBitQualFlag = 0; + } + + if(!strncmp(g->gOggBitQual, "B", 1)) { + + /* Bitrate */ + g->gOggBitQualFlag = 1; + } + + g->gAutoCountdown = atoi(g->gAutoStartSec); + if(strlen(g->gMountpoint) > 0) { + strcpy(g->gIceFlag, "1"); + } + else { + strcpy(g->gIceFlag, "0"); + } + + char tempString[255] = ""; + + memset(tempString, '\000', sizeof(tempString)); + ReplaceString(g->gServer, tempString, " ", ""); + strcpy(g->gServer, tempString); + + memset(tempString, '\000', sizeof(tempString)); + ReplaceString(g->gPort, tempString, " ", ""); + strcpy(g->gPort, tempString); + +// sprintf(desc,"This LAME flag indicates that CBR encoding is desired. If this flag is set then LAME with use CBR, if not set then it will use VBR (and you must then specify a VBR mode). Valid values are (1 for SET, 0 for NOT SET) (example: 1)"); + sprintf(desc,"LAME specific settings. Note: Setting the low/highpass freq to 0 will disable them."); + g->gLAMEOptions.cbrflag = GetConfigVariableLong(g, g->gAppName, "LameCBRFlag", 1, desc); +// sprintf(desc,"A number between 1 and 10 which indicates the desired quality level of the stream. The higher the number, the higher the quality. Also, the higher the number, the higher the CPU utilization. So for slower CPUs, try a low quality number (example: 5)"); + g->gLAMEOptions.quality = GetConfigVariableLong(g, g->gAppName, "LameQuality", 1, NULL); + +// sprintf(desc, "Copywrite flag-> Not used for much. Valid values (1 for YES, 0 for NO)"); + g->gLAMEOptions.copywrite = GetConfigVariableLong(g, g->gAppName, "LameCopywrite", 0, NULL); +// sprintf(desc, "Original flag-> Not used for much. Valid values (1 for YES, 0 for NO)"); + g->gLAMEOptions.original = GetConfigVariableLong(g, g->gAppName, "LameOriginal", 0, NULL); +// sprintf(desc, "Strict ISO flag-> Not used for much. Valid values (1 for YES, 0 for NO)"); + g->gLAMEOptions.strict_ISO = GetConfigVariableLong(g, g->gAppName, "LameStrictISO", 0, NULL); +// sprintf(desc, "Disable Reservior flag-> Not used for much. Valid values (1 for YES, 0 for NO)"); + g->gLAMEOptions.disable_reservoir = GetConfigVariableLong(g, g->gAppName, "LameDisableReservior", 0, NULL); +// sprintf(desc, "This specifies the type of VBR encoding LAME will perform if VBR encoding is set (CBRFlag is NOT SET). See the LAME documention for more on what these mean. Valid values are (vbr_rh, vbr_mt, vbr_mtrh, vbr_abr)"); + GetConfigVariable(g, g->gAppName, "LameVBRMode", "vbr_abr", g->gLAMEOptions.VBR_mode, sizeof(g->gLAMEOptions.VBR_mode), NULL); + +// sprintf(desc, "Use LAMEs lowpass filter. If you set this to 0, then no filtering is done."); + g->gLAMEOptions.lowpassfreq = GetConfigVariableLong(g, g->gAppName, "LameLowpassfreq", 0, NULL); +// sprintf(desc, "Use LAMEs highpass filter. If you set this to 0, then no filtering is done."); + g->gLAMEOptions.highpassfreq = GetConfigVariableLong(g, g->gAppName, "LameHighpassfreq", 0, NULL); + + if(g->gLAMEOptions.lowpassfreq > 0) { + g->gLAMELowpassFlag = 1; + } + + if(g->gLAMEOptions.highpassfreq > 0) { + g->gLAMELowpassFlag = 1; + } + sprintf(desc, "LAME Preset"); + int defaultPreset = 0; +#ifdef WIN32 + defaultPreset = LQP_NOPRESET; +#endif + g->gLAMEpreset = GetConfigVariableLong(g, g->gAppName, "LAMEPreset", defaultPreset, NULL); + + sprintf(desc, "AAC (FAAC) specific settings."); +// sprintf(desc, "AAC Quality Level. Valid values are between 10 (lowest quality) and 500 (highest)."); + GetConfigVariable(g, g->gAppName, "AACQuality", "100", g->gAACQuality, sizeof(g->gAACQuality), desc); +// sprintf(desc, "AAC Cutoff Frequency."); + GetConfigVariable(g, g->gAppName, "AACCutoff", "", g->gAACCutoff, sizeof(g->gAACCutoff), NULL); + + + + if(!strcmp(g->gServerType, "KasterBlaster")) { + g->gShoutcastFlag = 1; + g->gIcecastFlag = 0; + g->gIcecast2Flag = 0; + } + + if(!strcmp(g->gServerType, "Shoutcast")) { + g->gShoutcastFlag = 1; + g->gIcecastFlag = 0; + g->gIcecast2Flag = 0; + } + + if(!strcmp(g->gServerType, "Icecast")) { + g->gShoutcastFlag = 0; + g->gIcecastFlag = 1; + g->gIcecast2Flag = 0; + } + + if(!strcmp(g->gServerType, "Icecast2")) { + g->gShoutcastFlag = 0; + g->gIcecastFlag = 0; + g->gIcecast2Flag = 1; + } + + if(g->serverTypeCallback) { + g->serverTypeCallback(g, (void *) g->gServerType); + } + + if(g->serverNameCallback) { + char *pdata = NULL; + int pdatalen = strlen(g->gServDesc) + strlen(g->gServName) + strlen(" () ") + 1; + + pdata = (char *) calloc(1, pdatalen); + sprintf(pdata, "%s (%s)", g->gServName, g->gServDesc); + g->serverNameCallback(g, (void *) pdata); + free(pdata); + } + + sprintf(desc, "If recording from linein, what device to use (not needed for win32) (example: /dev/dsp)"); + GetConfigVariable(g, g->gAppName, "AdvRecDevice", "/dev/dsp", buf, sizeof(buf), desc); + strcpy(g->gAdvRecDevice, buf); + + + sprintf(desc, "If recording from linein, what sample rate to open the device with. (example: 44100, 48000)"); + GetConfigVariable(g, g->gAppName, "LiveInSamplerate", "44100", buf, sizeof(buf), desc); + g->gLiveInSamplerate = atoi(buf); + + sprintf(desc, "Used for any window positions (X value)"); + g->lastX = GetConfigVariableLong(g, g->gAppName, "lastX", 0, desc); + sprintf(desc, "Used for any window positions (Y value)"); + g->lastY = GetConfigVariableLong(g, g->gAppName, "lastY", 0, desc); + sprintf(desc, "Used for dummy window positions (X value)"); + g->lastDummyX = GetConfigVariableLong(g, g->gAppName, "lastDummyX", 0, desc); + sprintf(desc, "Used for dummy window positions (Y value)"); + g->lastDummyY = GetConfigVariableLong(g, g->gAppName, "lastDummyY", 0, desc); + sprintf(desc, "Used for plugins that show the VU meter"); + g->vuShow = GetConfigVariableLong(g, g->gAppName, "showVU", 0, desc); + + sprintf(desc, "Flag which indicates we are recording from line in"); + + int lineInDefault = 0; + +#ifdef ODDCASTSTANDALONE + lineInDefault = 1; +#endif + g->gLiveRecordingFlag = GetConfigVariableLong(g, g->gAppName, "LineInFlag", lineInDefault, desc); + + sprintf(desc, "Locked Metadata"); + GetConfigVariable(g, g->gAppName, "LockMetadata", "", g->gManualSongTitle, sizeof(g->gManualSongTitle), desc); + sprintf(desc, "Flag which indicates if we are using locked metadata"); + g->gLockSongTitle = GetConfigVariableLong(g, g->gAppName, "LockMetadataFlag", 0, desc); + + sprintf(desc, "Save directory for archive streams"); + GetConfigVariable(g, g->gAppName, "SaveDirectory", "", g->gSaveDirectory, sizeof(g->gSaveDirectory), desc); + sprintf(desc, "Flag which indicates if we are saving archives"); + g->gSaveDirectoryFlag = GetConfigVariableLong(g, g->gAppName, "SaveDirectoryFlag", 0, desc); + sprintf(desc, "Log Level 1 = LOG_ERROR, 2 = LOG_ERROR+LOG_INFO, 3 = LOG_ERROR+LOG_INFO+LOG_DEBUG"); + g->gLogLevel = GetConfigVariableLong(g, g->gAppName, "LogLevel", 2, desc); + sprintf(desc, "Log File"); + GetConfigVariable(g, g->gAppName, "LogFile", defaultLogFileName, g->gLogFile, sizeof(g->gLogFile), desc); + setgLogFile(g, g->gLogFile); + + sprintf(desc, "Save Archives in WAV format"); + g->gSaveAsWAV = GetConfigVariableLong(g, g->gAppName, "SaveAsWAV", 0, desc); + + + sprintf(desc, "Append this string to all metadata"); + GetConfigVariable(g, g->gAppName, "MetadataAppend", "", g->metadataAppendString, sizeof(g->metadataAppendString), desc); + sprintf(desc, + "Remove this string (and everything after) from the window title of the window class the metadata is coming from"); + GetConfigVariable(g, g->gAppName, "MetadataRemoveAfter", "", g->metadataRemoveStringAfter, sizeof(g->metadataRemoveStringAfter), desc); + sprintf(desc,"Remove this string (and everything before) from the window title of the window class the metadata is coming from"); + GetConfigVariable(g, g->gAppName, "MetadataRemoveBefore", "", g->metadataRemoveStringBefore, sizeof(g->metadataRemoveStringBefore), desc); + sprintf(desc, "Window classname to grab metadata from (uses window title)"); + GetConfigVariable(g, g->gAppName, "MetadataWindowClass", "", g->metadataWindowClass, sizeof(g->metadataWindowClass), desc); + sprintf(desc, "Indicator which tells edcast to grab metadata from a defined window class"); + + if (GetConfigVariableLong(g, g->gAppName, "MetadataWindowClassInd", 0, desc)) { + g->metadataWindowClassInd = true; + } + else { + g->metadataWindowClassInd = false; + } + + + + /* Set some derived values */ + char localBitrate[255] = ""; + char mode[50] = ""; + + if(g->currentChannels == 1) { + strcpy(mode, "Mono"); + } + + if(g->currentChannels == 2) { + strcpy(mode, "Stereo"); + } + + if(g->gOggFlag) { + if(g->bitrateCallback) { + if(g->gOggBitQualFlag == 0) { + + /* Quality */ + sprintf(localBitrate, "Vorbis: Quality %s/%s/%d", g->gOggQuality, mode, g->currentSamplerate); + } + else { + sprintf(localBitrate, "Vorbis: %dkbps/%s/%d", g->currentBitrate, mode, g->currentSamplerate); + } + + g->bitrateCallback(g, (void *) localBitrate); + } + } + + if(g->gLAMEFlag) { + if(g->bitrateCallback) { + if(g->gLAMEOptions.cbrflag) { + sprintf(localBitrate, "MP3: %dkbps/%dHz/%s", g->currentBitrate, g->currentSamplerate, mode); + } + else { + sprintf(localBitrate, + "MP3: (%d/%d/%d)/%s/%d", + g->currentBitrateMin, + g->currentBitrate, + g->currentBitrateMax, + mode, + g->currentSamplerate); + } + + g->bitrateCallback(g, (void *) localBitrate); + } + } + + if(g->gAACFlag) { + if(g->bitrateCallback) { + sprintf(localBitrate, "AAC: Quality %s/%dHz/%s", g->gAACQuality, g->currentSamplerate, mode); + g->bitrateCallback(g, (void *) localBitrate); + } + } + + if(g->gAACPFlag) { + if(g->bitrateCallback) { + long bitrateLong = g->currentBitrate * 1000; + + if(bitrateLong >= 64000) { + if(g->currentChannels == 2) { + strcpy(mode, "Stereo"); + } + else { + strcpy(mode, "Mono"); + } + } + + if((bitrateLong <= 48000) && (bitrateLong >= 16000)) { + if(g->currentChannels == 2) { + strcpy(mode, "Parametric Stereo"); + } + else { + strcpy(mode, "Mono"); + } + } + + if(bitrateLong <= 12000) { + strcpy(mode, "Mono"); + } + + sprintf(localBitrate, "AAC+V2: %dkbps/%dHz/%s", g->currentBitrate, g->currentSamplerate, mode); + g->bitrateCallback(g, (void *) localBitrate); + } + } + + if(g->gFLACFlag) { + if(g->bitrateCallback) { + sprintf(localBitrate, "FLAC: %dHz/%s", g->currentSamplerate, mode); + g->bitrateCallback(g, (void *) localBitrate); + } + } + + if(g->serverStatusCallback) { + g->serverStatusCallback(g, (void *) "Disconnected"); + } + + sprintf(desc, "Number of encoders to use"); + g->gNumEncoders = GetConfigVariableLong(g, g->gAppName, "NumEncoders", 0, desc); + + sprintf(desc, "Enable external metadata calls (DISABLED, URL, FILE)"); + GetConfigVariable(g, g->gAppName, "ExternalMetadata", "DISABLED", g->externalMetadata, sizeof(g->gLogFile), desc); + sprintf(desc, "URL to retrieve for external metadata"); + GetConfigVariable(g, g->gAppName, "ExternalURL", "", g->externalURL, sizeof(g->externalURL), desc); + sprintf(desc, "File to retrieve for external metadata"); + GetConfigVariable(g, g->gAppName, "ExternalFile", "", g->externalFile, sizeof(g->externalFile), desc); + sprintf(desc, "Interval for retrieving external metadata"); + GetConfigVariable(g, g->gAppName, "ExternalInterval", "60", g->externalInterval, sizeof(g->externalInterval), desc); + sprintf(desc, "Advanced setting"); + GetConfigVariable(g, g->gAppName, "OutputControl", "", g->outputControl, sizeof(g->outputControl), desc); + + sprintf(desc, "Windows Recording Device"); + GetConfigVariable(g, g->gAppName, "WindowsRecDevice", "", buf, sizeof(buf), desc); + strcpy(g->WindowsRecDevice, buf); + + sprintf(desc, "LAME Joint Stereo Flag"); + g->LAMEJointStereoFlag = GetConfigVariableLong(g, g->gAppName, "LAMEJointStereo", 1, desc); + +} + +void config_write(edcastGlobals *g) { + strcpy(g->gAppName, "edcast"); + + char buf[255] = ""; + char desc[1024] = ""; + char tempString[1024] = ""; + + memset(tempString, '\000', sizeof(tempString)); + ReplaceString(g->gServer, tempString, " ", ""); + strcpy(g->gServer, tempString); + + memset(tempString, '\000', sizeof(tempString)); + ReplaceString(g->gPort, tempString, " ", ""); + strcpy(g->gPort, tempString); + + PutConfigVariable(g, g->gAppName, "SourceURL", g->gSourceURL); + PutConfigVariable(g, g->gAppName, "ServerType", g->gServerType); + PutConfigVariable(g, g->gAppName, "Server", g->gServer); + PutConfigVariable(g, g->gAppName, "Port", g->gPort); + PutConfigVariable(g, g->gAppName, "ServerMountpoint", g->gMountpoint); + PutConfigVariable(g, g->gAppName, "ServerPassword", g->gPassword); + PutConfigVariableLong(g, g->gAppName, "ServerPublic", g->gPubServ); + PutConfigVariable(g, g->gAppName, "ServerIRC", g->gServIRC); + PutConfigVariable(g, g->gAppName, "ServerAIM", g->gServAIM); + PutConfigVariable(g, g->gAppName, "ServerICQ", g->gServICQ); + PutConfigVariable(g, g->gAppName, "ServerStreamURL", g->gServURL); + PutConfigVariable(g, g->gAppName, "ServerDescription", g->gServDesc); + PutConfigVariable(g, g->gAppName, "ServerName", g->gServName); + PutConfigVariable(g, g->gAppName, "ServerGenre", g->gServGenre); + PutConfigVariableLong(g, g->gAppName, "AutomaticReconnect", g->gAutoReconnect); + PutConfigVariableLong(g, g->gAppName, "AutomaticReconnectSecs", g->gReconnectSec); + PutConfigVariableLong(g, g->gAppName, "AutoConnect", g->autoconnect); + PutConfigVariable(g, g->gAppName, "Encode", g->gEncodeType); + + PutConfigVariableLong(g, g->gAppName, "BitrateNominal", g->currentBitrate); + PutConfigVariableLong(g, g->gAppName, "BitrateMin", g->currentBitrateMin); + PutConfigVariableLong(g, g->gAppName, "BitrateMax", g->currentBitrateMax); + PutConfigVariableLong(g, g->gAppName, "NumberChannels", g->currentChannels); + PutConfigVariableLong(g, g->gAppName, "Samplerate", g->currentSamplerate); + PutConfigVariable(g, g->gAppName, "OggQuality", g->gOggQuality); + if(g->gOggBitQualFlag) { + strcpy(g->gOggBitQual, "Bitrate"); + } + else { + strcpy(g->gOggBitQual, "Quality"); + } + + PutConfigVariable(g, g->gAppName, "OggBitrateQualityFlag", g->gOggBitQual); + PutConfigVariableLong(g, g->gAppName, "LameCBRFlag", g->gLAMEOptions.cbrflag); + PutConfigVariableLong(g, g->gAppName, "LameQuality", g->gLAMEOptions.quality); + PutConfigVariableLong(g, g->gAppName, "LameCopywrite", g->gLAMEOptions.copywrite); + PutConfigVariableLong(g, g->gAppName, "LameOriginal", g->gLAMEOptions.original); + PutConfigVariableLong(g, g->gAppName, "LameStrictISO", g->gLAMEOptions.strict_ISO); + PutConfigVariableLong(g, g->gAppName, "LameDisableReservior", g->gLAMEOptions.disable_reservoir); + PutConfigVariable(g, g->gAppName, "LameVBRMode", g->gLAMEOptions.VBR_mode); + PutConfigVariableLong(g, g->gAppName, "LameLowpassfreq", g->gLAMEOptions.lowpassfreq); + PutConfigVariableLong(g, g->gAppName, "LameHighpassfreq", g->gLAMEOptions.highpassfreq); + PutConfigVariableLong(g, g->gAppName, "LAMEPreset", g->gLAMEpreset); + PutConfigVariable(g, g->gAppName, "AACQuality", g->gAACQuality); + PutConfigVariable(g, g->gAppName, "AACCutoff", g->gAACCutoff); + + PutConfigVariable(g, g->gAppName, "AdvRecDevice", g->gAdvRecDevice); + PutConfigVariableLong(g, g->gAppName, "LiveInSamplerate", g->gLiveInSamplerate); + PutConfigVariableLong(g, g->gAppName, "LineInFlag", g->gLiveRecordingFlag); + + PutConfigVariableLong(g, g->gAppName, "lastX", g->lastX); + PutConfigVariableLong(g, g->gAppName, "lastY", g->lastY); + PutConfigVariableLong(g, g->gAppName, "lastDummyX", g->lastDummyX); + PutConfigVariableLong(g, g->gAppName, "lastDummyY", g->lastDummyY); + PutConfigVariableLong(g, g->gAppName, "showVU", g->vuShow); + + PutConfigVariable(g, g->gAppName, "LockMetadata", g->gManualSongTitle); + PutConfigVariableLong(g, g->gAppName, "LockMetadataFlag", g->gLockSongTitle); + + PutConfigVariable(g, g->gAppName, "SaveDirectory", g->gSaveDirectory); + PutConfigVariableLong(g, g->gAppName, "SaveDirectoryFlag", g->gSaveDirectoryFlag); + PutConfigVariableLong(g, g->gAppName, "LogLevel", g->gLogLevel); + PutConfigVariableLong(g, g->gAppName, "SaveAsWAV", g->gSaveAsWAV); + PutConfigVariable(g, g->gAppName, "LogFile", g->gLogFile); + + PutConfigVariableLong(g, g->gAppName, "NumEncoders", g->gNumEncoders); + + PutConfigVariable(g, g->gAppName, "ExternalMetadata", g->externalMetadata); + PutConfigVariable(g, g->gAppName, "ExternalURL", g->externalURL); + PutConfigVariable(g, g->gAppName, "ExternalFile", g->externalFile); + PutConfigVariable(g, g->gAppName, "ExternalInterval", g->externalInterval); + + PutConfigVariable(g, g->gAppName, "OutputControl", g->outputControl); + + PutConfigVariable(g, g->gAppName, "MetadataAppend", g->metadataAppendString); + PutConfigVariable(g, g->gAppName, "MetadataRemoveBefore", g->metadataRemoveStringBefore); + PutConfigVariable(g, g->gAppName, "MetadataRemoveAfter", g->metadataRemoveStringAfter); + PutConfigVariable(g, g->gAppName, "MetadataWindowClass", g->metadataWindowClass); + PutConfigVariableLong(g, g->gAppName, "MetadataWindowClassInd", g->metadataWindowClassInd); + + PutConfigVariable(g, g->gAppName, "WindowsRecDevice", g->WindowsRecDevice); + PutConfigVariableLong(g, g->gAppName, "LAMEJointStereo", g->LAMEJointStereoFlag); + +} + +/* + ======================================================================================================================= + Input is in interleaved float samples + ======================================================================================================================= + */ +int handle_output(edcastGlobals *g, float *samples, int nsamples, int nchannels, int in_samplerate) { + int ret = 1; + static int current_insamplerate = 0; + static int current_nchannels = 0; + long out_samplerate = 0; + long out_nch = 0; + int samplecount = 0; + float *samplePtr = 0; + int in_nch = nchannels; + + nchannels = 2; + + float *samples_resampled = NULL; + short *samples_resampled_int = NULL; + float *samples_rechannel = NULL; + + if(g == NULL) { + return 1; + } + + if(g->weareconnected) { + // LogMessage(g,LOG_DEBUG, "%d Calling handle output", g->encoderNumber); + out_samplerate = getCurrentSamplerate(g); + out_nch = getCurrentChannels(g); + if(g->gSaveAsWAV) { + int sizeofData = nsamples * nchannels * sizeof(short int); + short int *int_samples; + + int_samples = (short int *) malloc(sizeofData); + + for(int i = 0; i < nsamples * nchannels; i = i + 1) { + int_samples[i] = (short int) (samples[i] * 32767.f); + } + + fwrite(int_samples, sizeofData, 1, g->gSaveFile); + g->written += sizeofData; + free(int_samples); + + /* + * int sizeofData = nsamples*nchannels*sizeof(float); + * fwrite(samples, sizeofData, 1, g->gSaveFile); + * g->written += sizeofData; + * ; + * Write to WAV file + */ + } + + if(current_insamplerate != in_samplerate) { + resetResampler(g); + current_insamplerate = in_samplerate; + } + + if(current_nchannels != nchannels) { + resetResampler(g); + current_nchannels = nchannels; + } + + samples_rechannel = (float *) malloc(sizeof(float) * nsamples * nchannels); + memset(samples_rechannel, '\000', sizeof(float) * nsamples * nchannels); + + samplePtr = samples; + + int make_mono = 0; + int make_stereo = 0; + + if((in_nch == 2) && (out_nch == 1)) { + make_mono = 1; + } + + if((in_nch == 1) && (out_nch == 2)) { + make_stereo = 1; + } + + if((in_nch == 1) && (out_nch == 1)) { + make_stereo = 1; + } + + int samplecounter = 0; + + if(make_mono) { + for(int i = 0; i < nsamples * 2; i = i + 2) { + samples_rechannel[i] = (samples[i] + samples[i + 1]) / 2; + samples_rechannel[i + 1] = (samples[i] + samples[i + 1]) / 2; + } + } + + if(make_stereo) { + for(int i = 0; i < nsamples; i = i + 1) { + samples_rechannel[samplecounter] = (samples[i]); + samplecounter++; + samples_rechannel[samplecounter] = (samples[i]); + samplecounter++; + } + } + + if(!(make_mono) && !(make_stereo)) { + for(int i = 0; i < nsamples * 2; i = i + 1) { + samples_rechannel[i] = (samples[i]); + } + } + + LogMessage(g,LOG_DEBUG, "In samplerate = %d, Out = %d", in_samplerate, out_samplerate); + samplePtr = samples_rechannel; + if(in_samplerate != out_samplerate) { + nchannels = 2; + + /* Call the resampler */ + int buf_samples = ((nsamples * out_samplerate) / in_samplerate); + + LogMessage(g,LOG_DEBUG, "Initializing resampler"); + + initializeResampler(g, in_samplerate, nchannels); + + samples_resampled = (float *) malloc(sizeof(float) * buf_samples * nchannels); + memset(samples_resampled, '\000', sizeof(float) * buf_samples * nchannels); + + LogMessage(g,LOG_DEBUG, "calling ocConvertAudio"); + long out_samples = ocConvertAudio(g, + (float *) samplePtr, + (float *) samples_resampled, + nsamples, + buf_samples); + + samples_resampled_int = (short *) malloc(sizeof(short) * out_samples * nchannels); + memset(samples_resampled_int, '\000', sizeof(short) * out_samples * nchannels); + + LogMessage(g,LOG_DEBUG, "ready to do encoding"); + + if(out_samples > 0) { + samplecount = 0; + + /* Here is the call to actually do the encoding->... */ + LogMessage(g,LOG_DEBUG, "do_encoding start"); + ret = do_encoding(g, (float *) (samples_resampled), out_samples, out_nch); + LogMessage(g,LOG_DEBUG, "do_encoding end (%d)", ret); + } + + if(samples_resampled_int) { + free(samples_resampled_int); + samples_resampled_int = NULL; + } + + if(samples_resampled) { + free(samples_resampled); + samples_resampled = NULL; + } + } + else { + LogMessage(g,LOG_DEBUG, "do_encoding start"); + ret = do_encoding(g, (float *) samples_rechannel, nsamples, nchannels); + LogMessage(g,LOG_DEBUG, "do_encoding end (%d)", ret); + } + + if(samples_rechannel) { + free(samples_rechannel); + samples_rechannel = NULL; + } + LogMessage(g,LOG_DEBUG, "%d Calling handle output - Ret = %d", g->encoderNumber, ret); + } + + return ret; +} + +#ifdef WIN32 +void freeupGlobals(edcastGlobals *g) { + if(g->hDLL) { + FreeLibrary(g->hDLL); + } + + if(g->faacFIFO) { + free(g->faacFIFO); + } +} +#endif + +void addUISettings(edcastGlobals *g) { + + + addConfigVariable(g, "AutomaticReconnect"); + addConfigVariable(g, "AutomaticReconnectSecs"); + addConfigVariable(g, "AutoConnect"); + addConfigVariable(g, "AdvRecDevice"); + addConfigVariable(g, "LiveInSamplerate"); + addConfigVariable(g, "LineInFlag"); + addConfigVariable(g, "lastX"); + addConfigVariable(g, "lastY"); + addConfigVariable(g, "lastDummyX"); + addConfigVariable(g, "lastDummyY"); + addConfigVariable(g, "showVU"); + addConfigVariable(g, "LockMetadata"); + addConfigVariable(g, "LockMetadataFlag"); + addConfigVariable(g, "SaveDirectory"); + addConfigVariable(g, "SaveDirectoryFlag"); + addConfigVariable(g, "LogLevel"); + addConfigVariable(g, "SaveAsWAV"); + addConfigVariable(g, "LogFile"); + addConfigVariable(g, "NumEncoders"); + addConfigVariable(g, "ExternalMetadata"); + addConfigVariable(g, "ExternalURL"); + addConfigVariable(g, "ExternalFile"); + addConfigVariable(g, "ExternalInterval"); + addConfigVariable(g, "OutputControl"); + addConfigVariable(g, "MetadataAppend"); + addConfigVariable(g, "MetadataRemoveBefore"); + addConfigVariable(g, "MetadataRemoveAfter"); + addConfigVariable(g, "MetadataWindowClass"); + addConfigVariable(g, "MetadataWindowClassInd"); + addConfigVariable(g, "WindowsRecDevice"); + +} + +void addBasicEncoderSettings(edcastGlobals *g) { + addConfigVariable(g, "ServerType"); + addConfigVariable(g, "Server"); + addConfigVariable(g, "Port"); + addConfigVariable(g, "ServerMountpoint"); + addConfigVariable(g, "ServerPassword"); + addConfigVariable(g, "ServerPublic"); + addConfigVariable(g, "ServerIRC"); + addConfigVariable(g, "ServerAIM"); + addConfigVariable(g, "ServerICQ"); + addConfigVariable(g, "ServerStreamURL"); + addConfigVariable(g, "ServerDescription"); + addConfigVariable(g, "ServerName"); + addConfigVariable(g, "ServerGenre"); +// addConfigVariable(g, "AutomaticReconnect"); + addConfigVariable(g, "AutomaticReconnectSecs"); + addConfigVariable(g, "AutoConnect"); + addConfigVariable(g, "Encode"); + addConfigVariable(g, "BitrateNominal"); + addConfigVariable(g, "BitrateMin"); + addConfigVariable(g, "BitrateMax"); + addConfigVariable(g, "NumberChannels"); + addConfigVariable(g, "Samplerate"); + addConfigVariable(g, "OggQuality"); + addConfigVariable(g, "OggBitrateQualityFlag"); + addConfigVariable(g, "LameCBRFlag"); + addConfigVariable(g, "LameQuality"); + addConfigVariable(g, "LameCopywrite"); + addConfigVariable(g, "LameOriginal"); + addConfigVariable(g, "LameStrictISO"); + addConfigVariable(g, "LameDisableReservior"); + addConfigVariable(g, "LameVBRMode"); + addConfigVariable(g, "LameLowpassfreq"); + addConfigVariable(g, "LameHighpassfreq"); + addConfigVariable(g, "LAMEPreset"); + addConfigVariable(g, "AACQuality"); + addConfigVariable(g, "AACCutoff"); + addConfigVariable(g, "LogLevel"); + addConfigVariable(g, "LogFile"); + addConfigVariable(g, "LAMEJointStereo"); + addConfigVariable(g, "SaveDirectory"); + addConfigVariable(g, "SaveDirectoryFlag"); + addConfigVariable(g, "SaveAsWAV"); +} + +void LogMessage(edcastGlobals *g, int type, char *source, int line, char *fmt, ...) { + va_list parms; + char errortype[25] = ""; + int addNewline = 1; + struct tm *tp; + time_t t; + int parseableOutput = 0; + char timeStamp[255]; + + char sourceLine[1024] = ""; + + char *p1 = NULL; + +#ifdef WIN32 + p1 = strrchr(source, '\\'); +#else + p1 = strrchr(source, '/'); +#endif + + if (p1) { + strcpy(sourceLine, p1+1); + } + else { + strcpy(sourceLine, source); + } + memset(timeStamp, '\000', sizeof(timeStamp)); + + time(&t); + tp = localtime(&t); + strftime(timeStamp, sizeof(timeStamp), "%m/%d/%y %H:%M:%S", tp); + + + switch (type) { + case LM_ERROR: + strcpy(errortype, "Error"); + break; + case LM_INFO: + strcpy(errortype, "Info"); + break; + case LM_DEBUG: + strcpy(errortype, "Debug"); + break; + default: + strcpy(errortype, "Unknown"); + break; + } + + if (fmt[strlen(fmt)-1] == '\n') { + addNewline = 0; + } + + + if (type <= g->gLogLevel) { + va_start(parms, fmt); + char_t logfile[1024] = ""; + + if (g->logFilep == 0) { + sprintf(logfile, "%s.log", g->gLogFile); + g->logFilep = fopen(logfile, "a"); + } + + if (!g->logFilep) { + fprintf(stdout, "Cannot open logfile: %s(%s:%d): ", logfile, sourceLine, line); + vfprintf(stdout, fmt, parms); + va_end(parms); + if (addNewline) { + fprintf(stdout, "\n"); + } + } + else { + fprintf(g->logFilep, "%s %s(%s:%d): ", timeStamp, errortype, sourceLine, line); + vfprintf(g->logFilep, fmt, parms); + va_end(parms); + if (addNewline) { + fprintf(g->logFilep, "\n"); + } + fflush(g->logFilep); + } + + } + +} + + +char_t *getWindowsRecordingDevice(edcastGlobals *g) { + return g->WindowsRecDevice; +} +void setWindowsRecordingDevice(edcastGlobals *g, char_t *device) { + strcpy(g->WindowsRecDevice, device); +} +int getLAMEJointStereoFlag(edcastGlobals *g) { + return g->LAMEJointStereoFlag; +} +void setLAMEJointStereoFlag(edcastGlobals *g, int flag) { + g->LAMEJointStereoFlag = flag; +} + diff --git a/tools/edcast-jack/libedcast/libedcast.dsp b/tools/edcast-jack/libedcast/libedcast.dsp new file mode 100644 index 0000000..cc25b1a --- /dev/null +++ b/tools/edcast-jack/libedcast/libedcast.dsp @@ -0,0 +1,132 @@ +# Microsoft Developer Studio Project File - Name="libedcast" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=libedcast - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "libedcast.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "libedcast.mak" CFG="libedcast - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "libedcast - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "libedcast - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "libedcast - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 2 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +MTL=midl.exe +F90=df.exe +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../../external/include" /I "../../external/include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "HAVE_VORBIS" /D "HAVE_LAME" /D "HAVE_FAAC" /D "HAVE_AACP" /D "HAVE_FLAC" /D "_AFXDLL" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "libedcast - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 2 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +MTL=midl.exe +F90=df.exe +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../../external/include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "HAVE_VORBIS" /D "HAVE_LAME" /D "HAVE_FAAC" /D "HAVE_AACP" /D "HAVE_FLAC" /D "_AFXDLL" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "libedcast - Win32 Release" +# Name "libedcast - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\cbuffer.c +# End Source File +# Begin Source File + +SOURCE=.\cbuffer.h +# End Source File +# Begin Source File + +SOURCE=.\libedcast.cpp +# End Source File +# Begin Source File + +SOURCE=.\resample.c +# End Source File +# Begin Source File + +SOURCE=.\Socket.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\enc_if.h +# End Source File +# Begin Source File + +SOURCE=.\libedcast.h +# End Source File +# Begin Source File + +SOURCE=.\libedcast_resample.h +# End Source File +# Begin Source File + +SOURCE=.\libedcast_socket.h +# End Source File +# End Group +# End Target +# End Project diff --git a/tools/edcast-jack/libedcast/libedcast.h b/tools/edcast-jack/libedcast/libedcast.h new file mode 100644 index 0000000..a259d87 --- /dev/null +++ b/tools/edcast-jack/libedcast/libedcast.h @@ -0,0 +1,495 @@ +#ifndef __DSP_ODDCAST_H +#define __DSP_ODDCAST_H + +#include + +#include "cbuffer.h" + +#include "libedcast_socket.h" +#ifdef HAVE_VORBIS +#include +#endif + +#include +#include + +#ifdef _DMALLOC_ +#include +#endif + +/* +#ifdef _UNICODE +#define char_t wchar_t +#define atoi _wtoi +#define LPCSTR LPCWSTR +#define strcpy wcscpy +#define strcmp wcscmp +#define strlen wcslen +#define fopen _wfopen +#define strstr wcsstr +#define sprintf swprintf +#define strcat wcscat +#define fgets fgetws +#else +#define char_t char +#endif +*/ +#define char_t char + +#ifdef __cplusplus +extern "C" { +#endif +#include "libedcast_resample.h" +#ifdef __cplusplus +} +#endif + +#ifdef WIN32 +#include +#else +#ifdef HAVE_LAME +#include +#endif +#endif + +#ifdef HAVE_FAAC +#undef MPEG2 // hack *cough* hack +typedef signed int int32_t; +#include +#endif + +#ifdef HAVE_AACP +#include "enc_if.h" +typedef AudioCoder* (*CREATEAUDIO3TYPE)(int , int , int , unsigned int , unsigned int *, char_t *); +typedef unsigned int (*GETAUDIOTYPES3TYPE)(int, char_t *); +#endif + +#define LM_FORCE 0 +#define LM_ERROR 1 +#define LM_INFO 2 +#define LM_DEBUG 3 +#ifdef WIN32 +#define LOG_FORCE LM_FORCE, TEXT(__FILE__), __LINE__ +#define LOG_ERROR LM_ERROR, TEXT(__FILE__), __LINE__ +#define LOG_INFO LM_INFO, TEXT(__FILE__), __LINE__ +#define LOG_DEBUG LM_DEBUG, TEXT(__FILE__), __LINE__ +#else +#define LOG_FORCE LM_FORCE, __FILE__, __LINE__ +#define LOG_ERROR LM_ERROR, __FILE__, __LINE__ +#define LOG_INFO LM_INFO, __FILE__, __LINE__ +#define LOG_DEBUG LM_DEBUG, __FILE__, __LINE__ +#endif + + +#ifdef HAVE_FLAC +#include +extern "C" { +#include +} +#endif + +#define FormatID 'fmt ' /* chunkID for Format Chunk. NOTE: There is a space at the end of this ID. */ +// For skin stuff +#define WINDOW_WIDTH 276 +#define WINDOW_HEIGHT 150 + +#ifndef FALSE +#define FALSE false +#endif +#ifndef TRUE +#define TRUE true +#endif +#ifndef WIN32 +#include +#else +#include +#endif +// Callbacks +#define BYTES_PER_SECOND 1 + +#define FRONT_END_ODDCAST_PLUGIN 1 +#define FRONT_END_TRANSCODER 2 + +typedef struct tagLAMEOptions { + int cbrflag; + int out_samplerate; + int quality; +#ifdef WIN32 + int mode; +#else +#ifdef HAVE_LAME + MPEG_mode mode; +#endif +#endif + int brate; + int copywrite; + int original; + int strict_ISO; + int disable_reservoir; + char_t VBR_mode[25]; + int VBR_mean_bitrate_kbps; + int VBR_min_bitrate_kbps; + int VBR_max_bitrate_kbps; + int lowpassfreq; + int highpassfreq; +} LAMEOptions; + +typedef struct { + char_t RIFF[4]; + long chunkSize; + char_t WAVE[4]; +} RIFFChunk; + +typedef struct { + char_t chunkID[4]; + long chunkSize; + + short wFormatTag; + unsigned short wChannels; + unsigned long dwSamplesPerSec; + unsigned long dwAvgBytesPerSec; + unsigned short wBlockAlign; + unsigned short wBitsPerSample; + +/* Note: there may be additional fields here, depending upon wFormatTag. */ + +} FormatChunk; + + +typedef struct { + char_t chunkID[4]; + long chunkSize; + short * waveformData; +} DataChunk; + +struct wavhead +{ + unsigned int main_chunk; + unsigned int length; + unsigned int chunk_type; + unsigned int sub_chunk; + unsigned int sc_len; + unsigned short format; + unsigned short modus; + unsigned int sample_fq; + unsigned int byte_p_sec; + unsigned short byte_p_spl; + unsigned short bit_p_spl; + unsigned int data_chunk; + unsigned int data_length; +}; + + +static struct wavhead wav_header; + +// Global variables....gotta love em... +typedef struct { + long currentSamplerate; + int currentBitrate; + int currentBitrateMin; + int currentBitrateMax; + int currentChannels; + int gSCSocket; + int gSCSocket2; + int gSCSocketControl; + CMySocket dataChannel; + CMySocket controlChannel; + int gSCFlag; + int gCountdown; + int gAutoCountdown; + int automaticconnect; + char_t gSourceURL[1024]; + char_t gServer[256]; + char_t gPort[10]; + char_t gPassword[256]; + int weareconnected; + char_t gIniFile[1024]; + char_t gAppName[256]; + char_t gCurrentSong[1024]; + int gSongUpdateCounter; + char_t gMetadataUpdate[10]; + int gPubServ; + char_t gServIRC[20]; + char_t gServICQ[20]; + char_t gServAIM[20]; + char_t gServURL[1024]; + char_t gServDesc[1024]; + char_t gServName[1024]; + char_t gServGenre[100]; + char_t gMountpoint[100]; + char_t gFrequency[10]; + char_t gChannels[10]; + int gAutoReconnect; + int gReconnectSec; + char_t gAutoStart[10]; + char_t gAutoStartSec[20]; + char_t gQuality[5]; +#ifndef WIN32 +#ifdef HAVE_LAME + lame_global_flags *gf; +#endif +#endif + int gCurrentlyEncoding; + int gFLACFlag; + int gAACFlag; + int gAACPFlag; + int gOggFlag; + char_t gIceFlag[10]; + int gLAMEFlag; + char_t gOggQuality[25]; + int gLiveRecordingFlag; + int gOggBitQualFlag; + char_t gOggBitQual[40]; + char_t gEncodeType[25]; + int gAdvancedRecording; + int gNOggchannels; + char_t gModes[4][255]; + int gShoutcastFlag; + int gIcecastFlag; + int gIcecast2Flag; + char_t gSaveDirectory[1024]; + char_t gLogFile[1024]; + int gLogLevel; + FILE *logFilep; + int gSaveDirectoryFlag; + int gSaveAsWAV; + FILE *gSaveFile; + LAMEOptions gLAMEOptions; + int gLAMEHighpassFlag; + int gLAMELowpassFlag; + + int oggflag; + int serialno; +#ifdef HAVE_VORBIS + ogg_sync_state oy_stream; + ogg_packet header_main_save; + ogg_packet header_comments_save; + ogg_packet header_codebooks_save; +#endif + bool ice2songChange; + int in_header; + long written; + int vuShow; + + int gLAMEpreset; + char_t gLAMEbasicpreset[255]; + char_t gLAMEaltpreset[255]; + char_t gSongTitle[1024]; + char_t gManualSongTitle[1024]; + int gLockSongTitle; + int gNumEncoders; + + res_state resampler; + int initializedResampler; + void (*sourceURLCallback)(void *, void *); + void (*destURLCallback)(void *, void *); + void (*serverStatusCallback)(void *, void *); + void (*generalStatusCallback)(void *, void *); + void (*writeBytesCallback)(void *, void *); + void (*serverTypeCallback)(void *, void *); + void (*serverNameCallback)(void *, void *); + void (*streamTypeCallback)(void *, void *); + void (*bitrateCallback)(void *, void *); + void (*VUCallback)(int, int); + long startTime; + long endTime; + char_t sourceDescription[255]; + + char_t gServerType[25]; +#ifdef WIN32 + WAVEFORMATEX waveFormat; + HWAVEIN inHandle; + WAVEHDR WAVbuffer1; + WAVEHDR WAVbuffer2; +#else + int inHandle; // for advanced recording +#endif + unsigned long result; + short int WAVsamplesbuffer1[1152*2]; + short int WAVsamplesbuffer2[1152*2]; + bool areLiveRecording; + char_t gAdvRecDevice[255]; +#ifndef WIN32 + char_t gAdvRecServerTitle[255]; +#endif + int gLiveInSamplerate; +#ifdef WIN32 + // These are for the LAME DLL + BEINITSTREAM beInitStream; + BEENCODECHUNK beEncodeChunk; + BEDEINITSTREAM beDeinitStream; + BECLOSESTREAM beCloseStream; + BEVERSION beVersion; + BEWRITEVBRHEADER beWriteVBRHeader; + HINSTANCE hDLL; + HINSTANCE hFAACDLL; + HINSTANCE hAACPDLL; + DWORD dwSamples; + DWORD dwMP3Buffer; + HBE_STREAM hbeStream; +#endif + char_t gConfigFileName[255]; + char_t gOggEncoderText[255]; + int gForceStop; + char_t gCurrentRecordingName[1024]; + long lastX; + long lastY; + long lastDummyX; + long lastDummyY; + +#ifdef HAVE_VORBIS + ogg_stream_state os; + vorbis_dsp_state vd; + vorbis_block vb; + vorbis_info vi; +#endif + + int frontEndType; + int ReconnectTrigger; +#ifdef HAVE_AACP + CREATEAUDIO3TYPE CreateAudio3; + GETAUDIOTYPES3TYPE GetAudioTypes3; + + AudioCoder *(*finishAudio3)(char_t *fn, AudioCoder *c); + void (*PrepareToFinish)(const char_t *filename, AudioCoder *coder); + AudioCoder * aacpEncoder; +#endif +#ifdef HAVE_FAAC + faacEncHandle aacEncoder; +#endif + unsigned long samplesInput, maxBytesOutput; + float *faacFIFO; + int faacFIFOendpos; + char_t gAACQuality[25]; + char_t gAACCutoff[25]; + int encoderNumber; + bool forcedDisconnect; + time_t forcedDisconnectSecs; + int autoconnect; + char_t externalMetadata[255]; + char_t externalURL[255]; + char_t externalFile[255]; + char_t externalInterval[25]; + char_t *vorbisComments[30]; + int numVorbisComments; + char_t outputControl[255]; + char_t metadataAppendString[255]; + char_t metadataRemoveStringBefore[255]; + char_t metadataRemoveStringAfter[255]; + char_t metadataWindowClass[255]; + bool metadataWindowClassInd; +#ifdef HAVE_FLAC + FLAC__StreamEncoder *flacEncoder; + FLAC__StreamMetadata *flacMetadata; + int flacFailure; +#endif + char_t *configVariables[255]; + int numConfigVariables; + pthread_mutex_t mutex; + + char_t WindowsRecDevice[255]; + + int LAMEJointStereoFlag; + CBUFFER circularBuffer; +} edcastGlobals; + + +void addConfigVariable(edcastGlobals *g, char_t *variable); +int initializeencoder(edcastGlobals *g); +void getCurrentSongTitle(edcastGlobals *g, char_t *song, char_t *artist, char_t *full); +void initializeGlobals(edcastGlobals *g); +void ReplaceString(char_t *source, char_t *dest, char_t *from, char_t *to); +void config_read(edcastGlobals *g); +void config_write(edcastGlobals *g); +int connectToServer(edcastGlobals *g); +int disconnectFromServer(edcastGlobals *g); +int do_encoding(edcastGlobals *g, short int *samples, int numsamples, int nch); +void URLize(char_t *input, char_t *output, int inputlen, int outputlen); +int updateSongTitle(edcastGlobals *g, int forceURL); +int setCurrentSongTitleURL(edcastGlobals *g, char_t *song); +void icecast2SendMetadata(edcastGlobals *g); +int ogg_encode_dataout(edcastGlobals *g); +int trimVariable(char_t *variable); +int readConfigFile(edcastGlobals *g,int readOnly = 0); +int writeConfigFile(edcastGlobals *g); +void printConfigFileValues(); +void ErrorMessage(char_t *title, char_t *fmt, ...); +int setCurrentSongTitle(edcastGlobals *g,char_t *song); +char_t* getSourceURL(edcastGlobals *g); +void setSourceURL(edcastGlobals *g,char_t *url); +long getCurrentSamplerate(edcastGlobals *g); +int getCurrentBitrate(edcastGlobals *g); +int getCurrentChannels(edcastGlobals *g); +int ocConvertAudio(edcastGlobals *g,float *in_samples, float *out_samples, int num_in_samples, int num_out_samples); +int initializeResampler(edcastGlobals *g,long inSampleRate, long inNCH); +int handle_output(edcastGlobals *g, float *samples, int nsamples, int nchannels, int in_samplerate); +void setServerStatusCallback(edcastGlobals *g,void (*pCallback)(void *,void *)); +void setGeneralStatusCallback(edcastGlobals *g, void (*pCallback)(void *,void *)); +void setWriteBytesCallback(edcastGlobals *g, void (*pCallback)(void *,void *)); +void setServerTypeCallback(edcastGlobals *g, void (*pCallback)(void *,void *)); +void setServerNameCallback(edcastGlobals *g, void (*pCallback)(void *,void *)); +void setStreamTypeCallback(edcastGlobals *g, void (*pCallback)(void *,void *)); +void setBitrateCallback(edcastGlobals *g, void (*pCallback)(void *,void *)); +void setVUCallback(edcastGlobals *g, void (*pCallback)(int, int)); +void setSourceURLCallback(edcastGlobals *g, void (*pCallback)(void *,void *)); +void setDestURLCallback(edcastGlobals *g, void (*pCallback)(void *,void *)); +void setSourceDescription(edcastGlobals *g, char_t *desc); +int getOggFlag(edcastGlobals *g); +bool getLiveRecordingFlag(edcastGlobals *g); +void setLiveRecordingFlag(edcastGlobals *g, bool flag); +void setDumpData(edcastGlobals *g, int dump); +void setConfigFileName(edcastGlobals *g, char_t *configFile); +char_t *getConfigFileName(edcastGlobals *g); +char_t* getServerDesc(edcastGlobals *g); +int getReconnectFlag(edcastGlobals *g); +int getReconnectSecs(edcastGlobals *g); +int getIsConnected(edcastGlobals *g); +int resetResampler(edcastGlobals *g); +void setOggEncoderText(edcastGlobals *g, char_t *text); +int getLiveRecordingSetFlag(edcastGlobals *g); +char_t *getCurrentRecordingName(edcastGlobals *g); +void setCurrentRecordingName(edcastGlobals *g, char_t *name); +void setForceStop(edcastGlobals *g, int forceStop); +long getLastXWindow(edcastGlobals *g); +long getLastYWindow(edcastGlobals *g); +void setLastXWindow(edcastGlobals *g, long x); +void setLastYWindow(edcastGlobals *g, long y); +long getLastDummyXWindow(edcastGlobals *g); +long getLastDummyYWindow(edcastGlobals *g); +void setLastDummyXWindow(edcastGlobals *g, long x); +void setLastDummyYWindow(edcastGlobals *g, long y); +long getVUShow(edcastGlobals *g); +void setVUShow(edcastGlobals *g, long x); +int getFrontEndType(edcastGlobals *g); +void setFrontEndType(edcastGlobals *g, int x); +int getReconnectTrigger(edcastGlobals *g); +void setReconnectTrigger(edcastGlobals *g, int x); +char_t *getCurrentlyPlaying(edcastGlobals *g); +long GetConfigVariableLong(char_t *appName, char_t *paramName, long defaultvalue, char_t *desc); +char_t *getLockedMetadata(edcastGlobals *g); +void setLockedMetadata(edcastGlobals *g, char_t *buf); +int getLockedMetadataFlag(edcastGlobals *g); +void setLockedMetadataFlag(edcastGlobals *g, int flag); +void setSaveDirectory(edcastGlobals *g, char_t *saveDir); +char_t *getSaveDirectory(edcastGlobals *g); +char_t *getgLogFile(edcastGlobals *g); +void setgLogFile(edcastGlobals *g,char_t *logFile); +int getSaveAsWAV(edcastGlobals *g); +void setSaveAsWAV(edcastGlobals *g, int flag); +FILE *getSaveFileP(edcastGlobals *g); +long getWritten(edcastGlobals *g); +void setWritten(edcastGlobals *g, long writ); +int deleteConfigFile(edcastGlobals *g); +void setAutoConnect(edcastGlobals *g, int flag); +void addVorbisComment(edcastGlobals *g, char_t *comment); +void freeVorbisComments(edcastGlobals *g); +void addBasicEncoderSettings(edcastGlobals *g); +void addUISettings(edcastGlobals *g); +void setDefaultLogFileName(char_t *filename); +void LogMessage(edcastGlobals *g, int type, char_t *source, int line, char_t *fmt, ...); +char_t *getWindowsRecordingDevice(edcastGlobals *g); +void setWindowsRecordingDevice(edcastGlobals *g, char_t *device); +int getLAMEJointStereoFlag(edcastGlobals *g); +void setLAMEJointStereoFlag(edcastGlobals *g, int flag); +int triggerDisconnect(edcastGlobals *g); +#endif diff --git a/tools/edcast-jack/libedcast/libedcast_resample.h b/tools/edcast-jack/libedcast/libedcast_resample.h new file mode 100644 index 0000000..561bdb2 --- /dev/null +++ b/tools/edcast-jack/libedcast/libedcast_resample.h @@ -0,0 +1,110 @@ +/* This program is licensed under the GNU Library General Public License, + * version 2, a copy of which is included with this program (LICENCE.LGPL). + * + * (c) 2002 Simon Hosie + * + * + * A resampler + * + * reference: + * 'Digital Filters', third edition, by R. W. Hamming ISBN 0-486-65088-X + * + * history: + * 2002-05-31 ready for the world (or some small section thereof) + * + * + * TOOD: + * zero-crossing clipping in coefficient table + */ + +#ifndef _RESAMPLE_H_INCLUDED +#define _RESAMPLE_H_INCLUDED + +typedef float SAMPLE; + +typedef struct +{ + unsigned int channels, infreq, outfreq, taps; + float *table; + SAMPLE *pool; + + /* dynamic bits */ + int poolfill; + int offset; +} res_state; + +typedef enum +{ + RES_END, + RES_GAIN, /* (double)1.0 */ + RES_CUTOFF, /* (double)0.80 */ + RES_TAPS, /* (int)45 */ + RES_BETA /* (double)16.0 */ +} res_parameter; + +int res_init(res_state *state, int channels, int outfreq, int infreq, res_parameter op1, ...); +/* + * Configure *state to manage a data stream with the specified parameters. The + * string 'params' is currently unspecified, but will configure the parameters + * of the filter. + * + * This function allocates memory, and requires that res_clear() be called when + * the buffer is no longer needed. + * + * + * All counts/lengths used in the following functions consider only the data in + * a single channel, and in numbers of samples rather than bytes, even though + * functionality will be mirrored across as many channels as specified here. + */ + + +int res_push_max_input(res_state const *state, size_t maxoutput); +/* + * Returns the maximum number of input elements that may be provided without + * risk of flooding an output buffer of size maxoutput. maxoutput is + * specified in counts of elements, NOT in bytes. + */ + + +int res_push_check(res_state const *state, size_t srclen); +/* + * Returns the number of elements that will be returned if the given srclen + * is used in the next call to res_push(). + */ + + +int res_push(res_state *state, SAMPLE **dstlist, SAMPLE const **srclist, size_t srclen); +int res_push_interleaved(res_state *state, SAMPLE *dest, SAMPLE const *source, size_t srclen); +/* + * Pushes srclen samples into the front end of the filter, and returns the + * number of resulting samples. + * + * res_push(): srclist and dstlist point to lists of pointers, each of which + * indicates the beginning of a list of samples. + * + * res_push_interleaved(): source and dest point to the beginning of a list of + * interleaved samples. + */ + + +int res_drain(res_state *state, SAMPLE **dstlist); +int res_drain_interleaved(res_state *state, SAMPLE *dest); +/* + * Recover the remaining elements by flushing the internal pool with 0 values, + * and storing the resulting samples. + * + * After either of these functions are called, *state should only re-used in a + * final call to res_clear(). + */ + + +void res_clear(res_state *state); +/* + * Free allocated buffers, etc. + */ +void make_mono(float *stereo,float *mono,int num); +/* take a single mono channel and make it into 2 stereo channels */ +void make_stereo(float *mono,float *stereo,int num); + +#endif + diff --git a/tools/edcast-jack/libedcast/libedcast_socket.h b/tools/edcast-jack/libedcast/libedcast_socket.h new file mode 100644 index 0000000..f8ed896 --- /dev/null +++ b/tools/edcast-jack/libedcast/libedcast_socket.h @@ -0,0 +1,74 @@ +/* +Oddsock - MySocket +Copyright (C) 2000 Oddsock + +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +oddsock@oddsock.org +*/ +// Socket.h: interface for the CMySocket class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_SOCKET_H__5EFF0BE2_257B_11D3_BF65_006008B82A90__INCLUDED_) +#define AFX_SOCKET_H__5EFF0BE2_257B_11D3_BF65_006008B82A90__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifdef _WIN32 +#include +//#include +//#define int SOCKET +#else +#include +#include +#include +#include +#include +#include +#ifdef _DMALLOC_ +#include +#endif + +#define SOCKET int +#define SOCKET_ERROR -1 +#define closesocket close +#endif + +#ifndef SOCKET +#define SOCKET int +#endif + +class CMySocket +{ +public: + CMySocket(); + virtual ~CMySocket(); + + void initWinsockLib(void); + void socketErrorExit(char *szError); + SOCKET DoSocketListen(unsigned short portnum); + SOCKET DoSocketAccept(SOCKET s); + SOCKET DoSocketConnect(char *hostname, unsigned short portnum); + void CheckSocketError(int iError, char *szMessage); + void CleanAndExit(int iError); + + // struct sockaddr_in connectedIP; + +}; + +#endif // !defined(AFX_SOCKET_H__5EFF0BE2_257B_11D3_BF65_006008B82A90__INCLUDED_) diff --git a/tools/edcast-jack/libedcast/resample.c b/tools/edcast-jack/libedcast/resample.c new file mode 100644 index 0000000..07b3806 --- /dev/null +++ b/tools/edcast-jack/libedcast/resample.c @@ -0,0 +1,457 @@ +/* resample.c: see libedcast_resample.h for interesting stuff */ + +#include +#include +#include +#include +#include + +#include "libedcast_resample.h" + +/* Some systems don't define this */ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +/* average two stereo channels into a single mono channel */ +void make_mono(float *stereo,float *mono,int num){ + int i; + for(i=0;i>= 1, arg2 >>= 1, mult <<= 1; + + while (arg1 > 0) + { + if (~(arg1 & arg2) & 1) + { + arg1 >>= (~arg1 & 1); + arg2 >>= (~arg2 & 1); + } + else if (arg1 < arg2) + arg2 = (arg2 - arg1) >> 1; + else + arg1 = (arg1 - arg2) >> 1; + } + + return arg2 * mult; +} + + +static void filt_sinc(float *dest, int N, int step, double fc, double gain, int width) +{ + double s = fc / step; + int mid, x; + float *endpoint = dest + N, + *base = dest, + *origdest = dest; + + assert(width <= N); + + if ((N & 1) == 0) + { + *dest = 0.0; + dest += width; + if (dest >= endpoint) + dest = ++base; + N--; + } + + mid = N / 2; + x = -mid; + + while (N--) + { + *dest = (float)(x ? sin(x * M_PI * s) / (float)(x * M_PI) * step : fc) * (float)gain; + x++; + dest += width; + if (dest >= endpoint) + dest = ++base; + } + assert(dest == origdest + width); +} + + +static double I_zero(double x) +{ + int n = 0; + double u = 1.0, + s = 1.0, + t; + + do + { + n += 2; + t = x / n; + u *= t * t; + s += u; + } while (u > 1e-21 * s); + + return s; +} + + +static void win_kaiser(float *dest, int N, double alpha, int width) +{ + double I_alpha, midsq; + int x; + float *endpoint = dest + N, + *base = dest, + *origdest = dest; + + assert(width <= N); + + if ((N & 1) == 0) + { + *dest = 0.0; + dest += width; + if (dest >= endpoint) + dest = ++base; + N--; + } + + x = -(N / 2); + midsq = (double)(x - 1) * (double)(x - 1); + I_alpha = I_zero(alpha); + + while (N--) + { + *dest *= (float)I_zero(alpha * sqrt(1.0 - ((double)x * (double)x) / midsq)) / (float)I_alpha; + x++; + dest += width; + if (dest >= endpoint) + dest = ++base; + } + assert(dest == origdest + width); +} + + +int res_init(res_state *state, int channels, int outfreq, int infreq, res_parameter op1, ...) +{ + double beta = 16.0, + cutoff = 0.80, + gain = 1.0; + int taps = 45; + + int factor; + + assert(state); + assert(channels > 0); + assert(outfreq > 0); + assert(infreq > 0); + assert(taps > 0); + + if (state == NULL || channels <= 0 || outfreq <= 0 || infreq <= 0 || taps <= 0) + return -1; + + if (op1 != RES_END) + { + va_list argp; + va_start(argp, op1); + do + { + switch (op1) + { + case RES_GAIN: + gain = va_arg(argp, double); + break; + + case RES_CUTOFF: + cutoff = va_arg(argp, double); + assert(cutoff > 0.01 && cutoff <= 1.0); + break; + + case RES_TAPS: + taps = va_arg(argp, int); + assert(taps > 2 && taps < 1000); + break; + + case RES_BETA: + beta = va_arg(argp, double); + assert(beta > 2.0); + break; + default: + assert("arglist" == "valid"); + return -1; + } + op1 = va_arg(argp, res_parameter); + } while (op1 != RES_END); + va_end(argp); + } + + factor = hcf(infreq, outfreq); + outfreq /= factor; + infreq /= factor; + + /* adjust to rational values for downsampling */ + if (outfreq < infreq) + { + /* push the cutoff frequency down to the output frequency */ + cutoff = cutoff * outfreq / infreq; + + /* compensate for the sharper roll-off requirement + * by using a bigger hammer */ + taps = taps * infreq/outfreq; + } + + assert(taps >= (infreq + outfreq - 1) / outfreq); + + if ((state->table = calloc(outfreq * taps, sizeof(float))) == NULL) + return -1; + if ((state->pool = calloc(channels * taps, sizeof(SAMPLE))) == NULL) + { + free(state->table); + state->table = NULL; + return -1; + } + + state->poolfill = taps / 2 + 1; + state->channels = channels; + state->outfreq = outfreq; + state->infreq = infreq; + state->taps = taps; + state->offset = 0; + + filt_sinc(state->table, outfreq * taps, outfreq, cutoff, gain, taps); + win_kaiser(state->table, outfreq * taps, beta, taps); + + return 0; +} + + +static SAMPLE sum(float const *scale, int count, SAMPLE const *source, SAMPLE const *trigger, SAMPLE const *reset, int srcstep) +{ + float total = 0.0; + + while (count--) + { + total += *source * *scale; + + if (source == trigger) + source = reset, srcstep = 1; + source -= srcstep; + scale++; + } + + return total; +} + + +static int push(res_state const * const state, SAMPLE *pool, int * const poolfill, int * const offset, SAMPLE *dest, int dststep, SAMPLE const *source, int srcstep, size_t srclen) +{ + SAMPLE * const destbase = dest, + *poolhead = pool + *poolfill, + *poolend = pool + state->taps, + *newpool = pool; + SAMPLE const *refill, *base, *endpoint; + int lencheck; + + + assert(state); + assert(pool); + assert(poolfill); + assert(dest); + assert(source); + + assert(state->poolfill != -1); + + lencheck = res_push_check(state, srclen); + + /* fill the pool before diving in */ + while (poolhead < poolend && srclen > 0) + { + *poolhead++ = *source; + source += srcstep; + srclen--; + } + + if (srclen <= 0) + return 0; + + base = source; + endpoint = source + srclen * srcstep; + + while (source < endpoint) + { + *dest = sum(state->table + *offset * state->taps, state->taps, source, base, poolend, srcstep); + dest += dststep; + *offset += state->infreq; + while (*offset >= (int)state->outfreq) + { + *offset -= state->outfreq; + source += srcstep; + } + } + + assert(dest == destbase + lencheck * dststep); + + /* pretend that source has that underrun data we're not going to get */ + srclen += (source - endpoint) / srcstep; + + /* if we didn't get enough to completely replace the pool, then shift things about a bit */ + if (srclen < state->taps) + { + refill = pool + srclen; + while (refill < poolend) + *newpool++ = *refill++; + + refill = source - srclen * srcstep; + } + else + refill = source - state->taps * srcstep; + + /* pull in fresh pool data */ + while (refill < endpoint) + { + *newpool++ = *refill; + refill += srcstep; + } + + assert(newpool > pool); + assert(newpool <= poolend); + + *poolfill = newpool - pool; + + return (dest - destbase) / dststep; +} + + +int res_push_max_input(res_state const * state, size_t maxoutput) +{ + return maxoutput * state->infreq / state->outfreq; +} + + +int res_push_check(res_state const * state, size_t srclen) +{ + if (state->poolfill < (int)state->taps) + srclen -= state->taps - state->poolfill; + + return (srclen * state->outfreq - state->offset + state->infreq - 1) / state->infreq; +} + + +int res_push(res_state *state, SAMPLE **dstlist, SAMPLE const **srclist, size_t srclen) +{ + int result = -1, poolfill = -1, offset = -1, i; + + assert(state); + assert(dstlist); + assert(srclist); + assert(state->poolfill >= 0); + + for (i = 0; i < (int)state->channels; i++) + { + poolfill = state->poolfill; + offset = state->offset; + result = push(state, state->pool + i * state->taps, &poolfill, &offset, dstlist[i], 1, srclist[i], 1, srclen); + } + state->poolfill = poolfill; + state->offset = offset; + + return result; +} + + +int res_push_interleaved(res_state *state, SAMPLE *dest, SAMPLE const *source, size_t srclen) +{ + int result = -1, poolfill = -1, offset = -1, i; + + assert(state); + assert(dest); + assert(source); + assert(state->poolfill >= 0); + + for (i = 0; i < (int)state->channels; i++) + { + poolfill = state->poolfill; + offset = state->offset; + result = push(state, state->pool + i * state->taps, &poolfill, &offset, dest + i, state->channels, source + i, state->channels, srclen); + } + state->poolfill = poolfill; + state->offset = offset; + + return result; +} + + +int res_drain(res_state *state, SAMPLE **dstlist) +{ + SAMPLE *tail; + int result = -1, poolfill = -1, offset = -1, i; + + assert(state); + assert(dstlist); + assert(state->poolfill >= 0); + + if ((tail = calloc(state->taps, sizeof(SAMPLE))) == NULL) + return -1; + + for (i = 0; i < (int)state->channels; i++) + { + poolfill = state->poolfill; + offset = state->offset; + result = push(state, state->pool + i * state->taps, &poolfill, &offset, dstlist[i], 1, tail, 1, state->taps / 2 - 1); + } + + free(tail); + + state->poolfill = -1; + + return result; +} + + +int res_drain_interleaved(res_state *state, SAMPLE *dest) +{ + SAMPLE *tail; + int result = -1, poolfill = -1, offset = -1, i; + + assert(state); + assert(dest); + assert(state->poolfill >= 0); + + if ((tail = calloc(state->taps, sizeof(SAMPLE))) == NULL) + return -1; + + for (i = 0; i < (int)state->channels; i++) + { + poolfill = state->poolfill; + offset = state->offset; + result = push(state, state->pool + i * state->taps, &poolfill, &offset, dest + i, state->channels, tail, 1, state->taps / 2 - 1); + } + + free(tail); + + state->poolfill = -1; + + return result; +} + + +void res_clear(res_state *state) +{ + assert(state); + assert(state->table); + assert(state->pool); + + free(state->table); + free(state->pool); + memset(state, 0, sizeof(*state)); +} +