[xiph-commits] r3165 - in liboggplay/trunk: . plugin python src/liboggplay

shans at svn.annodex.net shans at svn.annodex.net
Fri Jul 20 00:28:58 PDT 2007


Author: shans
Date: 2007-07-20 00:28:58 -0700 (Fri, 20 Jul 2007)
New Revision: 3165

Added:
   liboggplay/trunk/python/
   liboggplay/trunk/python/__init__.py
   liboggplay/trunk/python/liboggplay.i
   liboggplay/trunk/python/setup.py
Modified:
   liboggplay/trunk/plugin/plugin_cmml.c
   liboggplay/trunk/src/liboggplay/oggplay_callback_info.c
Log:
Python wrappers for liboggplay - probably don't completely work yet.


Modified: liboggplay/trunk/plugin/plugin_cmml.c
===================================================================
--- liboggplay/trunk/plugin/plugin_cmml.c	2007-07-19 08:00:37 UTC (rev 3164)
+++ liboggplay/trunk/plugin/plugin_cmml.c	2007-07-20 07:28:58 UTC (rev 3165)
@@ -288,7 +288,7 @@
 
   if (r < 0) return NULL;
 
-#define CHUNK_SIZE    2048
+#define CHUNK_SIZE    16394
 
   while (1) {
 

Added: liboggplay/trunk/python/__init__.py
===================================================================
--- liboggplay/trunk/python/__init__.py	                        (rev 0)
+++ liboggplay/trunk/python/__init__.py	2007-07-20 07:28:58 UTC (rev 3165)
@@ -0,0 +1 @@
+from oggplay import *

Added: liboggplay/trunk/python/liboggplay.i
===================================================================
--- liboggplay/trunk/python/liboggplay.i	                        (rev 0)
+++ liboggplay/trunk/python/liboggplay.i	2007-07-20 07:28:58 UTC (rev 3165)
@@ -0,0 +1,226 @@
+%module oggplay
+%{
+#include "oggplay/oggplay.h"
+%}
+
+typedef enum OggPlayErrorCode {
+  E_OGGPLAY_CONTINUE          = 1,
+  E_OGGPLAY_OK                = 0,
+  E_OGGPLAY_BAD_OGGPLAY       = -1,
+  E_OGGPLAY_BAD_READER        = -2,
+  E_OGGPLAY_BAD_INPUT         = -3,
+  E_OGGPLAY_NO_SUCH_CHUNK     = -4,
+  E_OGGPLAY_BAD_TRACK         = -5,
+  E_OGGPLAY_TRACK_IS_SKELETON = -6,
+  E_OGGPLAY_OGGZ_UNHAPPY      = -7,
+  E_OGGPLAY_END_OF_FILE       = -8,
+  E_OGGPLAY_TRACK_IS_OVER     = -9,
+  E_OGGPLAY_BAD_CALLBACK_INFO = -10,
+  E_OGGPLAY_WRONG_TRACK_TYPE  = -11,
+  E_OGGPLAY_UNINITIALISED     = -12,
+  E_OGGPLAY_CALLBACK_MODE     = -13,
+  E_OGGPLAY_BUFFER_MODE       = -14,
+  E_OGGPLAY_USER_INTERRUPT    = -15,
+  E_OGGPLAY_SOCKET_ERROR      = -16,
+  E_OGGPLAY_TIMEOUT           = -17,
+  E_OGGPLAY_CANT_SEEK         = -18,
+  E_OGGPLAY_NOTCHICKENPAYBACK = -777
+} OggPlayErrorCode;
+
+typedef enum OggzStreamContent {
+  OGGZ_CONTENT_THEORA = 0,
+  OGGZ_CONTENT_VORBIS,
+  OGGZ_CONTENT_SPEEX,
+  OGGZ_CONTENT_PCM,
+  OGGZ_CONTENT_CMML,
+  OGGZ_CONTENT_ANX2,
+  OGGZ_CONTENT_SKELETON,
+  OGGZ_CONTENT_FLAC0,
+  OGGZ_CONTENT_FLAC,
+  OGGZ_CONTENT_ANXDATA,
+  OGGZ_CONTENT_UNKNOWN
+} OggzStreamContent;
+
+typedef int (OggPlayDataCallback)(OggPlay *player, int num_records,
+                OggPlayCallbackInfo **records, void *user);
+
+%{
+static int PythonCallBack(OggPlay *player, int num_records, 
+                OggPlayCallbackInfo **records, void *user_data) {
+    
+    PyObject  * func;
+    PyObject  * arglist;
+    PyObject  * player_p;
+    PyObject  * result;
+    int         r = 0;
+    int         i;
+    PyObject  * list;
+
+    list = PyList_New(4);
+    for (i = 0; i < num_records; i++) {
+      PyList_SetItem(list, i, SWIG_NewPointerObj(SWIG_as_voidptr(records[i]),
+              SWIGTYPE_p_OggPlayCallbackInfo, 0 | 0));
+    }
+
+    player_p = SWIG_NewPointerObj(SWIG_as_voidptr(player), SWIGTYPE_p_OggPlay,
+                                      0 | 0);
+
+    func = (PyObject *)user_data;
+    arglist = Py_BuildValue("NN", player_p, list);
+    result = PyEval_CallObject(func, arglist);
+    Py_DECREF(arglist);
+    Py_DECREF(list);
+    if (result) {
+      r = (int)PyInt_AsLong(result);
+    }
+    Py_XDECREF(result);
+    return r;
+}
+
+static void oggplay_set_data_pycallback(OggPlay *me, PyObject *pycallback) {
+  oggplay_set_data_callback(me, PythonCallBack, pycallback);
+  Py_INCREF(pycallback);
+}
+%}
+
+%typemap(out) OggPlayDataHeader ** {
+  int len = 0;
+  $result = PyList_New(0);
+  while ($1[len]) {
+    PyList_Append($result, SWIG_NewPointerObj(SWIG_as_voidptr($1[len]),
+              SWIGTYPE_p__OggPlayDataHeader, 0 | 0));
+    len++;
+  }
+}
+
+typedef long long ogg_int64_t;
+
+OggPlay *
+oggplay_open_with_reader(OggPlayReader *reader);
+
+OggPlay *
+oggplay_new_with_reader(OggPlayReader *reader);
+
+OggPlayErrorCode
+oggplay_initialise(OggPlay *me, int block);
+
+void
+oggplay_set_data_pycallback(OggPlay *me, PyObject *pycallback);
+
+OggPlayErrorCode
+oggplay_set_callback_num_frames(OggPlay *me, int stream, int frames);
+
+OggPlayErrorCode
+oggplay_set_offset(OggPlay *me, int track, ogg_int64_t offset);
+
+OggPlayErrorCode
+oggplay_get_video_y_size(OggPlay *me, int track, int *y_width, int *y_height);
+
+OggPlayErrorCode
+oggplay_get_video_uv_size(OggPlay *me, int track, int *uv_width, int *uv_height);
+
+OggPlayErrorCode
+oggplay_get_audio_channels(OggPlay *me, int track, int *channels);
+
+OggPlayErrorCode
+oggplay_get_audio_samplerate(OggPlay *me, int track, int *samplerate); 
+
+OggPlayErrorCode
+oggplay_get_video_fps(OggPlay *me, int track, int* fps_denom, int* fps_num);
+
+OggPlayErrorCode
+oggplay_start_decoding(OggPlay *me);
+
+OggPlayErrorCode
+oggplay_step_decoding(OggPlay *me);
+
+OggPlayErrorCode
+oggplay_use_buffer(OggPlay *player, int size);
+
+OggPlayCallbackInfo **
+oggplay_buffer_retrieve_next(OggPlay *player);
+
+OggPlayErrorCode
+oggplay_buffer_release(OggPlay *player, OggPlayCallbackInfo **track_info);
+
+void
+oggplay_prepare_for_close(OggPlay *me);
+
+OggPlayErrorCode
+oggplay_close(OggPlay *player);
+
+int
+oggplay_get_available(OggPlay *player);
+
+int
+oggplay_get_duration(OggPlay * player);
+
+OggPlayReader *
+oggplay_file_reader_new(char *filename);
+
+OggPlayReader *
+oggplay_tcp_reader_new(char *uri, char *proxy, int proxy_port);
+
+int
+oggplay_get_num_tracks (OggPlay * me);
+
+OggzStreamContent
+oggplay_get_track_type (OggPlay * me, int track_num);
+
+const char *
+oggplay_get_track_typename (OggPlay * me, int track_num);
+
+OggPlayErrorCode
+oggplay_set_track_active(OggPlay *me, int track_num);
+
+typedef struct {
+  unsigned char   * y;
+  unsigned char   * u;
+  unsigned char   * v;
+} OggPlayVideoData;
+
+typedef void * OggPlayAudioData;
+
+typedef char OggPlayTextData;
+
+struct _OggPlayDataHeader;
+typedef struct _OggPlayDataHeader OggPlayDataHeader;
+
+OggPlayDataType
+oggplay_callback_info_get_type(OggPlayCallbackInfo *info);
+
+int
+oggplay_callback_info_get_available(OggPlayCallbackInfo *info);
+
+int
+oggplay_callback_info_get_required(OggPlayCallbackInfo *info);
+
+OggPlayDataHeader **
+oggplay_callback_info_get_headers(OggPlayCallbackInfo *info);
+
+int
+oggplay_callback_info_get_record_size(OggPlayDataHeader *header);
+
+OggPlayVideoData *
+oggplay_callback_info_get_video_data(OggPlayDataHeader *header);
+
+OggPlayAudioData *
+oggplay_callback_info_get_audio_data(OggPlayDataHeader *header);
+
+OggPlayTextData *
+oggplay_callback_info_get_text_data(OggPlayDataHeader *header);
+
+OggPlayStreamInfo
+oggplay_callback_info_get_stream_info(OggPlayCallbackInfo *info);
+
+void
+oggplay_callback_info_lock_item(OggPlayDataHeader *header);
+
+void
+oggplay_callback_info_unlock_item(OggPlayDataHeader *header);
+
+long
+oggplay_callback_info_get_presentation_time(OggPlayDataHeader *header);
+
+OggPlayErrorCode
+oggplay_seek(OggPlay *me, ogg_int64_t milliseconds);

Added: liboggplay/trunk/python/setup.py
===================================================================
--- liboggplay/trunk/python/setup.py	                        (rev 0)
+++ liboggplay/trunk/python/setup.py	2007-07-20 07:28:58 UTC (rev 3165)
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+
+"""Setup script for the PyAnnodex module distribution."""
+
+import os
+import re
+import sys
+import string
+
+from distutils.core import setup
+from distutils.extension import Extension
+
+oggplay_include_dir = "../include"
+oggplay_lib_dir = "../src/liboggplay/.libs"
+oggplay_libs = ["oggplay"]
+
+
+_oggplaymodule = Extension(
+    name='_oggplay',
+    sources=['liboggplay_wrap.c'],
+    include_dirs=[oggplay_include_dir],
+    library_dirs=[oggplay_lib_dir],
+    libraries=oggplay_libs)
+
+setup (
+    name = "pyoggplay",
+    version = "1",
+    description = "Python bindings for oggplay libraries",
+    author = "Shane Stephens",
+    author_email = "shane.stephens at csiro.au",
+    platforms = ["POSIX", "MacOS", "Windows"],
+    license = "BSD",
+    packages = ["oggplay"],
+    package_dir = {"oggplay" : "."},
+    ext_package = "oggplay",
+    ext_modules = [_oggplaymodule],
+    classifiers = ["Development Status :: 4 - Beta",
+                   "Intended Audience :: Developers",
+                   "Operating System :: OS Independent",
+                   "Programming Language :: C",
+                   "Programming Language :: Python",
+                   "Topic :: Multimedia :: Video",
+                   "Topic :: Software Development :: Libraries :: Python Modules"]
+    )


Property changes on: liboggplay/trunk/python/setup.py
___________________________________________________________________
Name: svn:executable
   + *

Modified: liboggplay/trunk/src/liboggplay/oggplay_callback_info.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_callback_info.c	2007-07-19 08:00:37 UTC (rev 3164)
+++ liboggplay/trunk/src/liboggplay/oggplay_callback_info.c	2007-07-20 07:28:58 UTC (rev 3165)
@@ -118,8 +118,11 @@
    } else {
       track_info->stream_info = OGGPLAY_STREAM_UNINITIALISED;
     }
-    
-    track_info->records = malloc (count * sizeof (OggPlayDataHeader *));
+   
+    /* null-terminate the record list for the python interface */
+    track_info->records = malloc ((count + 1) * sizeof (OggPlayDataHeader *));
+    track_info->records[count] = NULL;
+
     track_info->available_records = count;
     track_info->required_records = 0;
 



More information about the commits mailing list