[xiph-cvs] cvs commit: ogg-python/src _oggmodule.c _oggmodule.h pyoggpage.c pyoggstreamstate.c pyoggsyncstate.c pyoggsyncstate.h

Andrew Catham Master of Python andrew at xiph.org
Tue Mar 27 15:54:41 PST 2001



andrew      01/03/27 15:54:40

  Modified:    .        ChangeLog
               src      _oggmodule.c _oggmodule.h pyoggpage.c
                        pyoggstreamstate.c pyoggsyncstate.c
                        pyoggsyncstate.h
  Log:
  3-27-2001 Andrew H. Chatham <andrew.chatham at duke.edu>
          * src/_oggmodule.c: Added OggSyncState
  
          * src/pyoggpage.c: Added _continued, _bos, _granulepos
  
          * src/pyoggstreamstate.c: Added _clear
  
          * src/pyoggsyncstate.c: Added _pageseek, _clear and constructor

Revision  Changes    Path
1.3       +9 -0      ogg-python/ChangeLog

Index: ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/ogg-python/ChangeLog,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ChangeLog	2001/03/18 02:46:12	1.2
+++ ChangeLog	2001/03/27 23:54:39	1.3
@@ -1,3 +1,12 @@
+3-27-2001 Andrew H. Chatham <andrew.chatham at duke.edu>
+	* src/_oggmodule.c: Added OggSyncState
+
+	* src/pyoggpage.c: Added _continued, _bos, _granulepos
+
+	* src/pyoggstreamstate.c: Added _clear
+
+	* src/pyoggsyncstate.c: Added _pageseek, _clear and constructor
+	
 3-17-2001 Andrew H. Chatham <andrew.chatham at duke.edu>
         * src/_oggmodule.c: Remove dependency on Vorbis
 

1.3       +2 -0      ogg-python/src/_oggmodule.c

Index: _oggmodule.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-python/src/_oggmodule.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- _oggmodule.c	2001/03/18 02:46:12	1.2
+++ _oggmodule.c	2001/03/27 23:54:39	1.3
@@ -12,6 +12,8 @@
    METH_VARARGS, py_ogg_stream_state_doc},
   {"OggPackBuff", py_oggpack_buffer_new,
    METH_VARARGS, py_oggpack_buffer_doc},
+  {"OggSyncState", py_ogg_sync_state_new,
+   METH_VARARGS, py_ogg_sync_state_doc},
   {NULL, NULL}
 };
 

1.3       +1 -0      ogg-python/src/_oggmodule.h

Index: _oggmodule.h
===================================================================
RCS file: /usr/local/cvsroot/ogg-python/src/_oggmodule.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- _oggmodule.h	2001/03/18 02:46:12	1.2
+++ _oggmodule.h	2001/03/27 23:54:39	1.3
@@ -9,5 +9,6 @@
 
 extern char py_ogg_stream_state_doc[];
 extern char py_oggpack_buffer_doc[];
+extern char py_ogg_sync_state_doc[];
 
 #endif /* __OGGMODULE_H__ */

1.2       +28 -0     ogg-python/src/pyoggpage.c

Index: pyoggpage.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-python/src/pyoggpage.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pyoggpage.c	2001/02/06 03:18:19	1.1
+++ pyoggpage.c	2001/03/27 23:54:39	1.2
@@ -17,6 +17,9 @@
 FDEF(ogg_page_version) "Return the stream version";
 FDEF(ogg_page_serialno) "Return the serial number of the page";
 FDEF(ogg_page_pageno) "Return the page number of the page";
+FDEF(ogg_page_continued) "Return whether this page contains data continued from the previous page.";
+FDEF(ogg_page_bos) "Return whether this page is the beginning of a logical bistream.";
+FDEF(ogg_page_granulepos) "Return the granular position of the data contained in this page.";
 
 PyTypeObject py_ogg_page_type = {
   PyObject_HEAD_INIT(&PyType_Type)
@@ -58,6 +61,12 @@
    METH_VARARGS, py_ogg_page_serialno_doc},
   {"pageno", py_ogg_page_pageno,
    METH_VARARGS, py_ogg_page_pageno_doc},
+  {"continued", py_ogg_page_continued,
+   METH_VARARGS, py_ogg_page_continued_doc},
+  {"bos", py_ogg_page_bos,
+   METH_VARARGS, py_ogg_page_bos_doc},
+  {"granulepos", py_ogg_page_granulepos,
+   METH_VARARGS, py_ogg_page_granulepos_doc},
   {NULL, NULL}
 };
 
@@ -129,3 +138,22 @@
 {
   return PyLong_FromLong(ogg_page_pageno(PY_OGG_PAGE(self)));
 }
+
+static PyObject *
+py_ogg_page_continued(PyObject *self, PyObject *args) 
+{
+  return PyInt_FromLong(ogg_page_continued(PY_OGG_PAGE(self)));
+}
+
+static PyObject *
+py_ogg_page_bos(PyObject *self, PyObject *args) 
+{
+  return PyInt_FromLong(ogg_page_bos(PY_OGG_PAGE(self)));
+}
+
+static PyObject *
+py_ogg_page_granulepos(PyObject *self, PyObject *args) 
+{
+  return PyLong_FromLong(ogg_page_granulepos(PY_OGG_PAGE(self)));
+}
+

1.2       +14 -2     ogg-python/src/pyoggstreamstate.c

Index: pyoggstreamstate.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-python/src/pyoggstreamstate.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pyoggstreamstate.c	2001/02/06 03:18:19	1.1
+++ pyoggstreamstate.c	2001/03/27 23:54:39	1.2
@@ -15,9 +15,10 @@
 static PyObject* py_ogg_stream_state_getattr(PyObject *, char *);
 
 FDEF(ogg_stream_packetin) "Add a packet to the stream.";
+FDEF(ogg_stream_clear) "Clear the contents of the stream state.";
 FDEF(ogg_stream_flush) "Produce an ogg page suitable for writing to output.";
-FDEF(ogg_stream_eos) "Not quite sure what it does!!"; /* FIXME */
-FDEF(ogg_stream_pageout) "Not quite sure what it does!!"; /* FIXME */
+FDEF(ogg_stream_eos) "Return whether the end of the stream is reached.";
+FDEF(ogg_stream_pageout) "Extract and return an OggPage.";
 FDEF(ogg_stream_reset) "Reset the stream state";
 FDEF(ogg_stream_pagein) "Write a page to the stream";
 FDEF(ogg_stream_packetout) "Extract a packet from the stream";
@@ -52,6 +53,8 @@
 };
 
 static PyMethodDef py_ogg_stream_state_methods[] = {
+  {"clear", py_ogg_stream_clear,
+   METH_VARARGS, py_ogg_stream_clear_doc},
   {"packetin", py_ogg_stream_packetin,
    METH_VARARGS, py_ogg_stream_packetin_doc},
   {"flush", py_ogg_stream_flush,
@@ -68,6 +71,7 @@
 static void 
 py_ogg_stream_state_dealloc(py_ogg_stream_state *self)
 {
+  ogg_stream_destroy(PY_OGG_STREAM(self));
   PyMem_DEL(self);
 }
 
@@ -97,6 +101,14 @@
   if (!PyArg_ParseTuple(args, "i", &serialno))
     return NULL;
   return py_ogg_stream_state_from_serialno(serialno);
+}
+
+static PyObject *
+py_ogg_stream_clear(PyObject *self, PyObject *args) 
+{
+  ogg_stream_clear(PY_OGG_STREAM(self));
+  Py_INCREF(Py_None);
+  return Py_None;
 }
 
 static PyObject *

1.3       +54 -6     ogg-python/src/pyoggsyncstate.c

Index: pyoggsyncstate.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-python/src/pyoggsyncstate.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pyoggsyncstate.c	2001/03/18 02:46:12	1.2
+++ pyoggsyncstate.c	2001/03/27 23:54:39	1.3
@@ -1,4 +1,5 @@
 #include "pyoggsyncstate.h"
+#include "pyoggpage.h"
 #include "general.h"
 #include "_oggmodule.h"
 
@@ -6,18 +7,15 @@
                             OggSyncState Object
  *****************************************************************/
 
-/* TODO : Actually add methods to this object and a way to create one! */
-
 char py_ogg_sync_state_doc[] = "";
 
 static void py_ogg_sync_state_dealloc(py_ogg_sync_state *);
 static PyObject* py_ogg_sync_state_getattr(PyObject *, char *);
 
-FDEF(ogg_sync_clear) "";
+FDEF(ogg_sync_clear) "Clear the contents of this object.";
 FDEF(ogg_sync_reset) "";
-FDEF(ogg_sync_wrote) "";
-FDEF(ogg_stream_pagein) "";
-FDEF(ogg_stream_packetout) "";
+FDEF(ogg_sync_wrote) "Tell how many bytes were written to the buffer.";
+FDEF(ogg_sync_pageseek) "Synchronize with the given OggPage.";
 
 PyTypeObject py_ogg_sync_state_type = {
   PyObject_HEAD_INIT(&PyType_Type)
@@ -48,17 +46,38 @@
   py_ogg_sync_state_doc
 };
 
+/*
+   TODO: Remove reset functions? Not useful in Python?
+*/
 static PyMethodDef py_ogg_sync_state_methods[] = {
   {"reset", py_ogg_sync_reset,
    METH_VARARGS, py_ogg_sync_reset_doc},
+  {"clear", py_ogg_sync_clear,
+   METH_VARARGS, py_ogg_sync_clear_doc},
   {"wrote", py_ogg_sync_wrote,
    METH_VARARGS, py_ogg_sync_wrote_doc},
+  {"pageseek", py_ogg_pageseek,
+   METH_VARARGS, py_ogg_pageseek_doc},
   {NULL, NULL}
 };
 
+PyObject *
+py_ogg_sync_state_new(PyObject *self, PyObject *args)
+{
+  py_ogg_sync_state *ret = PyObject_NEW(py_ogg_sync_state,
+					&py_ogg_sync_state_type);
+
+  if (ret == NULL) 
+    return NULL;
+
+  ogg_sync_init(PY_OGG_SYNC_STATE(ret));
+  return (PyObject *) ret;
+}
+
 static void 
 py_ogg_sync_state_dealloc(py_ogg_sync_state *self)
 {
+  ogg_sync_destroy(PY_OGG_SYNC_STATE(self));
   PyMem_DEL(self);
 }
 
@@ -78,6 +97,15 @@
 }
 
 static PyObject *
+py_ogg_sync_clear(PyObject *self, PyObject *args)
+{
+  int ret;
+  ret = ogg_sync_clear(PY_OGG_SYNC_STATE(self));
+  Py_INCREF(Py_None);
+  return Py_None;
+}
+
+static PyObject *
 py_ogg_sync_wrote(PyObject *self, PyObject *args)
 {
   long bytes;
@@ -86,6 +114,26 @@
     return NULL;
 
   ret = ogg_sync_wrote(PY_OGG_SYNC_STATE(self), bytes);
+  if (ret == -1) {
+    PyErr_SetString(Py_OggError, "Overflow of ogg_sync_state buffer.");
+    return NULL;
+  }
+
   Py_INCREF(Py_None);
   return Py_None;
+}
+
+static PyObject *
+py_ogg_sync_pageseek(PyObject *self, PyObject *args) 
+{
+  py_ogg_page *page;
+  int skipped;
+
+  if (!PyArg_ParseTuple(args, "O!", &py_ogg_page_type, &page))
+    return NULL;
+
+  skipped = ogg_sync_pageseek(PY_OGG_SYNC_STATE(self),
+			   PY_OGG_PAGE(page));
+
+  return skipped;
 }

1.3       +2 -0      ogg-python/src/pyoggsyncstate.h

Index: pyoggsyncstate.h
===================================================================
RCS file: /usr/local/cvsroot/ogg-python/src/pyoggsyncstate.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pyoggsyncstate.h	2001/03/18 02:46:12	1.2
+++ pyoggsyncstate.h	2001/03/27 23:54:39	1.3
@@ -13,4 +13,6 @@
 
 extern PyTypeObject py_ogg_sync_state_type;
 
+PyObject *py_ogg_sync_state_new(PyObject *, PyObject *);
+
 #endif

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list