- tag_internals_t*itag = tag_getinternals(self);
- videostream_internal_t*fi = (videostream_internal_t*)itag->data;
- /* TODO */
- return Py_BuildValue("s", 0);
-}
-static PyObject* videostream_addPFrame(PyObject*self, PyObject*args)
-{
- tag_internals_t*itag = tag_getinternals(self);
- videostream_internal_t*fi = (videostream_internal_t*)itag->data;
- /* TODO */
+ tag_internals_t*_itag = tag_getinternals(self);
+ videostream_internal_t*fi = (videostream_internal_t*)_itag->data;
+
+ PyObject*image = 0;
+ char*type=0; // none, "i", "p"
+ int quant=7;
+ static char *kwlist[] = {"image", "quant", "type", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|is", kwlist, &image, &quant, &type))
+ return NULL;
+ if(fi->stream->width != image_getWidth(image)) {
+ PyErr_SetString(PyExc_Exception, setError("bad image width %d!=%d", image_getWidth(image), fi->stream->width));return 0;
+ }
+ if(fi->stream->height != image_getHeight(image)) {
+ PyErr_SetString(PyExc_Exception, setError("bad image width %d!=%d", image_getHeight(image), fi->stream->height));return 0;
+ }
+ PyObject*tag = tag_new(&videoframe_tag);
+ tag_internals_t*itag = tag_getinternals(tag);
+
+ RGBA*pic = image_toRGBA(image);
+ TAG* t = swf_InsertTag(0, ST_VIDEOFRAME);
+ if((type && (type[0]=='I' || type[0]=='i')) || (type==0 && fi->lastiframe+64 < fi->stream->frame)) {
+ swf_SetU16(t,0);
+ swf_SetVideoStreamIFrame(t, fi->stream, pic, quant);
+ fi->lastiframe = fi->stream->frame;
+ } else {
+ swf_SetU16(t,0);
+ swf_SetVideoStreamPFrame(t, fi->stream, pic, quant);
+ }
+ itag->tag = t;
+ tagmap_addMapping(itag->tagmap, 0, self);
+ free(pic);