uh oh im bundling the deps
This commit is contained in:
		
							parent
							
								
									ae28da8d60
								
							
						
					
					
						commit
						ecca301ceb
					
				
					 584 changed files with 119933 additions and 24 deletions
				
			
		
							
								
								
									
										410
									
								
								resources/lib/deps/pyogg/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										410
									
								
								resources/lib/deps/pyogg/__init__.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,410 @@ | |||
| import ctypes | ||||
| from . import ogg | ||||
| from .ogg import PyOggError, PYOGG_OGG_AVAIL | ||||
| 
 | ||||
| from . import vorbis | ||||
| from.vorbis import PYOGG_VORBIS_AVAIL, PYOGG_VORBIS_FILE_AVAIL | ||||
| 
 | ||||
| from . import opus | ||||
| from.opus import PYOGG_OPUS_AVAIL, PYOGG_OPUS_FILE_AVAIL, PYOGG_OPUS_ENC_AVAIL | ||||
| 
 | ||||
| from . import flac | ||||
| from .flac import PYOGG_FLAC_AVAIL | ||||
| 
 | ||||
| from itertools import chain | ||||
| 
 | ||||
| def _to_char_p(string): | ||||
|     try: | ||||
|         return ctypes.c_char_p(string.encode("utf-8")) | ||||
|     except: | ||||
|         return ctypes.c_char_p(string) | ||||
| 
 | ||||
| def _resize_array(array, new_size): | ||||
|     return (array._type_*new_size).from_address(ctypes.addressof(array)) | ||||
| 
 | ||||
| PYOGG_STREAM_BUFFER_SIZE = 8192 | ||||
| 
 | ||||
| if (PYOGG_OGG_AVAIL and PYOGG_VORBIS_AVAIL and PYOGG_VORBIS_FILE_AVAIL): | ||||
|     class VorbisFile: | ||||
|         def __init__(self, path): | ||||
|             vf = vorbis.OggVorbis_File() | ||||
|             error = vorbis.libvorbisfile.ov_fopen(vorbis.to_char_p(path), ctypes.byref(vf)) | ||||
|             if error != 0: | ||||
|                 raise PyOggError("file couldn't be opened or doesn't exist. Error code : {}".format(error)) | ||||
|              | ||||
|             info = vorbis.libvorbisfile.ov_info(ctypes.byref(vf), -1) | ||||
| 
 | ||||
|             self.channels = info.contents.channels | ||||
| 
 | ||||
|             self.frequency = info.contents.rate | ||||
| 
 | ||||
|             array = (ctypes.c_char*4096)() | ||||
| 
 | ||||
|             buffer_ = ctypes.cast(ctypes.pointer(array), ctypes.c_char_p) | ||||
| 
 | ||||
|             self.buffer_array = [] | ||||
| 
 | ||||
|             bitstream = ctypes.c_int() | ||||
|             bitstream_pointer = ctypes.pointer(bitstream) | ||||
| 
 | ||||
|             while True: | ||||
|                 new_bytes = vorbis.libvorbisfile.ov_read(ctypes.byref(vf), buffer_, 4096, 0, 2, 1, bitstream_pointer) | ||||
|                  | ||||
|                 array_ = ctypes.cast(buffer_, ctypes.POINTER(ctypes.c_char*4096)).contents | ||||
|                  | ||||
|                 self.buffer_array.append(array_.raw[:new_bytes]) | ||||
| 
 | ||||
|                 if new_bytes == 0: | ||||
|                     break | ||||
| 
 | ||||
|             self.buffer = b"".join(self.buffer_array) | ||||
| 
 | ||||
|             vorbis.libvorbisfile.ov_clear(ctypes.byref(vf)) | ||||
| 
 | ||||
|             self.buffer_length = len(self.buffer) | ||||
| 
 | ||||
|     class VorbisFileStream: | ||||
|         def __init__(self, path): | ||||
|             self.vf = vorbis.OggVorbis_File() | ||||
|             error = vorbis.ov_fopen(path, ctypes.byref(self.vf)) | ||||
|             if error != 0: | ||||
|                 raise PyOggError("file couldn't be opened or doesn't exist. Error code : {}".format(error)) | ||||
|                             | ||||
|             info = vorbis.ov_info(ctypes.byref(self.vf), -1) | ||||
| 
 | ||||
|             self.channels = info.contents.channels | ||||
| 
 | ||||
|             self.frequency = info.contents.rate | ||||
| 
 | ||||
|             array = (ctypes.c_char*(PYOGG_STREAM_BUFFER_SIZE*self.channels))() | ||||
| 
 | ||||
|             self.buffer_ = ctypes.cast(ctypes.pointer(array), ctypes.c_char_p) | ||||
| 
 | ||||
|             self.bitstream = ctypes.c_int() | ||||
|             self.bitstream_pointer = ctypes.pointer(self.bitstream) | ||||
| 
 | ||||
|             self.exists = True | ||||
| 
 | ||||
|         def __del__(self): | ||||
|             if self.exists: | ||||
|                 vorbis.ov_clear(ctypes.byref(self.vf)) | ||||
|             self.exists = False | ||||
| 
 | ||||
|         def clean_up(self): | ||||
|             vorbis.ov_clear(ctypes.byref(self.vf)) | ||||
| 
 | ||||
|             self.exists = False | ||||
| 
 | ||||
|         def get_buffer(self): | ||||
|             """get_buffer() -> bytesBuffer, bufferLength""" | ||||
|             if not self.exists: | ||||
|                 return None | ||||
|             buffer = [] | ||||
|             total_bytes_written = 0 | ||||
|              | ||||
|             while True: | ||||
|                 new_bytes = vorbis.ov_read(ctypes.byref(self.vf), self.buffer_, PYOGG_STREAM_BUFFER_SIZE*self.channels - total_bytes_written, 0, 2, 1, self.bitstream_pointer) | ||||
|                  | ||||
|                 array_ = ctypes.cast(self.buffer_, ctypes.POINTER(ctypes.c_char*(PYOGG_STREAM_BUFFER_SIZE*self.channels))).contents | ||||
|                  | ||||
|                 buffer.append(array_.raw[:new_bytes]) | ||||
| 
 | ||||
|                 total_bytes_written += new_bytes | ||||
| 
 | ||||
|                 if new_bytes == 0 or total_bytes_written >= PYOGG_STREAM_BUFFER_SIZE*self.channels: | ||||
|                     break | ||||
| 
 | ||||
|             out_buffer = b"".join(buffer) | ||||
| 
 | ||||
|             if total_bytes_written == 0: | ||||
|                 self.clean_up() | ||||
|                 return(None) | ||||
| 
 | ||||
|             return(out_buffer, total_bytes_written) | ||||
| else: | ||||
|     class VorbisFile: | ||||
|         def __init__(*args, **kw): | ||||
|             if not PYOGG_OGG_AVAIL: | ||||
|                 raise PyOggError("The Ogg library wasn't found or couldn't be loaded (maybe you're trying to use 64bit libraries with 32bit Python?)") | ||||
|             raise PyOggError("The Vorbis libraries weren't found or couldn't be loaded (maybe you're trying to use 64bit libraries with 32bit Python?)") | ||||
| 
 | ||||
|     class VorbisFileStream: | ||||
|         def __init__(*args, **kw): | ||||
|             if not PYOGG_OGG_AVAIL: | ||||
|                 raise PyOggError("The Ogg library wasn't found or couldn't be loaded (maybe you're trying to use 64bit libraries with 32bit Python?)") | ||||
|             raise PyOggError("The Vorbis libraries weren't found or couldn't be loaded (maybe you're trying to use 64bit libraries with 32bit Python?)") | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| if (PYOGG_OGG_AVAIL and PYOGG_OPUS_AVAIL and PYOGG_OPUS_FILE_AVAIL): | ||||
|     class OpusFile: | ||||
|         def __init__(self, path): | ||||
|             error = ctypes.c_int() | ||||
| 
 | ||||
|             of = opus.op_open_file(ogg.to_char_p(path), ctypes.pointer(error)) | ||||
| 
 | ||||
|             if error.value != 0: | ||||
|                 raise PyOggError("file couldn't be opened or doesn't exist. Error code : {}".format(error.value)) | ||||
| 
 | ||||
|             self.channels = opus.op_channel_count(of, -1) | ||||
| 
 | ||||
|             pcm_size = opus.op_pcm_total(of, -1) | ||||
| 
 | ||||
|             samples_read = ctypes.c_int(0) | ||||
| 
 | ||||
|             bfarr_t = opus.opus_int16*(pcm_size*self.channels) | ||||
| 
 | ||||
|             self.buffer = ctypes.cast(ctypes.pointer(bfarr_t()),opus.opus_int16_p) | ||||
| 
 | ||||
|             ptr = ctypes.cast(ctypes.pointer(self.buffer), ctypes.POINTER(ctypes.c_void_p)) | ||||
| 
 | ||||
|             ptr_init = ptr.contents.value | ||||
| 
 | ||||
|             while samples_read.value < pcm_size: | ||||
|                 ptr.contents.value = ptr_init + samples_read.value*self.channels*2 | ||||
|                 ns = opus.op_read(of, self.buffer , pcm_size*self.channels,ogg.c_int_p()) | ||||
|                 samples_read.value += ns | ||||
| 
 | ||||
|             ptr.contents.value = ptr_init | ||||
| 
 | ||||
|             del ptr | ||||
| 
 | ||||
|             opus.op_free(of) | ||||
| 
 | ||||
|             self.buffer_length = samples_read.value*self.channels*2 | ||||
| 
 | ||||
|             self.frequency = 48000 | ||||
| 
 | ||||
|     class OpusFileStream: | ||||
|         def __init__(self, path): | ||||
|             error = ctypes.c_int() | ||||
| 
 | ||||
|             self.of = opus.op_open_file(ogg.to_char_p(path), ctypes.pointer(error)) | ||||
| 
 | ||||
|             if error.value != 0: | ||||
|                 raise PyOggError("file couldn't be opened or doesn't exist. Error code : {}".format(error.value)) | ||||
| 
 | ||||
|             self.channels = opus.op_channel_count(self.of, -1) | ||||
| 
 | ||||
|             self.pcm_size = opus.op_pcm_total(self.of, -1) | ||||
| 
 | ||||
|             self.frequency = 48000 | ||||
| 
 | ||||
|             self.bfarr_t = opus.opus_int16*(PYOGG_STREAM_BUFFER_SIZE*self.channels*2) | ||||
| 
 | ||||
|             self.buffer = ctypes.cast(ctypes.pointer(self.bfarr_t()),opus.opus_int16_p) | ||||
| 
 | ||||
|             self.ptr = ctypes.cast(ctypes.pointer(self.buffer), ctypes.POINTER(ctypes.c_void_p)) | ||||
| 
 | ||||
|             self.ptr_init = self.ptr.contents.value | ||||
| 
 | ||||
|         def get_buffer(self): | ||||
|             if not hasattr(self, 'ptr'): | ||||
|                 return None | ||||
| 
 | ||||
|             samples_read = ctypes.c_int(0) | ||||
|             while True: | ||||
|                 self.ptr.contents.value = self.ptr_init + samples_read.value*self.channels*2 | ||||
|                 ns = opus.op_read(self.of, self.buffer , PYOGG_STREAM_BUFFER_SIZE*self.channels,ogg.c_int_p()) | ||||
|                 if ns == 0: | ||||
|                     break | ||||
|                 samples_read.value += ns | ||||
|                 if samples_read.value*self.channels*2 + ns >= PYOGG_STREAM_BUFFER_SIZE: | ||||
|                     break | ||||
| 
 | ||||
|             if samples_read.value == 0: | ||||
|                 self.clean_up() | ||||
|                 return None | ||||
| 
 | ||||
|             self.ptr.contents.value = self.ptr_init | ||||
| 
 | ||||
|             buf = ctypes.pointer(self.bfarr_t()) | ||||
| 
 | ||||
|             buf[0] = ctypes.cast(self.buffer, ctypes.POINTER(self.bfarr_t))[0] | ||||
| 
 | ||||
|             return(buf, samples_read.value*self.channels*2) | ||||
| 
 | ||||
|         def clean_up(self): | ||||
|             self.ptr.contents.value = self.ptr_init | ||||
| 
 | ||||
|             del self.ptr | ||||
| 
 | ||||
|             opus.op_free(self.of) | ||||
| 
 | ||||
| else: | ||||
|     class OpusFile: | ||||
|         def __init__(*args, **kw): | ||||
|             if not PYOGG_OGG_AVAIL: | ||||
|                 raise PyOggError("The Ogg library wasn't found or couldn't be loaded (maybe you're trying to use 64bit libraries with 32bit Python?)") | ||||
|             raise PyOggError("The Opus libraries weren't found or couldn't be loaded (maybe you're trying to use 64bit libraries with 32bit Python?)") | ||||
| 
 | ||||
|     class OpusFileStream: | ||||
|         def __init__(*args, **kw): | ||||
|             if not PYOGG_OGG_AVAIL: | ||||
|                 raise PyOggError("The Ogg library wasn't found or couldn't be loaded (maybe you're trying to use 64bit libraries with 32bit Python?)") | ||||
|             raise PyOggError("The Opus libraries weren't found or couldn't be loaded (maybe you're trying to use 64bit libraries with 32bit Python?)") | ||||
| 
 | ||||
| if PYOGG_FLAC_AVAIL: | ||||
|     class FlacFile: | ||||
|         def write_callback(self,decoder, frame, buffer, client_data): | ||||
|             multi_channel_buf = _resize_array(buffer.contents, self.channels) | ||||
|             arr_size = frame.contents.header.blocksize | ||||
|             if frame.contents.header.channels >= 2: | ||||
|                 arrays = [] | ||||
|                 for i in range(frame.contents.header.channels): | ||||
|                     arr = ctypes.cast(multi_channel_buf[i], ctypes.POINTER(flac.FLAC__int32*arr_size)).contents | ||||
|                     arrays.append(arr[:]) | ||||
| 
 | ||||
|                 arr = list(chain.from_iterable(zip(*arrays))) | ||||
|                  | ||||
|                 self.buffer[self.buffer_pos : self.buffer_pos + len(arr)] = arr[:] | ||||
|                 self.buffer_pos += len(arr) | ||||
|                  | ||||
|             else: | ||||
|                 arr = ctypes.cast(multi_channel_buf[0], ctypes.POINTER(flac.FLAC__int32*arr_size)).contents | ||||
|                 self.buffer[self.buffer_pos : self.buffer_pos + arr_size] = arr[:] | ||||
|                 self.buffer_pos += arr_size | ||||
|             return 0 | ||||
| 
 | ||||
|         def metadata_callback(self,decoder, metadata, client_data): | ||||
|             if not self.buffer: | ||||
|                 self.total_samples = metadata.contents.data.stream_info.total_samples | ||||
|                 self.channels = metadata.contents.data.stream_info.channels | ||||
|                 self.buffer = (flac.FLAC__int16*(self.total_samples * self.channels * 2))() | ||||
|                 self.frequency = metadata.contents.data.stream_info.sample_rate | ||||
| 
 | ||||
|         def error_callback(self,decoder, status, client_data): | ||||
|             raise PyOggError("An error occured during the process of decoding. Status enum: {}".format(flac.FLAC__StreamDecoderErrorStatusEnum[status])) | ||||
|          | ||||
|         def __init__(self, path): | ||||
|             self.decoder = flac.FLAC__stream_decoder_new() | ||||
| 
 | ||||
|             self.client_data = ctypes.c_void_p() | ||||
| 
 | ||||
|             self.channels = None | ||||
| 
 | ||||
|             self.frequency = None | ||||
| 
 | ||||
|             self.total_samples = None | ||||
| 
 | ||||
|             self.buffer = None | ||||
| 
 | ||||
|             self.buffer_pos = 0 | ||||
| 
 | ||||
|             write_callback_ = flac.FLAC__StreamDecoderWriteCallback(self.write_callback) | ||||
| 
 | ||||
|             metadata_callback_ = flac.FLAC__StreamDecoderMetadataCallback(self.metadata_callback) | ||||
| 
 | ||||
|             error_callback_ = flac.FLAC__StreamDecoderErrorCallback(self.error_callback) | ||||
| 
 | ||||
|             init_status = flac.FLAC__stream_decoder_init_file(self.decoder, | ||||
|                                           _to_char_p(path), | ||||
|                                           write_callback_, | ||||
|                                           metadata_callback_, | ||||
|                                           error_callback_, | ||||
|                                           self.client_data) | ||||
| 
 | ||||
|             if init_status: # error | ||||
|                 raise PyOggError("An error occured when trying to open '{}': {}".format(path, flac.FLAC__StreamDecoderInitStatusEnum[init_status])) | ||||
| 
 | ||||
|             metadata_status = (flac.FLAC__stream_decoder_process_until_end_of_metadata(self.decoder)) | ||||
|             if not metadata_status: # error | ||||
|                 raise PyOggError("An error occured when trying to decode the metadata of {}".format(path)) | ||||
|              | ||||
|             stream_status = (flac.FLAC__stream_decoder_process_until_end_of_stream(self.decoder)) | ||||
|             if not stream_status: # error | ||||
|                 raise PyOggError("An error occured when trying to decode the audio stream of {}".format(path)) | ||||
| 
 | ||||
|             flac.FLAC__stream_decoder_finish(self.decoder) | ||||
| 
 | ||||
|             self.buffer_length = len(self.buffer) | ||||
| 
 | ||||
|     class FlacFileStream: | ||||
|         def write_callback(self,decoder, frame, buffer, client_data): | ||||
|             multi_channel_buf = _resize_array(buffer.contents, self.channels) | ||||
|             arr_size = frame.contents.header.blocksize | ||||
|             if frame.contents.header.channels >= 2: | ||||
|                 arrays = [] | ||||
|                 for i in range(frame.contents.header.channels): | ||||
|                     arr = ctypes.cast(multi_channel_buf[i], ctypes.POINTER(flac.FLAC__int32*arr_size)).contents | ||||
|                     arrays.append(arr[:]) | ||||
| 
 | ||||
|                 arr = list(chain.from_iterable(zip(*arrays))) | ||||
|                  | ||||
|                 self.buffer = (flac.FLAC__int16*len(arr))(*arr) | ||||
|                 self.bytes_written = len(arr) * 2 | ||||
|                  | ||||
|             else: | ||||
|                 arr = ctypes.cast(multi_channel_buf[0], ctypes.POINTER(flac.FLAC__int32*arr_size)).contents | ||||
|                 self.buffer = (flac.FLAC__int16*len(arr))(*arr[:]) | ||||
|                 self.bytes_written = arr_size * 2 | ||||
|             return 0 | ||||
| 
 | ||||
|         def metadata_callback(self,decoder, metadata, client_data): | ||||
|             self.total_samples = metadata.contents.data.stream_info.total_samples | ||||
|             self.channels = metadata.contents.data.stream_info.channels | ||||
|             self.frequency = metadata.contents.data.stream_info.sample_rate | ||||
| 
 | ||||
|         def error_callback(self,decoder, status, client_data): | ||||
|             raise PyOggError("An error occured during the process of decoding. Status enum: {}".format(flac.FLAC__StreamDecoderErrorStatusEnum[status])) | ||||
|          | ||||
|         def __init__(self, path): | ||||
|             self.decoder = flac.FLAC__stream_decoder_new() | ||||
| 
 | ||||
|             self.client_data = ctypes.c_void_p() | ||||
| 
 | ||||
|             self.channels = None | ||||
| 
 | ||||
|             self.frequency = None | ||||
| 
 | ||||
|             self.total_samples = None | ||||
| 
 | ||||
|             self.buffer = None | ||||
| 
 | ||||
|             self.bytes_written = None | ||||
| 
 | ||||
|             self.write_callback_ = flac.FLAC__StreamDecoderWriteCallback(self.write_callback) | ||||
| 
 | ||||
|             self.metadata_callback_ = flac.FLAC__StreamDecoderMetadataCallback(self.metadata_callback) | ||||
| 
 | ||||
|             self.error_callback_ = flac.FLAC__StreamDecoderErrorCallback(self.error_callback) | ||||
| 
 | ||||
|             init_status = flac.FLAC__stream_decoder_init_file(self.decoder, | ||||
|                                           _to_char_p(path), | ||||
|                                           self.write_callback_, | ||||
|                                           self.metadata_callback_, | ||||
|                                           self.error_callback_, | ||||
|                                           self.client_data) | ||||
| 
 | ||||
|             if init_status: # error | ||||
|                 raise PyOggError("An error occured when trying to open '{}': {}".format(path, flac.FLAC__StreamDecoderInitStatusEnum[init_status])) | ||||
| 
 | ||||
|             metadata_status = (flac.FLAC__stream_decoder_process_until_end_of_metadata(self.decoder)) | ||||
|             if not metadata_status: # error | ||||
|                 raise PyOggError("An error occured when trying to decode the metadata of {}".format(path)) | ||||
| 
 | ||||
|         def get_buffer(self): | ||||
|             if (flac.FLAC__stream_decoder_get_state(self.decoder) == 4): # end of stream | ||||
|                 return None | ||||
|             stream_status = (flac.FLAC__stream_decoder_process_single(self.decoder)) | ||||
|             if not stream_status: # error | ||||
|                 raise PyOggError("An error occured when trying to decode the audio stream of {}".format(path)) | ||||
| 
 | ||||
|             buffer_ = ctypes.pointer(self.buffer) | ||||
| 
 | ||||
|             return(buffer_, self.bytes_written) | ||||
| 
 | ||||
|         def clean_up(self): | ||||
|             flac.FLAC__stream_decoder_finish(self.decoder) | ||||
| else: | ||||
|     class FlacFile: | ||||
|         def __init__(*args, **kw): | ||||
|             raise PyOggError("The FLAC libraries weren't found or couldn't be loaded (maybe you're trying to use 64bit libraries with 32bit Python?)") | ||||
| 
 | ||||
|     class FlacFileStream: | ||||
|         def __init__(*args, **kw): | ||||
|             raise PyOggError("The FLAC libraries weren't found or couldn't be loaded (maybe you're trying to use 64bit libraries with 32bit Python?)") | ||||
| 
 | ||||
| def pyoggSetStreamBufferSize(size): | ||||
|     global PYOGG_STREAM_BUFFER_SIZE | ||||
|     PYOGG_STREAM_BUFFER_SIZE = size | ||||
							
								
								
									
										2013
									
								
								resources/lib/deps/pyogg/flac.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2013
									
								
								resources/lib/deps/pyogg/flac.py
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										91
									
								
								resources/lib/deps/pyogg/library_loader.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								resources/lib/deps/pyogg/library_loader.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,91 @@ | |||
| import ctypes | ||||
| import ctypes.util | ||||
| import os | ||||
| import sys | ||||
| import platform | ||||
| 
 | ||||
| _here = os.path.dirname(__file__) | ||||
| 
 | ||||
| class ExternalLibraryError(Exception): | ||||
|     pass | ||||
| 
 | ||||
| architecture = platform.architecture()[0] | ||||
| 
 | ||||
| _windows_styles = ["{}", "lib{}", "lib{}_dynamic", "{}_dynamic"] | ||||
| 
 | ||||
| _other_styles = ["{}", "lib{}"] | ||||
| 
 | ||||
| if architecture == "32bit": | ||||
|     for arch_style in ["32bit", "32" "86", "win32", "x86", "_x86", "_32", "_win32", "_32bit"]: | ||||
|         for style in ["{}", "lib{}"]: | ||||
|             _windows_styles.append(style.format("{}"+arch_style)) | ||||
|              | ||||
| elif architecture == "64bit": | ||||
|     for arch_style in ["64bit", "64" "86_64", "amd64", "win_amd64", "x86_64", "_x86_64", "_64", "_amd64", "_64bit"]: | ||||
|         for style in ["{}", "lib{}"]: | ||||
|             _windows_styles.append(style.format("{}"+arch_style)) | ||||
| 
 | ||||
| _loaded_libraries = {} | ||||
| 
 | ||||
| run_tests = lambda lib, tests: [f(lib) for f in tests] | ||||
| 
 | ||||
| class ExternalLibrary: | ||||
|     @staticmethod | ||||
|     def load(name, paths = None, tests = []): | ||||
|         if name in _loaded_libraries: | ||||
|             return _loaded_libraries[name] | ||||
|         if sys.platform == "win32": | ||||
|             lib = ExternalLibrary.load_windows(name, paths, tests) | ||||
|             _loaded_libraries[name] = lib | ||||
|             return lib | ||||
|         else: | ||||
|             lib = ExternalLibrary.load_other(name, paths, tests) | ||||
|             _loaded_libraries[name] = lib | ||||
|             return lib | ||||
| 
 | ||||
|     @staticmethod | ||||
|     def load_other(name, paths = None, tests = []): | ||||
|         os.environ["PATH"] += ";" + ";".join((os.getcwd(), _here)) | ||||
|         if paths: os.environ["PATH"] += ";" + ";".join(paths) | ||||
| 
 | ||||
|         for style in _other_styles: | ||||
|             candidate = style.format(name) | ||||
|             library = ctypes.util.find_library(candidate) | ||||
|             if library: | ||||
|                 try: | ||||
|                     lib = ctypes.CDLL(library) | ||||
|                     if tests and all(run_tests(lib, tests)): | ||||
|                         return lib | ||||
|                 except: | ||||
|                     pass | ||||
| 
 | ||||
|     @staticmethod | ||||
|     def load_windows(name, paths = None, tests = []): | ||||
|         os.environ["PATH"] += ";" + ";".join((os.getcwd(), _here)) | ||||
|         if paths: os.environ["PATH"] += ";" + ";".join(paths) | ||||
|          | ||||
|         not_supported = [] # libraries that were found, but are not supported | ||||
|         for style in _windows_styles: | ||||
|             candidate = style.format(name) | ||||
|             library = ctypes.util.find_library(candidate) | ||||
|             if library: | ||||
|                 try: | ||||
|                     lib = ctypes.CDLL(library) | ||||
|                     if tests and all(run_tests(lib, tests)): | ||||
|                         return lib | ||||
|                     not_supported.append(library) | ||||
|                 except WindowsError: | ||||
|                     pass | ||||
|                 except OSError: | ||||
|                     not_supported.append(library) | ||||
|              | ||||
| 
 | ||||
|         if not_supported: | ||||
|             raise ExternalLibraryError("library '{}' couldn't be loaded, because the following candidates were not supported:".format(name) | ||||
|                                  + ("\n{}" * len(not_supported)).format(*not_supported)) | ||||
| 
 | ||||
|         raise ExternalLibraryError("library '{}' couldn't be loaded".format(name)) | ||||
| 
 | ||||
|          | ||||
| 
 | ||||
|          | ||||
							
								
								
									
										645
									
								
								resources/lib/deps/pyogg/ogg.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										645
									
								
								resources/lib/deps/pyogg/ogg.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,645 @@ | |||
| ############################################################ | ||||
| # Ogg license:                                             # | ||||
| ############################################################ | ||||
| """ | ||||
| Copyright (c) 2002, Xiph.org Foundation | ||||
| 
 | ||||
| Redistribution and use in source and binary forms, with or without | ||||
| modification, are permitted provided that the following conditions | ||||
| are met: | ||||
| 
 | ||||
| - Redistributions of source code must retain the above copyright | ||||
| notice, this list of conditions and the following disclaimer. | ||||
| 
 | ||||
| - Redistributions in binary form must reproduce the above copyright | ||||
| notice, this list of conditions and the following disclaimer in the | ||||
| documentation and/or other materials provided with the distribution. | ||||
| 
 | ||||
| - Neither the name of the Xiph.org Foundation nor the names of its | ||||
| contributors may be used to endorse or promote products derived from | ||||
| this software without specific prior written permission. | ||||
| 
 | ||||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION | ||||
| OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| """ | ||||
| 
 | ||||
| import ctypes | ||||
| from ctypes import c_int, c_int8, c_int16, c_int32, c_int64, c_uint, c_uint8, c_uint16, c_uint32, c_uint64, c_float, c_long, c_ulong, c_char, c_char_p, c_ubyte, c_longlong, c_ulonglong, c_size_t, c_void_p, c_double, POINTER, pointer, cast | ||||
| import ctypes.util | ||||
| import sys | ||||
| from traceback import print_exc as _print_exc | ||||
| import os | ||||
| 
 | ||||
| from .library_loader import ExternalLibrary, ExternalLibraryError | ||||
| 
 | ||||
| class PyOggError(Exception): | ||||
|     pass | ||||
| 
 | ||||
| def get_raw_libname(name): | ||||
|     name = os.path.splitext(name)[0].lower() | ||||
|     for x in "0123456789._- ":name=name.replace(x,"") | ||||
|     return name | ||||
| 
 | ||||
| if sys.version_info.major > 2: | ||||
|     to_char_p = lambda s: s.encode('utf-8') | ||||
| else: | ||||
|     to_char_p = lambda s: s | ||||
| 
 | ||||
| __here = os.getcwd() | ||||
| 
 | ||||
| libogg = None | ||||
| 
 | ||||
| try: | ||||
|     libogg = ExternalLibrary.load("ogg", tests = [lambda lib: hasattr(lib, "oggpack_writeinit")]) | ||||
| except ExternalLibraryError: | ||||
|     pass | ||||
| except: | ||||
|     _print_exc() | ||||
| 
 | ||||
| if libogg: | ||||
|     PYOGG_OGG_AVAIL = True | ||||
| else: | ||||
|     PYOGG_OGG_AVAIL = False | ||||
| 
 | ||||
| if PYOGG_OGG_AVAIL: | ||||
| 
 | ||||
|     # ctypes | ||||
|     c_ubyte_p = POINTER(c_ubyte) | ||||
|     c_uchar = c_ubyte | ||||
|     c_uchar_p = c_ubyte_p | ||||
|     c_float_p = POINTER(c_float) | ||||
|     c_float_p_p = POINTER(c_float_p) | ||||
|     c_float_p_p_p = POINTER(c_float_p_p) | ||||
|     c_char_p_p = POINTER(c_char_p) | ||||
|     c_int_p = POINTER(c_int) | ||||
|     c_long_p = POINTER(c_long) | ||||
| 
 | ||||
|     # os_types | ||||
|     ogg_int16_t = c_int16 | ||||
|     ogg_uint16_t = c_uint16 | ||||
|     ogg_int32_t = c_int32 | ||||
|     ogg_uint32_t = c_uint32 | ||||
|     ogg_int64_t = c_int64 | ||||
|     ogg_uint64_t = c_uint64 | ||||
|     ogg_int64_t_p = POINTER(ogg_int64_t) | ||||
| 
 | ||||
|     # ogg | ||||
|     class ogg_iovec_t(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct ogg_iovec_t; | ||||
|         """ | ||||
|         _fields_ = [("iov_base", c_void_p), | ||||
|                     ("iov_len", c_size_t)] | ||||
| 
 | ||||
|     class oggpack_buffer(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct oggpack_buffer; | ||||
|         """ | ||||
|         _fields_ = [("endbyte", c_long), | ||||
|                     ("endbit", c_int), | ||||
|                     ("buffer", c_uchar_p), | ||||
|                     ("ptr", c_uchar_p), | ||||
|                     ("storage", c_long)] | ||||
| 
 | ||||
|     class ogg_page(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct ogg_page; | ||||
|         """ | ||||
|         _fields_ = [("header", c_uchar_p), | ||||
|                     ("header_len", c_long), | ||||
|                     ("body", c_uchar_p), | ||||
|                     ("body_len", c_long)] | ||||
| 
 | ||||
|     class ogg_stream_state(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct ogg_stream_state; | ||||
|         """ | ||||
|         _fields_ = [("body_data", c_uchar_p), | ||||
|                     ("body_storage", c_long), | ||||
|                     ("body_fill", c_long), | ||||
|                     ("body_returned", c_long), | ||||
| 
 | ||||
|                     ("lacing_vals", c_int), | ||||
|                     ("granule_vals", ogg_int64_t), | ||||
| 
 | ||||
|                     ("lacing_storage", c_long), | ||||
|                     ("lacing_fill", c_long), | ||||
|                     ("lacing_packet", c_long), | ||||
|                     ("lacing_returned", c_long), | ||||
| 
 | ||||
|                     ("header", c_uchar*282), | ||||
|                     ("header_fill", c_int), | ||||
| 
 | ||||
|                     ("e_o_s", c_int), | ||||
|                     ("b_o_s", c_int), | ||||
| 
 | ||||
|                     ("serialno", c_long), | ||||
|                     ("pageno", c_long), | ||||
|                     ("packetno", ogg_int64_t), | ||||
|                     ("granulepos", ogg_int64_t)] | ||||
| 
 | ||||
|     class ogg_packet(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct ogg_packet; | ||||
|         """ | ||||
|         _fields_ = [("packet", c_uchar_p), | ||||
|                     ("bytes", c_long), | ||||
|                     ("b_o_s", c_long), | ||||
|                     ("e_o_s", c_long), | ||||
| 
 | ||||
|                     ("granulepos", ogg_int64_t), | ||||
| 
 | ||||
|                     ("packetno", ogg_int64_t)] | ||||
| 
 | ||||
|     class ogg_sync_state(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct ogg_sync_state; | ||||
|         """ | ||||
|         _fields_ = [("data", c_uchar_p), | ||||
|                     ("storage", c_int), | ||||
|                     ("fill", c_int), | ||||
|                     ("returned", c_int), | ||||
| 
 | ||||
|                     ("unsynched", c_int), | ||||
|                     ("headerbytes", c_int), | ||||
|                     ("bodybytes", c_int)] | ||||
| 
 | ||||
|     b_p = POINTER(oggpack_buffer) | ||||
|     oy_p = POINTER(ogg_sync_state) | ||||
|     op_p = POINTER(ogg_packet) | ||||
|     og_p = POINTER(ogg_page) | ||||
|     os_p = POINTER(ogg_stream_state) | ||||
|     iov_p = POINTER(ogg_iovec_t) | ||||
|          | ||||
|     libogg.oggpack_writeinit.restype = None | ||||
|     libogg.oggpack_writeinit.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpack_writeinit(b): | ||||
|         libogg.oggpack_writeinit(b) | ||||
| 
 | ||||
|     try: | ||||
|         libogg.oggpack_writecheck.restype = c_int | ||||
|         libogg.oggpack_writecheck.argtypes = [b_p] | ||||
|         def oggpack_writecheck(b): | ||||
|             libogg.oggpack_writecheck(b) | ||||
|     except: | ||||
|         pass | ||||
| 
 | ||||
|     libogg.oggpack_writetrunc.restype = None | ||||
|     libogg.oggpack_writetrunc.argtypes = [b_p, c_long] | ||||
| 
 | ||||
|     def oggpack_writetrunc(b, bits): | ||||
|         libogg.oggpack_writetrunc(b, bits) | ||||
| 
 | ||||
|     libogg.oggpack_writealign.restype = None | ||||
|     libogg.oggpack_writealign.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpack_writealign(b): | ||||
|         libogg.oggpack_writealign(b) | ||||
| 
 | ||||
|     libogg.oggpack_writecopy.restype = None | ||||
|     libogg.oggpack_writecopy.argtypes = [b_p, c_void_p, c_long] | ||||
| 
 | ||||
|     def oggpack_writecopy(b, source, bits): | ||||
|         libogg.oggpack_writecopy(b, source, bits) | ||||
| 
 | ||||
|     libogg.oggpack_reset.restype = None | ||||
|     libogg.oggpack_reset.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpack_reset(b): | ||||
|         libogg.oggpack_reset(b) | ||||
| 
 | ||||
|     libogg.oggpack_writeclear.restype = None | ||||
|     libogg.oggpack_writeclear.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpack_writeclear(b): | ||||
|         libogg.oggpack_writeclear(b) | ||||
| 
 | ||||
|     libogg.oggpack_readinit.restype = None | ||||
|     libogg.oggpack_readinit.argtypes = [b_p, c_uchar_p, c_int] | ||||
| 
 | ||||
|     def oggpack_readinit(b, buf, bytes): | ||||
|         libogg.oggpack_readinit(b, buf, bytes) | ||||
| 
 | ||||
|     libogg.oggpack_write.restype = None | ||||
|     libogg.oggpack_write.argtypes = [b_p, c_ulong, c_int] | ||||
| 
 | ||||
|     def oggpack_write(b, value, bits): | ||||
|         libogg.oggpack_write(b, value, bits) | ||||
| 
 | ||||
|     libogg.oggpack_look.restype = c_long | ||||
|     libogg.oggpack_look.argtypes = [b_p, c_int] | ||||
| 
 | ||||
|     def oggpack_look(b, bits): | ||||
|         return libogg.oggpack_look(b, bits) | ||||
| 
 | ||||
|     libogg.oggpack_look1.restype = c_long | ||||
|     libogg.oggpack_look1.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpack_look1(b): | ||||
|         return libogg.oggpack_look1(b) | ||||
| 
 | ||||
|     libogg.oggpack_adv.restype = None | ||||
|     libogg.oggpack_adv.argtypes = [b_p, c_int] | ||||
| 
 | ||||
|     def oggpack_adv(b, bits): | ||||
|         libogg.oggpack_adv(b, bits) | ||||
| 
 | ||||
|     libogg.oggpack_adv1.restype = None | ||||
|     libogg.oggpack_adv1.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpack_adv1(b): | ||||
|         libogg.oggpack_adv1(b) | ||||
| 
 | ||||
|     libogg.oggpack_read.restype = c_long | ||||
|     libogg.oggpack_read.argtypes = [b_p, c_int] | ||||
| 
 | ||||
|     def oggpack_read(b, bits): | ||||
|         return libogg.oggpack_read(b, bits) | ||||
| 
 | ||||
|     libogg.oggpack_read1.restype = c_long | ||||
|     libogg.oggpack_read1.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpack_read1(b): | ||||
|         return libogg.oggpack_read1(b) | ||||
| 
 | ||||
|     libogg.oggpack_bytes.restype = c_long | ||||
|     libogg.oggpack_bytes.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpack_bytes(b): | ||||
|         return libogg.oggpack_bytes(b) | ||||
| 
 | ||||
|     libogg.oggpack_bits.restype = c_long | ||||
|     libogg.oggpack_bits.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpack_bits(b): | ||||
|         return libogg.oggpack_bits(b) | ||||
| 
 | ||||
|     libogg.oggpack_get_buffer.restype = c_uchar_p | ||||
|     libogg.oggpack_get_buffer.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpack_get_buffer(b): | ||||
|         return libogg.oggpack_get_buffer(b) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libogg.oggpackB_writeinit.restype = None | ||||
|     libogg.oggpackB_writeinit.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpackB_writeinit(b): | ||||
|         libogg.oggpackB_writeinit(b) | ||||
|      | ||||
|     try: | ||||
|         libogg.oggpackB_writecheck.restype = c_int | ||||
|         libogg.oggpackB_writecheck.argtypes = [b_p] | ||||
| 
 | ||||
|         def oggpackB_writecheck(b): | ||||
|             return libogg.oggpackB_writecheck(b)  | ||||
|     except: | ||||
|         pass | ||||
| 
 | ||||
|     libogg.oggpackB_writetrunc.restype = None | ||||
|     libogg.oggpackB_writetrunc.argtypes = [b_p, c_long] | ||||
| 
 | ||||
|     def oggpackB_writetrunc(b, bits): | ||||
|         libogg.oggpackB_writetrunc(b, bits) | ||||
| 
 | ||||
|     libogg.oggpackB_writealign.restype = None | ||||
|     libogg.oggpackB_writealign.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpackB_writealign(b): | ||||
|         libogg.oggpackB_writealign(b) | ||||
| 
 | ||||
|     libogg.oggpackB_writecopy.restype = None | ||||
|     libogg.oggpackB_writecopy.argtypes = [b_p, c_void_p, c_long] | ||||
| 
 | ||||
|     def oggpackB_writecopy(b, source, bits): | ||||
|         libogg.oggpackB_writecopy(b, source, bits) | ||||
| 
 | ||||
|     libogg.oggpackB_reset.restype = None | ||||
|     libogg.oggpackB_reset.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpackB_reset(b): | ||||
|         libogg.oggpackB_reset(b) | ||||
| 
 | ||||
|     libogg.oggpackB_reset.restype = None | ||||
|     libogg.oggpackB_writeclear.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpackB_reset(b): | ||||
|         libogg.oggpackB_reset(b) | ||||
| 
 | ||||
|     libogg.oggpackB_readinit.restype = None | ||||
|     libogg.oggpackB_readinit.argtypes = [b_p, c_uchar_p, c_int] | ||||
| 
 | ||||
|     def oggpackB_readinit(b, buf, bytes): | ||||
|         libogg.oggpackB_readinit(b, buf, bytes) | ||||
| 
 | ||||
|     libogg.oggpackB_write.restype = None | ||||
|     libogg.oggpackB_write.argtypes = [b_p, c_ulong, c_int] | ||||
| 
 | ||||
|     def oggpackB_write(b, value, bits): | ||||
|         libogg.oggpackB_write(b, value, bits) | ||||
| 
 | ||||
|     libogg.oggpackB_look.restype = c_long | ||||
|     libogg.oggpackB_look.argtypes = [b_p, c_int] | ||||
| 
 | ||||
|     def oggpackB_look(b, bits): | ||||
|         return libogg.oggpackB_look(b, bits) | ||||
| 
 | ||||
|     libogg.oggpackB_look1.restype = c_long | ||||
|     libogg.oggpackB_look1.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpackB_look1(b): | ||||
|         return libogg.oggpackB_look1(b) | ||||
| 
 | ||||
|     libogg.oggpackB_adv.restype = None | ||||
|     libogg.oggpackB_adv.argtypes = [b_p, c_int] | ||||
| 
 | ||||
|     def oggpackB_adv(b, bits): | ||||
|         libogg.oggpackB_adv(b, bits) | ||||
| 
 | ||||
|     libogg.oggpackB_adv1.restype = None | ||||
|     libogg.oggpackB_adv1.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpackB_adv1(b): | ||||
|         libogg.oggpackB_adv1(b) | ||||
| 
 | ||||
|     libogg.oggpackB_read.restype = c_long | ||||
|     libogg.oggpackB_read.argtypes = [b_p, c_int] | ||||
| 
 | ||||
|     def oggpackB_read(b, bits): | ||||
|         return libogg.oggpackB_read(b, bits) | ||||
| 
 | ||||
|     libogg.oggpackB_read1.restype = c_long | ||||
|     libogg.oggpackB_read1.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpackB_read1(b): | ||||
|         return libogg.oggpackB_read1(b) | ||||
| 
 | ||||
|     libogg.oggpackB_bytes.restype = c_long | ||||
|     libogg.oggpackB_bytes.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpackB_bytes(b): | ||||
|         return libogg.oggpackB_bytes(b) | ||||
| 
 | ||||
|     libogg.oggpackB_bits.restype = c_long | ||||
|     libogg.oggpackB_bits.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpackB_bits(b): | ||||
|         return libogg.oggpackB_bits(b) | ||||
| 
 | ||||
|     libogg.oggpackB_get_buffer.restype = c_uchar_p | ||||
|     libogg.oggpackB_get_buffer.argtypes = [b_p] | ||||
| 
 | ||||
|     def oggpackB_get_buffer(b): | ||||
|         return libogg.oggpackB_get_buffer(b) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libogg.ogg_stream_packetin.restype = c_int | ||||
|     libogg.ogg_stream_packetin.argtypes = [os_p, op_p] | ||||
| 
 | ||||
|     def ogg_stream_packetin(os, op): | ||||
|         return libogg.ogg_stream_packetin(os, op) | ||||
| 
 | ||||
|     try: | ||||
|         libogg.ogg_stream_iovecin.restype = c_int | ||||
|         libogg.ogg_stream_iovecin.argtypes = [os_p, iov_p, c_int, c_long, ogg_int64_t] | ||||
| 
 | ||||
|         def ogg_stream_iovecin(os, iov, count, e_o_s, granulepos): | ||||
|             return libogg.ogg_stream_iovecin(os, iov, count, e_o_s, granulepos) | ||||
|     except: | ||||
|         pass | ||||
| 
 | ||||
|     libogg.ogg_stream_pageout.restype = c_int | ||||
|     libogg.ogg_stream_pageout.argtypes = [os_p, og_p] | ||||
| 
 | ||||
|     def ogg_stream_pageout(os, og): | ||||
|         return libogg.ogg_stream_pageout(os, og) | ||||
| 
 | ||||
|     try: | ||||
|         libogg.ogg_stream_pageout_fill.restype = c_int | ||||
|         libogg.ogg_stream_pageout_fill.argtypes = [os_p, og_p, c_int] | ||||
|         def ogg_stream_pageout_fill(os, og, nfill): | ||||
|             return libogg.ogg_stream_pageout_fill(os, og, nfill) | ||||
|     except: | ||||
|         pass | ||||
| 
 | ||||
|     libogg.ogg_stream_flush.restype = c_int | ||||
|     libogg.ogg_stream_flush.argtypes = [os_p, og_p] | ||||
| 
 | ||||
|     def ogg_stream_flush(os, og): | ||||
|         return libogg.ogg_stream_flush(os, og) | ||||
| 
 | ||||
|     try: | ||||
|         libogg.ogg_stream_flush_fill.restype = c_int | ||||
|         libogg.ogg_stream_flush_fill.argtypes = [os_p, og_p, c_int] | ||||
|         def ogg_stream_flush_fill(os, og, nfill): | ||||
|             return libogg.ogg_stream_flush_fill(os, og, nfill) | ||||
|     except: | ||||
|         pass | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libogg.ogg_sync_init.restype = c_int | ||||
|     libogg.ogg_sync_init.argtypes = [oy_p] | ||||
| 
 | ||||
|     def ogg_sync_init(oy): | ||||
|         return libogg.ogg_sync_init(oy) | ||||
| 
 | ||||
|     libogg.ogg_sync_clear.restype = c_int | ||||
|     libogg.ogg_sync_clear.argtypes = [oy_p] | ||||
| 
 | ||||
|     def oggpack_writeinit(oy): | ||||
|         return libogg.oggpack_writeinit(oy) | ||||
| 
 | ||||
|     libogg.ogg_sync_reset.restype = c_int | ||||
|     libogg.ogg_sync_reset.argtypes = [oy_p] | ||||
| 
 | ||||
|     def oggpack_writeinit(oy): | ||||
|         return libogg.oggpack_writeinit(oy) | ||||
| 
 | ||||
|     libogg.ogg_sync_destroy.restype = c_int | ||||
|     libogg.ogg_sync_destroy.argtypes = [oy_p] | ||||
| 
 | ||||
|     def oggpack_writeinit(oy): | ||||
|         return libogg.oggpack_writeinit(oy) | ||||
| 
 | ||||
|     try: | ||||
|         libogg.ogg_sync_check.restype = c_int | ||||
|         libogg.ogg_sync_check.argtypes = [oy_p] | ||||
|         def oggpack_writeinit(oy): | ||||
|             return libogg.oggpack_writeinit(oy) | ||||
|     except: | ||||
|         pass | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libogg.ogg_sync_buffer.restype = c_char_p | ||||
|     libogg.ogg_sync_buffer.argtypes = [oy_p, c_long] | ||||
| 
 | ||||
|     def ogg_sync_buffer(oy, size): | ||||
|         return libogg.ogg_sync_buffer(oy, size) | ||||
| 
 | ||||
|     libogg.ogg_sync_wrote.restype = c_int | ||||
|     libogg.ogg_sync_wrote.argtypes = [oy_p, c_long] | ||||
| 
 | ||||
|     def ogg_sync_wrote(oy, bytes): | ||||
|         return libogg.ogg_sync_wrote(oy, bytes) | ||||
| 
 | ||||
|     libogg.ogg_sync_pageseek.restype = c_int | ||||
|     libogg.ogg_sync_pageseek.argtypes = [oy_p, og_p] | ||||
| 
 | ||||
|     def ogg_sync_pageseek(oy, og): | ||||
|         return libogg.ogg_sync_pageseek(oy, og) | ||||
| 
 | ||||
|     libogg.ogg_sync_pageout.restype = c_long | ||||
|     libogg.ogg_sync_pageout.argtypes = [oy_p, og_p] | ||||
| 
 | ||||
|     def ogg_sync_pageout(oy, og): | ||||
|         return libogg.ogg_sync_pageout(oy, og) | ||||
| 
 | ||||
|     libogg.ogg_stream_pagein.restype = c_int | ||||
|     libogg.ogg_stream_pagein.argtypes = [os_p, og_p] | ||||
| 
 | ||||
|     def ogg_stream_pagein(os, og): | ||||
|         return libogg.ogg_stream_pagein(oy, og) | ||||
| 
 | ||||
|     libogg.ogg_stream_packetout.restype = c_int | ||||
|     libogg.ogg_stream_packetout.argtypes = [os_p, op_p] | ||||
| 
 | ||||
|     def ogg_stream_packetout(os, op): | ||||
|         return libogg.ogg_stream_packetout(oy, op) | ||||
| 
 | ||||
|     libogg.ogg_stream_packetpeek.restype = c_int | ||||
|     libogg.ogg_stream_packetpeek.argtypes = [os_p, op_p] | ||||
| 
 | ||||
|     def ogg_stream_packetpeek(os, op): | ||||
|         return libogg.ogg_stream_packetpeek(os, op) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libogg.ogg_stream_init.restype = c_int | ||||
|     libogg.ogg_stream_init.argtypes = [os_p, c_int] | ||||
| 
 | ||||
|     def ogg_stream_init(os, serialno): | ||||
|         return libogg.ogg_stream_init(os, serialno) | ||||
| 
 | ||||
|     libogg.ogg_stream_clear.restype = c_int | ||||
|     libogg.ogg_stream_clear.argtypes = [os_p] | ||||
| 
 | ||||
|     def ogg_stream_clear(os): | ||||
|         return libogg.ogg_stream_clear(os) | ||||
| 
 | ||||
|     libogg.ogg_stream_reset.restype = c_int | ||||
|     libogg.ogg_stream_reset.argtypes = [os_p] | ||||
| 
 | ||||
|     def ogg_stream_reset(os): | ||||
|         return libogg.ogg_stream_reset(os) | ||||
| 
 | ||||
|     libogg.ogg_stream_reset_serialno.restype = c_int | ||||
|     libogg.ogg_stream_reset_serialno.argtypes = [os_p, c_int] | ||||
| 
 | ||||
|     def ogg_stream_reset_serialno(os, serialno): | ||||
|         return libogg.ogg_stream_reset_serialno(os, serialno) | ||||
| 
 | ||||
|     libogg.ogg_stream_destroy.restype = c_int | ||||
|     libogg.ogg_stream_destroy.argtypes = [os_p] | ||||
| 
 | ||||
|     def ogg_stream_destroy(os): | ||||
|         return libogg.ogg_stream_destroy(os) | ||||
| 
 | ||||
|     try: | ||||
|         libogg.ogg_stream_check.restype = c_int | ||||
|         libogg.ogg_stream_check.argtypes = [os_p] | ||||
|         def ogg_stream_check(os): | ||||
|             return libogg.ogg_stream_check(os) | ||||
|     except: | ||||
|         pass | ||||
| 
 | ||||
|     libogg.ogg_stream_eos.restype = c_int | ||||
|     libogg.ogg_stream_eos.argtypes = [os_p] | ||||
| 
 | ||||
|     def ogg_stream_eos(os): | ||||
|         return libogg.ogg_stream_eos(os) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libogg.ogg_page_checksum_set.restype = None | ||||
|     libogg.ogg_page_checksum_set.argtypes = [og_p] | ||||
| 
 | ||||
|     def ogg_page_checksum_set(og): | ||||
|         libogg.ogg_page_checksum_set(og) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libogg.ogg_page_version.restype = c_int | ||||
|     libogg.ogg_page_version.argtypes = [og_p] | ||||
| 
 | ||||
|     def ogg_page_version(og): | ||||
|         return libogg.ogg_page_version(og) | ||||
| 
 | ||||
|     libogg.ogg_page_continued.restype = c_int | ||||
|     libogg.ogg_page_continued.argtypes = [og_p] | ||||
| 
 | ||||
|     def ogg_page_continued(og): | ||||
|         return libogg.ogg_page_continued(og) | ||||
| 
 | ||||
|     libogg.ogg_page_bos.restype = c_int | ||||
|     libogg.ogg_page_bos.argtypes = [og_p] | ||||
| 
 | ||||
|     def ogg_page_bos(og): | ||||
|         return libogg.ogg_page_bos(og) | ||||
| 
 | ||||
|     libogg.ogg_page_eos.restype = c_int | ||||
|     libogg.ogg_page_eos.argtypes = [og_p] | ||||
| 
 | ||||
|     def ogg_page_eos(og): | ||||
|         return libogg.ogg_page_eos(og) | ||||
| 
 | ||||
|     libogg.ogg_page_granulepos.restype = ogg_int64_t | ||||
|     libogg.ogg_page_granulepos.argtypes = [og_p] | ||||
| 
 | ||||
|     def ogg_page_granulepos(og): | ||||
|         return libogg.ogg_page_granulepos(og) | ||||
| 
 | ||||
|     libogg.ogg_page_serialno.restype = c_int | ||||
|     libogg.ogg_page_serialno.argtypes = [og_p] | ||||
| 
 | ||||
|     def ogg_page_serialno(og): | ||||
|         return libogg.ogg_page_serialno(og) | ||||
| 
 | ||||
|     libogg.ogg_page_pageno.restype = c_long | ||||
|     libogg.ogg_page_pageno.argtypes = [og_p] | ||||
| 
 | ||||
|     def ogg_page_pageno(og): | ||||
|         return libogg.ogg_page_pageno(og) | ||||
| 
 | ||||
|     libogg.ogg_page_packets.restype = c_int | ||||
|     libogg.ogg_page_packets.argtypes = [og_p] | ||||
| 
 | ||||
|     def ogg_page_packets(og): | ||||
|         return libogg.ogg_page_packets(og) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libogg.ogg_packet_clear.restype = None | ||||
|     libogg.ogg_packet_clear.argtypes = [op_p] | ||||
| 
 | ||||
|     def ogg_packet_clear(op): | ||||
|         libogg.ogg_packet_clear(op) | ||||
							
								
								
									
										1290
									
								
								resources/lib/deps/pyogg/opus.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1290
									
								
								resources/lib/deps/pyogg/opus.py
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										808
									
								
								resources/lib/deps/pyogg/vorbis.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										808
									
								
								resources/lib/deps/pyogg/vorbis.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,808 @@ | |||
| ############################################################ | ||||
| # Vorbis license:                                          # | ||||
| ############################################################ | ||||
| """ | ||||
| Copyright (c) 2002-2015 Xiph.org Foundation | ||||
| 
 | ||||
| Redistribution and use in source and binary forms, with or without | ||||
| modification, are permitted provided that the following conditions | ||||
| are met: | ||||
| 
 | ||||
| - Redistributions of source code must retain the above copyright | ||||
| notice, this list of conditions and the following disclaimer. | ||||
| 
 | ||||
| - Redistributions in binary form must reproduce the above copyright | ||||
| notice, this list of conditions and the following disclaimer in the | ||||
| documentation and/or other materials provided with the distribution. | ||||
| 
 | ||||
| - Neither the name of the Xiph.org Foundation nor the names of its | ||||
| contributors may be used to endorse or promote products derived from | ||||
| this software without specific prior written permission. | ||||
| 
 | ||||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION | ||||
| OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| """ | ||||
| 
 | ||||
| import ctypes | ||||
| import ctypes.util | ||||
| from traceback import print_exc as _print_exc | ||||
| import os | ||||
| 
 | ||||
| OV_EXCLUDE_STATIC_CALLBACKS = False | ||||
| 
 | ||||
| __MINGW32__ = False | ||||
| 
 | ||||
| _WIN32 = False | ||||
| 
 | ||||
| from .ogg import * | ||||
| 
 | ||||
| from .library_loader import ExternalLibrary, ExternalLibraryError | ||||
| 
 | ||||
| __here = os.getcwd() | ||||
| 
 | ||||
| libvorbis = None | ||||
| 
 | ||||
| try: | ||||
|     libvorbis = ExternalLibrary.load("vorbis", tests = [lambda lib: hasattr(lib, "vorbis_info_init")]) | ||||
| except ExternalLibraryError: | ||||
|     pass | ||||
| except: | ||||
|     _print_exc() | ||||
| 
 | ||||
| libvorbisfile = None | ||||
| 
 | ||||
| try: | ||||
|     libvorbisfile = ExternalLibrary.load("vorbisfile", tests = [lambda lib: hasattr(lib, "ov_clear")]) | ||||
| except ExternalLibraryError: | ||||
|     pass | ||||
| except: | ||||
|     _print_exc() | ||||
| 
 | ||||
| libvorbisenc = None | ||||
| 
 | ||||
| try: | ||||
|     libvorbisenc = ExternalLibrary.load("vorbisenc", tests = [lambda lib: hasattr(lib, "vorbis_encode_init")]) | ||||
| except ExternalLibraryError: | ||||
|     pass | ||||
| except: | ||||
|     _print_exc() | ||||
| 
 | ||||
| if libvorbis is None: | ||||
|     PYOGG_VORBIS_AVAIL = False | ||||
| else: | ||||
|     PYOGG_VORBIS_AVAIL = True | ||||
| 
 | ||||
| if libvorbisfile is None: | ||||
|     PYOGG_VORBIS_FILE_AVAIL = False | ||||
| else: | ||||
|     PYOGG_VORBIS_FILE_AVAIL = True | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| if PYOGG_OGG_AVAIL and  PYOGG_VORBIS_AVAIL and PYOGG_VORBIS_FILE_AVAIL: | ||||
|     # codecs | ||||
|     class vorbis_info(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct vorbis_info vorbis_info; | ||||
|         """ | ||||
|         _fields_ = [("version", c_int), | ||||
|                     ("channels", c_int), | ||||
|                     ("rate", c_long), | ||||
| 
 | ||||
|                     ("bitrate_upper", c_long), | ||||
|                     ("bitrate_nominal", c_long), | ||||
|                     ("bitrate_lower", c_long), | ||||
|                     ("bitrate_window", c_long), | ||||
|                     ("codec_setup", c_void_p)] | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     class vorbis_dsp_state(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct vorbis_dsp_state vorbis_dsp_state; | ||||
|         """ | ||||
|         _fields_ = [("analysisp", c_int), | ||||
|                     ("vi", POINTER(vorbis_info)), | ||||
|                     ("pcm", c_float_p_p), | ||||
|                     ("pcmret", c_float_p_p), | ||||
|                     ("pcm_storage", c_int), | ||||
|                     ("pcm_current", c_int), | ||||
|                     ("pcm_returned", c_int), | ||||
| 
 | ||||
|                     ("preextrapolate", c_int), | ||||
|                     ("eofflag", c_int), | ||||
| 
 | ||||
|                     ("lW", c_long), | ||||
|                     ("W", c_long), | ||||
|                     ("nW", c_long), | ||||
|                     ("centerW", c_long), | ||||
| 
 | ||||
|                     ("granulepos", ogg_int64_t), | ||||
|                     ("sequence", ogg_int64_t), | ||||
| 
 | ||||
|                     ("glue_bits", ogg_int64_t), | ||||
|                     ("time_bits", ogg_int64_t), | ||||
|                     ("floor_bits", ogg_int64_t), | ||||
|                     ("res_bits", ogg_int64_t), | ||||
| 
 | ||||
|                     ("backend_state", c_void_p)] | ||||
|          | ||||
|     class alloc_chain(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct alloc_chain; | ||||
|         """ | ||||
|         pass | ||||
| 
 | ||||
|     alloc_chain._fields_ = [("ptr", c_void_p), | ||||
|                     ("next", POINTER(alloc_chain))] | ||||
| 
 | ||||
|     class vorbis_block(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct vorbis_block vorbis_block; | ||||
|         """ | ||||
|         _fields_ = [("pcm", c_float_p_p), | ||||
|                     ("opb", oggpack_buffer), | ||||
|                     ("lW", c_long), | ||||
|                     ("W", c_long), | ||||
|                     ("nW", c_long), | ||||
|                     ("pcmend", c_int), | ||||
|                     ("mode", c_int), | ||||
| 
 | ||||
|                     ("eofflag", c_int), | ||||
|                     ("granulepos", ogg_int64_t), | ||||
|                     ("sequence", ogg_int64_t), | ||||
|                     ("vd", POINTER(vorbis_dsp_state)), | ||||
| 
 | ||||
|                     ("localstore", c_void_p), | ||||
|                     ("localtop", c_long), | ||||
|                     ("localalloc", c_long), | ||||
|                     ("totaluse", c_long), | ||||
|                     ("reap", POINTER(alloc_chain)), | ||||
| 
 | ||||
|                     ("glue_bits", c_long), | ||||
|                     ("time_bits", c_long), | ||||
|                     ("floor_bits", c_long), | ||||
|                     ("res_bits", c_long), | ||||
| 
 | ||||
|                     ("internal", c_void_p)] | ||||
| 
 | ||||
|     class vorbis_comment(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct vorbis_comment vorbis_comment; | ||||
|         """ | ||||
|         _fields_ = [("user_comments", c_char_p_p), | ||||
|                     ("comment_lengths", c_int_p), | ||||
|                     ("comments", c_int), | ||||
|                     ("vendor", c_char_p)] | ||||
| 
 | ||||
|          | ||||
| 
 | ||||
|     vi_p = POINTER(vorbis_info) | ||||
|     vc_p = POINTER(vorbis_comment) | ||||
|     vd_p = POINTER(vorbis_dsp_state) | ||||
|     vb_p = POINTER(vorbis_block) | ||||
| 
 | ||||
|     libvorbis.vorbis_info_init.restype = None | ||||
|     libvorbis.vorbis_info_init.argtypes = [vi_p] | ||||
|     def vorbis_info_init(vi): | ||||
|         libvorbis.vorbis_info_init(vi) | ||||
| 
 | ||||
|     libvorbis.vorbis_info_clear.restype = None | ||||
|     libvorbis.vorbis_info_clear.argtypes = [vi_p] | ||||
|     def vorbis_info_clear(vi): | ||||
|         libvorbis.vorbis_info_clear(vi) | ||||
| 
 | ||||
|     libvorbis.vorbis_info_blocksize.restype = c_int | ||||
|     libvorbis.vorbis_info_blocksize.argtypes = [vi_p, c_int] | ||||
|     def vorbis_info_blocksize(vi, zo): | ||||
|         return libvorbis.vorbis_info_blocksize(vi, zo) | ||||
| 
 | ||||
|     libvorbis.vorbis_comment_init.restype = None | ||||
|     libvorbis.vorbis_comment_init.argtypes = [vc_p] | ||||
|     def vorbis_comment_init(vc): | ||||
|         libvorbis.vorbis_comment_init(vc) | ||||
| 
 | ||||
|     libvorbis.vorbis_comment_add.restype = None | ||||
|     libvorbis.vorbis_comment_add.argtypes = [vc_p, c_char_p] | ||||
|     def vorbis_comment_add(vc, comment): | ||||
|         libvorbis.vorbis_comment_add(vc, comment) | ||||
| 
 | ||||
|     libvorbis.vorbis_info_clear.restype = None | ||||
|     libvorbis.vorbis_info_clear.argtypes = [vc_p, c_char_p, c_char_p] | ||||
|     def vorbis_info_init(vc, tag, comment): | ||||
|         libvorbis.vorbis_info_init(vc, tag, comment) | ||||
| 
 | ||||
|     libvorbis.vorbis_comment_query.restype = c_char_p | ||||
|     libvorbis.vorbis_comment_query.argtypes = [vc_p, c_char_p, c_int] | ||||
|     def vorbis_comment_query(vc, tag, count): | ||||
|         libvorbis.vorbis_comment_query(vc, tag, count) | ||||
| 
 | ||||
|     libvorbis.vorbis_comment_query_count.restype = c_int | ||||
|     libvorbis.vorbis_comment_query_count.argtypes = [vc_p, c_char_p] | ||||
|     def vorbis_comment_query_count(vc, tag): | ||||
|         libvorbis.vorbis_comment_query_count(vc, tag) | ||||
| 
 | ||||
|     libvorbis.vorbis_comment_clear.restype = None | ||||
|     libvorbis.vorbis_comment_clear.argtypes = [vc_p] | ||||
|     def vorbis_comment_clear(vc): | ||||
|         libvorbis.vorbis_comment_clear(vc) | ||||
| 
 | ||||
| 
 | ||||
|          | ||||
|     libvorbis.vorbis_block_init.restype = c_int | ||||
|     libvorbis.vorbis_block_init.argtypes = [vd_p, vb_p] | ||||
|     def vorbis_block_init(v,vb): | ||||
|         return libvorbis.vorbis_block_init(v,vb) | ||||
| 
 | ||||
|     libvorbis.vorbis_block_clear.restype = c_int | ||||
|     libvorbis.vorbis_block_clear.argtypes = [vb_p] | ||||
|     def vorbis_block_clear(vb): | ||||
|         return libvorbis.vorbis_block_clear(vb) | ||||
| 
 | ||||
|     libvorbis.vorbis_dsp_clear.restype = None | ||||
|     libvorbis.vorbis_dsp_clear.argtypes = [vd_p] | ||||
|     def vorbis_dsp_clear(v): | ||||
|         return libvorbis.vorbis_dsp_clear(v) | ||||
| 
 | ||||
|     libvorbis.vorbis_granule_time.restype = c_double | ||||
|     libvorbis.vorbis_granule_time.argtypes = [vd_p, ogg_int64_t] | ||||
|     def vorbis_granule_time(v, granulepos): | ||||
|         return libvorbis.vorbis_granule_time(v, granulepos) | ||||
| 
 | ||||
| 
 | ||||
|          | ||||
|     libvorbis.vorbis_version_string.restype = c_char_p | ||||
|     libvorbis.vorbis_version_string.argtypes = None | ||||
|     def vorbis_version_string(): | ||||
|         return libvorbis.vorbis_version_string() | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbis.vorbis_analysis_init.restype = c_int | ||||
|     libvorbis.vorbis_analysis_init.argtypes = [vd_p, vi_p] | ||||
|     def vorbis_analysis_init(v, vi): | ||||
|         return libvorbis.vorbis_analysis_init(v, vi) | ||||
| 
 | ||||
|     libvorbis.vorbis_commentheader_out.restype = c_int | ||||
|     libvorbis.vorbis_commentheader_out.argtypes = [vc_p, op_p] | ||||
|     def vorbis_commentheader_out(vc, op): | ||||
|         return libvorbis.vorbis_commentheader_out(vc, op) | ||||
|          | ||||
|     libvorbis.vorbis_analysis_headerout.restype = c_int | ||||
|     libvorbis.vorbis_analysis_headerout.argtypes = [vd_p, vc_p, op_p, op_p, op_p] | ||||
|     def vorbis_analysis_headerout(v,vc, op, op_comm, op_code): | ||||
|         return libvorbis.vorbis_analysis_headerout(v,vc, op, op_comm, op_code) | ||||
| 
 | ||||
|     libvorbis.vorbis_analysis_buffer.restype = c_float_p_p | ||||
|     libvorbis.vorbis_analysis_buffer.argtypes = [vd_p, c_int] | ||||
|     def vorbis_analysis_buffer(v, vals): | ||||
|         return libvorbis.vorbis_analysis_buffer(v, vals) | ||||
| 
 | ||||
|     libvorbis.vorbis_analysis_wrote.restype = c_int | ||||
|     libvorbis.vorbis_analysis_wrote.argtypes = [vd_p, c_int] | ||||
|     def vorbis_analysis_wrote(v, vals): | ||||
|         return libvorbis.vorbis_analysis_wrote(v, vals) | ||||
| 
 | ||||
|     libvorbis.vorbis_analysis_blockout.restype = c_int | ||||
|     libvorbis.vorbis_analysis_blockout.argtypes = [vd_p, vb_p] | ||||
|     def vorbis_analysis_blockout(v, vb): | ||||
|         return libvorbis.vorbis_analysis_blockout(v, vb) | ||||
|          | ||||
|     libvorbis.vorbis_analysis.restype = c_int | ||||
|     libvorbis.vorbis_analysis.argtypes = [vb_p, op_p] | ||||
|     def vorbis_analysis(vb, op): | ||||
|         return libvorbis.vorbis_analysis(vb, op) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbis.vorbis_bitrate_addblock.restype = c_int | ||||
|     libvorbis.vorbis_bitrate_addblock.argtypes = [vb_p] | ||||
|     def vorbis_bitrate_addblock(vb): | ||||
|         return libvorbis.vorbis_bitrate_addblock(vb) | ||||
|          | ||||
|     libvorbis.vorbis_bitrate_flushpacket.restype = c_int | ||||
|     libvorbis.vorbis_bitrate_flushpacket.argtypes = [vd_p, op_p] | ||||
|     def vorbis_bitrate_flushpacket(vd, op): | ||||
|         return libvorbis.vorbis_bitrate_flushpacket(vd, op) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbis.vorbis_synthesis_idheader.restype = c_int | ||||
|     libvorbis.vorbis_synthesis_idheader.argtypes = [op_p] | ||||
|     def vorbis_synthesis_idheader(op): | ||||
|         return libvorbis.vorbis_synthesis_idheader(op) | ||||
|          | ||||
|     libvorbis.vorbis_bitrate_flushpacket.restype = c_int | ||||
|     libvorbis.vorbis_bitrate_flushpacket.argtypes = [vi_p, vc_p, op_p] | ||||
|     def vorbis_bitrate_flushpacket(vi, vc, op): | ||||
|         return libvorbis.vorbis_bitrate_flushpacket(vi, vc, op) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbis.vorbis_synthesis_init.restype = c_int | ||||
|     libvorbis.vorbis_synthesis_init.argtypes = [vd_p, vi_p] | ||||
|     def vorbis_synthesis_init(v,vi): | ||||
|         return libvorbis.vorbis_synthesis_init(v,vi) | ||||
| 
 | ||||
|     libvorbis.vorbis_synthesis_restart.restype = c_int | ||||
|     libvorbis.vorbis_synthesis_restart.argtypes = [vd_p] | ||||
|     def vorbis_synthesis_restart(v): | ||||
|         return libvorbis.vorbis_synthesis_restart(v) | ||||
| 
 | ||||
|     libvorbis.vorbis_synthesis.restype = c_int | ||||
|     libvorbis.vorbis_synthesis.argtypes = [vb_p, op_p] | ||||
|     def vorbis_synthesis(vb, op): | ||||
|         return libvorbis.vorbis_synthesis(vb, op) | ||||
| 
 | ||||
|     libvorbis.vorbis_synthesis_trackonly.restype = c_int | ||||
|     libvorbis.vorbis_synthesis_trackonly.argtypes = [vb_p, op_p] | ||||
|     def vorbis_synthesis_trackonly(vb, op): | ||||
|         return libvorbis.vorbis_synthesis_trackonly(vb, op) | ||||
|          | ||||
|     libvorbis.vorbis_synthesis_blockin.restype = c_int | ||||
|     libvorbis.vorbis_synthesis_blockin.argtypes = [vd_p, vb_p] | ||||
|     def vorbis_synthesis_blockin(v, vb): | ||||
|         return libvorbis.vorbis_synthesis_blockin(v, vb) | ||||
| 
 | ||||
|     libvorbis.vorbis_synthesis_pcmout.restype = c_int | ||||
|     libvorbis.vorbis_synthesis_pcmout.argtypes = [vd_p, c_float_p_p_p] | ||||
|     def vorbis_synthesis_pcmout(v, pcm): | ||||
|         return libvorbis.vorbis_synthesis_pcmout(v, pcm) | ||||
|          | ||||
|     libvorbis.vorbis_synthesis_lapout.restype = c_int | ||||
|     libvorbis.vorbis_synthesis_lapout.argtypes = [vd_p, c_float_p_p_p] | ||||
|     def vorbis_synthesis_lapout(v, pcm): | ||||
|         return libvorbis.vorbis_synthesis_lapout(v, pcm) | ||||
| 
 | ||||
|     libvorbis.vorbis_synthesis_read.restype = c_int | ||||
|     libvorbis.vorbis_synthesis_read.argtypes = [vd_p, c_int] | ||||
|     def vorbis_synthesis_read(v, samples): | ||||
|         return libvorbis.vorbis_synthesis_read(v, samples) | ||||
|          | ||||
|     libvorbis.vorbis_packet_blocksize.restype = c_long | ||||
|     libvorbis.vorbis_packet_blocksize.argtypes = [vi_p, op_p] | ||||
|     def vorbis_packet_blocksize(vi, op): | ||||
|         return libvorbis.vorbis_packet_blocksize(vi, op) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbis.vorbis_synthesis_halfrate.restype = c_int | ||||
|     libvorbis.vorbis_synthesis_halfrate.argtypes = [vi_p, c_int] | ||||
|     def vorbis_synthesis_halfrate(v, flag): | ||||
|         return libvorbis.vorbis_synthesis_halfrate(v, flag) | ||||
|          | ||||
|     libvorbis.vorbis_synthesis_halfrate_p.restype = c_int | ||||
|     libvorbis.vorbis_synthesis_halfrate_p.argtypes = [vi_p] | ||||
|     def vorbis_synthesis_halfrate_p(vi): | ||||
|         return libvorbis.vorbis_synthesis_halfrate_p(vi) | ||||
| 
 | ||||
|     OV_FALSE =     -1 | ||||
|     OV_EOF  =      -2 | ||||
|     OV_HOLE  =     -3 | ||||
| 
 | ||||
|     OV_EREAD  =    -128 | ||||
|     OV_EFAULT    = -129 | ||||
|     OV_EIMPL      =-130 | ||||
|     OV_EINVAL     =-131 | ||||
|     OV_ENOTVORBIS =-132 | ||||
|     OV_EBADHEADER =-133 | ||||
|     OV_EVERSION   =-134 | ||||
|     OV_ENOTAUDIO  =-135 | ||||
|     OV_EBADPACKET =-136 | ||||
|     OV_EBADLINK   =-137 | ||||
|     OV_ENOSEEK    =-138 | ||||
|     # end of codecs | ||||
| 
 | ||||
|     # vorbisfile | ||||
|     read_func = ctypes.CFUNCTYPE(c_size_t, | ||||
|                                  c_void_p, | ||||
|                                  c_size_t, | ||||
|                                  c_size_t, | ||||
|                                  c_void_p) | ||||
| 
 | ||||
|     seek_func = ctypes.CFUNCTYPE(c_int, | ||||
|                                  c_void_p, | ||||
|                                  ogg_int64_t, | ||||
|                                  c_int) | ||||
| 
 | ||||
|     close_func = ctypes.CFUNCTYPE(c_int, | ||||
|                                   c_void_p) | ||||
| 
 | ||||
|     tell_func = ctypes.CFUNCTYPE(c_long, | ||||
|                                  c_void_p) | ||||
| 
 | ||||
|     class ov_callbacks(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct ov_callbacks; | ||||
|         """ | ||||
| 
 | ||||
|         _fields_ = [("read_func", read_func), | ||||
|                     ("seek_func", seek_func), | ||||
|                     ("close_func", close_func), | ||||
|                     ("tell_func", tell_func)] | ||||
|          | ||||
|     NOTOPEN   = 0 | ||||
|     PARTOPEN  = 1 | ||||
|     OPENED    = 2 | ||||
|     STREAMSET = 3 | ||||
|     INITSET   = 4 | ||||
| 
 | ||||
|     class OggVorbis_File(ctypes.Structure): | ||||
|         """ | ||||
|         Wrapper for: | ||||
|             typedef struct OggVorbis_File OggVorbis_File; | ||||
|         """ | ||||
| 
 | ||||
|         _fields_ = [("datasource", c_void_p), | ||||
|                     ("seekable", c_int), | ||||
|                     ("offset", ogg_int64_t), | ||||
|                     ("end", ogg_int64_t), | ||||
|                     ("oy", ogg_sync_state), | ||||
| 
 | ||||
|                     ("links", c_int), | ||||
|                     ("offsets", ogg_int64_t_p), | ||||
|                     ("dataoffsets", ogg_int64_t_p), | ||||
|                     ("serialnos", c_long_p), | ||||
|                     ("pcmlengths", ogg_int64_t_p), | ||||
|                     ("vi", vi_p), | ||||
|                     ("vc", vc_p), | ||||
| 
 | ||||
|                     ("pcm_offset", ogg_int64_t), | ||||
|                     ("ready_state", c_int), | ||||
|                     ("current_serialno", c_long), | ||||
|                     ("current_link", c_int), | ||||
| 
 | ||||
|                     ("bittrack", c_double), | ||||
|                     ("samptrack", c_double), | ||||
| 
 | ||||
|                     ("os", ogg_stream_state), | ||||
| 
 | ||||
|                     ("vd", vorbis_dsp_state), | ||||
|                     ("vb", vorbis_block), | ||||
| 
 | ||||
|                     ("callbacks", ov_callbacks)] | ||||
|     vf_p = POINTER(OggVorbis_File) | ||||
| 
 | ||||
|     libvorbisfile.ov_clear.restype = c_int | ||||
|     libvorbisfile.ov_clear.argtypes = [vf_p] | ||||
| 
 | ||||
|     def ov_clear(vf): | ||||
|         return libvorbisfile.ov_clear(vf) | ||||
| 
 | ||||
|     libvorbisfile.ov_fopen.restype = c_int | ||||
|     libvorbisfile.ov_fopen.argtypes = [c_char_p, vf_p] | ||||
| 
 | ||||
|     def ov_fopen(path, vf): | ||||
|         return libvorbisfile.ov_fopen(to_char_p(path), vf) | ||||
| 
 | ||||
|     libvorbisfile.ov_open_callbacks.restype = c_int | ||||
|     libvorbisfile.ov_open_callbacks.argtypes = [c_void_p, vf_p, c_char_p, c_long, ov_callbacks] | ||||
| 
 | ||||
|     def ov_open_callbacks(datasource, vf, initial, ibytes, callbacks): | ||||
|         return libvorbisfile.ov_open_callbacks(datasource, vf, initial, ibytes, callbacks) | ||||
| 
 | ||||
|     def ov_open(*args, **kw): | ||||
|         raise PyOggError("ov_open is not supported, please use ov_fopen instead") | ||||
| 
 | ||||
|     def ov_test(*args, **kw): | ||||
|         raise PyOggError("ov_test is not supported") | ||||
| 
 | ||||
|     libvorbisfile.ov_test_callbacks.restype = c_int | ||||
|     libvorbisfile.ov_test_callbacks.argtypes = [c_void_p, vf_p, c_char_p, c_long, ov_callbacks] | ||||
| 
 | ||||
|     def ov_test_callbacks(datasource, vf, initial, ibytes, callbacks): | ||||
|         return libvorbisfile.ov_test_callbacks(datasource, vf, initial, ibytes, callbacks) | ||||
| 
 | ||||
|     libvorbisfile.ov_test_open.restype = c_int | ||||
|     libvorbisfile.ov_test_open.argtypes = [vf_p] | ||||
| 
 | ||||
|     def ov_test_open(vf): | ||||
|         return libvorbisfile.ov_test_open(vf) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbisfile.ov_bitrate.restype = c_long | ||||
|     libvorbisfile.ov_bitrate.argtypes = [vf_p, c_int] | ||||
| 
 | ||||
|     def ov_bitrate(vf, i): | ||||
|         return libvorbisfile.ov_bitrate(vf, i) | ||||
| 
 | ||||
|     libvorbisfile.ov_bitrate_instant.restype = c_long | ||||
|     libvorbisfile.ov_bitrate_instant.argtypes = [vf_p] | ||||
| 
 | ||||
|     def ov_bitrate_instant(vf): | ||||
|         return libvorbisfile.ov_bitrate_instant(vf) | ||||
| 
 | ||||
|     libvorbisfile.ov_streams.restype = c_long | ||||
|     libvorbisfile.ov_streams.argtypes = [vf_p] | ||||
| 
 | ||||
|     def ov_streams(vf): | ||||
|         return libvorbisfile.ov_streams(vf) | ||||
| 
 | ||||
|     libvorbisfile.ov_seekable.restype = c_long | ||||
|     libvorbisfile.ov_seekable.argtypes = [vf_p] | ||||
| 
 | ||||
|     def ov_seekable(vf): | ||||
|         return libvorbisfile.ov_seekable(vf) | ||||
| 
 | ||||
|     libvorbisfile.ov_serialnumber.restype = c_long | ||||
|     libvorbisfile.ov_serialnumber.argtypes = [vf_p, c_int] | ||||
| 
 | ||||
|     def ov_serialnumber(vf, i): | ||||
|         return libvorbisfile.ov_serialnumber(vf, i) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbisfile.ov_raw_total.restype = ogg_int64_t | ||||
|     libvorbisfile.ov_raw_total.argtypes = [vf_p, c_int] | ||||
| 
 | ||||
|     def ov_raw_total(vf, i): | ||||
|         return libvorbisfile.ov_raw_total(vf, i) | ||||
| 
 | ||||
|     libvorbisfile.ov_pcm_total.restype = ogg_int64_t | ||||
|     libvorbisfile.ov_pcm_total.argtypes = [vf_p, c_int] | ||||
| 
 | ||||
|     def ov_pcm_total(vf, i): | ||||
|         return libvorbisfile.ov_pcm_total(vf, i) | ||||
| 
 | ||||
|     libvorbisfile.ov_time_total.restype = c_double | ||||
|     libvorbisfile.ov_time_total.argtypes = [vf_p, c_int] | ||||
| 
 | ||||
|     def ov_time_total(vf, i): | ||||
|         return libvorbisfile.ov_time_total(vf, i) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbisfile.ov_raw_seek.restype = c_int | ||||
|     libvorbisfile.ov_raw_seek.argtypes = [vf_p, ogg_int64_t] | ||||
| 
 | ||||
|     def ov_raw_seek(vf, pos): | ||||
|         return libvorbisfile.ov_raw_seek(vf, pos) | ||||
| 
 | ||||
|     libvorbisfile.ov_pcm_seek.restype = c_int | ||||
|     libvorbisfile.ov_pcm_seek.argtypes = [vf_p, ogg_int64_t] | ||||
| 
 | ||||
|     def ov_pcm_seek(vf, pos): | ||||
|         return libvorbisfile.ov_pcm_seek(vf, pos) | ||||
| 
 | ||||
|     libvorbisfile.ov_pcm_seek_page.restype = c_int | ||||
|     libvorbisfile.ov_pcm_seek_page.argtypes = [vf_p, ogg_int64_t] | ||||
| 
 | ||||
|     def ov_pcm_seek_page(vf, pos): | ||||
|         return libvorbisfile.ov_pcm_seek_page(vf, pos) | ||||
| 
 | ||||
|     libvorbisfile.ov_time_seek.restype = c_int | ||||
|     libvorbisfile.ov_time_seek.argtypes = [vf_p, c_double] | ||||
| 
 | ||||
|     def ov_time_seek(vf, pos): | ||||
|         return libvorbisfile.ov_time_seek(vf, pos) | ||||
| 
 | ||||
|     libvorbisfile.ov_time_seek_page.restype = c_int | ||||
|     libvorbisfile.ov_time_seek_page.argtypes = [vf_p, c_double] | ||||
| 
 | ||||
|     def ov_time_seek_page(vf, pos): | ||||
|         return libvorbisfile.ov_time_seek_page(vf, pos) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbisfile.ov_raw_seek_lap.restype = c_int | ||||
|     libvorbisfile.ov_raw_seek_lap.argtypes = [vf_p, ogg_int64_t] | ||||
| 
 | ||||
|     def ov_raw_seek_lap(vf, pos): | ||||
|         return libvorbisfile.ov_raw_seek_lap(vf, pos) | ||||
| 
 | ||||
|     libvorbisfile.ov_pcm_seek_lap.restype = c_int | ||||
|     libvorbisfile.ov_pcm_seek_lap.argtypes = [vf_p, ogg_int64_t] | ||||
| 
 | ||||
|     def ov_pcm_seek_lap(vf, pos): | ||||
|         return libvorbisfile.ov_pcm_seek_lap(vf, pos) | ||||
| 
 | ||||
|     libvorbisfile.ov_pcm_seek_page_lap.restype = c_int | ||||
|     libvorbisfile.ov_pcm_seek_page_lap.argtypes = [vf_p, ogg_int64_t] | ||||
| 
 | ||||
|     def ov_pcm_seek_page_lap(vf, pos): | ||||
|         return libvorbisfile.ov_pcm_seek_page_lap(vf, pos) | ||||
| 
 | ||||
|     libvorbisfile.ov_time_seek_lap.restype = c_int | ||||
|     libvorbisfile.ov_time_seek_lap.argtypes = [vf_p, c_double] | ||||
| 
 | ||||
|     def ov_time_seek_lap(vf, pos): | ||||
|         return libvorbisfile.ov_time_seek_lap(vf, pos) | ||||
| 
 | ||||
|     libvorbisfile.ov_time_seek_page_lap.restype = c_int | ||||
|     libvorbisfile.ov_time_seek_page_lap.argtypes = [vf_p, c_double] | ||||
| 
 | ||||
|     def ov_time_seek_page_lap(vf, pos): | ||||
|         return libvorbisfile.ov_time_seek_page_lap(vf, pos) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbisfile.ov_raw_tell.restype = ogg_int64_t | ||||
|     libvorbisfile.ov_raw_tell.argtypes = [vf_p] | ||||
| 
 | ||||
|     def ov_raw_tell(vf): | ||||
|         return libvorbisfile.ov_raw_tell(vf) | ||||
| 
 | ||||
|     libvorbisfile.ov_pcm_tell.restype = ogg_int64_t | ||||
|     libvorbisfile.ov_pcm_tell.argtypes = [vf_p] | ||||
| 
 | ||||
|     def ov_pcm_tell(vf): | ||||
|         return libvorbisfile.ov_pcm_tell(vf) | ||||
| 
 | ||||
|     libvorbisfile.ov_time_tell.restype = c_double | ||||
|     libvorbisfile.ov_time_tell.argtypes = [vf_p] | ||||
| 
 | ||||
|     def ov_time_tell(vf): | ||||
|         return libvorbisfile.ov_time_tell(vf) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbisfile.ov_info.restype = vi_p | ||||
|     libvorbisfile.ov_info.argtypes = [vf_p, c_int] | ||||
| 
 | ||||
|     def ov_info(vf, link): | ||||
|         return libvorbisfile.ov_info(vf, link) | ||||
| 
 | ||||
|     libvorbisfile.ov_comment.restype = vc_p | ||||
|     libvorbisfile.ov_comment.argtypes = [vf_p, c_int] | ||||
| 
 | ||||
|     def ov_comment(vf, link): | ||||
|         return libvorbisfile.ov_comment(vf, link) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbisfile.ov_read_float.restype = c_long | ||||
|     libvorbisfile.ov_read_float.argtypes = [vf_p, c_float_p_p_p, c_int, c_int_p] | ||||
| 
 | ||||
|     def ov_read_float(vf, pcm_channels, samples, bitstream): | ||||
|         return libvorbisfile.ov_read_float(vf, pcm_channels, samples, bitstream) | ||||
| 
 | ||||
|     filter_ = ctypes.CFUNCTYPE(None, | ||||
|                               c_float_p_p, | ||||
|                               c_long, | ||||
|                               c_long, | ||||
|                               c_void_p) | ||||
| 
 | ||||
|     try: | ||||
|         libvorbisfile.ov_read_filter.restype = c_long | ||||
|         libvorbisfile.ov_read_filter.argtypes = [vf_p, c_char_p, c_int, c_int, c_int, c_int, c_int_p, filter_, c_void_p] | ||||
| 
 | ||||
|         def ov_read_filter(vf, buffer, length, bigendianp, word, sgned, bitstream, filter_, filter_param): | ||||
|             return libvorbisfile.ov_read_filter(vf, buffer, length, bigendianp, word, sgned, bitstream, filter_, filter_param) | ||||
|     except: | ||||
|         pass | ||||
| 
 | ||||
|     libvorbisfile.ov_read.restype = c_long | ||||
|     libvorbisfile.ov_read.argtypes = [vf_p, c_char_p, c_int, c_int, c_int, c_int, c_int_p] | ||||
| 
 | ||||
|     def ov_read(vf, buffer, length, bigendianp, word, sgned, bitstream): | ||||
|         return libvorbisfile.ov_read(vf, buffer, length, bigendianp, word, sgned, bitstream) | ||||
| 
 | ||||
|     libvorbisfile.ov_crosslap.restype = c_int | ||||
|     libvorbisfile.ov_crosslap.argtypes = [vf_p, vf_p] | ||||
| 
 | ||||
|     def ov_crosslap(vf1, cf2): | ||||
|         return libvorbisfile.ov_crosslap(vf1, vf2) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     libvorbisfile.ov_halfrate.restype = c_int | ||||
|     libvorbisfile.ov_halfrate.argtypes = [vf_p, c_int] | ||||
| 
 | ||||
|     def ov_halfrate(vf, flag): | ||||
|         return libvorbisfile.ov_halfrate(vf, flag) | ||||
| 
 | ||||
|     libvorbisfile.ov_halfrate_p.restype = c_int | ||||
|     libvorbisfile.ov_halfrate_p.argtypes = [vf_p] | ||||
| 
 | ||||
|     def ov_halfrate_p(vf): | ||||
|         return libvorbisfile.ov_halfrate_p(vf) | ||||
|     # end of vorbisfile | ||||
| 
 | ||||
|     try: | ||||
|         # vorbisenc | ||||
|         libvorbisenc.vorbis_encode_init.restype = c_int | ||||
|         libvorbisenc.vorbis_encode_init.argtypes = [vi_p, c_long, c_long, c_long, c_long, c_long] | ||||
| 
 | ||||
|         def vorbis_encode_init(vi, channels, rate, max_bitrate, nominal_bitrate, min_bitrate): | ||||
|             return libvorbisenc.vorbis_encode_init(vi, channels, rate, max_bitrate, nominal_bitrate, min_bitrate) | ||||
| 
 | ||||
|         libvorbisenc.vorbis_encode_setup_managed.restype = c_int | ||||
|         libvorbisenc.vorbis_encode_setup_managed.argtypes = [vi_p, c_long, c_long, c_long, c_long, c_long] | ||||
| 
 | ||||
|         def vorbis_encode_setup_managed(vi, channels, rate, max_bitrate, nominal_bitrate, min_bitrate): | ||||
|             return libvorbisenc.vorbis_encode_setup_managed(vi, channels, rate, max_bitrate, nominal_bitrate, min_bitrate) | ||||
| 
 | ||||
|         libvorbisenc.vorbis_encode_setup_vbr.restype = c_int | ||||
|         libvorbisenc.vorbis_encode_setup_vbr.argtypes = [vi_p, c_long, c_long, c_float] | ||||
| 
 | ||||
|         def vorbis_encode_setup_vbr(vi, channels, rate, quality): | ||||
|             return libvorbisenc.vorbis_encode_setup_vbr(vi, channels, rate, quality) | ||||
| 
 | ||||
|         libvorbisenc.vorbis_encode_init_vbr.restype = c_int | ||||
|         libvorbisenc.vorbis_encode_init_vbr.argtypes = [vi_p, c_long, c_long, c_float] | ||||
| 
 | ||||
|         def vorbis_encode_init_vbr(vi, channels, rate, quality): | ||||
|             return libvorbisenc.vorbis_encode_init_vbr(vi, channels, rate, quality) | ||||
| 
 | ||||
|         libvorbisenc.vorbis_encode_setup_init.restype = c_int | ||||
|         libvorbisenc.vorbis_encode_setup_init.argtypes = [vi_p] | ||||
| 
 | ||||
|         def vorbis_encode_setup_init(vi): | ||||
|             return libvorbisenc.vorbis_encode_setup_init(vi) | ||||
| 
 | ||||
|         libvorbisenc.vorbis_encode_setup_init.restype = c_int | ||||
|         libvorbisenc.vorbis_encode_setup_init.argtypes = [vi_p, c_int, c_void_p] | ||||
| 
 | ||||
|         def vorbis_encode_setup_init(vi, number, arg): | ||||
|             return libvorbisenc.vorbis_encode_setup_init(vi, number, arg) | ||||
| 
 | ||||
|         class ovectl_ratemanage_arg(ctypes.Structure): | ||||
|             _fields_ = [("management_active", c_int), | ||||
|                         ("bitrate_hard_min", c_long), | ||||
|                         ("bitrate_hard_max", c_long), | ||||
|                         ("bitrate_hard_window", c_double), | ||||
|                         ("bitrate_av_lo", c_long), | ||||
|                         ("bitrate_av_hi", c_long), | ||||
|                         ("bitrate_av_window", c_double), | ||||
|                         ("bitrate_av_window_center", c_double)] | ||||
| 
 | ||||
|         class ovectl_ratemanage2_arg(ctypes.Structure): | ||||
|             _fields_ = [("management_active", c_int), | ||||
|                         ("bitrate_limit_min_kbps", c_long), | ||||
|                         ("bitrate_limit_max_kbps", c_long), | ||||
|                         ("bitrate_limit_reservoir_bits", c_long), | ||||
|                         ("bitrate_limit_reservoir_bias", c_double), | ||||
|                         ("bitrate_average_kbps", c_long), | ||||
|                         ("bitrate_average_damping", c_double)] | ||||
| 
 | ||||
|         OV_ECTL_RATEMANAGE2_GET      =0x14 | ||||
| 
 | ||||
|         OV_ECTL_RATEMANAGE2_SET      =0x15 | ||||
| 
 | ||||
|         OV_ECTL_LOWPASS_GET          =0x20 | ||||
| 
 | ||||
|         OV_ECTL_LOWPASS_SET          =0x21 | ||||
| 
 | ||||
|         OV_ECTL_IBLOCK_GET           =0x30 | ||||
| 
 | ||||
|         OV_ECTL_IBLOCK_SET           =0x31 | ||||
| 
 | ||||
|         OV_ECTL_COUPLING_GET         =0x40 | ||||
| 
 | ||||
|         OV_ECTL_COUPLING_SET         =0x41 | ||||
| 
 | ||||
|         OV_ECTL_RATEMANAGE_GET       =0x10 | ||||
| 
 | ||||
|         OV_ECTL_RATEMANAGE_SET       =0x11 | ||||
| 
 | ||||
|         OV_ECTL_RATEMANAGE_AVG       =0x12 | ||||
| 
 | ||||
|         OV_ECTL_RATEMANAGE_HARD      =0x13 | ||||
|         # end of vorbisenc | ||||
|     except: | ||||
|         pass | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue