seal 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -0
- data/LICENSE +13 -0
- data/README.md +265 -0
- data/ext/seal/extconf.rb +45 -0
- data/include/al/al.h +724 -0
- data/include/al/alc.h +277 -0
- data/include/al/efx-presets.h +402 -0
- data/include/al/efx.h +758 -0
- data/include/mpg123/mpg123.h +1034 -0
- data/include/ogg/config_types.h +25 -0
- data/include/ogg/ogg.h +210 -0
- data/include/ogg/os_types.h +147 -0
- data/include/seal.h +23 -0
- data/include/seal/buf.h +143 -0
- data/include/seal/core.h +95 -0
- data/include/seal/efs.h +112 -0
- data/include/seal/err.h +93 -0
- data/include/seal/fmt.h +58 -0
- data/include/seal/listener.h +103 -0
- data/include/seal/raw.h +86 -0
- data/include/seal/rvb.h +520 -0
- data/include/seal/src.h +413 -0
- data/include/seal/stream.h +81 -0
- data/include/vorbis/codec.h +243 -0
- data/include/vorbis/vorbisfile.h +206 -0
- data/mpg123/AUTHORS +150 -0
- data/mpg123/COPYING +773 -0
- data/mpg123/ChangeLog +3 -0
- data/mpg123/INSTALL +111 -0
- data/mpg123/Makefile.am +99 -0
- data/mpg123/Makefile.in +1043 -0
- data/mpg123/NEWS +1200 -0
- data/mpg123/NEWS.libmpg123 +133 -0
- data/mpg123/README +203 -0
- data/mpg123/TODO +38 -0
- data/mpg123/aclocal.m4 +1168 -0
- data/mpg123/build/config.guess +1530 -0
- data/mpg123/build/config.sub +1782 -0
- data/mpg123/build/depcomp +707 -0
- data/mpg123/build/install-sh +527 -0
- data/mpg123/build/ltmain.sh +9655 -0
- data/mpg123/build/missing +330 -0
- data/mpg123/configure +20267 -0
- data/mpg123/configure.ac +2178 -0
- data/mpg123/doc/ACCURACY +2 -0
- data/mpg123/doc/BENCHMARKING +110 -0
- data/mpg123/doc/BUGS +3 -0
- data/mpg123/doc/CONTACT +17 -0
- data/mpg123/doc/LICENSE +22 -0
- data/mpg123/doc/Makefile.am +32 -0
- data/mpg123/doc/Makefile.in +490 -0
- data/mpg123/doc/PATENTS +39 -0
- data/mpg123/doc/README.3DNOW +56 -0
- data/mpg123/doc/README.gain +171 -0
- data/mpg123/doc/README.remote +218 -0
- data/mpg123/doc/ROAD_TO_LGPL +270 -0
- data/mpg123/doc/THANKS +13 -0
- data/mpg123/doc/TODO +63 -0
- data/mpg123/doc/doxy_examples.c +21 -0
- data/mpg123/doc/doxygen.conf +41 -0
- data/mpg123/doc/doxyhead.xhtml +12 -0
- data/mpg123/doc/examples/dump_seekindex.c +41 -0
- data/mpg123/doc/examples/extract_frames.c +92 -0
- data/mpg123/doc/examples/feedseek.c +238 -0
- data/mpg123/doc/examples/id3dump.c +178 -0
- data/mpg123/doc/examples/mpg123_to_wav.c +118 -0
- data/mpg123/doc/examples/mpglib.c +92 -0
- data/mpg123/doc/examples/scan.c +47 -0
- data/mpg123/doc/libmpg123_speed.txt +84 -0
- data/mpg123/equalize.dat +37 -0
- data/mpg123/libmpg123.pc.in +11 -0
- data/mpg123/m4/addrconfig.m4 +34 -0
- data/mpg123/m4/libtool.m4 +7982 -0
- data/mpg123/m4/ltoptions.m4 +384 -0
- data/mpg123/m4/ltsugar.m4 +123 -0
- data/mpg123/m4/ltversion.m4 +23 -0
- data/mpg123/m4/lt~obsolete.m4 +98 -0
- data/mpg123/makedll.sh +19 -0
- data/mpg123/man1/mpg123.1 +512 -0
- data/mpg123/mpg123.spec +68 -0
- data/mpg123/mpg123.spec.in +68 -0
- data/mpg123/ports/MSVC++/2005/libmpg123/libmpg123.vcproj +741 -0
- data/mpg123/ports/MSVC++/2008/dump_seekindex/dump_seekindex.vcproj +194 -0
- data/mpg123/ports/MSVC++/2008/feedseek/feedseek.vcproj +195 -0
- data/mpg123/ports/MSVC++/2008/libmpg123/libmpg123.vcproj +1357 -0
- data/mpg123/ports/MSVC++/2008/mpg123.sln +44 -0
- data/mpg123/ports/MSVC++/2008/mpglib/mpglib.vcproj +191 -0
- data/mpg123/ports/MSVC++/2008/scan/scan.vcproj +195 -0
- data/mpg123/ports/MSVC++/2008clr/2008clr.sln +81 -0
- data/mpg123/ports/MSVC++/2008clr/examples/ReplaceReaderclr/Program.cs +435 -0
- data/mpg123/ports/MSVC++/2008clr/examples/ReplaceReaderclr/Properties/AssemblyInfo.cs +36 -0
- data/mpg123/ports/MSVC++/2008clr/examples/ReplaceReaderclr/ReplaceReaderclr.csproj +72 -0
- data/mpg123/ports/MSVC++/2008clr/examples/feedseekclr/Program.cs +331 -0
- data/mpg123/ports/MSVC++/2008clr/examples/feedseekclr/Properties/AssemblyInfo.cs +36 -0
- data/mpg123/ports/MSVC++/2008clr/examples/feedseekclr/feedseekclr.csproj +71 -0
- data/mpg123/ports/MSVC++/2008clr/examples/scanclr/Program.cs +79 -0
- data/mpg123/ports/MSVC++/2008clr/examples/scanclr/Properties/AssemblyInfo.cs +36 -0
- data/mpg123/ports/MSVC++/2008clr/examples/scanclr/scanclr.csproj +70 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/AssemblyInfo.cpp +76 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/ReadMe.txt +165 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/advanced.cpp +91 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/advanced.h +130 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/dllmain.cpp +19 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/enum.h +218 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/error.cpp +48 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/error.h +134 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v1.cpp +92 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v1.h +132 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v2.cpp +138 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v2.h +152 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.cpp +896 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.h +953 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.rc +102 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.vcproj +328 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/resource.h +14 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/stdafx.cpp +8 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/stdafx.h +38 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/string.cpp +166 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/string.h +265 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/targetver.h +24 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/text.cpp +67 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/text.h +111 -0
- data/mpg123/ports/MSVC++/2010/dump_seekindex/dump_seekindex.vcxproj +90 -0
- data/mpg123/ports/MSVC++/2010/dump_seekindex/dump_seekindex.vcxproj.filters +6 -0
- data/mpg123/ports/MSVC++/2010/feedseek/feedseek.vcxproj +95 -0
- data/mpg123/ports/MSVC++/2010/feedseek/feedseek.vcxproj.filters +6 -0
- data/mpg123/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj +960 -0
- data/mpg123/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj.user +3 -0
- data/mpg123/ports/MSVC++/2010/libmpg123/yasm.exe +0 -0
- data/mpg123/ports/MSVC++/2010/mpg123.sln +38 -0
- data/mpg123/ports/MSVC++/2010/scan/scan.vcxproj +93 -0
- data/mpg123/ports/MSVC++/2010/scan/scan.vcxproj.filters +6 -0
- data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/CORE/CORE_FileIn.H +15 -0
- data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/CORE/SourceFilter_MP3.H +139 -0
- data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/IIEP_Def.H +206 -0
- data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/IIEP_FileIn.H +167 -0
- data/mpg123/ports/MSVC++/CMP3Stream/README +4 -0
- data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/CORE_FileIn.CPP +462 -0
- data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/CORE_Log.CPP +122 -0
- data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/CORE_Mutex.CPP +35 -0
- data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/SourceFilter_MP3Stream.CPP +586 -0
- data/mpg123/ports/MSVC++/CMP3Stream/libMPG123/PLACE_LIBMPG123_SOURCES_HERE +0 -0
- data/mpg123/ports/MSVC++/CMP3Stream/libMPG123/libMPG123.vcproj +245 -0
- data/mpg123/ports/MSVC++/config.h +35 -0
- data/mpg123/ports/MSVC++/examples/feedseek.c +240 -0
- data/mpg123/ports/MSVC++/examples/scan.c +47 -0
- data/mpg123/ports/MSVC++/mpg123.h +46 -0
- data/mpg123/ports/MSVC++/msvc.c +59 -0
- data/mpg123/ports/README +26 -0
- data/mpg123/ports/Sony_PSP/Makefile.psp +38 -0
- data/mpg123/ports/Sony_PSP/README +11 -0
- data/mpg123/ports/Sony_PSP/config.h +368 -0
- data/mpg123/ports/Sony_PSP/readers.c.patch +2 -0
- data/mpg123/ports/Xcode/config.h +197 -0
- data/mpg123/ports/Xcode/mpg123.h +17 -0
- data/mpg123/ports/Xcode/mpg123.xcodeproj/project.pbxproj +670 -0
- data/mpg123/ports/mpg123_.pas +478 -0
- data/mpg123/scripts/benchmark-cpu.pl +56 -0
- data/mpg123/scripts/tag_lyrics.py +76 -0
- data/mpg123/src/Makefile.am +186 -0
- data/mpg123/src/Makefile.in +1097 -0
- data/mpg123/src/audio.c +725 -0
- data/mpg123/src/audio.h +106 -0
- data/mpg123/src/buffer.c +312 -0
- data/mpg123/src/buffer.h +45 -0
- data/mpg123/src/common.c +240 -0
- data/mpg123/src/common.h +29 -0
- data/mpg123/src/config.h.in +436 -0
- data/mpg123/src/control_generic.c +809 -0
- data/mpg123/src/equalizer.c +48 -0
- data/mpg123/src/genre.c +271 -0
- data/mpg123/src/genre.h +15 -0
- data/mpg123/src/getlopt.c +148 -0
- data/mpg123/src/getlopt.h +77 -0
- data/mpg123/src/httpget.c +700 -0
- data/mpg123/src/httpget.h +66 -0
- data/mpg123/src/legacy_module.c +74 -0
- data/mpg123/src/libmpg123/Makefile.am +141 -0
- data/mpg123/src/libmpg123/Makefile.in +919 -0
- data/mpg123/src/libmpg123/compat.c +138 -0
- data/mpg123/src/libmpg123/compat.h +178 -0
- data/mpg123/src/libmpg123/dct36_3dnow.S +505 -0
- data/mpg123/src/libmpg123/dct36_3dnowext.S +512 -0
- data/mpg123/src/libmpg123/dct64.c +174 -0
- data/mpg123/src/libmpg123/dct64_3dnow.S +712 -0
- data/mpg123/src/libmpg123/dct64_3dnowext.S +714 -0
- data/mpg123/src/libmpg123/dct64_altivec.c +315 -0
- data/mpg123/src/libmpg123/dct64_i386.c +336 -0
- data/mpg123/src/libmpg123/dct64_i486.c +342 -0
- data/mpg123/src/libmpg123/dct64_mmx.S +811 -0
- data/mpg123/src/libmpg123/dct64_neon.S +297 -0
- data/mpg123/src/libmpg123/dct64_neon_float.S +270 -0
- data/mpg123/src/libmpg123/dct64_sse.S +454 -0
- data/mpg123/src/libmpg123/dct64_sse_float.S +401 -0
- data/mpg123/src/libmpg123/dct64_x86_64.S +464 -0
- data/mpg123/src/libmpg123/dct64_x86_64_float.S +426 -0
- data/mpg123/src/libmpg123/debug.h +171 -0
- data/mpg123/src/libmpg123/decode.h +268 -0
- data/mpg123/src/libmpg123/dither.c +119 -0
- data/mpg123/src/libmpg123/dither.h +23 -0
- data/mpg123/src/libmpg123/equalizer.c +17 -0
- data/mpg123/src/libmpg123/equalizer_3dnow.S +70 -0
- data/mpg123/src/libmpg123/feature.c +106 -0
- data/mpg123/src/libmpg123/format.c +521 -0
- data/mpg123/src/libmpg123/frame.c +1046 -0
- data/mpg123/src/libmpg123/frame.h +410 -0
- data/mpg123/src/libmpg123/gapless.h +119 -0
- data/mpg123/src/libmpg123/getbits.h +100 -0
- data/mpg123/src/libmpg123/getcpuflags.S +91 -0
- data/mpg123/src/libmpg123/getcpuflags.h +47 -0
- data/mpg123/src/libmpg123/huffman.h +340 -0
- data/mpg123/src/libmpg123/icy.c +32 -0
- data/mpg123/src/libmpg123/icy.h +38 -0
- data/mpg123/src/libmpg123/icy2utf8.c +438 -0
- data/mpg123/src/libmpg123/icy2utf8.h +10 -0
- data/mpg123/src/libmpg123/id3.c +999 -0
- data/mpg123/src/libmpg123/id3.h +43 -0
- data/mpg123/src/libmpg123/index.c +134 -0
- data/mpg123/src/libmpg123/index.h +59 -0
- data/mpg123/src/libmpg123/intsym.h +256 -0
- data/mpg123/src/libmpg123/l12_integer_tables.h +278 -0
- data/mpg123/src/libmpg123/l2tables.h +164 -0
- data/mpg123/src/libmpg123/l3_integer_tables.h +1002 -0
- data/mpg123/src/libmpg123/layer1.c +155 -0
- data/mpg123/src/libmpg123/layer2.c +371 -0
- data/mpg123/src/libmpg123/layer3.c +2053 -0
- data/mpg123/src/libmpg123/lfs_alias.c +252 -0
- data/mpg123/src/libmpg123/lfs_wrap.c +751 -0
- data/mpg123/src/libmpg123/libmpg123.c +1607 -0
- data/mpg123/src/libmpg123/mangle.h +74 -0
- data/mpg123/src/libmpg123/mpeghead.h +87 -0
- data/mpg123/src/libmpg123/mpg123.h.in +1075 -0
- data/mpg123/src/libmpg123/mpg123lib_intern.h +338 -0
- data/mpg123/src/libmpg123/ntom.c +148 -0
- data/mpg123/src/libmpg123/optimize.c +964 -0
- data/mpg123/src/libmpg123/optimize.h +219 -0
- data/mpg123/src/libmpg123/parse.c +1179 -0
- data/mpg123/src/libmpg123/parse.h +25 -0
- data/mpg123/src/libmpg123/reader.h +137 -0
- data/mpg123/src/libmpg123/readers.c +1235 -0
- data/mpg123/src/libmpg123/sample.h +152 -0
- data/mpg123/src/libmpg123/stringbuf.c +163 -0
- data/mpg123/src/libmpg123/synth.c +816 -0
- data/mpg123/src/libmpg123/synth.h +196 -0
- data/mpg123/src/libmpg123/synth_3dnow.S +318 -0
- data/mpg123/src/libmpg123/synth_3dnowext.S +6 -0
- data/mpg123/src/libmpg123/synth_8bit.c +142 -0
- data/mpg123/src/libmpg123/synth_8bit.h +86 -0
- data/mpg123/src/libmpg123/synth_altivec.c +1057 -0
- data/mpg123/src/libmpg123/synth_arm.S +271 -0
- data/mpg123/src/libmpg123/synth_arm_accurate.S +287 -0
- data/mpg123/src/libmpg123/synth_i486.c +252 -0
- data/mpg123/src/libmpg123/synth_i586.S +336 -0
- data/mpg123/src/libmpg123/synth_i586_dither.S +375 -0
- data/mpg123/src/libmpg123/synth_mmx.S +125 -0
- data/mpg123/src/libmpg123/synth_mono.h +64 -0
- data/mpg123/src/libmpg123/synth_neon.S +123 -0
- data/mpg123/src/libmpg123/synth_neon_accurate.S +173 -0
- data/mpg123/src/libmpg123/synth_neon_float.S +149 -0
- data/mpg123/src/libmpg123/synth_neon_s32.S +168 -0
- data/mpg123/src/libmpg123/synth_ntom.h +213 -0
- data/mpg123/src/libmpg123/synth_real.c +404 -0
- data/mpg123/src/libmpg123/synth_s32.c +411 -0
- data/mpg123/src/libmpg123/synth_sse.S +6 -0
- data/mpg123/src/libmpg123/synth_sse3d.h +246 -0
- data/mpg123/src/libmpg123/synth_sse_accurate.S +294 -0
- data/mpg123/src/libmpg123/synth_sse_float.S +241 -0
- data/mpg123/src/libmpg123/synth_sse_s32.S +306 -0
- data/mpg123/src/libmpg123/synth_stereo_neon.S +175 -0
- data/mpg123/src/libmpg123/synth_stereo_neon_accurate.S +262 -0
- data/mpg123/src/libmpg123/synth_stereo_neon_float.S +220 -0
- data/mpg123/src/libmpg123/synth_stereo_neon_s32.S +247 -0
- data/mpg123/src/libmpg123/synth_stereo_sse_accurate.S +508 -0
- data/mpg123/src/libmpg123/synth_stereo_sse_float.S +416 -0
- data/mpg123/src/libmpg123/synth_stereo_sse_s32.S +540 -0
- data/mpg123/src/libmpg123/synth_stereo_x86_64.S +335 -0
- data/mpg123/src/libmpg123/synth_stereo_x86_64_accurate.S +454 -0
- data/mpg123/src/libmpg123/synth_stereo_x86_64_float.S +396 -0
- data/mpg123/src/libmpg123/synth_stereo_x86_64_s32.S +473 -0
- data/mpg123/src/libmpg123/synth_x86_64.S +244 -0
- data/mpg123/src/libmpg123/synth_x86_64_accurate.S +301 -0
- data/mpg123/src/libmpg123/synth_x86_64_float.S +259 -0
- data/mpg123/src/libmpg123/synth_x86_64_s32.S +312 -0
- data/mpg123/src/libmpg123/synths.h +52 -0
- data/mpg123/src/libmpg123/tabinit.c +294 -0
- data/mpg123/src/libmpg123/tabinit_mmx.S +210 -0
- data/mpg123/src/libmpg123/testcpu.c +35 -0
- data/mpg123/src/libmpg123/true.h +14 -0
- data/mpg123/src/local.c +63 -0
- data/mpg123/src/local.h +21 -0
- data/mpg123/src/metaprint.c +373 -0
- data/mpg123/src/metaprint.h +17 -0
- data/mpg123/src/module.c +306 -0
- data/mpg123/src/module.h +48 -0
- data/mpg123/src/mpg123.c +1405 -0
- data/mpg123/src/mpg123app.h +171 -0
- data/mpg123/src/output/Makefile.am +213 -0
- data/mpg123/src/output/Makefile.in +1238 -0
- data/mpg123/src/output/aix.c +300 -0
- data/mpg123/src/output/alib.c +209 -0
- data/mpg123/src/output/alsa.c +297 -0
- data/mpg123/src/output/arts.c +117 -0
- data/mpg123/src/output/coreaudio.c +370 -0
- data/mpg123/src/output/dummy.c +78 -0
- data/mpg123/src/output/esd.c +167 -0
- data/mpg123/src/output/hp.c +184 -0
- data/mpg123/src/output/jack.c +450 -0
- data/mpg123/src/output/mint.c +197 -0
- data/mpg123/src/output/nas.c +335 -0
- data/mpg123/src/output/openal.c +197 -0
- data/mpg123/src/output/os2.c +665 -0
- data/mpg123/src/output/oss.c +319 -0
- data/mpg123/src/output/portaudio.c +255 -0
- data/mpg123/src/output/pulse.c +164 -0
- data/mpg123/src/output/sdl.c +206 -0
- data/mpg123/src/output/sgi.c +213 -0
- data/mpg123/src/output/sndio.c +161 -0
- data/mpg123/src/output/sun.c +281 -0
- data/mpg123/src/output/win32.c +229 -0
- data/mpg123/src/playlist.c +596 -0
- data/mpg123/src/playlist.h +52 -0
- data/mpg123/src/resolver.c +319 -0
- data/mpg123/src/resolver.h +25 -0
- data/mpg123/src/sfifo.c +146 -0
- data/mpg123/src/sfifo.h +95 -0
- data/mpg123/src/streamdump.c +74 -0
- data/mpg123/src/streamdump.h +20 -0
- data/mpg123/src/term.c +479 -0
- data/mpg123/src/term.h +81 -0
- data/mpg123/src/tests/noise.c +52 -0
- data/mpg123/src/tests/plain_id3.c +109 -0
- data/mpg123/src/tests/seek_accuracy.c +261 -0
- data/mpg123/src/tests/seek_whence.c +56 -0
- data/mpg123/src/tests/testtext.h +34 -0
- data/mpg123/src/tests/text.c +80 -0
- data/mpg123/src/wav.c +464 -0
- data/mpg123/src/wavhead.h +68 -0
- data/mpg123/src/win32_net.c +599 -0
- data/mpg123/src/win32_support.c +191 -0
- data/mpg123/src/win32_support.h +152 -0
- data/mpg123/src/xfermem.c +321 -0
- data/mpg123/src/xfermem.h +74 -0
- data/mpg123/windows-builds.sh +137 -0
- data/msvc/lib/OpenAL32.lib +0 -0
- data/spec/fixtures/heal.ogg +0 -0
- data/spec/fixtures/tone_up.wav +0 -0
- data/spec/seal/buffer_spec.rb +37 -0
- data/spec/seal/core_spec.rb +29 -0
- data/spec/seal/effect_slot_spec.rb +38 -0
- data/spec/seal/listener_spec.rb +33 -0
- data/spec/seal/reverb_spec.rb +51 -0
- data/spec/seal/source_spec.rb +370 -0
- data/spec/seal/stream_spec.rb +38 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/support/attribute_examples.rb +75 -0
- data/spec/support/audio_object_with_format.rb +27 -0
- data/spec/support/movable_object.rb +22 -0
- data/src/libogg/bitwise.c +857 -0
- data/src/libogg/framing.c +2093 -0
- data/src/libvorbis/backends.h +144 -0
- data/src/libvorbis/bitrate.c +253 -0
- data/src/libvorbis/bitrate.h +59 -0
- data/src/libvorbis/block.c +1046 -0
- data/src/libvorbis/codebook.c +484 -0
- data/src/libvorbis/codebook.h +119 -0
- data/src/libvorbis/codec_internal.h +167 -0
- data/src/libvorbis/envelope.c +375 -0
- data/src/libvorbis/envelope.h +80 -0
- data/src/libvorbis/floor0.c +221 -0
- data/src/libvorbis/floor1.c +1100 -0
- data/src/libvorbis/highlevel.h +58 -0
- data/src/libvorbis/info.c +668 -0
- data/src/libvorbis/lookup.c +94 -0
- data/src/libvorbis/lookup.h +32 -0
- data/src/libvorbis/lookup_data.h +192 -0
- data/src/libvorbis/lpc.c +160 -0
- data/src/libvorbis/lpc.h +29 -0
- data/src/libvorbis/lsp.c +456 -0
- data/src/libvorbis/lsp.h +28 -0
- data/src/libvorbis/mapping0.c +816 -0
- data/src/libvorbis/masking.h +785 -0
- data/src/libvorbis/mdct.c +563 -0
- data/src/libvorbis/mdct.h +71 -0
- data/src/libvorbis/misc.h +57 -0
- data/src/libvorbis/os.h +186 -0
- data/src/libvorbis/psy.c +1206 -0
- data/src/libvorbis/psy.h +154 -0
- data/src/libvorbis/registry.c +45 -0
- data/src/libvorbis/registry.h +32 -0
- data/src/libvorbis/res0.c +889 -0
- data/src/libvorbis/scales.h +90 -0
- data/src/libvorbis/sharedbook.c +579 -0
- data/src/libvorbis/smallft.c +1255 -0
- data/src/libvorbis/smallft.h +34 -0
- data/src/libvorbis/synthesis.c +184 -0
- data/src/libvorbis/vorbisfile.c +2337 -0
- data/src/libvorbis/window.c +2135 -0
- data/src/libvorbis/window.h +26 -0
- data/src/rubyext.c +2329 -0
- data/src/seal/buf.c +124 -0
- data/src/seal/core.c +283 -0
- data/src/seal/efs.c +74 -0
- data/src/seal/err.c +118 -0
- data/src/seal/fmt.c +86 -0
- data/src/seal/listener.c +111 -0
- data/src/seal/mpg.c +174 -0
- data/src/seal/mpg.h +24 -0
- data/src/seal/ov.c +180 -0
- data/src/seal/ov.h +22 -0
- data/src/seal/raw.c +59 -0
- data/src/seal/reader.c +102 -0
- data/src/seal/reader.h +59 -0
- data/src/seal/rvb.c +368 -0
- data/src/seal/src.c +654 -0
- data/src/seal/stream.c +109 -0
- data/src/seal/threading.c +66 -0
- data/src/seal/threading.h +20 -0
- data/src/seal/wav.c +297 -0
- data/src/seal/wav.h +23 -0
- data/src/win32api.rb +29 -0
- metadata +563 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
/*
|
2
|
+
getlopt: command line option/parameter parsing
|
3
|
+
|
4
|
+
copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1
|
5
|
+
see COPYING and AUTHORS files in distribution or http://mpg123.org
|
6
|
+
initially written Oliver Fromme
|
7
|
+
old timestamp: Tue Apr 8 07:13:39 MET DST 1997
|
8
|
+
*/
|
9
|
+
|
10
|
+
#include <stdlib.h>
|
11
|
+
#include <string.h>
|
12
|
+
|
13
|
+
|
14
|
+
#ifndef _MPG123_GETLOPT_H_
|
15
|
+
#define _MPG123_GETLOPT_H_
|
16
|
+
|
17
|
+
extern int loptind; /* index in argv[] */
|
18
|
+
extern int loptchr; /* index in argv[loptind] */
|
19
|
+
extern char *loptarg; /* points to argument if present, else to option */
|
20
|
+
|
21
|
+
typedef struct {
|
22
|
+
char sname; /* short option name, can be 0 */
|
23
|
+
char *lname; /* long option name, can be 0 */
|
24
|
+
int flags; /* see below */
|
25
|
+
void (*func)(char *); /* called if != 0 (after setting of var) */
|
26
|
+
void *var; /* type is *long, *char or **char, see below */
|
27
|
+
long value;
|
28
|
+
} topt;
|
29
|
+
|
30
|
+
/* ThOr: make this clear; distict long from int (since this is != on my Alpha) and really use a flag for every case (spare the 0 case
|
31
|
+
for .... no flag) */
|
32
|
+
#define GLO_ARG 1
|
33
|
+
#define GLO_CHAR 2
|
34
|
+
#define GLO_INT 4
|
35
|
+
#define GLO_LONG 8
|
36
|
+
#define GLO_DOUBLE 16
|
37
|
+
|
38
|
+
/* flags:
|
39
|
+
* bit 0 = 0 - no argument
|
40
|
+
* if var != NULL
|
41
|
+
* *var := value or (char)value [see bit 1]
|
42
|
+
* else
|
43
|
+
* loptarg = &option
|
44
|
+
* return ((value != 0) ? value : sname)
|
45
|
+
* bit 0 = 1 - argument required
|
46
|
+
* if var != NULL
|
47
|
+
* *var := atoi(arg) or strdup(arg) [see bit 1]
|
48
|
+
* else
|
49
|
+
* loptarg = &arg
|
50
|
+
* return ((value != 0) ? value : sname)
|
51
|
+
*
|
52
|
+
* bit 1 = 1 - var is a pointer to a char (or string),
|
53
|
+
* and value is interpreted as char
|
54
|
+
* bit 2 = 1 - var is a pointer to int
|
55
|
+
* bit 3 = 1 - var is a pointer to long
|
56
|
+
*
|
57
|
+
* Note: The options definition is terminated by a topt
|
58
|
+
* containing only zeroes.
|
59
|
+
*/
|
60
|
+
|
61
|
+
#define GLO_END 0
|
62
|
+
#define GLO_UNKNOWN -1
|
63
|
+
#define GLO_NOARG -2
|
64
|
+
#define GLO_CONTINUE -3
|
65
|
+
|
66
|
+
int getlopt (int argc, char *argv[], topt *opts);
|
67
|
+
|
68
|
+
/* return values:
|
69
|
+
* GLO_END (0) end of options
|
70
|
+
* GLO_UNKNOWN (-1) unknown option *loptarg
|
71
|
+
* GLO_NOARG (-2) missing argument
|
72
|
+
* GLO_CONTINUE (-3) (reserved for internal use)
|
73
|
+
* else - return value according to flags (see above)
|
74
|
+
*/
|
75
|
+
|
76
|
+
|
77
|
+
#endif
|
@@ -0,0 +1,700 @@
|
|
1
|
+
/*
|
2
|
+
httpget.c: http communication
|
3
|
+
|
4
|
+
copyright ?-2011 by the mpg123 project - free software under the terms of the LGPL 2.1
|
5
|
+
see COPYING and AUTHORS files in distribution or http://mpg123.org
|
6
|
+
initially written Oliver Fromme
|
7
|
+
old timestamp: Wed Apr 9 20:57:47 MET DST 1997
|
8
|
+
|
9
|
+
Thomas' notes:
|
10
|
+
|
11
|
+
I used to do
|
12
|
+
GET http://server/path HTTP/1.0
|
13
|
+
|
14
|
+
But RFC 1945 says: The absoluteURI form is only allowed when the request is being made to a proxy.
|
15
|
+
|
16
|
+
so I should not do that. Since name based virtual hosts need the hostname in the request, I still need to provide that info.
|
17
|
+
Enter HTTP/1.1... there is a Host eader field to use (that mpg123 supposedly has used since some time anyway - but did it really work with my vhost test server)?
|
18
|
+
Now
|
19
|
+
GET /path/bla HTTP/1.1\r\nHost: host[:port]
|
20
|
+
Should work, but as a funny sidenote:
|
21
|
+
|
22
|
+
RFC2616: To allow for transition to absoluteURIs in all requests in future versions of HTTP, all HTTP/1.1 servers MUST accept the absoluteURI form in requests, even though HTTP/1.1 clients will only generate them in requests to proxies.
|
23
|
+
|
24
|
+
I was already full-on HTTP/1.1 as I recognized that mpg123 then would have to accept the chunked transfer encoding.
|
25
|
+
That is not desireable for its purpose... maybe when interleaving of shoutcasts with metadata chunks is supported, we can upgrade to 1.1.
|
26
|
+
Funny aspect there is that shoutcast servers do not do HTTP/1.1 chunked transfer but implement some different chunking themselves...
|
27
|
+
*/
|
28
|
+
|
29
|
+
#include "mpg123app.h"
|
30
|
+
#include "httpget.h"
|
31
|
+
|
32
|
+
#ifdef NETWORK
|
33
|
+
#include "resolver.h"
|
34
|
+
|
35
|
+
#include <errno.h>
|
36
|
+
#include "true.h"
|
37
|
+
#endif
|
38
|
+
|
39
|
+
#include "debug.h"
|
40
|
+
|
41
|
+
void httpdata_init(struct httpdata *e)
|
42
|
+
{
|
43
|
+
mpg123_init_string(&e->content_type);
|
44
|
+
mpg123_init_string(&e->icy_url);
|
45
|
+
mpg123_init_string(&e->icy_name);
|
46
|
+
e->icy_interval = 0;
|
47
|
+
e->proxystate = PROXY_UNKNOWN;
|
48
|
+
mpg123_init_string(&e->proxyhost);
|
49
|
+
mpg123_init_string(&e->proxyport);
|
50
|
+
}
|
51
|
+
|
52
|
+
void httpdata_reset(struct httpdata *e)
|
53
|
+
{
|
54
|
+
mpg123_free_string(&e->content_type);
|
55
|
+
mpg123_free_string(&e->icy_url);
|
56
|
+
mpg123_free_string(&e->icy_name);
|
57
|
+
e->icy_interval = 0;
|
58
|
+
/* the other stuff shall persist */
|
59
|
+
}
|
60
|
+
|
61
|
+
void httpdata_free(struct httpdata *e)
|
62
|
+
{
|
63
|
+
httpdata_reset(e);
|
64
|
+
mpg123_free_string(&e->proxyhost);
|
65
|
+
mpg123_free_string(&e->proxyport);
|
66
|
+
}
|
67
|
+
|
68
|
+
/* mime type classes */
|
69
|
+
#define M_FILE 0
|
70
|
+
#define M_M3U 1
|
71
|
+
#define M_PLS 2
|
72
|
+
static const char* mime_file[] =
|
73
|
+
{
|
74
|
+
"audio/mpeg", "audio/x-mpeg",
|
75
|
+
"audio/mp3", "audio/x-mp3",
|
76
|
+
"audio/mpeg3", "audio/x-mpeg3",
|
77
|
+
"audio/mpg", "audio/x-mpg",
|
78
|
+
"audio/x-mpegaudio",
|
79
|
+
"application/octet-stream", /* Assume raw binary data is some MPEG data. */
|
80
|
+
NULL
|
81
|
+
};
|
82
|
+
static const char* mime_m3u[] = { "audio/mpegurl", "audio/mpeg-url", "audio/x-mpegurl", NULL };
|
83
|
+
static const char* mime_pls[] = { "audio/x-scpls", "audio/scpls", "application/pls", NULL };
|
84
|
+
static const char** mimes[] = { mime_file, mime_m3u, mime_pls, NULL };
|
85
|
+
|
86
|
+
int debunk_mime(const char* mime)
|
87
|
+
{
|
88
|
+
int i,j;
|
89
|
+
size_t len;
|
90
|
+
int r = 0;
|
91
|
+
char *aux;
|
92
|
+
/* Watch out for such: "audio/x-mpegurl; charset=utf-8" */
|
93
|
+
aux = strchr(mime, ';');
|
94
|
+
if(aux != NULL)
|
95
|
+
{
|
96
|
+
fprintf(stderr, "Warning: additional info in content-type ignored (%s)\n", aux+1);
|
97
|
+
/* Just compare up to before the ";". */
|
98
|
+
len = aux-mime;
|
99
|
+
}
|
100
|
+
/* Else, compare the whole string -- including the end. */
|
101
|
+
else len = strlen(mime)+1;
|
102
|
+
|
103
|
+
for(i=0; mimes[i] != NULL; ++i)
|
104
|
+
for(j=0; mimes[i][j] != NULL; ++j)
|
105
|
+
if(!strncasecmp(mimes[i][j], mime, len)) goto debunk_result;
|
106
|
+
|
107
|
+
debunk_result:
|
108
|
+
if(mimes[i] != NULL)
|
109
|
+
{
|
110
|
+
switch(i)
|
111
|
+
{
|
112
|
+
case M_FILE: r = IS_FILE; break;
|
113
|
+
case M_M3U: r = IS_LIST|IS_M3U; break;
|
114
|
+
case M_PLS: r = IS_LIST|IS_PLS; break;
|
115
|
+
default: error("unexpected MIME debunk result -- coding error?!");
|
116
|
+
}
|
117
|
+
}
|
118
|
+
return r;
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
#ifdef NETWORK
|
123
|
+
#if !defined (WANT_WIN32_SOCKETS)
|
124
|
+
static int writestring (int fd, mpg123_string *string)
|
125
|
+
{
|
126
|
+
size_t result, bytes;
|
127
|
+
char *ptr = string->p;
|
128
|
+
bytes = string->fill ? string->fill-1 : 0;
|
129
|
+
|
130
|
+
while(bytes)
|
131
|
+
{
|
132
|
+
result = write(fd, ptr, bytes);
|
133
|
+
if(result < 0 && errno != EINTR)
|
134
|
+
{
|
135
|
+
perror ("writing http string");
|
136
|
+
return FALSE;
|
137
|
+
}
|
138
|
+
else if(result == 0)
|
139
|
+
{
|
140
|
+
error("write: socket closed unexpectedly");
|
141
|
+
return FALSE;
|
142
|
+
}
|
143
|
+
ptr += result;
|
144
|
+
bytes -= result;
|
145
|
+
}
|
146
|
+
return TRUE;
|
147
|
+
}
|
148
|
+
|
149
|
+
static size_t readstring (mpg123_string *string, size_t maxlen, FILE *f)
|
150
|
+
{
|
151
|
+
int err;
|
152
|
+
debug2("Attempting readstring on %d for %"SIZE_P" bytes", f ? fileno(f) : 0, (size_p)maxlen);
|
153
|
+
string->fill = 0;
|
154
|
+
while(maxlen == 0 || string->fill < maxlen)
|
155
|
+
{
|
156
|
+
if(string->size-string->fill < 1)
|
157
|
+
if(!mpg123_grow_string(string, string->fill+4096))
|
158
|
+
{
|
159
|
+
error("Cannot allocate memory for reading.");
|
160
|
+
string->fill = 0;
|
161
|
+
return 0;
|
162
|
+
}
|
163
|
+
err = read(fileno(f),string->p+string->fill,1);
|
164
|
+
/* Whoa... reading one byte at a time... one could ensure the line break in another way, but more work. */
|
165
|
+
if( err == 1)
|
166
|
+
{
|
167
|
+
string->fill++;
|
168
|
+
if(string->p[string->fill-1] == '\n') break;
|
169
|
+
}
|
170
|
+
else if(errno != EINTR)
|
171
|
+
{
|
172
|
+
error("Error reading from socket or unexpected EOF.");
|
173
|
+
string->fill = 0;
|
174
|
+
/* bail out to prevent endless loop */
|
175
|
+
return 0;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
if(!mpg123_grow_string(string, string->fill+1))
|
180
|
+
{
|
181
|
+
string->fill=0;
|
182
|
+
}
|
183
|
+
else
|
184
|
+
{
|
185
|
+
string->p[string->fill] = 0;
|
186
|
+
string->fill++;
|
187
|
+
}
|
188
|
+
return string->fill;
|
189
|
+
}
|
190
|
+
#endif /* WANT_WIN32_SOCKETS */
|
191
|
+
|
192
|
+
void encode64 (char *source,char *destination)
|
193
|
+
{
|
194
|
+
static char *Base64Digits =
|
195
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
196
|
+
int n = 0;
|
197
|
+
int ssiz=strlen(source);
|
198
|
+
int i;
|
199
|
+
|
200
|
+
for (i = 0 ; i < ssiz ; i += 3) {
|
201
|
+
unsigned int buf;
|
202
|
+
buf = ((unsigned char *)source)[i] << 16;
|
203
|
+
if (i+1 < ssiz)
|
204
|
+
buf |= ((unsigned char *)source)[i+1] << 8;
|
205
|
+
if (i+2 < ssiz)
|
206
|
+
buf |= ((unsigned char *)source)[i+2];
|
207
|
+
|
208
|
+
destination[n++] = Base64Digits[(buf >> 18) % 64];
|
209
|
+
destination[n++] = Base64Digits[(buf >> 12) % 64];
|
210
|
+
if (i+1 < ssiz)
|
211
|
+
destination[n++] = Base64Digits[(buf >> 6) % 64];
|
212
|
+
else
|
213
|
+
destination[n++] = '=';
|
214
|
+
if (i+2 < ssiz)
|
215
|
+
destination[n++] = Base64Digits[buf % 64];
|
216
|
+
else
|
217
|
+
destination[n++] = '=';
|
218
|
+
}
|
219
|
+
destination[n++] = 0;
|
220
|
+
}
|
221
|
+
|
222
|
+
/* Look out for HTTP header field to parse, construct C string with the value.
|
223
|
+
Attention: Modifies argument, since it's so convenient... */
|
224
|
+
char *get_header_val(const char *hname, mpg123_string *response)
|
225
|
+
{
|
226
|
+
char *tmp = NULL;
|
227
|
+
size_t prelen = strlen(hname);
|
228
|
+
/* if header name found, next char is at least something, so just check for : */
|
229
|
+
if(!strncasecmp(hname, response->p, prelen) && (response->p[prelen] == ':'))
|
230
|
+
{
|
231
|
+
++prelen;
|
232
|
+
if((tmp = strchr(response->p, '\r')) != NULL ) tmp[0] = 0;
|
233
|
+
if((tmp = strchr(response->p, '\n')) != NULL ) tmp[0] = 0;
|
234
|
+
tmp = response->p+prelen;
|
235
|
+
/* I _know_ that there is a terminating zero, so this loop is safe. */
|
236
|
+
while((tmp[0] == ' ') || (tmp[0] == '\t'))
|
237
|
+
{
|
238
|
+
++tmp;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
return tmp;
|
242
|
+
}
|
243
|
+
|
244
|
+
/* Iterate over header field names and storage locations, to possibly get those values. */
|
245
|
+
void get_header_string(mpg123_string *response, const char *fieldname, mpg123_string *store)
|
246
|
+
{
|
247
|
+
char *tmp;
|
248
|
+
if((tmp = get_header_val(fieldname, response)))
|
249
|
+
{
|
250
|
+
if(mpg123_set_string(store, tmp)){ debug2("got %s %s", fieldname, store->p); return; }
|
251
|
+
else{ error2("unable to set %s to %s!", fieldname, tmp); }
|
252
|
+
}
|
253
|
+
}
|
254
|
+
|
255
|
+
/* shoutcsast meta data: 1=on, 0=off */
|
256
|
+
|
257
|
+
char *httpauth = NULL;
|
258
|
+
|
259
|
+
size_t accept_length(void)
|
260
|
+
{
|
261
|
+
int i,j;
|
262
|
+
static size_t l = 0;
|
263
|
+
if(l) return l;
|
264
|
+
l += strlen("Accept: ");
|
265
|
+
for(i=0; mimes[i] != NULL; ++i)
|
266
|
+
for(j=0; mimes[i][j] != NULL; ++j){ l += strlen(mimes[i][j]) + strlen(", "); }
|
267
|
+
l += strlen("*/*\r\n");
|
268
|
+
debug1("initial computation of accept header length: %lu", (unsigned long)l);
|
269
|
+
return l;
|
270
|
+
}
|
271
|
+
|
272
|
+
/* Returns TRUE or FALSE for success. */
|
273
|
+
int proxy_init(struct httpdata *hd)
|
274
|
+
{
|
275
|
+
int ret = TRUE;
|
276
|
+
/* If we don't have explicit proxy given, probe the environment. */
|
277
|
+
if (!param.proxyurl)
|
278
|
+
if (!(param.proxyurl = getenv("MP3_HTTP_PROXY")))
|
279
|
+
if (!(param.proxyurl = getenv("http_proxy")))
|
280
|
+
param.proxyurl = getenv("HTTP_PROXY");
|
281
|
+
/* Now continue if we have something. */
|
282
|
+
if (param.proxyurl && param.proxyurl[0] && strcmp(param.proxyurl, "none"))
|
283
|
+
{
|
284
|
+
mpg123_string proxyurl;
|
285
|
+
mpg123_init_string(&proxyurl);
|
286
|
+
if( !mpg123_set_string(&proxyurl, param.proxyurl)
|
287
|
+
|| !split_url(&proxyurl, NULL, &hd->proxyhost, &hd->proxyport, NULL))
|
288
|
+
{
|
289
|
+
error("splitting proxy URL");
|
290
|
+
ret = FALSE;
|
291
|
+
}
|
292
|
+
else if(param.verbose > 1) fprintf(stderr, "Note: Using proxy %s\n", hd->proxyhost.p);
|
293
|
+
#if 0 /* not yet there */
|
294
|
+
if(!try_host_lookup(proxyhost))
|
295
|
+
{
|
296
|
+
error("Unknown proxy host \"%s\".\n", proxyhost.p);
|
297
|
+
ret = FALSE;
|
298
|
+
}
|
299
|
+
#endif
|
300
|
+
mpg123_free_string(&proxyurl);
|
301
|
+
if(ret) hd->proxystate = PROXY_HOST; /* We got hostname and port settled. */
|
302
|
+
else hd->proxystate = PROXY_NONE;
|
303
|
+
}
|
304
|
+
else hd->proxystate = PROXY_NONE;
|
305
|
+
|
306
|
+
return ret;
|
307
|
+
}
|
308
|
+
|
309
|
+
static int append_accept(mpg123_string *s)
|
310
|
+
{
|
311
|
+
size_t i,j;
|
312
|
+
if(!mpg123_add_string(s, "Accept: ")) return FALSE;
|
313
|
+
|
314
|
+
/* We prefer what we know. */
|
315
|
+
for(i=0; mimes[i] != NULL; ++i)
|
316
|
+
for(j=0; mimes[i][j] != NULL; ++j)
|
317
|
+
{
|
318
|
+
if( !mpg123_add_string(s, mimes[i][j])
|
319
|
+
|| !mpg123_add_string(s, ", ") )
|
320
|
+
return FALSE;
|
321
|
+
}
|
322
|
+
/* Well... in the end, we accept everything, trying to make sense with reality. */
|
323
|
+
if(!mpg123_add_string(s, "*/*\r\n")) return FALSE;
|
324
|
+
|
325
|
+
return TRUE;
|
326
|
+
}
|
327
|
+
|
328
|
+
|
329
|
+
/*
|
330
|
+
Converts spaces to "%20" ... actually, I have to ask myself why.
|
331
|
+
What about converting them to "+" instead? Would make things a lot easier.
|
332
|
+
Or, on the other hand... what about avoiding HTML encoding at all?
|
333
|
+
*/
|
334
|
+
int translate_url(const char *url, mpg123_string *purl)
|
335
|
+
{
|
336
|
+
const char *sptr;
|
337
|
+
/* The length of purl is upper bound by 3*strlen(url) + 1 if
|
338
|
+
* everything in it is a space (%20) - or any encoded character */
|
339
|
+
if (strlen(url) >= SIZE_MAX/3)
|
340
|
+
{
|
341
|
+
error("URL too long. Skipping...");
|
342
|
+
return FALSE;
|
343
|
+
}
|
344
|
+
/* Prepare purl in one chunk, to minimize mallocs. */
|
345
|
+
if(!mpg123_resize_string(purl, strlen(url) + 31)) return FALSE;
|
346
|
+
/*
|
347
|
+
* 2000-10-21:
|
348
|
+
* We would like spaces to be automatically converted to %20's when
|
349
|
+
* fetching via HTTP.
|
350
|
+
* -- Martin Sj�gren <md9ms@mdstud.chalmers.se>
|
351
|
+
* Hm, why only spaces? Maybe one should do this http stuff more properly...
|
352
|
+
*/
|
353
|
+
if ((sptr = strchr(url, ' ')) == NULL)
|
354
|
+
mpg123_set_string(purl, url);
|
355
|
+
else
|
356
|
+
{ /* Note that sptr is set from the if to this else... */
|
357
|
+
const char *urlptr = url;
|
358
|
+
mpg123_set_string(purl, "");
|
359
|
+
do {
|
360
|
+
if(! ( mpg123_add_substring(purl, urlptr, 0, sptr-urlptr)
|
361
|
+
&& mpg123_add_string(purl, "%20") ) )
|
362
|
+
return FALSE;
|
363
|
+
urlptr = sptr + 1;
|
364
|
+
} while ((sptr = strchr (urlptr, ' ')) != NULL);
|
365
|
+
if(!mpg123_add_string(purl, urlptr)) return FALSE;
|
366
|
+
}
|
367
|
+
/* now see if a terminating / may be needed */
|
368
|
+
if(strchr(purl->p+(strncmp("http://", purl->p, 7) ? 0 : 7), '/') == NULL
|
369
|
+
&& !mpg123_add_string(purl, "/"))
|
370
|
+
return FALSE;
|
371
|
+
|
372
|
+
return TRUE;
|
373
|
+
}
|
374
|
+
|
375
|
+
int fill_request(mpg123_string *request, mpg123_string *host, mpg123_string *port, mpg123_string *httpauth1, int *try_without_port)
|
376
|
+
{
|
377
|
+
char* ttemp;
|
378
|
+
int ret = TRUE;
|
379
|
+
const char *icy = param.talk_icy ? icy_yes : icy_no;
|
380
|
+
|
381
|
+
/* hm, my test redirection had troubles with line break before HTTP/1.0 */
|
382
|
+
if((ttemp = strchr(request->p,'\r')) != NULL){ *ttemp = 0; request->fill = ttemp-request->p+1; }
|
383
|
+
|
384
|
+
if((ttemp = strchr(request->p,'\n')) != NULL){ *ttemp = 0; request->fill = ttemp-request->p+1; }
|
385
|
+
|
386
|
+
/* Fill out the request further... */
|
387
|
+
if( !mpg123_add_string(request, " HTTP/1.0\r\nUser-Agent: ")
|
388
|
+
|| !mpg123_add_string(request, PACKAGE_NAME)
|
389
|
+
|| !mpg123_add_string(request, "/")
|
390
|
+
|| !mpg123_add_string(request, PACKAGE_VERSION)
|
391
|
+
|| !mpg123_add_string(request, "\r\n") )
|
392
|
+
return FALSE;
|
393
|
+
|
394
|
+
if(host->fill)
|
395
|
+
{ /* Give virtual hosting a chance... adding the "Host: ... " line. */
|
396
|
+
debug2("Host: %s:%s", host->p, port->p);
|
397
|
+
if( mpg123_add_string(request, "Host: ")
|
398
|
+
&& mpg123_add_string(request, host->p)
|
399
|
+
&& ( *try_without_port || (
|
400
|
+
mpg123_add_string(request, ":")
|
401
|
+
&& mpg123_add_string(request, port->p) ))
|
402
|
+
&& mpg123_add_string(request, "\r\n") )
|
403
|
+
{
|
404
|
+
if(*try_without_port) *try_without_port = 0;
|
405
|
+
}
|
406
|
+
else return FALSE;
|
407
|
+
}
|
408
|
+
|
409
|
+
/* Acceptance, stream setup. */
|
410
|
+
if( !append_accept(request)
|
411
|
+
|| !mpg123_add_string(request, CONN_HEAD)
|
412
|
+
|| !mpg123_add_string(request, icy) )
|
413
|
+
return FALSE;
|
414
|
+
|
415
|
+
/* Authorization. */
|
416
|
+
if (httpauth1->fill || httpauth) {
|
417
|
+
char *buf;
|
418
|
+
if(!mpg123_add_string(request,"Authorization: Basic ")) return FALSE;
|
419
|
+
if(httpauth1->fill) {
|
420
|
+
if(httpauth1->fill > SIZE_MAX / 4) return FALSE;
|
421
|
+
|
422
|
+
buf=(char *)malloc(httpauth1->fill * 4);
|
423
|
+
if(!buf)
|
424
|
+
{
|
425
|
+
error("malloc() failed for http auth, out of memory.");
|
426
|
+
return FALSE;
|
427
|
+
}
|
428
|
+
encode64(httpauth1->p,buf);
|
429
|
+
} else {
|
430
|
+
if(strlen(httpauth) > SIZE_MAX / 4 - 4 ) return FALSE;
|
431
|
+
|
432
|
+
buf=(char *)malloc((strlen(httpauth) + 1) * 4);
|
433
|
+
if(!buf)
|
434
|
+
{
|
435
|
+
error("malloc() for http auth failed, out of memory.");
|
436
|
+
return FALSE;
|
437
|
+
}
|
438
|
+
encode64(httpauth,buf);
|
439
|
+
}
|
440
|
+
|
441
|
+
if( !mpg123_add_string(request, buf) || !mpg123_add_string(request, "\r\n"))
|
442
|
+
ret = FALSE;
|
443
|
+
|
444
|
+
free(buf); /* Watch out for leaking if you introduce returns before this line. */
|
445
|
+
}
|
446
|
+
if(ret) ret = mpg123_add_string(request, "\r\n");
|
447
|
+
|
448
|
+
return ret;
|
449
|
+
}
|
450
|
+
#if !defined (WANT_WIN32_SOCKETS)
|
451
|
+
static int resolve_redirect(mpg123_string *response, mpg123_string *request_url, mpg123_string *purl)
|
452
|
+
{
|
453
|
+
debug1("request_url:%s", request_url->p);
|
454
|
+
/* initialized with full old url */
|
455
|
+
if(!mpg123_copy_string(request_url, purl)) return FALSE;
|
456
|
+
|
457
|
+
/* We may strip it down to a prefix ot totally. */
|
458
|
+
if(strncasecmp(response->p, "Location: http://", 17))
|
459
|
+
{ /* OK, only partial strip, need prefix for relative path. */
|
460
|
+
char* ptmp = NULL;
|
461
|
+
/* though it's not RFC (?), accept relative URIs as wget does */
|
462
|
+
fprintf(stderr, "NOTE: no complete URL in redirect, constructing one\n");
|
463
|
+
/* not absolute uri, could still be server-absolute */
|
464
|
+
/* I prepend a part of the request... out of the request */
|
465
|
+
if(response->p[10] == '/')
|
466
|
+
{
|
467
|
+
/* only prepend http://server/ */
|
468
|
+
/* I null the first / after http:// */
|
469
|
+
ptmp = strchr(purl->p+7,'/');
|
470
|
+
if(ptmp != NULL){ purl->fill = ptmp-purl->p+1; purl->p[purl->fill-1] = 0; }
|
471
|
+
}
|
472
|
+
else
|
473
|
+
{
|
474
|
+
/* prepend http://server/path/ */
|
475
|
+
/* now we want the last / */
|
476
|
+
ptmp = strrchr(purl->p+7, '/');
|
477
|
+
if(ptmp != NULL){ purl->fill = ptmp-purl->p+2; purl->p[purl->fill-1] = 0; }
|
478
|
+
}
|
479
|
+
}
|
480
|
+
else purl->fill = 0;
|
481
|
+
|
482
|
+
debug1("prefix=%s", purl->fill ? purl->p : "");
|
483
|
+
if(!mpg123_add_string(purl, response->p+10)) return FALSE;
|
484
|
+
|
485
|
+
debug1(" purl: %s", purl->p);
|
486
|
+
debug1("old request_url: %s", request_url->p);
|
487
|
+
|
488
|
+
return TRUE;
|
489
|
+
}
|
490
|
+
|
491
|
+
int http_open(char* url, struct httpdata *hd)
|
492
|
+
{
|
493
|
+
mpg123_string purl, host, port, path;
|
494
|
+
mpg123_string request, response, request_url;
|
495
|
+
mpg123_string httpauth1;
|
496
|
+
int sock = -1;
|
497
|
+
int oom = 0;
|
498
|
+
int relocate, numrelocs = 0;
|
499
|
+
int got_location = FALSE;
|
500
|
+
FILE *myfile = NULL;
|
501
|
+
/*
|
502
|
+
workaround for http://www.global24music.com/rautemusik/files/extreme/isdn.pls
|
503
|
+
this site's apache gives me a relocation to the same place when I give the port in Host request field
|
504
|
+
for the record: Apache/2.0.51 (Fedora)
|
505
|
+
*/
|
506
|
+
int try_without_port = 0;
|
507
|
+
mpg123_init_string(&purl);
|
508
|
+
mpg123_init_string(&host);
|
509
|
+
mpg123_init_string(&port);
|
510
|
+
mpg123_init_string(&path);
|
511
|
+
mpg123_init_string(&request);
|
512
|
+
mpg123_init_string(&response);
|
513
|
+
mpg123_init_string(&request_url);
|
514
|
+
mpg123_init_string(&httpauth1);
|
515
|
+
|
516
|
+
/* Get initial info for proxy server. Once. */
|
517
|
+
if(hd->proxystate == PROXY_UNKNOWN && !proxy_init(hd)) goto exit;
|
518
|
+
|
519
|
+
if(!translate_url(url, &purl)){ oom=1; goto exit; }
|
520
|
+
|
521
|
+
/* Don't confuse the different auth strings... */
|
522
|
+
if(!split_url(&purl, &httpauth1, NULL, NULL, NULL) ){ oom=1; goto exit; }
|
523
|
+
|
524
|
+
/* "GET http://" 11
|
525
|
+
* " HTTP/1.0\r\nUser-Agent: <PACKAGE_NAME>/<PACKAGE_VERSION>\r\n"
|
526
|
+
* 26 + PACKAGE_NAME + PACKAGE_VERSION
|
527
|
+
* accept header + accept_length()
|
528
|
+
* "Authorization: Basic \r\n" 23
|
529
|
+
* "\r\n" 2
|
530
|
+
* ... plus the other predefined header lines
|
531
|
+
*/
|
532
|
+
/* Just use this estimate as first guess to reduce malloc calls in string library. */
|
533
|
+
{
|
534
|
+
size_t length_estimate = 62 + strlen(PACKAGE_NAME) + strlen(PACKAGE_VERSION)
|
535
|
+
+ accept_length() + strlen(CONN_HEAD) + strlen(icy_yes) + purl.fill;
|
536
|
+
if( !mpg123_grow_string(&request, length_estimate)
|
537
|
+
|| !mpg123_grow_string(&response,4096) )
|
538
|
+
{
|
539
|
+
oom=1; goto exit;
|
540
|
+
}
|
541
|
+
}
|
542
|
+
|
543
|
+
do
|
544
|
+
{
|
545
|
+
/* Storing the request url, with http:// prepended if needed. */
|
546
|
+
/* used to be url here... seemed wrong to me (when loop advanced...) */
|
547
|
+
if(strncasecmp(purl.p, "http://", 7) != 0) mpg123_set_string(&request_url, "http://");
|
548
|
+
else mpg123_set_string(&request_url, "");
|
549
|
+
|
550
|
+
mpg123_add_string(&request_url, purl.p);
|
551
|
+
|
552
|
+
if (hd->proxystate >= PROXY_HOST)
|
553
|
+
{
|
554
|
+
/* We will connect to proxy, full URL goes into the request. */
|
555
|
+
if( !mpg123_copy_string(&hd->proxyhost, &host)
|
556
|
+
|| !mpg123_copy_string(&hd->proxyport, &port)
|
557
|
+
|| !mpg123_set_string(&request, "GET ")
|
558
|
+
|| !mpg123_add_string(&request, request_url.p) )
|
559
|
+
{
|
560
|
+
oom=1; goto exit;
|
561
|
+
}
|
562
|
+
}
|
563
|
+
else
|
564
|
+
{
|
565
|
+
/* We will connect to the host from the URL and only the path goes into the request. */
|
566
|
+
if(!split_url(&purl, NULL, &host, &port, &path)){ oom=1; goto exit; }
|
567
|
+
if( !mpg123_set_string(&request, "GET ")
|
568
|
+
|| !mpg123_add_string(&request, path.p) )
|
569
|
+
{
|
570
|
+
oom=1; goto exit;
|
571
|
+
}
|
572
|
+
}
|
573
|
+
|
574
|
+
if(!fill_request(&request, &host, &port, &httpauth1, &try_without_port)){ oom=1; goto exit; }
|
575
|
+
|
576
|
+
httpauth1.fill = 0; /* We use the auth data from the URL only once. */
|
577
|
+
debug2("attempting to open_connection to %s:%s", host.p, port.p);
|
578
|
+
sock = open_connection(&host, &port);
|
579
|
+
if(sock < 0)
|
580
|
+
{
|
581
|
+
error1("Unable to establish connection to %s", host.fill ? host.p : "");
|
582
|
+
goto exit;
|
583
|
+
}
|
584
|
+
#define http_failure close(sock); sock=-1; goto exit;
|
585
|
+
|
586
|
+
if(param.verbose > 2) fprintf(stderr, "HTTP request:\n%s\n",request.p);
|
587
|
+
if(!writestring(sock, &request)){ http_failure; }
|
588
|
+
if (!(myfile = fdopen(sock, "rb")))
|
589
|
+
{
|
590
|
+
error1("fdopen: %s", strerror(errno));
|
591
|
+
http_failure;
|
592
|
+
}
|
593
|
+
relocate = FALSE;
|
594
|
+
/* Arbitrary length limit here... */
|
595
|
+
#define safe_readstring \
|
596
|
+
readstring(&response, SIZE_MAX/16, myfile); \
|
597
|
+
if(response.fill > SIZE_MAX/16) /* > because of appended zero. */ \
|
598
|
+
{ \
|
599
|
+
error("HTTP response line exceeds max. length"); \
|
600
|
+
http_failure; \
|
601
|
+
} \
|
602
|
+
else if(response.fill == 0) \
|
603
|
+
{ \
|
604
|
+
error("readstring failed"); \
|
605
|
+
http_failure; \
|
606
|
+
} \
|
607
|
+
if(param.verbose > 2) fprintf(stderr, "HTTP in: %s", response.p);
|
608
|
+
safe_readstring;
|
609
|
+
|
610
|
+
{
|
611
|
+
char *sptr;
|
612
|
+
if((sptr = strchr(response.p, ' ')))
|
613
|
+
{
|
614
|
+
if(response.fill > sptr-response.p+2)
|
615
|
+
switch (sptr[1])
|
616
|
+
{
|
617
|
+
case '3':
|
618
|
+
relocate = TRUE;
|
619
|
+
case '2':
|
620
|
+
break;
|
621
|
+
default:
|
622
|
+
fprintf (stderr, "HTTP request failed: %s", sptr+1); /* '\n' is included */
|
623
|
+
http_failure;
|
624
|
+
}
|
625
|
+
else{ error("Too short response,"); http_failure; }
|
626
|
+
}
|
627
|
+
}
|
628
|
+
|
629
|
+
/* If we are relocated, we need to look out for a Location header. */
|
630
|
+
got_location = FALSE;
|
631
|
+
|
632
|
+
do
|
633
|
+
{
|
634
|
+
safe_readstring; /* Think about that: Should we really error out when we get nothing? Could be that the server forgot the trailing empty line... */
|
635
|
+
if (!strncasecmp(response.p, "Location: ", 10))
|
636
|
+
{ /* It is a redirection! */
|
637
|
+
if(!resolve_redirect(&response, &request_url, &purl)){ oom=1, http_failure; }
|
638
|
+
|
639
|
+
if(!strcmp(purl.p, request_url.p))
|
640
|
+
{
|
641
|
+
warning("relocated to very same place! trying request again without host port");
|
642
|
+
try_without_port = 1;
|
643
|
+
}
|
644
|
+
got_location = TRUE;
|
645
|
+
}
|
646
|
+
else
|
647
|
+
{ /* We got a header line (or the closing empty line). */
|
648
|
+
char *tmp;
|
649
|
+
debug1("searching for header values... %s", response.p);
|
650
|
+
/* Not sure if I want to bail out on error here. */
|
651
|
+
/* Also: What text encoding are these strings in? Doesn't need to be plain ASCII... */
|
652
|
+
get_header_string(&response, "content-type", &hd->content_type);
|
653
|
+
get_header_string(&response, "icy-name", &hd->icy_name);
|
654
|
+
get_header_string(&response, "icy-url", &hd->icy_url);
|
655
|
+
|
656
|
+
/* watch out for icy-metaint */
|
657
|
+
if((tmp = get_header_val("icy-metaint", &response)))
|
658
|
+
{
|
659
|
+
hd->icy_interval = (off_t) atol(tmp); /* atoll ? */
|
660
|
+
debug1("got icy-metaint %li", (long int)hd->icy_interval);
|
661
|
+
}
|
662
|
+
}
|
663
|
+
} while(response.p[0] != '\r' && response.p[0] != '\n');
|
664
|
+
} while(relocate && got_location && purl.fill && numrelocs++ < HTTP_MAX_RELOCATIONS);
|
665
|
+
if(relocate)
|
666
|
+
{
|
667
|
+
if(!got_location)
|
668
|
+
error("Server meant to redirect but failed to provide a location!");
|
669
|
+
else
|
670
|
+
error1("Too many HTTP relocations (%i).", numrelocs);
|
671
|
+
|
672
|
+
http_failure;
|
673
|
+
}
|
674
|
+
|
675
|
+
exit: /* The end as well as the exception handling point... */
|
676
|
+
if(oom) error("Apparently, I ran out of memory or had some bad input data...");
|
677
|
+
|
678
|
+
mpg123_free_string(&purl);
|
679
|
+
mpg123_free_string(&host);
|
680
|
+
mpg123_free_string(&port);
|
681
|
+
mpg123_free_string(&path);
|
682
|
+
mpg123_free_string(&request);
|
683
|
+
mpg123_free_string(&response);
|
684
|
+
mpg123_free_string(&request_url);
|
685
|
+
mpg123_free_string(&httpauth1);
|
686
|
+
return sock;
|
687
|
+
}
|
688
|
+
#endif /*WANT_WIN32_SOCKETS*/
|
689
|
+
|
690
|
+
#else /* NETWORK */
|
691
|
+
|
692
|
+
/* stub */
|
693
|
+
int http_open (char* url, struct httpdata *hd)
|
694
|
+
{
|
695
|
+
return -1;
|
696
|
+
}
|
697
|
+
#endif
|
698
|
+
|
699
|
+
/* EOF */
|
700
|
+
|