Author: ArcRiley
Date: 2007-07-05 01:11:45 -0400 (Thu, 05 Jul 2007)
New Revision: 353
Added:
trunk/pysoy/src/_internals/Loadable.pxi
Modified:
trunk/pysoy/scripts/__init__.py
trunk/pysoy/setup.py
trunk/pysoy/src/_internals/Children.pxi
trunk/pysoy/src/_internals/FaceList.pxi
trunk/pysoy/src/_internals/soy._internals.pxd
trunk/pysoy/src/_internals/soy._internals.pyx
trunk/pysoy/src/textures/Texture.pxi
trunk/pysoy/src/textures/Video.pxi
trunk/pysoy/src/textures/soy.textures.pxd
trunk/pysoy/src/textures/soy.textures.pyx
trunk/pysoy/src/transports/File.pxi
trunk/pysoy/src/transports/Transport.pxi
trunk/pysoy/src/transports/soy.transports.pxd
Log:
*grumble*
Modified: trunk/pysoy/scripts/__init__.py
===================================================================
--- trunk/pysoy/scripts/__init__.py 2007-07-05 02:44:09 UTC (rev 352)
+++ trunk/pysoy/scripts/__init__.py 2007-07-05 05:11:45 UTC (rev 353)
@@ -25,5 +25,5 @@
import colors
import materials
import textures
-#import transports
+import transports
import widgets
Modified: trunk/pysoy/setup.py
===================================================================
--- trunk/pysoy/setup.py 2007-07-05 02:44:09 UTC (rev 352)
+++ trunk/pysoy/setup.py 2007-07-05 05:11:45 UTC (rev 353)
@@ -36,7 +36,7 @@
'materials' : ['GL'],
'textures' : ['GLEW','GL', 'ogg', 'theora'],
'shapes' : ['ode'],
-# 'transports' : ['ogg2'],
+ 'transports' : ['ogg'],
'widgets' : ['GLEW','GL','GLU'],
}
Modified: trunk/pysoy/src/_internals/Children.pxi
===================================================================
--- trunk/pysoy/src/_internals/Children.pxi 2007-07-05 02:44:09 UTC (rev
352)
+++ trunk/pysoy/src/_internals/Children.pxi 2007-07-05 05:11:45 UTC (rev
353)
@@ -17,6 +17,8 @@
#
# $Id$
+cimport py
+
cdef class Children :
'''PySoy Children
Modified: trunk/pysoy/src/_internals/FaceList.pxi
===================================================================
--- trunk/pysoy/src/_internals/FaceList.pxi 2007-07-05 02:44:09 UTC (rev
352)
+++ trunk/pysoy/src/_internals/FaceList.pxi 2007-07-05 05:11:45 UTC (rev
353)
@@ -17,15 +17,18 @@
#
# $Id$
-# This class is not intended to be stored or transfered on it's own but
-# rather as part of it's parent Mesh. Parent must be in __new__ as
-# it's parent holds the data this class works on.
+cimport soy.atoms
+cimport soy.bodies._bodies
cdef class FaceList :
'''PySoy FaceList
This is a list-like container class for the faces of a soy.bodies.Mesh
'''
+ # This class is not intended to be stored or transfered on it's own but
+ # rather as part of it's parent Mesh. Parent must be in __new__ as
+ # it's parent holds the data this class works on.
+
def __new__(self, mesh) :
if not isinstance(mesh, soy.bodies._bodies.Mesh) :
raise TypeError('argument must be of type soy.bodies.Mesh')
Added: trunk/pysoy/src/_internals/Loadable.pxi
===================================================================
--- trunk/pysoy/src/_internals/Loadable.pxi (rev 0)
+++ trunk/pysoy/src/_internals/Loadable.pxi 2007-07-05 05:11:45 UTC (rev
353)
@@ -0,0 +1,29 @@
+# PySoy _internals.Loadable class
+#
+# Copyright (C) 2007 Team PySoy
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+
+cdef class Loadable :
+ '''PySoy Loadable
+
+ This should be inherited by any PySoy class which can be loaded or saved.
+ '''
+ cdef int _load(self, void *data) :
+ return 0
+
+ cdef int _save(self, void *data) :
+ return 0
Property changes on: trunk/pysoy/src/_internals/Loadable.pxi
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/pysoy/src/_internals/soy._internals.pxd
===================================================================
--- trunk/pysoy/src/_internals/soy._internals.pxd 2007-07-05 02:44:09 UTC
(rev 352)
+++ trunk/pysoy/src/_internals/soy._internals.pxd 2007-07-05 05:11:45 UTC
(rev 353)
@@ -35,8 +35,15 @@
cdef void remove ( self, void* )
+cdef class FaceList :
+ cdef object _mesh
+
+
+cdef class Loadable :
+ cdef int _load(self, void *data)
+ cdef int _save(self, void *data)
+
+
cdef class VertexList :
cdef object _mesh
-cdef class FaceList :
- cdef object _mesh
Modified: trunk/pysoy/src/_internals/soy._internals.pyx
===================================================================
--- trunk/pysoy/src/_internals/soy._internals.pyx 2007-07-05 02:44:09 UTC
(rev 352)
+++ trunk/pysoy/src/_internals/soy._internals.pyx 2007-07-05 05:11:45 UTC
(rev 353)
@@ -26,10 +26,7 @@
'by '+'$Author$'[9:-2]
__version__ = 'Trunk (r'+'$Rev$'[6:-2]+')'
-cimport py
-cimport soy.atoms
-cimport soy.bodies._bodies
-
include "Children.pxi"
+include "Loadable.pxi"
include "FaceList.pxi"
include "VertexList.pxi"
Modified: trunk/pysoy/src/textures/Texture.pxi
===================================================================
--- trunk/pysoy/src/textures/Texture.pxi 2007-07-05 02:44:09 UTC (rev
352)
+++ trunk/pysoy/src/textures/Texture.pxi 2007-07-05 05:11:45 UTC (rev
353)
@@ -17,7 +17,7 @@
#
# $Id$
-cdef class Texture :
+cdef class Texture (soy._internals.Loadable) :
'''PySoy Texture
The base texture class which all others inherit
Modified: trunk/pysoy/src/textures/Video.pxi
===================================================================
--- trunk/pysoy/src/textures/Video.pxi 2007-07-05 02:44:09 UTC (rev 352)
+++ trunk/pysoy/src/textures/Video.pxi 2007-07-05 05:11:45 UTC (rev 353)
@@ -22,70 +22,45 @@
Renders an Ogg Theora stream to a texture
'''
- def __new__(self, filename, *args, **keywords) :
- cdef int f, i, lx, ly
- cdef ogg.ogg_page _oggPage
- cdef ogg_packet _oggPacket
- cdef ogg.ogg_stream_state _oggStream
- #
- self._fd = stdio.fopen(filename, 'rb')
- ogg.ogg_sync_init(&self._oy)
- ogg.theora_comment_init(&self._tc)
- ogg.theora_info_init(&self._ti)
- while not f :
- if _read() == 0 :
- break
- while ogg.ogg_sync_pageout(&self._oy, &_oggPage) > 0 :
- if not ogg.ogg_page_bos(&_oggPage) :
- queue_page(&_oggPage)
- f = 1
- break
- ogg.ogg_stream_init(&_oggStream, ogg.ogg_page_serialno(&_oggPage))
- ogg.ogg_stream_pagein(&_oggStream, &_oggPage)
- ogg.ogg_stream_packetout(&_oggStream, &_oggPacket)
+ cdef int _load(self, void *data) :
+ cdef ogg.ogg_page *_page
+ cdef ogg.yuv_buffer _yuvbuf
+ cdef ogg.ogg_packet _packet
+ _page = <ogg.ogg_page *> data
+ if self._stage == 0 :
+ ogg.ogg_stream_init(&self._stream, ogg.ogg_page_serialno(_page))
+ ogg.theora_info_init(&self._info)
+ ogg.theora_comment_init(&self._comment)
+ self._stage = 1
+ if self._stage > 0 :
+ if ogg.ogg_page_granulepos(_page) != 0 :
+ ogg.theora_decode_init(&self._decode, &self._info)
+ self._resize(3, self._squareup(self._info.width),
+ self._squareup(self._info.height), 1)
+ self._stage = 2
+ ogg.ogg_stream_pagein(&self._stream, _page)
+ if self._stage == 1 :
+ while ogg.ogg_stream_packetout(&self._stream, &_packet) :
+ if ogg.theora_decode_header(&self._info, &self._comment, &_packet)<0 :
+ # Error in header, clear what we've setup and bail
+ ogg.ogg_stream_clear(&self._stream)
+ ogg.theora_info_clear(&self._info)
+ ogg.theora_comment_clear(&self._comment)
+ self._stage = -1
+ return 0
+ if self._stage == 2 :
+ # We're not ready to do anything else yet
+ ogg.ogg_stream_clear(&self._stream)
+ ogg.theora_info_clear(&self._info)
+ ogg.theora_comment_clear(&self._comment)
+ ogg.theora_clear(&self._decode)
+ self._stage = -1
+ return 0
+ #ogg.theora_decode_YUVout(&self._td,&yuv);
+ return 1
- if(!theora_p && theora_decode_header(&ti,&tc,&op)>=0){
- /* it is theora -- save this stream state */
- memcpy(&to,&test,sizeof(test));
- theora_p=1;
- else :
- /* whatever it is, we don't care about it */
- ogg_stream_clear(&test);
+ cdef int _save(self, void *data) :
+ cdef ogg.ogg_page *_page
+ _page = <ogg.ogg_page *> data
+ return 1
-
-
- lx = self._squareup(img.size[0])
- ly = self._squareup(img.size[1])
- if lx != img.size[0] or ly != img.size[1] :
- idata = idata.resize((lx, ly))
- self._resize(3, lx, ly, 1)
- for b from 0 <= b < lx*ly :
- d = idata[b]
- for c from 0 <= c < self._chans :
- self._texels[(b*self._chans)+c] = d[c]
-
- cdef int _read(self) :
- cdef char *_buffer
- cdef int _bytes
- _buffer = ogg.ogg_sync_buffer(&self._oy, 4096)
- _bytes = stdio.fread(_buffer, 1, 4096, self._fd)
- ogg.ogg_sync_wrote(&self._oy, _bytes)
- return(_bytes)
-
- cdef int _getOggPage(self, *) :
-
- while 1 :
- if _read() == 0 :
- # End of File
- return -1
- while ogg.ogg_sync_pageout(&self._oy, &_oggPage) > 0 :
- if not ogg.ogg_page_bos(&_oggPage) :
- queue_page(&_oggPage)
- f = 1
- break
-
-
- cdef #### :
- cdef ogg.yuv_buffer yuv
- ogg.theora_decode_YUVout(&self._td,&yuv);
-
Modified: trunk/pysoy/src/textures/soy.textures.pxd
===================================================================
--- trunk/pysoy/src/textures/soy.textures.pxd 2007-07-05 02:44:09 UTC (rev
352)
+++ trunk/pysoy/src/textures/soy.textures.pxd 2007-07-05 05:11:45 UTC (rev
353)
@@ -23,7 +23,7 @@
cimport stdio
cimport soy._internals
-cdef class Texture :
+cdef class Texture (soy._internals.Loadable) :
cdef gl.GLuint _textureID
cdef gl.GLenum _textureTarget
cdef int _chans
@@ -31,10 +31,19 @@
cdef int _height
cdef int _depth
cdef gl.GLubyte *_texels
+ #
# Lookup Arrays
cdef int _iFormats[5]
cdef int _oFormats[5]
+ #
# C functions
cdef void _bind(self)
cdef void _resize(self, int, int, int, int)
cdef int _squareup(self, int)
+
+cdef class Video (Texture) :
+ cdef int _stage # -1=Null, 0=New, 1=Header, 2=Decode
+ cdef ogg.ogg_stream_state _stream
+ cdef ogg.theora_info _info
+ cdef ogg.theora_comment _comment
+ cdef ogg.theora_state _decode
Modified: trunk/pysoy/src/textures/soy.textures.pyx
===================================================================
--- trunk/pysoy/src/textures/soy.textures.pyx 2007-07-05 02:44:09 UTC (rev
352)
+++ trunk/pysoy/src/textures/soy.textures.pyx 2007-07-05 05:11:45 UTC (rev
353)
@@ -25,4 +25,4 @@
include "Texture.pxi"
include "Image.pxi"
-#include "Video.pxi"
+include "Video.pxi"
Modified: trunk/pysoy/src/transports/File.pxi
===================================================================
--- trunk/pysoy/src/transports/File.pxi 2007-07-05 02:44:09 UTC (rev 352)
+++ trunk/pysoy/src/transports/File.pxi 2007-07-05 05:11:45 UTC (rev 353)
@@ -1,4 +1,4 @@
-# PySoy storage.File Class
+# PySoy transports.File Class
#
# Copyright (C) 2006,2007 Team PySoy
#
@@ -17,151 +17,29 @@
#
# $Id$
-cdef class File :
+cdef class File (Transport) :
'''PySoy File
This class handles loading and saving .soy and .ogg files to disk.
'''
- def __new__(self, *args, **keywords) :
- self._chan = []
+ cdef int _open(self, path) :
+ self._file = stdio.fopen(path, 'rb')
+ if self._file :
+ return 1
- def __init__(self, path, *args, **keywords) :
- cdef char _magic[4]
- self._path = path
- self._file = stdio.fopen(self._path, 'r')
+
+ cdef int _read(self, char *_buffer, int _len) :
+ cdef int _ret
if not self._file :
- return
- if stdio.fread(<void *>_magic, 1, 4, self._file) < 4 :
+ return 0
+ _ret = stdio.fread(_buffer, 1, _len, self._file)
+ if _ret == 0 :
stdio.fclose(self._file)
- return
- if _magic[:4] != 'OggS' :
- stdio.fclose(self._file)
- raise IOError('Unknown file format')
- stdio.rewind(self._file)
+ self._file = NULL
+ return _ret
- cdef int _read(self, ogg2_sync_state* _sync) :
- cdef unsigned char *_buff
- cdef int _byts
- _buff = ogg.ogg2_sync_bufferin(_sync, 4096)
- if _buff == NULL :
- return ogg.OGG2_EEOS
- _byts = stdio.fread(_buff, 1, 4096, self._file)
- if _byts == 0 :
- return ogg.OGG2_EEOS
- self._oset = self._oset + _byts
- return ogg.ogg2_sync_wrote(_sync, _byts)
- return
- cdef int _write(self, ogg2_sync_state* _sync) :
- cdef unsigned char *_buff
- cdef int _byts
- _byts = ogg.ogg2_sync_bufferout(_sync, &_buff)
- if _byts == 0 :
- return ogg.OGG2_SUCCESS
- _byts = stdio.fwrite(_buff, 1, _byts, self._file)
- return ogg.ogg2_sync_read(_sync, _byts)
+ cdef int _write(self, char *_buffer, int _len) :
+ return stdio.fwrite(_buffer, 1, _len, self._file)
- cdef void _scan(self) :
- # Run scan for objects
- _bytes = 1
- _offset = 0
- _page.header = NULL
- _page.body = NULL
- _packet.packet = NULL
- _packbuffer = <ogg.ogg2pack_buffer *> py.PyMem_Malloc(
- ogg.ogg2pack_buffersize())
- if _packbuffer == NULL :
- raise('Out of Memory')
- _sync = ogg.ogg2_sync_create()
- while _bytes>0 :
- # This loops for each chained object in the file
- streams = {}
- _start = _offset
- _inhead = 1
-
- while True :
- while not (_status==1 or _bytes==0) :
- _status = ogg.ogg2_sync_pageout(_sync, &_page)
- if _status==1 :
- break
- _filebuffer = ogg.ogg2_sync_bufferin(_sync, 4096)
- _bytes = stdio.fread(_filebuffer, 1, 4096, self._file)
- _status = ogg.ogg2_sync_wrote(_sync, _bytes)
- if _status != ogg.OGG2_SUCCESS :
- py.PyMem_Free(_packbuffer)
- ogg.ogg2_page_release(&_page)
- raise('Error writing to ogg2_sync buffer')
- _status = ogg.ogg2_sync_pageout(_sync, &_page)
- if _bytes==0 :
- break
- _serialno = ogg.ogg2_page_serialno(&_page)
- _offset = _offset + _page.header_len + _page.body_len
- if streams.has_key(_serialno) :
- ogg.ogg2_page_release(&_page)
- _inhead = 0
- _status = 0
- else :
- if _inhead :
- _end = _offset
- # Read packet0 to a header string
- _stream = ogg.ogg2_stream_create(_serialno)
- _status = ogg.ogg2_stream_pagein(_stream, &_page)
- _status = ogg.ogg2_stream_packetout(_stream, &_packet)
- ogg.ogg2packB_readinit(_packbuffer, _packet.packet)
- if ogg.ogg2packB_read(_packbuffer, 32, &_v) == 0 :
- # detect then call the codec packet0 scanner
- if _v == 1936685312 :
- streams[_serialno] = ['.soy0','','']
- # Read Class Name
- ogg.ogg2packB_read(_packbuffer, 8, &_v)
- for _i from 0 <= _i < _v :
- ogg.ogg2packB_read(_packbuffer, 8, &_c)
- _string[_i] = _c
- streams[_serialno][1] = _string[:_v]
- # Read Object Name
- ogg.ogg2packB_read(_packbuffer, 8, &_v)
- for _i from 0 <= _i < _v :
- ogg.ogg2packB_read(_packbuffer, 8, &_c)
- _string[_i] = _c
- streams[_serialno][2] = _string[:_v]
- elif _v == 24538994 :
- streams[_serialno] = 'Vorbis'
- elif _v == 2155112549L :
- streams[_serialno] = 'Theora'
- elif _v == 7828073 :
- streams[_serialno] = 'Writ'
- elif _v == 1399874917L :
- streams[_serialno] = 'Speex'
- elif _v == 2135313473L :
- streams[_serialno] = 'FLAC'
- else :
- streams[_serialno] = 'Unknown'
- ogg.ogg2_stream_destroy(_stream)
- _status = 0
- else :
- break
- codecs = streams.values()
- codecs.sort()
- if codecs[0][0] == '.soy0' :
- for stream in streams :
- if streams[stream][0] == '.soy0' :
- modstr = '.'.join(streams[stream][1].split('.')[:-1])
- clsstr = streams[stream][1].split('.')[-1]
- module = __import__(modstr, [], [], [clsstr])
- self._objs[streams[stream][2]] = module.__dict__[clsstr]()
- # Ok, start main loop over, using this page first thing
- _status = 1
- py.PyMem_Free(_packbuffer)
- ogg.ogg2_sync_destroy(_sync)
- def __getitem__(self, key) :
- return self._chan[key]
-
- def __repr__(self) :
- return self._chan.__repr__()
-
- def __str__(self) :
- return self._chan.__str__()
-
- def __len__(self) :
- return self._chan.__len__()
Modified: trunk/pysoy/src/transports/Transport.pxi
===================================================================
--- trunk/pysoy/src/transports/Transport.pxi 2007-07-05 02:44:09 UTC (rev
352)
+++ trunk/pysoy/src/transports/Transport.pxi 2007-07-05 05:11:45 UTC (rev
353)
@@ -17,115 +17,140 @@
#
# $Id$
+cimport soy.textures
+
cdef class Transport :
'''PySoy Transport
This class provides the basic data stream parsing for all transports.
'''
- def __new__(self, *args, **keywords) :
- self._chan = []
-
- cdef void _scan(self) :
- # Run scan for objects
- _bytes = 1
- _offset = 0
- _page.header = NULL
- _page.body = NULL
- _packet.packet = NULL
- _packbuffer = <ogg.ogg2pack_buffer *> py.PyMem_Malloc(
- ogg.ogg2pack_buffersize())
- if _packbuffer == NULL :
- raise('Out of Memory')
- _sync = ogg.ogg2_sync_create()
- while _bytes>0 :
- # This loops for each chained object in the file
- streams = {}
- _start = _offset
- _inhead = 1
-
- while True :
- while not (_status==1 or _bytes==0) :
- _status = ogg.ogg2_sync_pageout(_sync, &_page)
- if _status==1 :
- break
- _filebuffer = ogg.ogg2_sync_bufferin(_sync, 4096)
- _bytes = stdio.fread(_filebuffer, 1, 4096, self._file)
- _status = ogg.ogg2_sync_wrote(_sync, _bytes)
- if _status != ogg.OGG2_SUCCESS :
- py.PyMem_Free(_packbuffer)
- ogg.ogg2_page_release(&_page)
- raise('Error writing to ogg2_sync buffer')
- _status = ogg.ogg2_sync_pageout(_sync, &_page)
- if _bytes==0 :
- break
- _serialno = ogg.ogg2_page_serialno(&_page)
- _offset = _offset + _page.header_len + _page.body_len
- if streams.has_key(_serialno) :
- ogg.ogg2_page_release(&_page)
- _inhead = 0
- _status = 0
+ def __init__(self, path, *args, **keywords) :
+ cdef char _magic[4]
+ self._objs = {}
+ self._snos = {}
+ if self._open(path) :
+ if self._read(_magic,4) == 0 :
+ self._vers = -1
+ else :
+ if _magic[:4] == 'OggS' :
+ self._headOgg()
+ #elif _magic == 'Soy0' :
else :
- if _inhead :
- _end = _offset
- # Read packet0 to a header string
- _stream = ogg.ogg2_stream_create(_serialno)
- _status = ogg.ogg2_stream_pagein(_stream, &_page)
- _status = ogg.ogg2_stream_packetout(_stream, &_packet)
- ogg.ogg2packB_readinit(_packbuffer, _packet.packet)
- if ogg.ogg2packB_read(_packbuffer, 32, &_v) == 0 :
- # detect then call the codec packet0 scanner
- if _v == 1936685312 :
- streams[_serialno] = ['.soy0','','']
- # Read Class Name
- ogg.ogg2packB_read(_packbuffer, 8, &_v)
- for _i from 0 <= _i < _v :
- ogg.ogg2packB_read(_packbuffer, 8, &_c)
- _string[_i] = _c
- streams[_serialno][1] = _string[:_v]
- # Read Object Name
- ogg.ogg2packB_read(_packbuffer, 8, &_v)
- for _i from 0 <= _i < _v :
- ogg.ogg2packB_read(_packbuffer, 8, &_c)
- _string[_i] = _c
- streams[_serialno][2] = _string[:_v]
- elif _v == 24538994 :
- streams[_serialno] = 'Vorbis'
- elif _v == 2155112549L :
- streams[_serialno] = 'Theora'
- elif _v == 7828073 :
- streams[_serialno] = 'Writ'
- elif _v == 1399874917L :
- streams[_serialno] = 'Speex'
- elif _v == 2135313473L :
- streams[_serialno] = 'FLAC'
- else :
- streams[_serialno] = 'Unknown'
- ogg.ogg2_stream_destroy(_stream)
- _status = 0
- else :
- break
- codecs = streams.values()
- codecs.sort()
- if codecs[0][0] == '.soy0' :
- for stream in streams :
- if streams[stream][0] == '.soy0' :
- modstr = '.'.join(streams[stream][1].split('.')[:-1])
- clsstr = streams[stream][1].split('.')[-1]
- module = __import__(modstr, [], [], [clsstr])
- self._objs[streams[stream][2]] = module.__dict__[clsstr]()
- # Ok, start main loop over, using this page first thing
- _status = 1
- py.PyMem_Free(_packbuffer)
- ogg.ogg2_sync_destroy(_sync)
+ raise TypeError('unsupported file type')
+ # This is called by _coreLoop()
+ cdef void _process(self) :
+ if self._mode == 1 :
+ if self._vers == 0 :
+ self._loadOgg()
+
+
+ ############################################################################
+ # Transport-specific functions
+ #
+ cdef int _open(self, path) :
+ return 0
+
+
+ cdef int _read(self, char *_buffer, int _len) :
+ return 0
+
+
+ cdef int _write(self, char *_buffer, int _len) :
+ return 0
+
+
+ ############################################################################
+ # Ogg functions
+ #
+ cdef void _headOgg(self) :
+ cdef unsigned int m
+ cdef char *_magic
+ cdef ogg.ogg_page _page
+ cdef ogg.ogg_packet _packet
+ cdef ogg.oggpack_buffer _buffer
+ cdef ogg.ogg_stream_state _testStream
+ #self._sync = <ogg.ogg_sync_state *> py.PyMem_Malloc(32)
+ ogg.ogg_sync_init(&self._sync)
+ _magic = ogg.ogg_sync_buffer(&self._sync, 4)
+ _magic[0] = 79
+ _magic[1] = 103
+ _magic[2] = 103
+ _magic[3] = 83
+ ogg.ogg_sync_wrote(&self._sync, 4)
+ while self._readOggPage(&_page) :
+ if not ogg.ogg_page_bos(&_page) :
+ (<soy._internals.Loadable> self._objs['video'])._load(&_page)
+ break
+ ogg.ogg_stream_init(&_testStream, ogg.ogg_page_serialno(&_page))
+ ogg.ogg_stream_pagein(&_testStream, &_page)
+ ogg.ogg_stream_packetout(&_testStream, &_packet)
+ ogg.oggpackB_readinit(&_buffer, _packet.packet, _packet.bytes)
+ m = ogg.oggpackB_read(&_buffer, 32)
+ if m == 2155112549L and not self._objs.has_key('video') :
+ self._objs['video'] = soy.textures.Video()
+ self._snos[ogg.ogg_page_serialno(&_page)] = 'video'
+ (<soy._internals.Loadable> self._objs['video'])._load(&_page)
+ # 24538994 = vorbis
+ # 7828073 = writ
+ # 1399874917L = speex
+ # 2135313473L = flac
+ ogg.ogg_stream_clear(&_testStream)
+ self._vers = 0 # Ogg
+ self._mode = 1 # Loading
+
+
+ cdef void _loadOgg(self) :
+ cdef int _sn
+ cdef ogg.ogg_page _page
+ if self._readOggPage(&_page) :
+ _sn = ogg.ogg_page_serialno(&_page)
+ if self._snos.has_key(_sn) :
+ (<soy._internals.Loadable> self._objs[self._snos[_sn]])._load(&_page)
+
+
+ cdef int _readOggPage(self, ogg.ogg_page *_oggPage) :
+ cdef char *_buffer
+ cdef int _bytes
+ while ogg.ogg_sync_pageout(&self._sync, _oggPage) == 0 :
+ _buffer = ogg.ogg_sync_buffer(&self._sync, 4096)
+ _bytes = self._read(_buffer, 4096)
+ ogg.ogg_sync_wrote(&self._sync, _bytes)
+ if _bytes == 0 :
+ # End of File
+ return 0
+ return 1
+
+
+ ############################################################################
+ # Soy functions
+ #
+ cdef void _headSoy(self) :
+ return
+
+
+ cdef void _loadSoy(self) :
+ return
+
+
+ cdef int _readSoyPage(self) :
+ return 0
+
+
+ ############################################################################
+ # Python methods
+ #
def __getitem__(self, key) :
- return self._chan[key]
+ return self._objs[key]
+
def __repr__(self) :
- return self._chan.__repr__()
+ return self._objs.__repr__()
+
def __str__(self) :
- return self._chan.__str__()
+ return self._objs.__str__()
+
def __len__(self) :
- return self._chan.__len__()
+ return self._objs.__len__()
Modified: trunk/pysoy/src/transports/soy.transports.pxd
===================================================================
--- trunk/pysoy/src/transports/soy.transports.pxd 2007-07-05 02:44:09 UTC
(rev 352)
+++ trunk/pysoy/src/transports/soy.transports.pxd 2007-07-05 05:11:45 UTC
(rev 353)
@@ -22,14 +22,31 @@
cimport stdio
cimport soy._internals
-cdef struct OggStream :
- char _name[257]
- ogg.ogg2_stream_state *state
+cdef class Transport :
+ cdef object _objs # OBJectS
+ cdef object _snos
+ cdef int _vers # -1 = empty, 0 = ogg, 1 = soy
+ cdef int _mode # 0 = idle, 1 = load, 2 = save
+ cdef ogg.ogg_sync_state _sync
+ #
+ # General Functions
+ cdef void _process(self)
+ #
+ # Transport-specific functions
+ cdef int _open(self, path)
+ cdef int _read(self, char *_buffer, int _len)
+ cdef int _write(self, char *_buffer, int _len)
+ #
+ # Ogg functions
+ cdef void _headOgg(self)
+ cdef void _loadOgg(self)
+ cdef int _readOggPage(self, ogg.ogg_page *_oggPage)
+ #
+ # Soy functions
+ cdef void _headSoy(self)
+ cdef void _loadSoy(self)
+ cdef int _readSoyPage(self)
+
-cdef class File :
- cdef object _path
- cdef object _objs
- cdef void* _file
- cdef int _mode # 0 = idle, 1 = load, 2 = save
- cdef ogg.ogg2_sync_state *_sync
- cdef OggStream _stat[256]
+cdef class File (Transport) :
+ cdef void *_file
_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn