diff --git a/Makefile b/Makefile index 65e34ba..20dee20 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,7 @@ ifeq ($(shell uname -s), Darwin) #ARCH_FLAGS = -arch ppc -arch i386 else SYSTEM = "other" - ARCH_FLAGS = + ARCH_FLAGS = -fPIC endif CFLAGS = $(WARNING_FLAGS) $(OPTIMISE_FLAGS) $(LFS_FLAGS) -I. $(PROFILE_FLAGS) $(ARCH_FLAGS) @@ -198,7 +198,7 @@ TEST_PRINTING_PROG = $(BINDIR)/test_printing TEST_PROGS = test_nal_unit_list test_es_unit_list # ------------------------------------------------------------ -all: $(BINDIR) $(LIBDIR) $(OBJDIR) $(PROGS) +all: $(BINDIR) $(LIBDIR) $(OBJDIR) $(PROGS) $(SHARED_LIB) # ts2ps is not yet an offical program, so for the moment build # it separately @@ -213,6 +213,8 @@ $(SHARED_LIB): $(OBJS) libtool -dynamic $(OBJS) -o $(SHARED_LIB) else $(STATIC_LIB): $(STATIC_LIB)($(OBJS)) +$(SHARED_LIB): $(SHARED_LIB)($(OBJS)) + $(LD) -shared -o $(SHARED_LIB) $(OBJS) -lc endif # Build all of the utilities with the static library, so that they can diff --git a/python/Setup.py b/python/Setup.py index 6853ca3..88b4b65 100644 --- a/python/Setup.py +++ b/python/Setup.py @@ -26,19 +26,17 @@ # ***** END LICENSE BLOCK ***** from distutils.core import setup -from Pyrex.Distutils.extension import Extension -from Pyrex.Distutils import build_ext - -tstools = Extension("tstools/tstools", - ['tstools/tstools.pyx'], - include_dirs=['..'], - library_dirs=['../lib'], - libraries=['tstools'], - ) - +from distutils.extension import Extension +from Cython.Distutils import build_ext +tstools = Extension("tstools.tstools", + ['tstools/tstools.pyx'], + include_dirs=['..'], + library_dirs=['../lib'], + libraries=['tstools'], + ) setup( name = 'tstools', - ext_modules=[tstools], - cmdclass = {'build_ext': build_ext} + cmdclass = {'build_ext': build_ext}, + ext_modules=[tstools] ) diff --git a/python/tstools/cwrapper.pxd b/python/tstools/cwrapper.pxd index 7e6eee9..469a302 100644 --- a/python/tstools/cwrapper.pxd +++ b/python/tstools/cwrapper.pxd @@ -166,13 +166,13 @@ cdef extern from "ts_fns.h": byte *desc_data, int desc_data_len) cdef extern from 'nalunit_defns.h': - struct nal_unit_context + struct nal_unit_context: pass ctypedef nal_unit_context *nal_unit_context_p - struct nal_unit + struct nal_unit: pass ctypedef nal_unit *nal_unit_p - struct nal_unit_list + struct nal_unit_list: nal_unit_p *array int length int size @@ -212,18 +212,18 @@ cdef extern from 'accessunit_fns.h': int build_access_unit_context(ES_p es, access_unit_context_p *context) void free_access_unit_context(access_unit_context_p *context) int rewind_access_unit_context(access_unit_context_p context) - void free_access_unit(access_unit_p *acc_unit) - int get_access_unit_bounds(access_unit_p access_unit, ES_offset *start, + void free_access_unit(access_unit_context_p *acc_unit) + int get_access_unit_bounds(access_unit_context_p access_unit, ES_offset *start, uint32_t *length) - int all_slices_I(access_unit_p access_unit) - int all_slices_P(access_unit_p access_unit) - int all_slices_I_or_P(access_unit_p access_unit) - int all_slices_B(access_unit_p access_unit) + int all_slices_I(access_unit_context_p access_unit) + int all_slices_P(access_unit_context_p access_unit) + int all_slices_I_or_P(access_unit_context_p access_unit) + int all_slices_B(access_unit_context_p access_unit) int get_next_access_unit(access_unit_context_p context, int quiet, - int show_details, access_unit_p *ret_access_unit) + int show_details, access_unit_context_p *ret_access_unit) int get_next_h264_frame(access_unit_context_p context, int quiet, - int show_details, access_unit_p *frame) - int access_unit_has_PTS(access_unit_p access_unit) + int show_details, access_unit_context_p *frame) + int access_unit_has_PTS(access_unit_context_p access_unit) cdef extern from 'printing_fns.h': void print_msg(const_char_ptr text) @@ -233,7 +233,8 @@ cdef extern from 'printing_fns.h': int redirect_output( void (*new_print_message_fn) (const_char_ptr message), void (*new_print_error_fn) (const_char_ptr message), void (*new_fprint_message_fn) (const_char_ptr format, va_list arg_ptr), - void (*new_fprint_error_fn) (const_char_ptr format, va_list arg_ptr) + void (*new_fprint_error_fn) (const_char_ptr format, va_list arg_ptr), + void (*new_flush_msg_fn) () ) # This one isn't properly declared - it's not in the header files diff --git a/python/tstools/tstools.pyx b/python/tstools/tstools.pyx index 9a26ab5..a12ed2a 100644 --- a/python/tstools/tstools.pyx +++ b/python/tstools/tstools.pyx @@ -118,10 +118,13 @@ cdef void our_format_msg(const_char_ptr format, va_list arg_ptr): PyOS_vsnprintf(buffer, 1000, format, arg_ptr) PySys_WriteStdout('%s',buffer) +cdef void our_flush(): + pass + def setup_printing(): cdef int err err = cwrapper.redirect_output(our_print_msg, our_print_msg, - our_format_msg, our_format_msg) + our_format_msg, our_format_msg, our_flush) if err: raise TSToolsException, 'Setting output redirection FAILED' @@ -137,7 +140,7 @@ cdef void our_doctest_format_msg(const_char_ptr format, va_list arg_ptr): def setup_printing_for_doctest(): cdef int err err = cwrapper.redirect_output(our_doctest_print_msg, our_doctest_print_msg, - our_doctest_format_msg, our_doctest_format_msg) + our_doctest_format_msg, our_doctest_format_msg, our_flush) if err: raise TSToolsException, 'Setting doctest output redirection FAILED' else: @@ -146,8 +149,8 @@ def setup_printing_for_doctest(): def test_printing(): cwrapper.print_msg('Message\n') cwrapper.print_err('Error\n') - cwrapper.fprint_msg('Message "%s"\n','Fred') - cwrapper.fprint_err('Error "%s"\n','Fred') + #cwrapper.fprint_msg('Message "%s"\n','Fred') + #cwrapper.fprint_err('Error "%s"\n','Fred') def test_c_printing(): cwrapper.test_C_printing() @@ -473,7 +476,7 @@ cdef class ESFile: retval = fclose(self.file_stream) if retval != 0: raise TSToolsException,"Error closing file '%s':"\ - " %s"%(filename,strerror(errno)) + " %s"%(self.name,strerror(errno)) if self.stream != NULL: cwrapper.free_elementary_stream(&self.stream) # And obviously we're not available any more