From: Klaus R. <kre...@us...> - 2008-06-22 13:56:45
|
Update of /cvsroot/ming/ming/php_ext In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20984 Modified Files: ming.c Log Message: Fix functions which take external data (e.g. bitmaps, sound, video ...) All these functions are more typesafe now. They take either a filename, a file ressource (php equivalent of FILE *) or a SWFInput object wrapping raw memory. Index: ming.c =================================================================== RCS file: /cvsroot/ming/ming/php_ext/ming.c,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** ming.c 19 Jun 2008 18:25:56 -0000 1.102 --- ming.c 22 Jun 2008 13:56:37 -0000 1.103 *************** *** 73,76 **** --- 73,77 ---- static SWFMovieClip getSprite(zval *id TSRMLS_DC); static SWFSound getSound(zval *id TSRMLS_DC); + static SWFInput getInput(zval *id TSRMLS_DC); #ifdef HAVE_NEW_MING static SWFFontCharacter getFontCharacter(zval *id TSRMLS_DC); *************** *** 216,219 **** --- 217,221 ---- static zend_class_entry *sound_class_entry_ptr; static zend_class_entry *character_class_entry_ptr; + static zend_class_entry *input_class_entry_ptr; #ifdef HAVE_NEW_MING static zend_class_entry *fontchar_class_entry_ptr; *************** *** 307,310 **** --- 309,313 ---- return NULL; } + /* }}} */ static SWFCharacter getCharacterClass(zval *id TSRMLS_DC) *************** *** 323,330 **** /* }}} */ - /* }}} */ - /* {{{ getInput - utility func for making an SWFInput from an fopened resource - */ static void destroy_SWFInput_resource(zend_rsrc_list_entry *resource TSRMLS_DC) { --- 326,330 ---- *************** *** 332,336 **** } ! static SWFInput getInput(zval **zfile TSRMLS_DC) { FILE *file; --- 332,337 ---- } ! /* {{{ getInput_fromFileResource - utility func for making an SWFInput from an fopened resource */ ! static SWFInput getInput_fromFileResource(zval **zfile TSRMLS_DC) { FILE *file; *************** *** 340,344 **** php_stream_from_zval_no_verify(stream, zfile); - if (stream == NULL) return NULL; --- 341,344 ---- *************** *** 354,357 **** --- 354,398 ---- /* }}} */ + /* {{{ internal function getInput */ + static SWFInput getInput(zval *id TSRMLS_DC) + { + void *in = SWFgetProperty(id, "input", strlen("input"), le_swfinputp TSRMLS_CC); + + if (!in) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFInput"); + } + return (SWFInput)in; + } + /* }}} */ + + + /* {{{ proto void swfinput::__construct(string data) */ + PHP_METHOD(swfinput, __construct) + { + SWFInput input; + zval **zdata; + int ret; + + if(ZEND_NUM_ARGS() != 1) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_ex(1, &zdata) == FAILURE) + WRONG_PARAM_COUNT; + + convert_to_string_ex(zdata); + input = newSWFInput_bufferCopy((unsigned char *)Z_STRVAL_PP(zdata), Z_STRLEN_PP(zdata)); + + ret = zend_list_insert(input, le_swfinputp); + object_init_ex(getThis(), input_class_entry_ptr); + add_property_resource(getThis(), "input", ret); + zend_list_addref(ret); + } + + static zend_function_entry swfinput_functions[] = { + PHP_ME(swfinput, __construct, NULL, 0) + { NULL, NULL, NULL } + }; + /* }}} */ + /* {{{ SWFCXform */ *************** *** 556,560 **** /* {{{ internal function getInitAction Returns the SWFInitAction object contained in zval *id */ ! static SWFInitAction getInitAction(zval *id TSRMLS_DC) { void *action = SWFgetProperty(id, "initaction", --- 597,601 ---- /* {{{ internal function getInitAction Returns the SWFInitAction object contained in zval *id */ ! static inline SWFInitAction getInitAction(zval *id TSRMLS_DC) { void *action = SWFgetProperty(id, "initaction", *************** *** 649,653 **** /* {{{ SWFBitmap */ ! /* {{{ proto void swfbitmap::__construct(mixed file [, mixed maskfile]) Creates a new SWFBitmap object from jpg (with optional mask) or dbl file */ PHP_METHOD(swfbitmap, __construct) --- 690,694 ---- /* {{{ SWFBitmap */ ! /* {{{ proto void swfbitmap::__construct(filename or SWFInput [, maskfilename / SWFInput]) Creates a new SWFBitmap object from jpg (with optional mask) or dbl file */ PHP_METHOD(swfbitmap, __construct) *************** *** 656,660 **** SWFBitmap bitmap; SWFJpegWithAlpha bitmap_alpha; ! SWFInput input, maskinput; int ret; --- 697,701 ---- SWFBitmap bitmap; SWFJpegWithAlpha bitmap_alpha; ! SWFInput input = NULL, maskinput = NULL; int ret; *************** *** 670,691 **** WRONG_PARAM_COUNT; } ! ! if (Z_TYPE_PP(zfile) != IS_RESOURCE) { convert_to_string_ex(zfile); ! PHP_MING_FILE_CHK(Z_STRVAL_PP(zfile)); ! input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile)); zend_list_addref(zend_list_insert(input, le_swfinputp)); ! } else { ! input = getInput(zfile TSRMLS_CC); } ! if (zmask != NULL) { ! if (Z_TYPE_PP(zmask) != IS_RESOURCE) { convert_to_string_ex(zmask); ! maskinput = newSWFInput_buffer(Z_STRVAL_PP(zmask), Z_STRLEN_PP(zmask)); zend_list_addref(zend_list_insert(maskinput, le_swfinputp)); ! } else { ! maskinput = getInput(zmask TSRMLS_CC); } bitmap_alpha = newSWFJpegWithAlpha_fromInput(input, maskinput); if(bitmap_alpha) { --- 711,759 ---- WRONG_PARAM_COUNT; } ! ! switch(Z_TYPE_PP(zfile)) ! { ! case IS_RESOURCE: ! input = getInput_fromFileResource(zfile TSRMLS_CC); ! break; ! case IS_OBJECT: ! input = getInput(*zfile TSRMLS_CC); ! break; ! case IS_STRING: convert_to_string_ex(zfile); ! input = newSWFInput_filename(Z_STRVAL_PP(zfile)); ! if(input == NULL) ! php_error(E_ERROR, "opening bitmap file failed"); zend_list_addref(zend_list_insert(input, le_swfinputp)); ! break; ! ! default: ! php_error(E_ERROR, "swfbitmap::__construct: need either a filename, " ! "a file ressource or SWFInput buffer."); } ! if (zmask != NULL) { ! switch(Z_TYPE_PP(zmask)) ! { ! case IS_RESOURCE: ! maskinput = getInput_fromFileResource(zmask TSRMLS_CC); ! break; ! case IS_OBJECT: ! maskinput = getInput(*zmask TSRMLS_CC); ! break; ! case IS_STRING: convert_to_string_ex(zmask); ! maskinput = newSWFInput_filename(Z_STRVAL_PP(zmask)); ! if(maskinput == NULL) ! php_error(E_ERROR, "opening mask file failed"); zend_list_addref(zend_list_insert(maskinput, le_swfinputp)); ! break; ! ! default: ! php_error(E_ERROR, "swfbitmap::__construct: need either a filename, " ! "a file ressource or SWFInput buffer."); } + + /* XXX: this is very optimistic! is it really a JPEG ?!? */ bitmap_alpha = newSWFJpegWithAlpha_fromInput(input, maskinput); if(bitmap_alpha) { *************** *** 3016,3049 **** */ ! /* {{{ proto class soundstream_init(file) ! */ PHP_METHOD(swfsoundstream, __construct) { zval **zfile; SWFSoundStream sound = NULL; ! SWFInput input; int ret; ! switch(ZEND_NUM_ARGS()) ! { ! case 1: ! if(zend_get_parameters_ex(1, &zfile) == FAILURE) ! WRONG_PARAM_COUNT; ! ! if(Z_TYPE_PP(zfile) != IS_RESOURCE) ! { ! convert_to_string_ex(zfile); ! input = newSWFInput_filename(Z_STRVAL_PP(zfile)); ! zend_list_addref(zend_list_insert(input, le_swfinputp)); ! } ! else ! input = getInput(zfile TSRMLS_CC); ! sound = newSWFSoundStream_fromInput(input); ! break; ! default: WRONG_PARAM_COUNT; break; } if(sound) { --- 3084,3123 ---- */ ! /* {{{ proto class soundstream::init(file) */ PHP_METHOD(swfsoundstream, __construct) { zval **zfile; SWFSoundStream sound = NULL; ! SWFInput input = NULL; int ret; ! if(ZEND_NUM_ARGS() != 1) ! WRONG_PARAM_COUNT; ! if(zend_get_parameters_ex(1, &zfile) == FAILURE) WRONG_PARAM_COUNT; + + switch(Z_TYPE_PP(zfile)) + { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); break; + case IS_OBJECT: + input = getInput(*zfile TSRMLS_CC); + break; + case IS_STRING: + convert_to_string_ex(zfile); + input = newSWFInput_filename(Z_STRVAL_PP(zfile)); + if(input == NULL) + php_error(E_ERROR, "opening sound file failed"); + zend_list_addref(zend_list_insert(input, le_swfinputp)); + break; + + default: + php_error(E_ERROR, "soundstream::init: need either a filename, " + "a file ressource or SWFInput buffer."); } + + sound = newSWFSoundStream_fromInput(input); if(sound) { *************** *** 3111,3121 **** /* }}} */ ! /* {{{ proto void swfsound::__construct(string filename, int flags) ! Creates a new SWFSound object from given file */ PHP_METHOD(swfsound, __construct) { zval **zfile, **zflags; SWFSound sound = NULL; ! SWFInput input; SWFSoundStream stream; int flags; --- 3185,3198 ---- /* }}} */ ! /* {{{ proto void swfsound::__construct(string filename/SWFInput/SWFSoundstream[, int flags]) ! Creates a new SWFSound object from given file ! Takes either a Filename or SWFInput memory buffer AND flags or ! a SWFSoundStream object with NO flags. ! */ PHP_METHOD(swfsound, __construct) { zval **zfile, **zflags; SWFSound sound = NULL; ! SWFInput input = NULL; SWFSoundStream stream; int flags; *************** *** 3137,3150 **** flags = Z_LVAL_PP(zflags); ! if(Z_TYPE_PP(zfile) != IS_RESOURCE) { convert_to_string_ex(zfile); ! PHP_MING_FILE_CHK(Z_STRVAL_PP(zfile)); ! input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile)); zend_list_addref(zend_list_insert(input, le_swfinputp)); ! } ! else ! input = getInput(zfile TSRMLS_CC); sound = newSWFSound_fromInput(input, flags); } --- 3214,3237 ---- flags = Z_LVAL_PP(zflags); ! switch(Z_TYPE_PP(zfile)) { + case IS_RESOURCE: + input = getInput_fromFileResource(zfile TSRMLS_CC); + break; + case IS_OBJECT: + input = getInput(*zfile TSRMLS_CC); + break; + case IS_STRING: convert_to_string_ex(zfile); ! input = newSWFInput_filename(Z_STRVAL_PP(zfile)); ! if(input == NULL) ! php_error(E_ERROR, "opening sound file failed"); zend_list_addref(zend_list_insert(input, le_swfinputp)); ! break; + default: + php_error(E_ERROR, "swfsound::__construct: need either a filename, " + "a file ressource or SWFInput buffer."); + } sound = newSWFSound_fromInput(input, flags); } *************** *** 3263,3303 **** /* {{{ SWFVideoStream */ ! /* {{{ proto class swfvideostream_init([file]) Returns a SWVideoStream object */ - PHP_METHOD(swfvideostream, __construct) { zval **zfile = NULL; SWFVideoStream stream; ! SWFInput input; int ret; ! switch(ZEND_NUM_ARGS()) { ! case 1: ! if(zend_get_parameters_ex(1, &zfile) == FAILURE) ! WRONG_PARAM_COUNT; ! if(Z_TYPE_PP(zfile) != IS_RESOURCE) ! { ! convert_to_string_ex(zfile); ! if(strcasecmp(".flv", Z_STRVAL_PP(zfile)+Z_STRLEN_PP(zfile)-4) == 0) ! input = newSWFInput_filename(Z_STRVAL_PP(zfile)); ! else // keep fingers crossed that it is file_get_contents() ! input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile)); ! zend_list_addref(zend_list_insert(input, le_swfinputp)); ! } ! else ! { ! input = getInput(zfile TSRMLS_CC); ! } ! ! stream = newSWFVideoStream_fromInput(input); break; ! case 0: ! stream = newSWFVideoStream(); break; default: ! WRONG_PARAM_COUNT; ! break; } --- 3350,3396 ---- /* {{{ SWFVideoStream */ ! /* {{{ proto class swfvideostream_init([filename]) Returns a SWVideoStream object */ PHP_METHOD(swfvideostream, __construct) { zval **zfile = NULL; SWFVideoStream stream; ! SWFInput input = NULL; int ret; ! switch(ZEND_NUM_ARGS()) ! { ! case 1: ! if(zend_get_parameters_ex(1, &zfile) == FAILURE) ! WRONG_PARAM_COUNT; ! switch(Z_TYPE_PP(zfile)) ! { ! case IS_RESOURCE: ! input = getInput_fromFileResource(zfile TSRMLS_CC); break; ! case IS_OBJECT: ! input = getInput(*zfile TSRMLS_CC); ! break; ! case IS_STRING: ! convert_to_string_ex(zfile); ! input = newSWFInput_filename(Z_STRVAL_PP(zfile)); ! if(input == NULL) ! php_error(E_ERROR, "opening sound video failed"); ! zend_list_addref(zend_list_insert(input, le_swfinputp)); break; + default: ! php_error(E_ERROR, "swfvideostream_init: need either a filename, " ! "a file ressource or SWFInput buffer."); ! } ! stream = newSWFVideoStream_fromInput(input); ! break; ! case 0: ! stream = newSWFVideoStream(); ! break; ! default: ! WRONG_PARAM_COUNT; ! break; } *************** *** 3308,3312 **** zend_list_addref(ret); } - } --- 3401,3404 ---- *************** *** 3319,3330 **** /* {{{ internal function getVideoStream Returns the SWFVideoStream object contained in zval *id */ - static SWFVideoStream getVideoStream(zval *id TSRMLS_DC) { void *stream = SWFgetProperty(id, "videostream", 11, le_swfvideostreamp TSRMLS_CC); - if(!stream) php_error(E_ERROR, "called object is not an SWFVideoStream!"); - return (SWFVideoStream)stream; } --- 3411,3419 ---- *************** *** 3339,3343 **** SWFVideoStream stream = getVideoStream(getThis() TSRMLS_CC); if(!stream) ! php_error(E_ERROR, "getVideoSTream returned NULL"); if( ZEND_NUM_ARGS() != 2 --- 3428,3432 ---- SWFVideoStream stream = getVideoStream(getThis() TSRMLS_CC); if(!stream) ! php_error(E_ERROR, "getVideoStream returned NULL"); if( ZEND_NUM_ARGS() != 2 *************** *** 3403,3407 **** convert_to_string_ex(zdata); convert_to_long_ex(zlen); ! bd = newSWFBinaryData(Z_STRVAL_PP(zdata), Z_LVAL_PP(zlen)); break; default: --- 3492,3496 ---- convert_to_string_ex(zdata); convert_to_long_ex(zlen); ! bd = newSWFBinaryData((unsigned char *)Z_STRVAL_PP(zdata), Z_LVAL_PP(zlen)); break; default: *************** *** 3421,3425 **** /* {{{ internal function getBinaryData Returns the SWFBinaryData object contained in zval *id */ ! static SWFBinaryData getBinaryData(zval *id TSRMLS_DC) { void *bd = SWFgetProperty(id, "binarydata", strlen("binarydata"), le_swfbinarydatap TSRMLS_CC); --- 3510,3514 ---- /* {{{ internal function getBinaryData Returns the SWFBinaryData object contained in zval *id */ ! static inline SWFBinaryData getBinaryData(zval *id TSRMLS_DC) { void *bd = SWFgetProperty(id, "binarydata", strlen("binarydata"), le_swfbinarydatap TSRMLS_CC); *************** *** 3444,3482 **** /* {{{ SWFPrebuiltClip */ ! /* {{{ proto class swfprebuiltclip_init([file]) Returns a SWFPrebuiltClip object */ - PHP_METHOD(swfprebuiltclip, __construct) { zval **zfile = NULL; SWFPrebuiltClip clip; ! SWFInput input; int ret; ! switch(ZEND_NUM_ARGS()) { ! case 1: ! if(zend_get_parameters_ex(1, &zfile) == FAILURE) ! WRONG_PARAM_COUNT; ! ! if(Z_TYPE_PP(zfile) != IS_RESOURCE) ! { ! convert_to_string_ex(zfile); ! input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile)); ! zend_list_addref(zend_list_insert(input, le_swfinputp)); ! } ! else ! input = getInput(zfile TSRMLS_CC); ! clip = newSWFPrebuiltClip_fromInput(input); ! break; ! /* not sure whether this makes sense ! there would have to be a function to add contents ! case 0: ! clip = newSWFPrebuiltClip(); ! break; */ ! default: ! WRONG_PARAM_COUNT; ! break; } if(clip) { --- 3533,3573 ---- /* {{{ SWFPrebuiltClip */ ! /* {{{ proto class swfprebuiltclip_init(filename / SWFInput ) Returns a SWFPrebuiltClip object */ PHP_METHOD(swfprebuiltclip, __construct) { zval **zfile = NULL; SWFPrebuiltClip clip; ! SWFInput input = NULL; int ret; ! if(ZEND_NUM_ARGS() != 1) ! WRONG_PARAM_COUNT; ! if(zend_get_parameters_ex(1, &zfile) == FAILURE) ! WRONG_PARAM_COUNT; ! ! switch(Z_TYPE_PP(zfile)) ! { ! case IS_RESOURCE: ! input = getInput_fromFileResource(zfile TSRMLS_CC); ! break; ! case IS_OBJECT: ! input = getInput(*zfile TSRMLS_CC); ! break; ! case IS_STRING: ! convert_to_string_ex(zfile); ! input = newSWFInput_filename(Z_STRVAL_PP(zfile)); ! if(input == NULL) ! php_error(E_ERROR, "opening prebuilt clip file failed"); ! zend_list_addref(zend_list_insert(input, le_swfinputp)); ! break; ! ! default: ! php_error(E_ERROR, "swfprebuiltclip_init: need either a filename, " ! "a file ressource or SWFInput buffer."); } + + clip = newSWFPrebuiltClip_fromInput(input); if(clip) { *************** *** 3498,3513 **** /* {{{ internal function getPrebuiltClip Returns the SWFPrebuiltClip object contained in zval *id */ - static SWFPrebuiltClip getPrebuiltClip(zval *id TSRMLS_DC) { void *clip = SWFgetProperty(id, "prebuiltclip", 12, le_swfprebuiltclipp TSRMLS_CC); - if(!clip) php_error(E_ERROR, "called object is not an SWFPrebuiltClip!"); - return (SWFPrebuiltClip)clip; } - /* }}} */ static zend_function_entry swfprebuiltclip_functions[] = { PHP_ME(swfprebuiltclip, __construct, NULL, 0) --- 3589,3601 ---- /* {{{ internal function getPrebuiltClip Returns the SWFPrebuiltClip object contained in zval *id */ static SWFPrebuiltClip getPrebuiltClip(zval *id TSRMLS_DC) { void *clip = SWFgetProperty(id, "prebuiltclip", 12, le_swfprebuiltclipp TSRMLS_CC); if(!clip) php_error(E_ERROR, "called object is not an SWFPrebuiltClip!"); return (SWFPrebuiltClip)clip; } /* }}} */ + static zend_function_entry swfprebuiltclip_functions[] = { PHP_ME(swfprebuiltclip, __construct, NULL, 0) *************** *** 3518,3524 **** #endif - /* }}} */ - - /* {{{ SWFMovie */ --- 3606,3609 ---- *************** *** 4034,4038 **** /* }}} */ ! /* {{{ proto long swfmovie::streamMP3(mixed file) Sets sound stream of the SWF movie. The parameter can be stream or string. */ PHP_METHOD(swfmovie, streamMP3) --- 4119,4123 ---- /* }}} */ ! /* {{{ proto long swfmovie::streamMP3(mixed filename / SWFInput) Sets sound stream of the SWF movie. The parameter can be stream or string. */ PHP_METHOD(swfmovie, streamMP3) *************** *** 4041,4073 **** float skip; SWFSoundStream sound; ! SWFInput input; SWFMovie movie = getMovie(getThis() TSRMLS_CC); ! switch (ZEND_NUM_ARGS()) { ! case 1: ! if(zend_get_parameters_ex(1, &zfile) == FAILURE) { WRONG_PARAM_COUNT; ! } ! skip = 0; ! break; ! case 2: ! if(zend_get_parameters_ex(2, &zfile, &zskip) == FAILURE) { ! WRONG_PARAM_COUNT; ! } ! convert_to_double_ex(zskip); ! skip = Z_DVAL_PP(zskip); ! break; ! default: ! WRONG_PARAM_COUNT; ! } ! ! if (Z_TYPE_PP(zfile) != IS_RESOURCE) { convert_to_string_ex(zfile); ! input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile)); zend_list_addref(zend_list_insert(input, le_swfinputp)); ! } else { ! input = getInput(zfile TSRMLS_CC); } ! sound = newSWFSoundStream_fromInput(input); SWFMovie_setSoundStreamAt(movie, sound, skip); --- 4126,4171 ---- float skip; SWFSoundStream sound; ! SWFInput input = NULL; SWFMovie movie = getMovie(getThis() TSRMLS_CC); ! switch (ZEND_NUM_ARGS()) { ! case 1: ! if(zend_get_parameters_ex(1, &zfile) == FAILURE) ! WRONG_PARAM_COUNT; ! skip = 0; ! break; ! case 2: ! if(zend_get_parameters_ex(2, &zfile, &zskip) == FAILURE) ! WRONG_PARAM_COUNT; ! ! convert_to_double_ex(zskip); ! skip = Z_DVAL_PP(zskip); ! break; ! default: WRONG_PARAM_COUNT; ! } ! ! switch(Z_TYPE_PP(zfile)) ! { ! case IS_RESOURCE: ! input = getInput_fromFileResource(zfile TSRMLS_CC); ! break; ! case IS_OBJECT: ! input = getInput(*zfile TSRMLS_CC); ! break; ! case IS_STRING: convert_to_string_ex(zfile); ! input = newSWFInput_filename(Z_STRVAL_PP(zfile)); ! if(input == NULL) ! php_error(E_ERROR, "opening mp3 file failed"); ! zend_list_addref(zend_list_insert(input, le_swfinputp)); ! break; ! ! default: ! php_error(E_ERROR, "swfmovie::streamMP3: need either a filename, " ! "a file ressource or SWFInput buffer."); } ! sound = newSWFSoundStream_fromInput(input); SWFMovie_setSoundStreamAt(movie, sound, skip); *************** *** 5252,5256 **** float skip, rate; SWFSoundStream sound; ! SWFInput input; SWFMovieClip mc = getSprite(getThis() TSRMLS_CC); --- 5350,5354 ---- float skip, rate; SWFSoundStream sound; ! SWFInput input = NULL; SWFMovieClip mc = getSprite(getThis() TSRMLS_CC); *************** *** 5274,5285 **** convert_to_double_ex(zrate); rate = Z_DVAL_PP(zrate); ! if (Z_TYPE_PP(zfile) != IS_RESOURCE) { convert_to_string_ex(zfile); ! input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile)); zend_list_addref(zend_list_insert(input, le_swfinputp)); ! } else { ! input = getInput(zfile TSRMLS_CC); ! } sound = newSWFSoundStream_fromInput(input); SWFMovieClip_setSoundStreamAt(mc, sound, Z_DVAL_PP(zrate), skip); --- 5372,5396 ---- convert_to_double_ex(zrate); rate = Z_DVAL_PP(zrate); ! ! switch(Z_TYPE_PP(zfile)) ! { ! case IS_RESOURCE: ! input = getInput_fromFileResource(zfile TSRMLS_CC); ! break; ! case IS_OBJECT: ! input = getInput(*zfile TSRMLS_CC); ! break; ! case IS_STRING: convert_to_string_ex(zfile); ! input = newSWFInput_filename(Z_STRVAL_PP(zfile)); ! if(input == NULL) ! php_error(E_ERROR, "opening sound file failed"); zend_list_addref(zend_list_insert(input, le_swfinputp)); ! break; + default: + php_error(E_ERROR, "swfmovieclip::setSoundStream: need either a filename, " + "a file ressource or SWFInput buffer."); + } sound = newSWFSoundStream_fromInput(input); SWFMovieClip_setSoundStreamAt(mc, sound, Z_DVAL_PP(zrate), skip); *************** *** 6155,6158 **** --- 6266,6270 ---- zend_class_entry cxform_class_entry; zend_class_entry matrix_class_entry; + zend_class_entry input_class_entry; #endif zend_class_entry character_class_entry; *************** *** 6374,6377 **** --- 6486,6490 ---- INIT_CLASS_ENTRY(cxform_class_entry, "SWFCXform", swfcxform_functions); INIT_CLASS_ENTRY(matrix_class_entry, "SWFMatrix", swfmatrix_functions); + INIT_CLASS_ENTRY(input_class_entry, "SWFInput", swfinput_functions); #endif INIT_CLASS_ENTRY(character_class_entry, "SWFCharacter", swfcharacter_functions); *************** *** 6408,6411 **** --- 6521,6525 ---- cxform_class_entry_ptr = zend_register_internal_class(&cxform_class_entry TSRMLS_CC); matrix_class_entry_ptr = zend_register_internal_class(&matrix_class_entry TSRMLS_CC); + input_class_entry_ptr = zend_register_internal_class(&input_class_entry TSRMLS_CC); #endif character_class_entry_ptr = zend_register_internal_class(&character_class_entry TSRMLS_CC); |