1 /* 2 3 Boost Software License - Version 1.0 - August 17th, 2003 4 5 Permission is hereby granted, free of charge, to any person or organization 6 obtaining a copy of the software and accompanying documentation covered by 7 this license (the "Software") to use, reproduce, display, distribute, 8 execute, and transmit the Software, and to prepare derivative works of the 9 Software, and to permit third-parties to whom the Software is furnished to 10 do so, all subject to the following: 11 12 The copyright notices in the Software and this entire statement, including 13 the above license grant, this restriction and the following disclaimer, 14 must be included in all copies of the Software, in whole or in part, and 15 all derivative works of the Software, unless such copies or derivative 16 works are solely in the form of machine-executable object code generated by 17 a source language processor. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 DEALINGS IN THE SOFTWARE. 26 27 */ 28 module derelict.vorbis.enc; 29 30 private { 31 import core.stdc.config; 32 import derelict.util.loader; 33 import derelict.util.system; 34 import derelict.vorbis.codec; 35 36 static if(Derelict_OS_Windows) 37 enum libNames = "vorbisenc.dll, libvorbisenc-0.dll, libvorbisenc.dll"; 38 else static if(Derelict_OS_Mac) 39 enum libNames = "libvorbisenc.dylib, libvorbisenc.0.dylib"; 40 else static if(Derelict_OS_Posix) 41 enum libNames = "libvorbisenc.so, libvorbisenc.so.0, libvorbisenc.so.0.3.0"; 42 else 43 static assert(0, "Need to implement libvorbisenc libnames for this operating system."); 44 } 45 46 struct ovectl_ratemanage_arg { 47 int management_active; 48 c_long bitrate_hard_min; 49 c_long bitrate_hard_max; 50 double bitrate_hard_window; 51 c_long bitrate_av_lo; 52 c_long bitrate_av_hi; 53 double bitrate_av_window; 54 double bitrate_av_window_center; 55 } 56 57 struct ovectl_ratemanage2_arg { 58 int management_active; 59 c_long bitrate_limit_min_kbps; 60 c_long bitrate_limit_max_kbps; 61 c_long bitrate_limit_reservoir_bits; 62 double bitrate_limit_reservoir_bias; 63 c_long bitrate_average_kbps; 64 double bitrate_average_damping; 65 } 66 67 enum { 68 OV_ECTL_RATEMANAGE_GET =0x10, 69 OV_ECTL_RATEMANAGE_SET =0x11, 70 OV_ECTL_RATEMANAGE_AVG =0x12, 71 OV_ECTL_RATEMANAGE_HARD =0x13, 72 OV_ECTL_RATEMANAGE2_GET =0x14, 73 OV_ECTL_RATEMANAGE2_SET =0x15, 74 OV_ECTL_LOWPASS_GET =0x20, 75 OV_ECTL_LOWPASS_SET =0x21, 76 OV_ECTL_IBLOCK_GET =0x30, 77 OV_ECTL_IBLOCK_SET =0x31, 78 } 79 80 extern(C) @nogc nothrow { 81 alias da_vorbis_encode_init = int function(vorbis_info*, c_long, c_long, c_long, c_long, c_long); 82 alias da_vorbis_encode_setup_managed = int function(vorbis_info*, c_long, c_long, c_long, c_long, c_long); 83 alias da_vorbis_encode_setup_vbr = int function(vorbis_info*, c_long, c_long, float); 84 alias da_vorbis_encode_init_vbr = int function(vorbis_info*, c_long, c_long, float); 85 alias da_vorbis_encode_setup_init = int function(vorbis_info*); 86 alias da_vorbis_encode_ctl = int function(vorbis_info*, int, void*); 87 } 88 89 __gshared { 90 da_vorbis_encode_init vorbis_encode_init; 91 da_vorbis_encode_setup_managed vorbis_encode_setup_managed; 92 da_vorbis_encode_setup_vbr vorbis_encode_setup_vbr; 93 da_vorbis_encode_init_vbr vorbis_encode_init_vbr; 94 da_vorbis_encode_setup_init vorbis_encode_setup_init; 95 da_vorbis_encode_ctl vorbis_encode_ctl; 96 } 97 98 class DerelictVorbisEncLoader : SharedLibLoader { 99 public this() { 100 super(libNames); 101 } 102 103 protected override void loadSymbols() { 104 bindFunc(cast(void**)&vorbis_encode_init, "vorbis_encode_init"); 105 bindFunc(cast(void**)&vorbis_encode_setup_managed, "vorbis_encode_setup_managed"); 106 bindFunc(cast(void**)&vorbis_encode_setup_vbr, "vorbis_encode_setup_vbr"); 107 bindFunc(cast(void**)&vorbis_encode_init_vbr, "vorbis_encode_init_vbr"); 108 bindFunc(cast(void**)&vorbis_encode_setup_init, "vorbis_encode_setup_init"); 109 bindFunc(cast(void**)&vorbis_encode_ctl, "vorbis_encode_ctl"); 110 } 111 } 112 113 __gshared DerelictVorbisEncLoader DerelictVorbisEnc; 114 115 shared static this() { 116 DerelictVorbisEnc = new DerelictVorbisEncLoader(); 117 }