From 09c1eee91febf291c5b8dec11978d1ac25ac22ee Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Tue, 15 May 2012 19:17:56 +0200 Subject: [PATCH] Imported Upstream version 0.4.5+svn4035~dfsg0 --- configure | 44 ++-- doc/GPAC UPnP.doc | Bin 74752 -> 77824 bytes include/gpac/internal/mpd.h | 17 +- include/gpac/internal/smjs_api.h | 41 ++++ include/gpac/internal/terminal_dev.h | 3 + modules/gpac_js/gpac_js.c | 20 +- modules/mpd_in/mpd_in.c | 263 +++++++++++++++++------ modules/platinum/GPACPlatinum.cpp | 23 ++ modules/widgetman/widget.c | 34 +-- modules/widgetman/widgetman.c | 92 ++++---- src/media_tools/mpd.c | 19 +- src/media_tools/mpegts.c | 3 + src/scenegraph/dom_smjs.c | 68 +++--- src/scenegraph/svg_smjs.c | 114 +++++----- src/scenegraph/vrml_smjs.c | 308 +++++++++++++-------------- src/terminal/media_memory.c | 4 - src/terminal/object_manager.c | 15 +- src/terminal/scene.c | 19 +- 18 files changed, 674 insertions(+), 413 deletions(-) diff --git a/configure b/configure index ac610b7..3b0f3a0 100755 --- a/configure +++ b/configure @@ -665,7 +665,7 @@ fi #spidermonkey test for new API if test "$has_js" = "no" ; then -cat > $TMPCPP << EOF +cat > $TMPC << EOF #include int main( void ) { JSContext *cx; jsval *rp; return JS_AddValueRoot(cx, rp); } EOF @@ -673,7 +673,7 @@ EOF #try local js_inc="$local_inc/js" js_flags="-DXP_UNIX -I$local_inc/js" - if $cpp -o $TMPO $TMPCPP $js_flags -L$local_lib -ljs -lpthread 2> /dev/null ; then + if $cc -o $TMPO $TMPC $js_flags -L$local_lib -ljs -lpthread 2> /dev/null ; then has_js="local" #dc added else @@ -681,7 +681,7 @@ EOF if $pkg_config --exists mozilla-js 2> /dev/null ; then js_flags=`$pkg_config --cflags mozilla-js` js_lib_pkg=`$pkg_config --libs mozilla-js` - if $cpp -o $TMPO $TMPCPP $js_flags $js_lib_pkg $LDFLAGS -lpthread 2> /dev/null ; then + if $cc -o $TMPO $TMPC $js_flags $js_lib_pkg $LDFLAGS -lpthread 2> /dev/null ; then has_js="system" js_lib=`$pkg_config --libs mozilla-js` fi @@ -692,10 +692,10 @@ EOF if test "$has_js" = "no" ; then js_inc="/usr/include/$i" js_flags="-DXP_UNIX -I$js_inc" - js_lib="-L/usr/lib/$i/ -lxul -lmozsqlite3 -lmozalloc -lnssutil3 -lnss3" - if $cpp -o $TMPO $TMPCPP $js_flags $js_lib 2> /dev/null ; then + js_lib="-L/usr/lib/$i/ -lxul -lmozsqlite3 -lmozalloc -lnssutil3 -lnss3 -lnspr4 -lsmime3" + if $cc -o $TMPO $TMPC $js_flags $js_lib 2> /dev/null ; then has_js="$i" - elif $cpp -o $TMPO $TMPCPP $js_flags -lnssutil3 $js_lib -lssl3 2> /dev/null ; then + elif $cc -o $TMPO $TMPC $js_flags -lnssutil3 $js_lib -lssl3 2> /dev/null ; then #firefox 11 compatibility has_js="$i" js_lib="-lnssutil3 $js_lib -lssl3" @@ -708,14 +708,14 @@ EOF #try prefix (DC) js_inc="$prefix/include/js" js_flags="-DXP_UNIX -I$prefix/include/js" - if $cpp -o $TMPO $TMPCPP $js_flags -L$prefix/lib -ljs -lpthread 2> /dev/null ; then + if $cc -o $TMPO $TMPC $js_flags -L$prefix/lib -ljs -lpthread 2> /dev/null ; then has_js="prefix" #dc added end else - if $cpp -o $TMPO $TMPCPP $js_flags $LDFLAGS -ljs -lpthread 2> /dev/null ; then + if $cc -o $TMPO $TMPC $js_flags $LDFLAGS -ljs -lpthread 2> /dev/null ; then js_inc="/usr/include" has_js="system" - elif $cpp -o $TMPO $TMPCPP -DXP_UNIX -I$alt_macosx_dir/include/js -L$alt_macosx_dir/lib $LDFLAGS -ljs -lpthread 2> /dev/null ; then + elif $cc -o $TMPO $TMPC -DXP_UNIX -I$alt_macosx_dir/include/js -L$alt_macosx_dir/lib $LDFLAGS -ljs -lpthread 2> /dev/null ; then has_js="system" js_flags="-DXP_UNIX -I$alt_macosx_dir/include/js" js_lib="-L$alt_macosx_dir/lib -ljs" @@ -724,14 +724,14 @@ EOF #debian spidermonkey (smjs) js_flags="-DXP_UNIX -I/usr/include/smjs" js_inc="/usr/include/smjs" - if $cpp -o $TMPO $TMPCPP $js_flags $LDFLAGS -lsmjs -lpthread 2> /dev/null ; then + if $cc -o $TMPO $TMPC $js_flags $LDFLAGS -lsmjs -lpthread 2> /dev/null ; then has_js="system" js_lib="-lsmjs" else #debian spidermonkey (mozjs) js_flags="-DXP_UNIX -I/usr/include/mozjs" js_inc="/usr/include/mozjs" - if $cpp -o $TMPO $TMPCPP $js_flags $LDFLAGS -lmozjs -lpthread 2> /dev/null ; then + if $cc -o $TMPO $TMPC $js_flags $LDFLAGS -lmozjs -lpthread 2> /dev/null ; then has_js="system" js_lib="-lmozjs" fi @@ -828,12 +828,28 @@ if test "$has_js" != "no" ; then else cat > $TMPC << EOF #include -int main( void ) { JSContext *cx; JS_SetRuntimeThread(cx); } +int main( void ) { JSObject *obj; JS_GetPrivate(obj); } EOF if $cc -o $TMPO $TMPC $js_flags $LDFLAGS $js_lib 2> /dev/null ; then - js_flags="$js_flags" + js_flags="-DUSE_FFDEV_12 $js_flags" else - js_flags="-DNO_JS_RUNTIMETHREAD $js_flags" +cat > $TMPC << EOF +#include +int main( void ) { JSContext *cx; JS_SetContextThread(cx); } +EOF + if $cc -o $TMPO $TMPC $js_flags $LDFLAGS $js_lib 2> /dev/null ; then +cat > $TMPC << EOF +#include +int main( void ) { JSContext *cx; JS_SetRuntimeThread(cx); } +EOF + if $cc -o $TMPO $TMPC $js_flags $LDFLAGS $js_lib 2> /dev/null ; then + js_flags="$js_flags" + else + js_flags="-DNO_JS_RUNTIMETHREAD $js_flags" + fi + else + js_flags="-DUSE_FFDEV_11 $js_flags" + fi fi fi fi diff --git a/doc/GPAC UPnP.doc b/doc/GPAC UPnP.doc index 61f915baccb46ff8c051f299d58684adb88e6035..817770b2cd648fb55ceb8edfb720a32292520823 100644 GIT binary patch delta 11869 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 diff --git a/include/gpac/internal/mpd.h b/include/gpac/internal/mpd.h index df14691..2a41d3b 100644 --- a/include/gpac/internal/mpd.h +++ b/include/gpac/internal/mpd.h @@ -28,8 +28,6 @@ #include #include #include -#include - /*TODO*/ typedef struct @@ -318,7 +316,20 @@ void gf_mpd_del(GF_MPD *mpd); /*frees a SegmentURL*/ void gf_mpd_segment_url_free(void *_item); -GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, const char *mpd_file, u32 reload_count, char *mimeTypeForM3U8Segments, GF_ClientService *service, Bool do_import, Bool use_mpd_templates); +typedef struct _gf_file_get GF_FileDownload; +struct _gf_file_get +{ + GF_Err (*new_session)(GF_FileDownload *getter, char *url); + void (*del_session)(GF_FileDownload *getter); + const char *(*get_cache_name)(GF_FileDownload *getter); + + void *udta; + /*created by udta after new_session*/ + void *session; +}; + +/*converts M3U8 to MPD - getter is optional (download will still be processed if NULL)*/ +GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, const char *mpd_file, u32 reload_count, char *mimeTypeForM3U8Segments, Bool do_import, Bool use_mpd_templates, GF_FileDownload *getter); #endif // _MPD_H_ diff --git a/include/gpac/internal/smjs_api.h b/include/gpac/internal/smjs_api.h index 03cd58b..f28e0ab 100644 --- a/include/gpac/internal/smjs_api.h +++ b/include/gpac/internal/smjs_api.h @@ -43,6 +43,14 @@ /*new APIs*/ #if (JS_VERSION>=185) + +#ifdef USE_FFDEV_12 +typedef unsigned uintN; +typedef uint32_t jsuint; +typedef int jsint; +typedef double jsdouble; +#endif + #define JS_NewDouble(c, v) v #define JS_PropertyStub_forSetter JS_StrictPropertyStub #define SMJS_PROP_SETTER jsid id, JSBool strict @@ -77,7 +85,35 @@ #define JS_THREADSAFE #endif + +#ifdef USE_FFDEV_12 +#define JS_ClearContextThread(__ctx) +#define JS_SetContextThread(__ctx) +#define SMJS_GET_PRIVATE(__ctx, __obj) JS_GetPrivate(__obj) +#define SMJS_SET_PRIVATE(__ctx, __obj, __val) JS_SetPrivate(__obj, __val) +#define SMJS_GET_PARENT(__ctx, __obj) JS_GetParent(__obj) +#define JS_GET_CLASS(__ctx, __obj) JS_GetClass(__obj) +#define SMJS_CONSTRUCT_OBJECT(__ctx, __class, __parent) JS_ConstructObject(__ctx, __class, __parent) + +#else + +#define SMJS_GET_PRIVATE(__ctx, __obj) JS_GetPrivate(__ctx, __obj) +#define SMJS_SET_PRIVATE(__ctx, __obj, __val) JS_SetPrivate(__ctx, __obj, __val) +#define SMJS_GET_PARENT(__ctx, __obj) JS_GetParent(__ctx, __obj) + +#ifdef USE_FFDEV_11 +#define JS_ClearContextThread(__ctx) +#define JS_SetContextThread(__ctx) +#define SMJS_CONSTRUCT_OBJECT(__ctx, __class, __parent) JS_ConstructObject(__ctx, __class, __parent) +#else +#define SMJS_CONSTRUCT_OBJECT(__ctx, __class, __parent) JS_ConstructObject(__ctx, __class, 0, __parent) +#endif + +#endif + + #else + #define SMJS_PROP_SETTER jsval id #define SMJS_PROP_GETTER jsval id #define JS_PropertyStub_forSetter JS_PropertyStub @@ -101,6 +137,11 @@ #define SMJS_ID_IS_INT JSVAL_IS_INT #define SMJS_ID_TO_INT JSVAL_TO_INT +#define SMJS_CONSTRUCT_OBJECT(__ctx, __class, __parent) JS_ConstructObject(__ctx, __class, 0, __parent) +#define SMJS_GET_PRIVATE(__ctx, __obj) JS_GetPrivate(__ctx, __obj) +#define SMJS_SET_PRIVATE(__ctx, __obj, __val) JS_SetPrivate(__ctx, __obj, __val) +#define SMJS_GET_PARENT(__ctx, __obj) JS_GetParent(__ctx, __obj) + #endif diff --git a/include/gpac/internal/terminal_dev.h b/include/gpac/internal/terminal_dev.h index 84d830f..bedef48 100644 --- a/include/gpac/internal/terminal_dev.h +++ b/include/gpac/internal/terminal_dev.h @@ -159,6 +159,9 @@ struct _scene This allows preventing OD/BIFS streams shutdown/startup when seeking.*/ Bool static_media_ressources; + /*set to 1 to force all sub-resources to share the timeline of this scene*/ + Bool force_single_timeline; + /*callback to call to dispatch SVG MediaEvent - this is a pointer to function only because of linking issues with static libgpac (avoids depending on SpiderMonkey and OpenGL32 if not needed)*/ diff --git a/modules/gpac_js/gpac_js.c b/modules/gpac_js/gpac_js.c index 6f90742..cca3b5b 100644 --- a/modules/gpac_js/gpac_js.c +++ b/modules/gpac_js/gpac_js.c @@ -79,7 +79,7 @@ typedef struct static GF_Terminal *gpac_get_term(JSContext *c, JSObject *obj) { - GF_GPACJSExt *ext = (GF_GPACJSExt *)JS_GetPrivate(c, obj); + GF_GPACJSExt *ext = (GF_GPACJSExt *)SMJS_GET_PRIVATE(c, obj); return ext ? ext->term : NULL; } @@ -187,12 +187,12 @@ static JSBool gpac_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, js *vp = DOUBLE_TO_JSVAL(JS_NewDouble(c, fps) ); } else if (!strcmp(prop_name, "cpu_load")) { - GF_GPACJSExt *ext = (GF_GPACJSExt *)JS_GetPrivate(c, obj); + GF_GPACJSExt *ext = (GF_GPACJSExt *)SMJS_GET_PRIVATE(c, obj); gf_sys_get_rti(ext->rti_refresh_rate, &ext->rti, 0); *vp = INT_TO_JSVAL(ext->rti.process_cpu_usage); } else if (!strcmp(prop_name, "memory")) { - GF_GPACJSExt *ext = (GF_GPACJSExt *)JS_GetPrivate(c, obj); + GF_GPACJSExt *ext = (GF_GPACJSExt *)SMJS_GET_PRIVATE(c, obj); gf_sys_get_rti(ext->rti_refresh_rate, &ext->rti, 0); *vp = INT_TO_JSVAL(ext->rti.process_memory); } @@ -664,7 +664,7 @@ static JSBool SMJS_FUNCTION(gpac_migrate_url) static JSBool gpacevt_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp) { - GF_GPACJSExt *gjs = JS_GetPrivate(c, obj); + GF_GPACJSExt *gjs = SMJS_GET_PRIVATE(c, obj); GF_Event *evt = gjs->evt; if (!evt) return 0; @@ -738,11 +738,11 @@ static Bool gjs_event_filter(void *udta, GF_Event *evt, Bool consumed_by_composi rval = JSVAL_VOID; gjs->evt = evt; - JS_SetPrivate(gjs->c, gjs->evt_obj, gjs); + SMJS_SET_PRIVATE(gjs->c, gjs->evt_obj, gjs); argv[0] = OBJECT_TO_JSVAL(gjs->evt_obj); rval = JSVAL_VOID; JS_CallFunctionValue(gjs->c, gjs->evt_filter_obj, gjs->evt_fun, 1, argv, &rval); - JS_SetPrivate(gjs->c, gjs->evt_obj, NULL); + SMJS_SET_PRIVATE(gjs->c, gjs->evt_obj, NULL); gjs->evt = NULL; res = 0; @@ -760,7 +760,7 @@ static JSBool SMJS_FUNCTION(gpac_set_event_filter) { SMJS_OBJ SMJS_ARGS - GF_GPACJSExt *gjs = (GF_GPACJSExt *)JS_GetPrivate(c, obj); + GF_GPACJSExt *gjs = (GF_GPACJSExt *)SMJS_GET_PRIVATE(c, obj); if (!argc || !JSVAL_IS_OBJECT(argv[0])) return JS_FALSE; if (! JSVAL_IS_NULL(gjs->evt_fun) ) return JS_TRUE; @@ -810,7 +810,7 @@ static JSBool SMJS_FUNCTION(gpac_get_scene) GF_Scene *scene=NULL; SMJS_OBJ SMJS_ARGS - GF_GPACJSExt *gjs = (GF_GPACJSExt *)JS_GetPrivate(c, obj); + GF_GPACJSExt *gjs = (GF_GPACJSExt *)SMJS_GET_PRIVATE(c, obj); if (!gjs || !argc || !JSVAL_IS_OBJECT(argv[0])) return JS_FALSE; elt = gf_sg_js_get_node(c, JSVAL_TO_OBJECT(argv[0])); @@ -835,7 +835,7 @@ static JSBool SMJS_FUNCTION(gpac_get_scene) scene_obj = JS_NewObject(c, &gjs->anyClass, 0, 0); - JS_SetPrivate(c, scene_obj, scene); + SMJS_SET_PRIVATE(c, scene_obj, scene); gf_sg_get_scene_size_info(scene->graph, &w, &h); JS_DefineProperty(c, scene_obj, "width", INT_TO_JSVAL(w), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineProperty(c, scene_obj, "height", INT_TO_JSVAL(h), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); @@ -918,7 +918,7 @@ static void gjs_load(GF_JSUserExtension *jsext, GF_SceneGraph *scene, JSContext gjs->term = par.term; } } - JS_SetPrivate(c, gjs->gpac_obj, gjs); + SMJS_SET_PRIVATE(c, gjs->gpac_obj, gjs); } else { JS_DefineProperty(c, global, "gpac", OBJECT_TO_JSVAL(gjs->gpac_obj), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); } diff --git a/modules/mpd_in/mpd_in.c b/modules/mpd_in/mpd_in.c index d73d4b4..4dcc2ac 100644 --- a/modules/mpd_in/mpd_in.c +++ b/modules/mpd_in/mpd_in.c @@ -73,7 +73,7 @@ typedef struct __mpd_group Bool selected; Bool done; - Bool force_switch_bandwidth; + Bool force_switch_bandwidth, min_bandwidth_selected; u32 nb_bw_check; u32 active_bitrate, max_bitrate, min_bitrate; @@ -109,6 +109,9 @@ typedef struct __mpd_group u32 force_representation_idx_plus_one; Bool force_segment_switch; + + /*set when switching segment, indicates the current downloaded segment duration*/ + u64 current_downloaded_segment_duration; } GF_MPD_Group; typedef struct __mpd_module { @@ -118,6 +121,9 @@ typedef struct __mpd_module { Used to detect when audio service connection request is made on the same URL as video */ char *url; + /*interface to mpd parser*/ + GF_FileDownload getter; + u32 option_max_cached; u32 auto_switch_count; Bool keep_files, disable_switching; @@ -240,12 +246,16 @@ void MPD_NetIO_Segment(void *cbk, GF_NETIO_Parameter *param) if (download_rate>group->max_bitrate) group->max_bitrate = download_rate; if (download_rate && (download_rate < group->active_bitrate)) { - fprintf(stdout, "Downloading from set %s at rate %d kbps but group bitrate is %d kbps\n", group->adaptation_set->id, download_rate/1024, group->active_bitrate/1024); + u32 set_idx = gf_list_find(group->period->adaptation_sets, group->adaptation_set)+1; group->nb_bw_check ++; - if (group->nb_bw_check>2) { - fprintf(stdout, "Downloading from group %s at rate %d kbps but group bitrate is %d kbps - switching\n", group->adaptation_set->id, download_rate/1024, group->active_bitrate/1024); + if (group->min_bandwidth_selected) { + fprintf(stdout, "Downloading from set #%d at rate %d kbps but media bitrate is %d kbps - no lower bitrate available ...\n", set_idx, download_rate/1024, group->active_bitrate/1024); + } else if (group->nb_bw_check>2) { + fprintf(stdout, "Downloading from set #%d at rate %d kbps but media bitrate is %d kbps - switching\n", set_idx, download_rate/1024, group->active_bitrate/1024); group->force_switch_bandwidth = 1; gf_dm_sess_abort(group->segment_dnload); + } else { + fprintf(stdout, "Downloading from set #%ds at rate %d kbps but media bitrate is %d kbps\n", set_idx, download_rate/1024, group->active_bitrate/1024); } } else { group->nb_bw_check = 0; @@ -342,7 +352,7 @@ static GF_Err MPD_UpdatePlaylist(GF_MPD_In *mpdin) /* Some servers, for instance http://tv.freebox.fr, serve m3u8 as text/plain */ if (MPD_isM3U8_mime(mime) || strstr(purl, ".m3u8")) { - gf_m3u8_to_mpd(local_url, purl, NULL, mpdin->reload_count, mpdin->mimeTypeForM3U8Segments, mpdin->service, 0, M3U8_TO_MPD_USE_TEMPLATE); + gf_m3u8_to_mpd(local_url, purl, NULL, mpdin->reload_count, mpdin->mimeTypeForM3U8Segments, 0, M3U8_TO_MPD_USE_TEMPLATE, &mpdin->getter); } else if (!MPD_is_MPD_mime(mime)) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[MPD_IN] mime '%s' should be m3u8 or mpd\n", mime)); gf_term_on_connect(mpdin->service, NULL, GF_BAD_PARAM); @@ -764,11 +774,26 @@ GF_Err MPD_downloadWithRetry( GF_ClientService * service, GF_DownloadSession **s } } +static void MPD_GetTimelineDuration(GF_MPD_SegmentTimeline *timeline, u32 *nb_segments, Double *seg_duration) +{ + u32 i, count; + + *nb_segments = 0; + *seg_duration = 0; + count = gf_list_count(timeline->entries); + for (i=0; ientries, i); + *nb_segments += 1 + ent->repeat_count; + if (*seg_duration < ent->duration) *seg_duration = ent->duration; + } +} + static void MPD_GetSegmentDuration(GF_MPD_Representation *rep, GF_MPD_AdaptationSet *set, GF_MPD_Period *period, GF_MPD *mpd, u32 *nb_segments, Double *seg_duration) { Double mediaDuration; u32 timescale; u64 duration; + GF_MPD_SegmentTimeline *timeline = NULL; *nb_segments = timescale = 0; duration = 0; @@ -782,50 +807,67 @@ static void MPD_GetSegmentDuration(GF_MPD_Representation *rep, GF_MPD_Adaptation if (period->segment_list->duration) duration = period->segment_list->duration; if (period->segment_list->timescale) timescale = period->segment_list->timescale; if (period->segment_list->segment_URLs) segments = period->segment_list->segment_URLs; + if (period->segment_list->segment_timeline) timeline = period->segment_list->segment_timeline; } if (set->segment_list) { if (set->segment_list->duration) duration = set->segment_list->duration; if (set->segment_list->timescale) timescale = set->segment_list->timescale; if (set->segment_list->segment_URLs) segments = set->segment_list->segment_URLs; + if (set->segment_list->segment_timeline) timeline = set->segment_list->segment_timeline; } if (rep->segment_list) { if (rep->segment_list->duration) duration = rep->segment_list->duration; if (rep->segment_list->timescale) timescale = rep->segment_list->timescale; if (rep->segment_list->segment_URLs) segments = rep->segment_list->segment_URLs; + if (rep->segment_list->segment_timeline) timeline = rep->segment_list->segment_timeline; } - if (segments) - *nb_segments = gf_list_count(segments); - if (! timescale) timescale=1; - *seg_duration = (Double) duration; - *seg_duration /= timescale; + + if (timeline) { + MPD_GetTimelineDuration(timeline, nb_segments, seg_duration); + *seg_duration /= timescale; + } else { + if (segments) + *nb_segments = gf_list_count(segments); + *seg_duration = (Double) duration; + *seg_duration /= timescale; + } return; } if (period->segment_template) { if (period->segment_template->duration) duration = period->segment_template->duration; if (period->segment_template->timescale) timescale = period->segment_template->timescale; + if (period->segment_template->segment_timeline) timeline = period->segment_template->segment_timeline; } if (set->segment_template) { if (set->segment_template->duration) duration = set->segment_template->duration; if (set->segment_template->timescale) timescale = set->segment_template->timescale; + if (set->segment_template->segment_timeline) timeline = set->segment_template->segment_timeline; } if (rep->segment_template) { if (rep->segment_template->duration) duration = rep->segment_template->duration; if (rep->segment_template->timescale) timescale = rep->segment_template->timescale; + if (rep->segment_template->segment_timeline) timeline = rep->segment_template->segment_timeline; } if (!timescale) timescale=1; - *seg_duration = (Double) duration; - *seg_duration /= timescale; - mediaDuration = period->duration; - if (!mediaDuration) mediaDuration = mpd->media_presentation_duration; - if (mediaDuration && duration) { - Double nb_seg = (Double) mediaDuration; - /*duration is given in ms*/ - nb_seg /= 1000; - nb_seg *= timescale; - nb_seg /= duration; - *nb_segments = (u32) ceil(nb_seg); + + if (timeline) { + MPD_GetTimelineDuration(timeline, nb_segments, seg_duration); + *seg_duration /= timescale; + } else { + *seg_duration = (Double) duration; + *seg_duration /= timescale; + mediaDuration = period->duration; + if (!mediaDuration) mediaDuration = mpd->media_presentation_duration; + if (mediaDuration && duration) { + Double nb_seg = (Double) mediaDuration; + /*duration is given in ms*/ + nb_seg /= 1000; + nb_seg *= timescale; + nb_seg /= duration; + *nb_segments = (u32) ceil(nb_seg); + } } } @@ -838,7 +880,7 @@ static void MPD_SetGroupRepresentation(GF_MPD_Group *group, GF_MPD_Representatio u32 width=0, height=0, samplerate=0; GF_MPD_Fractional *framerate=NULL; #endif - u32 timescale = 1; + u32 k, timescale = 1; GF_MPD_AdaptationSet *set; GF_MPD_Period *period; u32 i = gf_list_find(group->adaptation_set->representations, rep); @@ -848,6 +890,15 @@ static void MPD_SetGroupRepresentation(GF_MPD_Group *group, GF_MPD_Representatio group->active_bitrate = rep->bandwidth; group->nb_segments_in_rep = 1; + group->min_bandwidth_selected = 1; + for (k=0; kadaptation_set->representations); k++) { + GF_MPD_Representation *arep = gf_list_get(group->adaptation_set->representations, k); + if (group->active_bitrate > arep->bandwidth) { + group->min_bandwidth_selected = 0; + break; + } + } + set = group->adaptation_set; period = group->period; @@ -928,13 +979,16 @@ static void MPD_SwitchGroupRepresentation(GF_MPD_In *mpd, GF_MPD_Group *group) } -u64 MPD_ResolveDuration(GF_MPD_Representation *rep, GF_MPD_AdaptationSet *set, GF_MPD_Period *period, u32 item_index) +static void MPD_ResolveDuration(GF_MPD_Representation *rep, GF_MPD_AdaptationSet *set, GF_MPD_Period *period, u64 *out_duration, u32 *out_timescale) { + u32 timescale = 0; GF_MPD_SegmentTimeline *segment_timeline; GF_MPD_MultipleSegmentBase *mbase_rep, *mbase_set, *mbase_period; /*single media segment - duration is not known unless indicated in period*/ if (rep->segment_base || set->segment_base || period->segment_base) { - return period ? period->duration : 0; + *out_duration = period ? period->duration : 0; + *out_timescale = 1000; + return; } /*we have a segment template list or template*/ mbase_rep = rep->segment_list ? (GF_MPD_MultipleSegmentBase *) rep->segment_list : (GF_MPD_MultipleSegmentBase *) rep->segment_template; @@ -945,16 +999,17 @@ u64 MPD_ResolveDuration(GF_MPD_Representation *rep, GF_MPD_AdaptationSet *set, G if (mbase_period) segment_timeline = mbase_period->segment_timeline; if (mbase_set) segment_timeline = mbase_set->segment_timeline; if (mbase_rep) segment_timeline = mbase_rep->segment_timeline; - - if (segment_timeline) { - /*not supported yet*/ - assert(0); - return 0; - } - if (mbase_rep && mbase_rep->duration) return mbase_rep->duration; - if (mbase_set && mbase_set->duration) return mbase_set->duration; - if (mbase_period && mbase_period->duration) return mbase_period->duration; - return 0; + + timescale = mbase_rep ? mbase_rep->timescale : 0; + if (!timescale && mbase_set && mbase_set->timescale) timescale = mbase_set->timescale; + if (!timescale && mbase_period && mbase_period->timescale) timescale = mbase_period->timescale; + if (!timescale) timescale = 1; + *out_timescale = timescale; + + if (mbase_rep && mbase_rep->duration) *out_duration = mbase_rep->duration; + else if (mbase_set && mbase_set->duration) *out_duration = mbase_set->duration; + else if (mbase_period && mbase_period->duration) *out_duration = mbase_period->duration; + } typedef enum @@ -965,10 +1020,12 @@ typedef enum } GF_MPDURLResolveType; -GF_Err MPD_ResolveURL(GF_MPD *mpd, GF_MPD_Representation *rep, GF_MPD_AdaptationSet *set, GF_MPD_Period *period, char *mpd_url, GF_MPDURLResolveType resolve_type, u32 item_index, char **out_url, u64 *out_range_start, u64 *out_range_end) +GF_Err MPD_ResolveURL(GF_MPD *mpd, GF_MPD_Representation *rep, GF_MPD_AdaptationSet *set, GF_MPD_Period *period, char *mpd_url, GF_MPDURLResolveType resolve_type, u32 item_index, char **out_url, u64 *out_range_start, u64 *out_range_end, u64 *segment_duration) { GF_MPD_BaseURL *url_child; + GF_MPD_SegmentTimeline *timeline = NULL; u32 start_number = 1; + u32 timescale; char *url; char *url_to_solve, *solved_template, *first_sep, *media_url; char *init_template, *index_template; @@ -1006,6 +1063,9 @@ GF_Err MPD_ResolveURL(GF_MPD *mpd, GF_MPD_Representation *rep, GF_MPD_Adaptation url = t_url; } + MPD_ResolveDuration(rep, set, period, segment_duration, ×cale); + *segment_duration = (u32) ((Double) (*segment_duration) * 1000.0 / timescale); + /*single URL*/ if (rep->segment_base || set->segment_base || period->segment_base) { GF_MPD_URL *res_url; @@ -1065,18 +1125,21 @@ GF_Err MPD_ResolveURL(GF_MPD *mpd, GF_MPD_Representation *rep, GF_MPD_Adaptation if (period->segment_list->representation_index) index_url = period->segment_list->representation_index; if (period->segment_list->segment_URLs) segments = period->segment_list->segment_URLs; if (period->segment_list->start_number != (u32) -1) start_number = period->segment_list->start_number; + if (period->segment_list->segment_timeline) timeline = period->segment_list->segment_timeline; } if (set->segment_list) { if (set->segment_list->initialization_segment) init_url = set->segment_list->initialization_segment; if (set->segment_list->representation_index) index_url = set->segment_list->representation_index; if (set->segment_list->segment_URLs) segments = set->segment_list->segment_URLs; if (set->segment_list->start_number != (u32) -1) start_number = set->segment_list->start_number; + if (set->segment_list->segment_timeline) timeline = set->segment_list->segment_timeline; } if (rep->segment_list) { if (rep->segment_list->initialization_segment) init_url = rep->segment_list->initialization_segment; if (rep->segment_list->representation_index) index_url = rep->segment_list->representation_index; if (rep->segment_list->segment_URLs) segments = rep->segment_list->segment_URLs; if (rep->segment_list->start_number != (u32) -1) start_number = rep->segment_list->start_number; + if (rep->segment_list->segment_timeline) timeline = rep->segment_list->segment_timeline; } @@ -1144,7 +1207,7 @@ GF_Err MPD_ResolveURL(GF_MPD *mpd, GF_MPD_Representation *rep, GF_MPD_Adaptation } /*segmentTemplate*/ - init_template = index_template = NULL; + media_url = init_template = index_template = NULL; /*apply inheritance of attributes, lowest level having preceedence*/ if (period->segment_template) { @@ -1152,18 +1215,25 @@ GF_Err MPD_ResolveURL(GF_MPD *mpd, GF_MPD_Representation *rep, GF_MPD_Adaptation if (period->segment_template->index) index_template = period->segment_template->index; if (period->segment_template->media) media_url = period->segment_template->media; if (period->segment_template->start_number != (u32) -1) start_number = period->segment_template->start_number; + if (period->segment_template->segment_timeline) timeline = period->segment_template->segment_timeline; } if (set->segment_template) { if (set->segment_template->initialization) init_template = set->segment_template->initialization; if (set->segment_template->index) index_template = set->segment_template->index; if (set->segment_template->media) media_url = set->segment_template->media; if (set->segment_template->start_number != (u32) -1) start_number = set->segment_template->start_number; + if (set->segment_template->segment_timeline) timeline = set->segment_template->segment_timeline; } if (rep->segment_template) { if (rep->segment_template->initialization) init_template = rep->segment_template->initialization; if (rep->segment_template->index) index_template = rep->segment_template->index; if (rep->segment_template->media) media_url = rep->segment_template->media; if (rep->segment_template->start_number != (u32) -1) start_number = rep->segment_template->start_number; + if (rep->segment_template->segment_timeline) timeline = rep->segment_template->segment_timeline; + } + if (!media_url) { + GF_MPD_BaseURL *base = gf_list_get(rep->base_URLs, 0); + media_url = base->URL; } url_to_solve = NULL; switch (resolve_type) { @@ -1236,8 +1306,30 @@ GF_Err MPD_ResolveURL(GF_MPD *mpd, GF_MPD_Representation *rep, GF_MPD_Adaptation strcat(solved_template, szFormat); } else if (!strcmp(first_sep+1, "Time")) { - assert(0); - /*uses segment timeline, not supported yet*/ + if (timeline) { + /*uses segment timeline*/ + u32 k, nb_seg, cur_idx, nb_repeat; + u64 time, start_time; + nb_seg = gf_list_count(timeline->entries); + cur_idx = 0; + start_time=0; + for (k=0; kentries, k); + if (item_index>cur_idx+ent->repeat_count) { + cur_idx += 1 + ent->repeat_count; + start_time += ent->duration * (1 + ent->repeat_count); + continue; + } + *segment_duration = ent->duration; + *segment_duration = (u32) ((Double) (*segment_duration) * 1000.0 / timescale); + nb_repeat = item_index - cur_idx; + time = ent->start_time ? ent->start_time : start_time; + time += nb_repeat * ent->duration; + sprintf(szFormat, ""LLD"", time); + strcat(solved_template, szFormat); + break; + } + } } if (format_tag) format_tag[0] = '%'; second_sep[0] = '$'; @@ -1275,7 +1367,7 @@ static GF_Err MPD_DownloadInitSegment(GF_MPD_In *mpdin, GF_MPD_Group *group) } start_range = end_range = 0; - e = MPD_ResolveURL(mpdin->mpd, rep, group->adaptation_set, group->period, mpdin->url, GF_MPD_RESOLVE_URL_INIT, 0, &base_init_url, &start_range, &end_range); + e = MPD_ResolveURL(mpdin->mpd, rep, group->adaptation_set, group->period, mpdin->url, GF_MPD_RESOLVE_URL_INIT, 0, &base_init_url, &start_range, &end_range, &group->current_downloaded_segment_duration); if (e) { gf_mx_v(mpdin->dl_mutex); GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[MPD_IN] Unable to resolve initialization URL: %s\n", gf_error_to_string(e) )); @@ -1284,7 +1376,7 @@ static GF_Err MPD_DownloadInitSegment(GF_MPD_In *mpdin, GF_MPD_Group *group) /*no error and no init segment, go for media segment*/ if (!base_init_url) { - e = MPD_ResolveURL(mpdin->mpd, rep, group->adaptation_set, group->period, mpdin->url, GF_MPD_RESOLVE_URL_MEDIA, group->download_segment_index, &base_init_url, &start_range, &end_range); + e = MPD_ResolveURL(mpdin->mpd, rep, group->adaptation_set, group->period, mpdin->url, GF_MPD_RESOLVE_URL_MEDIA, group->download_segment_index, &base_init_url, &start_range, &end_range, &group->current_downloaded_segment_duration); if (e) { gf_mx_v(mpdin->dl_mutex); GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[MPD_IN] Unable to resolve media URL: %s\n", gf_error_to_string(e) )); @@ -1332,7 +1424,7 @@ static GF_Err MPD_DownloadInitSegment(GF_MPD_In *mpdin, GF_MPD_Group *group) gf_free(base_init_url); - e = MPD_ResolveURL(mpdin->mpd, rep, group->adaptation_set, group->period, mpdin->url, GF_MPD_RESOLVE_URL_MEDIA, group->download_segment_index + 1, &base_init_url, &start_range, &end_range); + e = MPD_ResolveURL(mpdin->mpd, rep, group->adaptation_set, group->period, mpdin->url, GF_MPD_RESOLVE_URL_MEDIA, group->download_segment_index + 1, &base_init_url, &start_range, &end_range, &group->current_downloaded_segment_duration); if (!e) { gf_mx_v(mpdin->dl_mutex); return e; @@ -1388,7 +1480,7 @@ static GF_Err MPD_DownloadInitSegment(GF_MPD_In *mpdin, GF_MPD_Group *group) stype2 = mime ? strchr(mime, '/') : NULL; if (stype1 && stype2 && !strcmp(stype1, stype2)) valid = 1; - if (!valid) { + if (!valid && 0) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[MPD_IN] Mime '%s' is not correct for '%s', it should be '%s'\n", mime, base_init_url, mime_type)); mpdin->mpd_stop_request = 0; gf_mx_v(mpdin->dl_mutex); @@ -1486,6 +1578,7 @@ restart_period: for (i=0; igroups, i); + if (!group->selected) continue; GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[MPD_IN] Connecting initial service... %s\n", group->segment_local_url)); if (! group->input_module) { e = GF_SERVICE_ERROR; @@ -1612,7 +1705,7 @@ restart_period: gf_mx_p(mpdin->dl_mutex); /* At this stage, there are some segments left to be downloaded */ - e = MPD_ResolveURL(mpdin->mpd, rep, group->adaptation_set, group->period, mpdin->url, GF_MPD_RESOLVE_URL_MEDIA, group->download_segment_index, &new_base_seg_url, &start_range, &end_range); + e = MPD_ResolveURL(mpdin->mpd, rep, group->adaptation_set, group->period, mpdin->url, GF_MPD_RESOLVE_URL_MEDIA, group->download_segment_index, &new_base_seg_url, &start_range, &end_range, &group->current_downloaded_segment_duration); gf_mx_v(mpdin->dl_mutex); if (e) { /*do something!!*/ @@ -1638,6 +1731,8 @@ restart_period: } } else { + u32 total_size, bytes_per_sec; + group->max_bitrate = 0; group->min_bitrate = (u32)-1; /*use persistent connection for segment downloads*/ @@ -1667,25 +1762,35 @@ restart_period: resource_name = gf_dm_sess_get_resource_name(group->segment_dnload); - { - u32 total_size, bytes_per_sec; - u64 duration; - Double bitrate; - gf_dm_sess_get_stats(group->segment_dnload, NULL, NULL, &total_size, NULL, &bytes_per_sec, NULL); + gf_dm_sess_get_stats(group->segment_dnload, NULL, NULL, &total_size, NULL, &bytes_per_sec, NULL); + if (total_size && bytes_per_sec && group->current_downloaded_segment_duration) { + Double bitrate, time; bitrate = 8*total_size; bitrate *= 1000; - duration = MPD_ResolveDuration(rep, group->adaptation_set, group->period, 0); - if (!duration) { - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("Downloaded segment (bandwidth %d) with bandwith %d kbps\n", 8*rep->bandwidth/1024, 8*bytes_per_sec/1024)); - } else { - bitrate /= duration; - bitrate /= 1024; - GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("Downloaded segment (bandwidth %d) bitrate %d with bandwith %d kbps\n", 8*rep->bandwidth/1024, (u32) bitrate, 8*bytes_per_sec/1024)); - } - /*TODO switch quality*/ - - if (!mpdin->auto_switch_count) { -// MPD_SwitchGroupRepresentation(mpdin, group); + bitrate /= group->current_downloaded_segment_duration; + bitrate /= 1024; + time = total_size; + time /= bytes_per_sec; + + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("Downloaded segment %d bytes in %g seconds - duration %g sec - Bandwidth (kbps): indicated %d - computed %d - download %d\n", total_size, time, group->current_downloaded_segment_duration/1000.0, rep->bandwidth/1024, (u32) bitrate, 8*bytes_per_sec/1024)); + + if (rep->bandwidth < 8*bytes_per_sec) { + u32 k; + /*find highest bandwidth that fits our bitrate*/ + GF_MPD_Representation *new_rep = NULL; + for (k=0; kadaptation_set->representations); k++) { + GF_MPD_Representation *arep = gf_list_get(group->adaptation_set->representations, k); + if (8*bytes_per_sec > arep->bandwidth) { + if (!new_rep) new_rep = arep; + else if (arep->bandwidth > new_rep->bandwidth) { + new_rep = arep; + } + } + } + if (new_rep) { + GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("Switching to new representation bitrate %d kbps\n", new_rep->bandwidth/1024)); + MPD_SetGroupRepresentation(group, new_rep); + } } } } @@ -1834,7 +1939,6 @@ static void MPD_DownloadStop(GF_MPD_In *mpdin) for (i=0; igroups); i++) { GF_MPD_Group *group = gf_list_get(mpdin->groups, i); assert( group ); - if (! group->service_connected ) return; if (group->selected && group->segment_dnload) { gf_dm_sess_abort(group->segment_dnload); group->done = 1; @@ -2144,7 +2248,8 @@ GF_Err MPD_SetupPeriod(GF_MPD_In *mpdin) if (!rep_sel->segment_base && !rep_sel->segment_list && !rep_sel->segment_template && !group->adaptation_set->segment_base && !group->adaptation_set->segment_list && !group->adaptation_set->segment_template && !group->period->segment_base && !group->period->segment_list && !group->period->segment_template - + && !gf_list_count(rep_sel->base_URLs) + ) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[MPD_IN] Error - cannot start: missing segments\n")); return GF_NON_COMPLIANT_BITSTREAM; @@ -2190,6 +2295,29 @@ exit: return e; } + +static GF_Err http_ifce_get(GF_FileDownload *getter, char *url) +{ + GF_MPD_In *mpdin = (GF_MPD_In*) getter->udta; + GF_DownloadSession *sess = gf_term_download_new(mpdin->service, url, GF_NETIO_SESSION_NOT_THREADED, NULL, NULL); + if (!sess) return GF_IO_ERR; + getter->session = sess; + return gf_dm_sess_process(sess); +} + +static void http_ifce_clean(GF_FileDownload *getter) +{ + GF_MPD_In *mpdin = (GF_MPD_In*) getter->udta; + if (getter->session) gf_term_download_del(getter->session); +} + +static const char *http_ifce_cache_name(GF_FileDownload *getter) +{ + GF_MPD_In *mpdin = (GF_MPD_In*) getter->udta; + if (getter->session) return gf_dm_sess_get_cache_name(getter->session); + return NULL; +} + GF_Err MPD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const char *url) { GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; @@ -2212,6 +2340,13 @@ GF_Err MPD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const c mpdin->url = gf_strdup(url); mpdin->option_max_cached = 0; + mpdin->getter.udta = mpdin; + mpdin->getter.new_session = http_ifce_get; + mpdin->getter.del_session = http_ifce_clean; + mpdin->getter.get_cache_name = http_ifce_cache_name; + mpdin->getter.session = NULL; + + opt = gf_modules_get_option((GF_BaseInterface *)plug, "DASH", "MaxCachedSegments"); if (!opt) gf_modules_set_option((GF_BaseInterface *)plug, "DASH", "MaxCachedSegments", "3"); if (opt) mpdin->option_max_cached = atoi(opt); @@ -2302,10 +2437,10 @@ GF_Err MPD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const c if (sep) sep[0]=0; strcat(local_path, ".mpd"); - gf_m3u8_to_mpd(local_url, url, local_path, mpdin->reload_count, mpdin->mimeTypeForM3U8Segments, mpdin->service, 0, M3U8_TO_MPD_USE_TEMPLATE); + gf_m3u8_to_mpd(local_url, url, local_path, mpdin->reload_count, mpdin->mimeTypeForM3U8Segments, 0, M3U8_TO_MPD_USE_TEMPLATE, &mpdin->getter); local_url = local_path; } else { - gf_m3u8_to_mpd(local_url, url, NULL, mpdin->reload_count, mpdin->mimeTypeForM3U8Segments, mpdin->service, 0, M3U8_TO_MPD_USE_TEMPLATE); + gf_m3u8_to_mpd(local_url, url, NULL, mpdin->reload_count, mpdin->mimeTypeForM3U8Segments, 0, M3U8_TO_MPD_USE_TEMPLATE, &mpdin->getter); } } diff --git a/modules/platinum/GPACPlatinum.cpp b/modules/platinum/GPACPlatinum.cpp index 0ad6076..7109b18 100644 --- a/modules/platinum/GPACPlatinum.cpp +++ b/modules/platinum/GPACPlatinum.cpp @@ -544,6 +544,10 @@ static JSBool upnpdevice_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETT else if (!strcmp(prop_name, "PresentationURL")) { *vp = STRING_TO_JSVAL( JS_NewStringCopyZ(c, dev->m_device->m_PresentationURL) ); } + else if (!strcmp(prop_name, "ServicesCount")) { + u32 count = gf_list_count(dev->m_Services); + *vp = INT_TO_JSVAL(count); + } SMJS_FREE(c, prop_name); return JS_TRUE; } @@ -587,6 +591,24 @@ static JSBool SMJS_FUNCTION(upnp_device_find_service) return JS_TRUE; } +static JSBool SMJS_FUNCTION(upnp_device_get_service) +{ + u32 service_index; + SMJS_OBJ + SMJS_ARGS + GPAC_DeviceItem *item = (GPAC_DeviceItem *)JS_GetPrivate(c, obj); + if (!item || !argc || !JSVAL_IS_INT(argv[0])) return JS_FALSE; + service_index = JSVAL_TO_INT(argv[0]); + + GPAC_ServiceItem *serv = (GPAC_ServiceItem*)gf_list_get(item->m_Services, service_index); + if (!serv) { + SMJS_SET_RVAL( JSVAL_NULL ); + return JS_TRUE; + } + SMJS_SET_RVAL( OBJECT_TO_JSVAL(serv->obj) ); + return JS_TRUE; +} + void GF_UPnP::OnDeviceAdd(GPAC_DeviceItem *item, int added) { @@ -1485,6 +1507,7 @@ Bool GF_UPnP::LoadJS(GF_TermExtJS *param) }; JSFunctionSpec upnpDeviceClassFuncs[] = { SMJS_FUNCTION_SPEC("FindService", upnp_device_find_service, 0), + SMJS_FUNCTION_SPEC("GetService", upnp_device_get_service, 0), SMJS_FUNCTION_SPEC(0, 0, 0) }; JS_SETUP_CLASS(upnpGenericDeviceClass, "UPNPDEVICE", JSCLASS_HAS_PRIVATE, upnpdevice_getProperty, JS_PropertyStub_forSetter, JS_FinalizeStub); diff --git a/modules/widgetman/widget.c b/modules/widgetman/widget.c index e5f8b07..58d986b 100644 --- a/modules/widgetman/widget.c +++ b/modules/widgetman/widget.c @@ -47,7 +47,7 @@ JSBool SMJS_FUNCTION(widget_has_feature) char *feat_name; SMJS_OBJ SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid) return JS_FALSE; if (!argc || !JSVAL_IS_STRING(argv[0])) return JS_TRUE; @@ -65,7 +65,7 @@ JSBool SMJS_FUNCTION(widget_open_url) GF_Event evt; SMJS_OBJ SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid || !argc || !JSVAL_IS_STRING(argv[0])) return JS_TRUE; memset(&evt, 0, sizeof(GF_Event)); @@ -81,7 +81,7 @@ JSBool SMJS_FUNCTION(widget_get_attention) { jsval fval; SMJS_OBJ - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid) return JS_TRUE; if ((JS_LookupProperty(c, wid->widget->wm->obj, "getAttention", &fval)==JS_TRUE) && JSVAL_IS_OBJECT(fval)) { @@ -97,7 +97,7 @@ JSBool SMJS_FUNCTION(widget_show_notification) jsval fval; SMJS_OBJ SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid) return JS_TRUE; if ((JS_LookupProperty(c, wid->widget->wm->obj, "showNotification", &fval)==JS_TRUE) && JSVAL_IS_OBJECT(fval)) { @@ -121,7 +121,7 @@ static JSBool SMJS_FUNCTION(widget_call_message_reply_callback) u32 i, count; SMJS_OBJ SMJS_ARGS - GF_WidgetMessage *msg = JS_GetPrivate(c, obj); + GF_WidgetMessage *msg = SMJS_GET_PRIVATE(c, obj); if (!msg || !argc || !JSVAL_IS_OBJECT(argv[0]) ) return JS_FALSE; if ((JS_LookupProperty(c, obj, "replyCallback", &fval)==JS_TRUE) && JSVAL_IS_OBJECT(fval)) { @@ -144,7 +144,7 @@ static JSBool SMJS_FUNCTION(widget_message_handler_factory) u32 i, count; SMJS_OBJ SMJS_ARGS - GF_WidgetInterfaceInstance *bifce = (GF_WidgetInterfaceInstance *)JS_GetPrivate(c, obj); + GF_WidgetInterfaceInstance *bifce = (GF_WidgetInterfaceInstance *)SMJS_GET_PRIVATE(c, obj); if (!bifce) return JS_FALSE; if (!argc) return JS_FALSE; @@ -159,7 +159,7 @@ static JSBool SMJS_FUNCTION(widget_message_handler_factory) GF_WidgetMessage *msg = gf_list_get(bifce->ifce->messages, i); if (!strcmp(msg->name, msg_name)) { JSObject *an_obj = JS_NewObject(c, &bifce->wid->widget->wm->widgetAnyClass, 0, 0); - JS_SetPrivate(c, an_obj, msg); + SMJS_SET_PRIVATE(c, an_obj, msg); JS_DefineProperty(c, an_obj, "msgName", STRING_TO_JSVAL( JS_NewStringCopyZ(c, msg->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineProperty(c, an_obj, "interfaceHandler", OBJECT_TO_JSVAL( obj ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(c, an_obj, "onInvokeReply", widget_call_message_reply_callback, 1, 0); @@ -179,14 +179,14 @@ static JSBool SMJS_FUNCTION(widget_invoke_message) GF_WidgetMessage *msg = NULL; SMJS_OBJ SMJS_ARGS - GF_WidgetInterfaceInstance *bifce = (GF_WidgetInterfaceInstance *)JS_GetPrivate(c, obj); + GF_WidgetInterfaceInstance *bifce = (GF_WidgetInterfaceInstance *)SMJS_GET_PRIVATE(c, obj); if (!bifce) return JS_FALSE; SMJS_SET_RVAL( JSVAL_NULL ); if (!JSVAL_IS_OBJECT(argv[0])) return JS_FALSE; if (JSVAL_IS_NULL(argv[0])) return JS_FALSE; - msg = (GF_WidgetMessage *)JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]) ); + msg = (GF_WidgetMessage *)SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]) ); if (!msg) return JS_FALSE; /*look for JS Callback "invoke" in the widget manager script*/ @@ -205,14 +205,14 @@ static JSBool SMJS_FUNCTION(widget_invoke_message_reply) SMJS_OBJ SMJS_ARGS GF_WidgetMessage *msg = NULL; - GF_WidgetInterfaceInstance *bifce = (GF_WidgetInterfaceInstance *)JS_GetPrivate(c, obj); + GF_WidgetInterfaceInstance *bifce = (GF_WidgetInterfaceInstance *)SMJS_GET_PRIVATE(c, obj); if (!bifce) return JS_FALSE; SMJS_SET_RVAL( JSVAL_NULL ); if (!JSVAL_IS_OBJECT(argv[0])) return JS_FALSE; if (JSVAL_IS_NULL(argv[0])) return JS_FALSE; - msg = (GF_WidgetMessage *)JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]) ); + msg = (GF_WidgetMessage *)SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]) ); if (!msg) return JS_FALSE; /*look for JS Callback "invokeReply" in the widget manager script*/ @@ -228,7 +228,7 @@ static void widget_interface_js_bind(JSContext *c, GF_WidgetInterfaceInstance *i { if (!ifce->obj) { ifce->obj = JS_NewObject(c, &ifce->wid->widget->wm->widgetAnyClass, 0, 0); - JS_SetPrivate(c, ifce->obj, ifce); + SMJS_SET_PRIVATE(c, ifce->obj, ifce); gf_js_add_root(c, &ifce->obj, GF_JSGC_OBJECT); JS_DefineProperty(c, ifce->obj, "type", STRING_TO_JSVAL( JS_NewStringCopyZ(c, ifce->ifce->type) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineProperty(c, ifce->obj, "bound", STRING_TO_JSVAL( JS_NewStringCopyZ(c, ifce->hostname) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); @@ -247,7 +247,7 @@ static JSBool SMJS_FUNCTION(widget_get_interfaces) jsval v; SMJS_OBJ SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid) return JS_FALSE; if (!argc || !JSVAL_IS_STRING(argv[0])) return JS_TRUE; @@ -277,7 +277,7 @@ static JSBool SMJS_FUNCTION_EXT(widget_activate_component, Bool is_deactivate) char *comp_id; SMJS_OBJ SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid) return JS_FALSE; if (!argc || !JSVAL_IS_STRING(argv[0])) return JS_TRUE; @@ -331,7 +331,7 @@ JSBool widget_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval * { const char *opt; char *prop_name; - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid) return JS_FALSE; if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; @@ -407,7 +407,7 @@ void widget_load(GF_WidgetManager *wm, GF_SceneGraph *scene, JSContext *c, JSObj for (i=0; ibound_ifces, i); if (ifce->obj) { - JS_SetPrivate(c, ifce->obj, NULL); + SMJS_SET_PRIVATE(c, ifce->obj, NULL); gf_js_remove_root(c, &ifce->obj, GF_JSGC_OBJECT); ifce->obj = NULL; } @@ -436,7 +436,7 @@ void widget_load(GF_WidgetManager *wm, GF_SceneGraph *scene, JSContext *c, JSObj wi->scene_obj = JS_DefineObject(c, global, "widget", &wm->widgetClass, 0, 0); //JS_AliasProperty(c, global, "widget", "MPEGWidget"); - JS_SetPrivate(c, wi->scene_obj, wi); + SMJS_SET_PRIVATE(c, wi->scene_obj, wi); /*and remember the script*/ wi->scene_context = c; wi->scene_global = global; diff --git a/modules/widgetman/widgetman.c b/modules/widgetman/widgetman.c index 593f60b..058cc8b 100644 --- a/modules/widgetman/widgetman.c +++ b/modules/widgetman/widgetman.c @@ -589,7 +589,7 @@ static void wm_delete_interface_instance(GF_WidgetManager *wm, GF_WidgetInterfac { if (bifce->hostname) gf_free(bifce->hostname); if (bifce->obj) { - JS_SetPrivate(wm->ctx, bifce->obj, NULL); + SMJS_SET_PRIVATE(wm->ctx, bifce->obj, NULL); gf_js_remove_root(wm->ctx, &bifce->obj, GF_JSGC_OBJECT); } gf_free(bifce); @@ -616,7 +616,7 @@ static void wm_delete_widget_instance(GF_WidgetManager *wm, GF_WidgetInstance *w gf_list_del(widg->output_triggers); if (widg->obj) { - JS_SetPrivate(wm->ctx, widg->obj, NULL); + SMJS_SET_PRIVATE(wm->ctx, widg->obj, NULL); gf_js_remove_root(wm->ctx, &widg->obj, GF_JSGC_OBJECT); } gf_list_del_item(wm->widget_instances, widg); @@ -655,7 +655,7 @@ static JSBool wm_widget_set_scene_input_value(JSContext *c, JSObject *obj, uintN GF_WidgetMessage *msg; GF_WidgetInterface *ifce; - if (!wid && obj) wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + if (!wid && obj) wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid) return JS_FALSE; if (!wid->scene) return JS_TRUE; @@ -666,21 +666,21 @@ static JSBool wm_widget_set_scene_input_value(JSContext *c, JSObject *obj, uintN /*set_input*/ case 0: if (argc!=2) return JS_FALSE; - param = JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]) ); + param = SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]) ); break; /*call_input_action*/ case 1: - msg = JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]) ); + msg = SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]) ); param = msg ? msg->input_action : NULL; break; /*bind_interface*/ case 2: - ifce = JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]) ); + ifce = SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]) ); param = ifce ? ifce->bind_action : NULL; break; /*unbind_interface*/ case 3: - ifce = JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]) ); + ifce = SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]) ); param = ifce ? ifce->unbind_action : NULL; break; } @@ -894,12 +894,12 @@ static JSBool SMJS_FUNCTION(wm_widget_call_input_script) GF_WidgetPin *param; SMJS_OBJ SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid || (argc!=2) ) return JS_FALSE; if (!wid->scene) return JS_TRUE; if (!JSVAL_IS_OBJECT(argv[0])) return JS_TRUE; - msg = JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]) ); + msg = SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]) ); param = msg ? msg->input_action : NULL; if (!param || !param->node || param->attribute) return JS_FALSE; @@ -1016,7 +1016,7 @@ static void wm_component_activation_event(GF_Node *hdl, GF_DOM_Event *evt, GF_No c = handler->js_context; obj = handler->evt_listen_obj; if (!c || !obj) return; - wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid) return; comp = (GF_WidgetComponent *)handler->js_fun; @@ -1059,7 +1059,7 @@ static void on_widget_activated(JSContext *c, JSObject *obj) jsval funval, rval; u32 i, count; GF_XMLNode *context = NULL; - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid || wid->activated) return; /*widget is now activated*/ @@ -1192,7 +1192,7 @@ static JSBool SMJS_FUNCTION(wm_widget_activate) GF_Node *inl; SMJS_OBJ SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid || !argc) return JS_FALSE; if (!JSVAL_IS_OBJECT(argv[0])) return JS_FALSE; @@ -1307,10 +1307,10 @@ static JSBool SMJS_FUNCTION(wm_widget_get_param_value) GF_WidgetPin *param; SMJS_OBJ SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid || !wid->scene || !argc || !JSVAL_IS_OBJECT(argv[0]) ) return JS_FALSE; - param = JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]) ); + param = SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]) ); if (!param) return JS_FALSE; if (!param->node) { @@ -1369,7 +1369,7 @@ static JSBool SMJS_FUNCTION(wm_widget_get_message_param) GF_WidgetPin *par = NULL; SMJS_OBJ SMJS_ARGS - GF_WidgetMessage *msg = (GF_WidgetMessage *)JS_GetPrivate(c, obj); + GF_WidgetMessage *msg = (GF_WidgetMessage *)SMJS_GET_PRIVATE(c, obj); if (!msg || !argc ) return JS_FALSE; if (JSVAL_IS_INT(argv[0])) { @@ -1388,7 +1388,7 @@ static JSBool SMJS_FUNCTION(wm_widget_get_message_param) if (par) { JSObject *obj = JS_NewObject(c, &msg->ifce->content->widget->wm->widgetAnyClass, 0, 0); - JS_SetPrivate(c, obj, par); + SMJS_SET_PRIVATE(c, obj, par); JS_DefineProperty(c, obj, "name", STRING_TO_JSVAL( JS_NewStringCopyZ(c, par->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineProperty(c, obj, "is_input", BOOLEAN_TO_JSVAL( (par->type == GF_WM_PARAM_OUTPUT) ? JS_FALSE : JS_TRUE), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); switch (par->script_type) { @@ -1413,7 +1413,7 @@ static JSBool SMJS_FUNCTION(wm_widget_get_message) GF_WidgetMessage *msg; SMJS_OBJ SMJS_ARGS - GF_WidgetInterface *ifce = (GF_WidgetInterface*)JS_GetPrivate(c, obj); + GF_WidgetInterface *ifce = (GF_WidgetInterface*)SMJS_GET_PRIVATE(c, obj); if (!ifce || !argc) return JS_FALSE; msg = NULL; @@ -1433,7 +1433,7 @@ static JSBool SMJS_FUNCTION(wm_widget_get_message) } if (msg) { JSObject *obj = JS_NewObject(c, &ifce->content->widget->wm->widgetAnyClass, 0, 0); - JS_SetPrivate(c, obj, msg); + SMJS_SET_PRIVATE(c, obj, msg); JS_DefineProperty(c, obj, "num_params", INT_TO_JSVAL( gf_list_count(msg->params) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineProperty(c, obj, "name", STRING_TO_JSVAL( JS_NewStringCopyZ(c, msg->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineProperty(c, obj, "is_input", BOOLEAN_TO_JSVAL( msg->is_output ? JS_FALSE : JS_TRUE ) , 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); @@ -1454,7 +1454,7 @@ static JSBool SMJS_FUNCTION(wm_widget_get_component) GF_WidgetComponentInstance *comp_inst; SMJS_OBJ SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid || !argc || !JSVAL_IS_STRING(argv[0]) ) return JS_FALSE; comp_id = SMJS_CHARS(c, argv[0]); @@ -1495,7 +1495,7 @@ static JSBool SMJS_FUNCTION(wm_widget_get_interface) GF_WidgetInterface *ifce; SMJS_OBJ SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid || !argc || !JSVAL_IS_INT(argv[0]) ) return JS_FALSE; idx = JSVAL_TO_INT(argv[0]); @@ -1504,7 +1504,7 @@ static JSBool SMJS_FUNCTION(wm_widget_get_interface) if (ifce) { if (!ifce->obj) { ifce->obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass, 0, 0); - JS_SetPrivate(c, ifce->obj, ifce); + SMJS_SET_PRIVATE(c, ifce->obj, ifce); JS_DefineProperty(c, ifce->obj, "num_messages", INT_TO_JSVAL( gf_list_count(ifce->messages) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineProperty(c, ifce->obj, "type", STRING_TO_JSVAL( JS_NewStringCopyZ(c, ifce->type) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineProperty(c, ifce->obj, "serviceProvider", BOOLEAN_TO_JSVAL( ifce->provider ? JS_TRUE : JS_FALSE ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); @@ -1524,7 +1524,7 @@ static JSBool SMJS_FUNCTION(wm_widget_bind_output_trigger) SVG_handlerElement *handler; SMJS_OBJ SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); SMJS_SET_RVAL( BOOLEAN_TO_JSVAL(JS_FALSE) ); if (!wid || !wid->scene || (argc!=3)) return JS_TRUE; @@ -1533,7 +1533,7 @@ static JSBool SMJS_FUNCTION(wm_widget_bind_output_trigger) if (!JSVAL_IS_OBJECT(argv[1])) return JS_TRUE; if (!JSVAL_IS_OBJECT(argv[2])) return JS_TRUE; - msg = (GF_WidgetMessage *)JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])); + msg = (GF_WidgetMessage *)SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])); if (!msg) return JS_TRUE; param = msg->output_trigger; if (!param) return JS_TRUE; @@ -1563,7 +1563,7 @@ static JSBool SMJS_FUNCTION(wm_widget_get_context) char *att; SMJS_OBJ //SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid) return JS_FALSE; if (!wid->scene) { SMJS_SET_RVAL(JSVAL_NULL); @@ -1643,7 +1643,7 @@ static JSBool wm_widget_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTE JSString *s; char *prop_name; const char *opt; - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid) return JS_FALSE; if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; @@ -1694,7 +1694,7 @@ static JSBool wm_widget_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTE char *abs_reloc_url; jsval icon_obj_val; JSObject *icon_obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass, 0, 0); - JS_SetPrivate(c, icon_obj, icon); + SMJS_SET_PRIVATE(c, icon_obj, icon); JS_DefineProperty(c, icon_obj, "src", STRING_TO_JSVAL( JS_NewStringCopyZ(c, icon->src) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); if (strlen(icon->relocated_src)) abs_reloc_url = gf_url_concatenate(wid->widget->url, icon->relocated_src); else abs_reloc_url = gf_strdup(""); @@ -1718,7 +1718,7 @@ static JSBool wm_widget_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTE if (pref) { jsval pref_obj_val; JSObject *pref_obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass, 0, 0); - JS_SetPrivate(c, pref_obj, pref); + SMJS_SET_PRIVATE(c, pref_obj, pref); JS_DefineProperty(c, pref_obj, "name", STRING_TO_JSVAL( JS_NewStringCopyZ(c, pref->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineProperty(c, pref_obj, "value", STRING_TO_JSVAL( JS_NewStringCopyZ(c, pref->value) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineProperty(c, pref_obj, "readonly", STRING_TO_JSVAL( JS_NewStringCopyZ(c, ((pref->flags & GF_WM_PREF_READONLY)?"true":"false")) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); @@ -1738,7 +1738,7 @@ static JSBool wm_widget_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTE if (feat) { jsval feat_obj_val; JSObject *feat_obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass, 0, 0); - JS_SetPrivate(c, feat_obj, feat); + SMJS_SET_PRIVATE(c, feat_obj, feat); JS_DefineProperty(c, feat_obj, "name", STRING_TO_JSVAL( JS_NewStringCopyZ(c, feat->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineProperty(c, feat_obj, "required", BOOLEAN_TO_JSVAL( (feat->required? JS_TRUE : JS_FALSE) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); { @@ -1750,7 +1750,7 @@ static JSBool wm_widget_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTE GF_WidgetFeatureParam *param = gf_list_get(feat->params, j); JSObject *param_obj = JS_NewObject(c, &wid->widget->wm->widgetAnyClass, 0, 0); jsval param_obj_val; - JS_SetPrivate(c, param_obj, param); + SMJS_SET_PRIVATE(c, param_obj, param); JS_DefineProperty(c, param_obj, "name", STRING_TO_JSVAL( JS_NewStringCopyZ(c, param->name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineProperty(c, param_obj, "value", STRING_TO_JSVAL( JS_NewStringCopyZ(c, param->value) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); param_obj_val = OBJECT_TO_JSVAL(param_obj); @@ -1898,7 +1898,7 @@ static JSBool wm_widget_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTE char szVal[32]; jsdouble val; char *prop_name; - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid) return JS_FALSE; if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; @@ -1946,13 +1946,13 @@ static JSBool wm_widget_bind_interface_ex(JSContext *c, JSObject *obj, uintN arg u32 i, count; GF_WidgetInterfaceInstance *bifce; GF_WidgetInterface *ifce; - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid || !wid->scene) return JS_FALSE; ifce = NULL; if (argc) { if (!JSVAL_IS_OBJECT(argv[0])) return JS_FALSE; - ifce = JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]) ); + ifce = SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]) ); if (!ifce) return JS_FALSE; } @@ -2056,7 +2056,7 @@ static JSBool SMJS_FUNCTION(wm_widget_deactivate) u32 i, count; jsval funval; SMJS_OBJ - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid) return JS_FALSE; /*widget is a component of another widget, unregister*/ @@ -2106,7 +2106,7 @@ static void wm_widget_jsbind(GF_WidgetManager *wm, GF_WidgetInstance *wid) if (wid->obj) return; wid->obj = JS_NewObject(wm->ctx, &wm->wmWidgetClass, 0, 0); - JS_SetPrivate(wm->ctx, wid->obj, wid); + SMJS_SET_PRIVATE(wm->ctx, wid->obj, wid); /*protect from GC*/ gf_js_add_root(wm->ctx, &wid->obj, GF_JSGC_OBJECT); } @@ -2185,10 +2185,10 @@ static JSBool SMJS_FUNCTION(wm_widget_is_interface_bound) GF_WidgetInterface *ifce; SMJS_OBJ SMJS_ARGS - GF_WidgetInstance *wid = (GF_WidgetInstance *)JS_GetPrivate(c, obj); + GF_WidgetInstance *wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, obj); if (!wid || !wid->scene || (argc<1) || !JSVAL_IS_OBJECT(argv[0]) ) return JS_FALSE; - ifce = JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]) ); + ifce = SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]) ); if (!ifce) return JS_FALSE; cookie = NULL; if ((argc==2) && JSVAL_IS_OBJECT(argv[1]) ) @@ -2214,7 +2214,7 @@ static JSBool SMJS_FUNCTION(wm_load) GF_WidgetInstance *wid; SMJS_OBJ SMJS_ARGS - GF_WidgetManager *wm = (GF_WidgetManager *)JS_GetPrivate(c, obj); + GF_WidgetManager *wm = (GF_WidgetManager *)SMJS_GET_PRIVATE(c, obj); if (!argc || !JSVAL_IS_STRING(argv[0])) return JS_TRUE; manifest = SMJS_CHARS(c, argv[0]); @@ -2223,7 +2223,7 @@ static JSBool SMJS_FUNCTION(wm_load) if ((argc==2) && ! JSVAL_IS_NULL(argv[1]) && JSVAL_IS_OBJECT(argv[1])) { GF_WidgetInstance *parent_widget; if (!JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[1]), &wm->wmWidgetClass, NULL) ) return JS_FALSE; - parent_widget = (GF_WidgetInstance *)JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[1]) ); + parent_widget = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[1]) ); if (parent_widget->widget->url) url = gf_url_concatenate(parent_widget->widget->url, manifest); } @@ -2285,11 +2285,11 @@ static JSBool SMJS_FUNCTION(wm_unload) GF_WidgetInstance *wid; SMJS_OBJ SMJS_ARGS - GF_WidgetManager *wm = (GF_WidgetManager *)JS_GetPrivate(c, obj); + GF_WidgetManager *wm = (GF_WidgetManager *)SMJS_GET_PRIVATE(c, obj); if (!argc || !JSVAL_IS_OBJECT(argv[0])) return JS_TRUE; if (!JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &wm->wmWidgetClass, NULL) ) return JS_FALSE; - wid = (GF_WidgetInstance *)JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]) ); + wid = (GF_WidgetInstance *)SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]) ); if (!wid) return JS_TRUE; /*unless explecetely requested, remove the section*/ @@ -2307,7 +2307,7 @@ static JSBool SMJS_FUNCTION(wm_unload) static JSBool wm_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp) { char *prop_name; - GF_WidgetManager *wm = (GF_WidgetManager *)JS_GetPrivate(c, obj); + GF_WidgetManager *wm = (GF_WidgetManager *)SMJS_GET_PRIVATE(c, obj); if (!wm) return JS_FALSE; if (!SMJS_ID_IS_STRING(id)) return JS_TRUE; @@ -2328,7 +2328,7 @@ static JSBool wm_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsva static JSBool wm_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *vp) { char *prop_name; - GF_WidgetManager *wm = (GF_WidgetManager *)JS_GetPrivate(c, obj); + GF_WidgetManager *wm = (GF_WidgetManager *)SMJS_GET_PRIVATE(c, obj); if (!wm) return JS_FALSE; if (!JSVAL_IS_STRING(*vp)) return JS_TRUE; @@ -2350,7 +2350,7 @@ static JSBool SMJS_FUNCTION(wm_get) GF_WidgetInstance *wid; SMJS_OBJ SMJS_ARGS - GF_WidgetManager *wm = (GF_WidgetManager *)JS_GetPrivate(c, obj); + GF_WidgetManager *wm = (GF_WidgetManager *)SMJS_GET_PRIVATE(c, obj); if (!argc || !JSVAL_IS_INT(argv[0])) return JS_TRUE; i = JSVAL_TO_INT(argv[0]); @@ -2366,7 +2366,7 @@ static JSBool SMJS_FUNCTION(wm_find_interface) GF_WidgetInstance *wid; SMJS_OBJ SMJS_ARGS - GF_WidgetManager *wm = (GF_WidgetManager *)JS_GetPrivate(c, obj); + GF_WidgetManager *wm = (GF_WidgetManager *)SMJS_GET_PRIVATE(c, obj); if (!argc || !JSVAL_IS_STRING(argv[0])) return JS_TRUE; ifce_name = SMJS_CHARS(c, argv[0]); @@ -3462,7 +3462,7 @@ static JSBool SMJS_FUNCTION(wm_initialize) const char*opt; SMJS_OBJ //SMJS_ARGS - GF_WidgetManager *wm = (GF_WidgetManager *)JS_GetPrivate(c, obj); + GF_WidgetManager *wm = (GF_WidgetManager *)SMJS_GET_PRIVATE(c, obj); count = gf_cfg_get_key_count(wm->term->user->config, "Widgets"); for (i=0; iwidmanClass, 0, 0, wmClassProps, wmClassFuncs, 0, 0); wm->obj = JS_DefineObject(c, global, "WidgetManager", &wm->widmanClass, 0, 0); - JS_SetPrivate(c, wm->obj, wm); + SMJS_SET_PRIVATE(c, wm->obj, wm); gf_js_add_root(c, &wm->obj, GF_JSGC_OBJECT); diff --git a/src/media_tools/mpd.c b/src/media_tools/mpd.c index bf2578a..21c6c7a 100644 --- a/src/media_tools/mpd.c +++ b/src/media_tools/mpd.c @@ -385,7 +385,8 @@ static GF_MPD_SegmentTemplate *gf_mpd_parse_segment_template(GF_XMLNode *root) while ( (att = gf_list_enum(root->attributes, &i)) ) { if (!strcmp(att->name, "media")) seg->media = gf_mpd_parse_string(att->value); else if (!strcmp(att->name, "index")) seg->index = gf_mpd_parse_string(att->value); - else if (!strcmp(att->name, "initialization")) seg->initialization = gf_mpd_parse_string(att->value); + else if (!strcmp(att->name, "initialization") ) seg->initialization = gf_mpd_parse_string(att->value); + else if (!strcmp(att->name, "initialisation") ) seg->initialization = gf_mpd_parse_string(att->value); else if (!strcmp(att->name, "bitstreamSwitching")) seg->bitstream_switching = gf_mpd_parse_string(att->value); } gf_mpd_parse_multiple_segment_base((GF_MPD_MultipleSegmentBase *)seg, root); @@ -928,7 +929,7 @@ GF_Err gf_mpd_init_from_dom(GF_XMLNode *root, GF_MPD *mpd, const char *default_b GF_EXPORT GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, const char *mpd_file, - u32 reload_count, char *mimeTypeForM3U8Segments, GF_ClientService *service, Bool do_import, Bool use_mpd_templates) + u32 reload_count, char *mimeTypeForM3U8Segments, Bool do_import, Bool use_mpd_templates, GF_FileDownload *getter) { GF_Err e; char *sep, *template_base, *template_ext; @@ -989,7 +990,18 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[MPD Generator] Not downloading, programs are identical for %s...\n", pe->url)); continue; } - if (service) { + if (getter && getter->new_session && getter->del_session && getter->get_cache_name) { + e = getter->new_session(getter, suburl); + if (e) { + gf_free(suburl); + break; + } + if (e==GF_OK) { + e = parse_sub_playlist(getter->get_cache_name(getter), &pl, suburl, prog, pe); + } + getter->del_session(getter); + +#if 0 GF_DownloadSession *sess = gf_term_download_new(service, suburl, GF_NETIO_SESSION_NOT_THREADED, NULL, NULL); if (!sess) { gf_free(suburl); @@ -1000,6 +1012,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url, e = parse_sub_playlist(gf_dm_sess_get_cache_name(sess), &pl, suburl, prog, pe); } gf_term_download_del(sess); +#endif gf_free(suburl); } else { /* for use in MP4Box */ if (strstr(suburl, "://") && !strstr(suburl, "://") ) { diff --git a/src/media_tools/mpegts.c b/src/media_tools/mpegts.c index 6c214e3..78521db 100644 --- a/src/media_tools/mpegts.c +++ b/src/media_tools/mpegts.c @@ -2155,7 +2155,10 @@ static void gf_m2ts_process_packet(GF_M2TS_Demuxer *ts, unsigned char *data) } paf = ⁡ memset(paf, 0, sizeof(GF_M2TS_AdaptationField)); + //this will stop you when processing invalid (yet existing) mpeg2ts streams in debug assert(af_size>=0 && af_size<=182); + if ( !(af_size>=0 && af_size<=182)) + GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] Detected wrong adaption field size %u when control value is 3\n", af_size)); if (af_size) gf_m2ts_get_adaptation_field(ts, paf, data+5, af_size, hdr.pid); pos += 1+af_size; payload_size = 183 - af_size; diff --git a/src/scenegraph/dom_smjs.c b/src/scenegraph/dom_smjs.c index 5ff9594..878cd63 100644 --- a/src/scenegraph/dom_smjs.c +++ b/src/scenegraph/dom_smjs.c @@ -61,7 +61,7 @@ static GFINLINE GF_SceneGraph *xml_get_scenegraph(JSContext *c) GF_SceneGraph *scene; JSObject *global = JS_GetGlobalObject(c); assert(global); - scene = JS_GetPrivate(c, global); + scene = SMJS_GET_PRIVATE(c, global); assert(scene); return scene; } @@ -200,14 +200,14 @@ JSBool dom_throw_exception(JSContext *c, u32 code) GF_Node *dom_get_node(JSContext *c, JSObject *obj) { - GF_Node *n = obj ? JS_GetPrivate(c, obj) : NULL; + GF_Node *n = obj ? SMJS_GET_PRIVATE(c, obj) : NULL; if (n && n->sgprivate) return n; return NULL; } GF_Node *dom_get_element(JSContext *c, JSObject *obj) { - GF_Node *n = JS_GetPrivate(c, obj); + GF_Node *n = SMJS_GET_PRIVATE(c, obj); if (!n || !n->sgprivate) return NULL; if (n->sgprivate->tag==TAG_DOMText) return NULL; return n; @@ -215,7 +215,7 @@ GF_Node *dom_get_element(JSContext *c, JSObject *obj) GF_SceneGraph *dom_get_doc(JSContext *c, JSObject *obj) { - GF_SceneGraph *sg = JS_GetPrivate(c, obj); + GF_SceneGraph *sg = SMJS_GET_PRIVATE(c, obj); if (sg && !sg->__reserved_null) return sg; return NULL; } @@ -237,7 +237,7 @@ static jsval dom_document_construct(JSContext *c, GF_SceneGraph *sg) if (!jsclass) jsclass = &dom_rt->domDocumentClass; new_obj = JS_NewObject(c, jsclass, 0, 0); - JS_SetPrivate(c, new_obj, sg); + SMJS_SET_PRIVATE(c, new_obj, sg); sg->document = new_obj; return OBJECT_TO_JSVAL(new_obj); } @@ -272,7 +272,7 @@ static jsval dom_base_node_construct(JSContext *c, JSClass *_class, GF_Node *n) gf_node_register(n, NULL); new_obj = JS_NewObject(c, _class, 0, 0); - JS_SetPrivate(c, new_obj, n); + SMJS_SET_PRIVATE(c, new_obj, n); if (!n->sgprivate->interact) GF_SAFEALLOC(n->sgprivate->interact, struct _node_interactive_ext); if (!n->sgprivate->interact->js_binding) { @@ -409,7 +409,7 @@ static jsval dom_nodelist_construct(JSContext *c, GF_ParentNode *n) gf_node_register((GF_Node*)n, NULL); new_obj = JS_NewObject(c, &dom_rt->domNodeListClass, 0, 0); - JS_SetPrivate(c, new_obj, nl); + SMJS_SET_PRIVATE(c, new_obj, nl); return OBJECT_TO_JSVAL(new_obj); } @@ -419,7 +419,7 @@ static void dom_nodelist_finalize(JSContext *c, JSObject *obj) if (!JS_InstanceOf(c, obj, &dom_rt->domNodeListClass, NULL) ) return; - nl = (DOMNodeList *) JS_GetPrivate(c, obj); + nl = (DOMNodeList *) SMJS_GET_PRIVATE(c, obj); if (!nl) return; if (nl->owner) { @@ -449,7 +449,7 @@ static JSBool SMJS_FUNCTION(dom_nodelist_item) if ((argc!=1) || !JSVAL_IS_INT(argv[0])) return JS_TRUE; - nl = (DOMNodeList *)JS_GetPrivate(c, obj); + nl = (DOMNodeList *)SMJS_GET_PRIVATE(c, obj); count = gf_node_list_get_count(nl->owner ? nl->owner->children : nl->child); idx = JSVAL_TO_INT(argv[0]); if ((idx<0) || ((u32) idx>=count)) { @@ -472,7 +472,7 @@ static JSBool dom_nodelist_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GE switch (SMJS_ID_TO_INT(id)) { case 0: - nl = (DOMNodeList *) JS_GetPrivate(c, obj); + nl = (DOMNodeList *) SMJS_GET_PRIVATE(c, obj); *vp = INT_TO_JSVAL( gf_node_list_get_count(nl->owner ? nl->owner->children : nl->child) ); return JS_TRUE; } @@ -763,12 +763,12 @@ JSBool SMJS_FUNCTION(dom_event_remove_listener) /*dom3 node*/ static void dom_node_finalize(JSContext *c, JSObject *obj) { - GF_Node *n = (GF_Node *) JS_GetPrivate(c, obj); + GF_Node *n = (GF_Node *) SMJS_GET_PRIVATE(c, obj); /*the JS proto of the svgClass or a destroyed object*/ if (!n) return; if (!n->sgprivate) return; - JS_SetPrivate(c, obj, NULL); + SMJS_SET_PRIVATE(c, obj, NULL); gf_list_del_item(n->sgprivate->scenegraph->objects, obj); dom_js_pre_destroy(c, n->sgprivate->scenegraph, n); @@ -1353,11 +1353,11 @@ void dom_document_finalize(JSContext *c, JSObject *obj) { GF_SceneGraph *sg = dom_get_doc(c, obj); - sg = (GF_SceneGraph*) JS_GetPrivate(c, obj); + sg = (GF_SceneGraph*) SMJS_GET_PRIVATE(c, obj); /*the JS proto of the svgClass or a destroyed object*/ if (!sg) return; - JS_SetPrivate(c, sg->document, NULL); + SMJS_SET_PRIVATE(c, sg->document, NULL); sg->document = NULL; if (sg->RootNode) { gf_node_unregister(sg->RootNode, NULL); @@ -1546,7 +1546,7 @@ static JSBool SMJS_FUNCTION(xml_document_elements_by_tag) if (name && !strcmp(name, "*")) name = NULL; xml_doc_gather_nodes((GF_ParentNode*)sg->RootNode, name, nl); new_obj = JS_NewObject(c, &dom_rt->domNodeListClass, 0, 0); - JS_SetPrivate(c, new_obj, nl); + SMJS_SET_PRIVATE(c, new_obj, nl); SMJS_SET_RVAL( OBJECT_TO_JSVAL(new_obj)); SMJS_FREE(c, name); return JS_TRUE; @@ -2051,7 +2051,7 @@ static JSBool SMJS_FUNCTION(xml_element_elements_by_tag) } xml_doc_gather_nodes((GF_ParentNode*)n, name, nl); new_obj = JS_NewObject(c, &dom_rt->domNodeListClass, 0, 0); - JS_SetPrivate(c, new_obj, nl); + SMJS_SET_PRIVATE(c, new_obj, nl); SMJS_SET_RVAL( OBJECT_TO_JSVAL(new_obj) ); SMJS_FREE(c, name); @@ -2150,7 +2150,7 @@ static JSBool dom_text_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER static JSBool SMJS_FUNCTION(event_stop_propagation) { SMJS_OBJ - GF_DOM_Event *evt = JS_GetPrivate(c, obj); + GF_DOM_Event *evt = SMJS_GET_PRIVATE(c, obj); if (!evt) return JS_TRUE; evt->event_phase |= GF_DOM_EVENT_PHASE_CANCEL; return JS_TRUE; @@ -2158,7 +2158,7 @@ static JSBool SMJS_FUNCTION(event_stop_propagation) static JSBool SMJS_FUNCTION(event_stop_immediate_propagation) { SMJS_OBJ - GF_DOM_Event *evt = JS_GetPrivate(c, obj); + GF_DOM_Event *evt = SMJS_GET_PRIVATE(c, obj); if (!evt) return JS_TRUE; evt->event_phase |= GF_DOM_EVENT_PHASE_CANCEL_ALL; return JS_TRUE; @@ -2166,7 +2166,7 @@ static JSBool SMJS_FUNCTION(event_stop_immediate_propagation) static JSBool SMJS_FUNCTION(event_prevent_default) { SMJS_OBJ - GF_DOM_Event *evt = JS_GetPrivate(c, obj); + GF_DOM_Event *evt = SMJS_GET_PRIVATE(c, obj); if (!evt) return JS_TRUE; evt->event_phase |= GF_DOM_EVENT_PHASE_PREVENT; return JS_TRUE; @@ -2175,7 +2175,7 @@ static JSBool SMJS_FUNCTION(event_prevent_default) static JSBool event_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp) { JSString *s; - GF_DOM_Event *evt = JS_GetPrivate(c, obj); + GF_DOM_Event *evt = SMJS_GET_PRIVATE(c, obj); if (evt==NULL) return JS_TRUE; if (SMJS_ID_IS_INT(id)) { switch (SMJS_ID_TO_INT(id)) { @@ -2531,7 +2531,7 @@ static void xml_http_finalize(JSContext *c, JSObject *obj) { XMLHTTPContext *ctx; if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return; - ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj); + ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); if (ctx) { if (ctx->onreadystatechange) gf_js_remove_root(c, &(ctx->onreadystatechange), GF_JSGC_VAL); xml_http_reset(ctx); @@ -2547,7 +2547,7 @@ static JSBool SMJS_FUNCTION(xml_http_constructor) GF_SAFEALLOC(p, XMLHTTPContext); p->c = c; p->_this = obj; - JS_SetPrivate(c, obj, p); + SMJS_SET_PRIVATE(c, obj, p); SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) ); return JS_TRUE; } @@ -2588,7 +2588,7 @@ static JSBool SMJS_FUNCTION(xml_http_open) SMJS_ARGS if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE; - ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj); + ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); if (!ctx) return JS_TRUE; /*reset*/ @@ -2657,7 +2657,7 @@ static JSBool SMJS_FUNCTION(xml_http_set_header) SMJS_ARGS if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE; - ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj); + ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); if (!ctx) return JS_TRUE; if (ctx->readyState!=1) return JS_TRUE; @@ -2896,7 +2896,7 @@ static JSBool SMJS_FUNCTION(xml_http_send) SMJS_ARGS if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE; - ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj); + ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); if (!ctx) return JS_TRUE; if (ctx->readyState!=1) return JS_TRUE; @@ -3000,7 +3000,7 @@ static JSBool SMJS_FUNCTION(xml_http_abort) SMJS_OBJ if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE; - ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj); + ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); if (!ctx) return JS_TRUE; sess = ctx->sess; @@ -3019,7 +3019,7 @@ static JSBool SMJS_FUNCTION(xml_http_get_all_headers) SMJS_OBJ if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE; - ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj); + ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); if (!ctx) return JS_TRUE; /*must be received or loaded*/ @@ -3053,7 +3053,7 @@ static JSBool SMJS_FUNCTION(xml_http_get_header) SMJS_OBJ SMJS_ARGS if (!argc || !JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE; - ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj); + ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); if (!ctx) return JS_TRUE; if (!JSVAL_CHECK_STRING(argv[0])) return JS_TRUE; @@ -3086,7 +3086,7 @@ static JSBool xml_http_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER JSString *s; XMLHTTPContext *ctx; if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE; - ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj); + ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); if (!ctx) return JS_TRUE; if (SMJS_ID_IS_INT(id)) { @@ -3145,7 +3145,7 @@ static JSBool xml_http_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER { XMLHTTPContext *ctx; if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE; - ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj); + ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj); if (!ctx) return JS_TRUE; if (SMJS_ID_IS_INT(id)) { @@ -3433,7 +3433,7 @@ static JSBool SMJS_FUNCTION(dcci_search_property) GF_SAFEALLOC(nl, DOMNodeList); dcci_prop_collect(nl, n, ns, name, deep, 1); new_obj = JS_NewObject(c, &dom_rt->domNodeListClass, 0, 0); - JS_SetPrivate(c, new_obj, nl); + SMJS_SET_PRIVATE(c, new_obj, nl); SMJS_SET_RVAL( OBJECT_TO_JSVAL(new_obj) ); SMJS_FREE(c, ns); SMJS_FREE(c, name); @@ -3837,7 +3837,7 @@ void dom_js_pre_destroy(JSContext *c, GF_SceneGraph *sg, GF_Node *n) if (n) { if (n->sgprivate->interact && n->sgprivate->interact->js_binding && n->sgprivate->interact->js_binding->node) { JSObject *obj = n->sgprivate->interact->js_binding->node; - JS_SetPrivate(c, obj, NULL); + SMJS_SET_PRIVATE(c, obj, NULL); n->sgprivate->interact->js_binding->node=NULL; if (gf_list_del_item(sg->objects, obj)>=0) { gf_js_remove_root(c, &(n->sgprivate->interact->js_binding->node), GF_JSGC_OBJECT); @@ -3853,7 +3853,7 @@ void dom_js_pre_destroy(JSContext *c, GF_SceneGraph *sg, GF_Node *n) JSObject *obj = gf_list_get(sg->objects, 0); n = dom_get_node(c, obj); if (n) { - JS_SetPrivate(c, obj, NULL); + SMJS_SET_PRIVATE(c, obj, NULL); n->sgprivate->interact->js_binding->node=NULL; gf_node_unregister(n, NULL); gf_js_remove_root(c, &(n->sgprivate->interact->js_binding->node), GF_JSGC_OBJECT); @@ -3907,7 +3907,7 @@ static void dom_js_define_document_ex(JSContext *c, JSObject *global, GF_SceneGr obj = JS_DefineObject(c, global, name, __class, 0, 0 ); gf_node_register(doc->RootNode, NULL); - JS_SetPrivate(c, obj, doc); + SMJS_SET_PRIVATE(c, obj, doc); doc->document = obj; } diff --git a/src/scenegraph/svg_smjs.c b/src/scenegraph/svg_smjs.c index d322061..63ab3a5 100644 --- a/src/scenegraph/svg_smjs.c +++ b/src/scenegraph/svg_smjs.c @@ -139,7 +139,7 @@ static JSBool SMJS_FUNCTION(svg_nav_to_location) SMJS_OBJ SMJS_ARGS if ((argc!=1) || !JS_InstanceOf(c, obj, &svg_rt->globalClass, NULL)) return JS_TRUE; - sg = JS_GetPrivate(c, obj); + sg = SMJS_GET_PRIVATE(c, obj); par.uri.url = SMJS_CHARS(c, argv[0]); par.uri.nb_params = 0; ScriptAction(sg, GF_JSAPI_OP_LOAD_URL, sg->RootNode, &par); @@ -183,7 +183,7 @@ static JSBool SMJS_FUNCTION(svg_echo) SMJS_OBJ SMJS_ARGS if ((argc!=1) || !JS_InstanceOf(c, obj, &svg_rt->globalClass, NULL)) return JS_TRUE; - sg = JS_GetPrivate(c, obj); + sg = SMJS_GET_PRIVATE(c, obj); if (!sg) return JS_TRUE; if (JSVAL_IS_STRING(argv[0])) { @@ -227,7 +227,7 @@ static JSBool global_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, if (!JS_InstanceOf(c, obj, &svg_rt->globalClass, NULL) ) return JS_TRUE; - sg = JS_GetPrivate(c, obj); + sg = SMJS_GET_PRIVATE(c, obj); if (SMJS_ID_IS_INT(id)) { switch (SMJS_ID_TO_INT(id)) { /*namespaceURI*/ @@ -353,7 +353,7 @@ static JSBool svg_element_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GET rc->x = FIX2FLT(par.pt.x); rc->y = FIX2FLT(par.pt.y); rc->sg = n->sgprivate->scenegraph; - JS_SetPrivate(c, r, rc); + SMJS_SET_PRIVATE(c, r, rc); *vp = OBJECT_TO_JSVAL(r); return JS_TRUE; } @@ -368,7 +368,7 @@ static JSBool svg_element_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GET rc->w = FIX2FLT(par.rc.width); rc->h = FIX2FLT(par.rc.height); rc->sg = n->sgprivate->scenegraph; - JS_SetPrivate(c, r, rc); + SMJS_SET_PRIVATE(c, r, rc); *vp = OBJECT_TO_JSVAL(r); return JS_TRUE; } @@ -841,7 +841,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_matrix_trait) gf_mx2d_init(*mx); gf_mx2d_copy(*mx, ((SVG_Transform*)info.far_ptr)->mat); - JS_SetPrivate(c, mO, mx); + SMJS_SET_PRIVATE(c, mO, mx); SMJS_SET_RVAL( OBJECT_TO_JSVAL(mO) ); return JS_TRUE; } @@ -875,7 +875,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_rect_trait) rc->y = FIX2FLT(v->y); rc->w = FIX2FLT(v->width); rc->h = FIX2FLT(v->height); - JS_SetPrivate(c, newObj, rc); + SMJS_SET_PRIVATE(c, newObj, rc); SMJS_SET_RVAL( OBJECT_TO_JSVAL(newObj) ); return JS_TRUE; } @@ -936,7 +936,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_rgb_color_trait) rgb->r = (u8) (255*FIX2FLT(col->red)) ; rgb->g = (u8) (255*FIX2FLT(col->green)) ; rgb->b = (u8) (255*FIX2FLT(col->blue)) ; - JS_SetPrivate(c, newObj, rgb); + SMJS_SET_PRIVATE(c, newObj, rgb); SMJS_SET_RVAL( OBJECT_TO_JSVAL(newObj) ); return JS_TRUE; } @@ -950,7 +950,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_rgb_color_trait) rgb->r = (u8) (255*FIX2FLT(paint->color.red) ); rgb->g = (u8) (255*FIX2FLT(paint->color.green) ); rgb->b = (u8) (255*FIX2FLT(paint->color.blue) ); - JS_SetPrivate(c, newObj, rgb); + SMJS_SET_PRIVATE(c, newObj, rgb); SMJS_SET_RVAL( OBJECT_TO_JSVAL(newObj) ); return JS_TRUE; } @@ -1089,7 +1089,7 @@ JSBool SMJS_FUNCTION(svg_udom_set_matrix_trait) if (JSVAL_IS_NULL(argv[1]) || !JSVAL_IS_OBJECT(argv[1])) return JS_TRUE; mO = JSVAL_TO_OBJECT(argv[1]); if (!JS_InstanceOf(c, mO, &svg_rt->matrixClass, NULL) ) return JS_TRUE; - mx = JS_GetPrivate(c, mO); + mx = SMJS_GET_PRIVATE(c, mO); if (!mx) return JS_TRUE; szName = SMJS_CHARS(c, argv[0]); @@ -1122,7 +1122,7 @@ JSBool SMJS_FUNCTION(svg_udom_set_rect_trait) if (JSVAL_IS_NULL(argv[1]) || !JSVAL_IS_OBJECT(argv[1])) return JS_TRUE; rO = JSVAL_TO_OBJECT(argv[1]); if (!JS_InstanceOf(c, rO, &svg_rt->rectClass, NULL) ) return JS_TRUE; - rc = JS_GetPrivate(c, rO); + rc = SMJS_GET_PRIVATE(c, rO); if (!rc) return JS_TRUE; szName = SMJS_CHARS(c, argv[0]); @@ -1158,7 +1158,7 @@ JSBool SMJS_FUNCTION(svg_udom_set_path_trait) if (JSVAL_IS_NULL(argv[1]) || !JSVAL_IS_OBJECT(argv[1])) return JS_TRUE; pO = JSVAL_TO_OBJECT(argv[1]); if (!JS_InstanceOf(c, pO, &svg_rt->pathClass, NULL) ) return JS_TRUE; - path = JS_GetPrivate(c, pO); + path = SMJS_GET_PRIVATE(c, pO); if (!path) return JS_TRUE; szName = SMJS_CHARS(c, argv[0]); @@ -1225,7 +1225,7 @@ JSBool SMJS_FUNCTION(svg_udom_set_rgb_color_trait) colO = JSVAL_TO_OBJECT(argv[1]); if (!colO) return JS_TRUE; if (!JS_InstanceOf(c, colO, &svg_rt->rgbClass, NULL) ) return JS_TRUE; - rgb = JS_GetPrivate(c, colO); + rgb = SMJS_GET_PRIVATE(c, colO); if (!rgb) return JS_TRUE; SMJS_SET_RVAL(JSVAL_VOID); @@ -1278,7 +1278,7 @@ static JSBool SMJS_FUNCTION_EXT(svg_get_bbox, Bool get_screen) rc->y = FIX2FLT(par.bbox.min_edge.y); rc->w = FIX2FLT(par.bbox.max_edge.x - par.bbox.min_edge.x); rc->h = FIX2FLT(par.bbox.max_edge.y - par.bbox.min_edge.y); - JS_SetPrivate(c, rO, rc); + SMJS_SET_PRIVATE(c, rO, rc); SMJS_SET_RVAL( OBJECT_TO_JSVAL(rO) ); } else { SMJS_SET_RVAL( JSVAL_VOID ); @@ -1307,7 +1307,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_screen_ctm) JSObject *mO = JS_NewObject(c, &svg_rt->matrixClass, 0, 0); GF_Matrix2D *mx = gf_malloc(sizeof(GF_Matrix2D)); gf_mx2d_from_mx(mx, &par.mx); - JS_SetPrivate(c, mO, mx); + SMJS_SET_PRIVATE(c, mO, mx); SMJS_SET_RVAL( OBJECT_TO_JSVAL(mO) ); return JS_TRUE; } @@ -1339,7 +1339,7 @@ JSBool SMJS_FUNCTION(svg_udom_create_matrix_components) JS_ValueToNumber(c, argv[5], &v); mx->m[5] = FLT2FIX(v); mat = JS_NewObject(c, &svg_rt->matrixClass, 0, 0); - JS_SetPrivate(c, mat, mx); + SMJS_SET_PRIVATE(c, mat, mx); SMJS_SET_RVAL( OBJECT_TO_JSVAL(mat) ); return JS_TRUE; } @@ -1353,7 +1353,7 @@ JSBool SMJS_FUNCTION(svg_udom_create_rect) GF_SAFEALLOC(rc, rectCI); r = JS_NewObject(c, &svg_rt->rectClass, 0, 0); - JS_SetPrivate(c, r, rc); + SMJS_SET_PRIVATE(c, r, rc); SMJS_SET_RVAL( OBJECT_TO_JSVAL(r) ); return JS_TRUE; } @@ -1367,7 +1367,7 @@ JSBool SMJS_FUNCTION(svg_udom_create_point) GF_SAFEALLOC(pt, pointCI); r = JS_NewObject(c, &svg_rt->pointClass, 0, 0); - JS_SetPrivate(c, r, pt); + SMJS_SET_PRIVATE(c, r, pt); SMJS_SET_RVAL( OBJECT_TO_JSVAL(r) ); return JS_TRUE; } @@ -1381,7 +1381,7 @@ JSBool SMJS_FUNCTION(svg_udom_create_path) GF_SAFEALLOC(path, pathCI); p = JS_NewObject(c, &svg_rt->pathClass, 0, 0); - JS_SetPrivate(c, p, path); + SMJS_SET_PRIVATE(c, p, path); SMJS_SET_RVAL( OBJECT_TO_JSVAL(p) ); return JS_TRUE; } @@ -1400,7 +1400,7 @@ JSBool SMJS_FUNCTION(svg_udom_create_color) col->g = JSVAL_TO_INT(argv[1]); col->b = JSVAL_TO_INT(argv[2]); p = JS_NewObject(c, &svg_rt->rgbClass, 0, 0); - JS_SetPrivate(c, p, col); + SMJS_SET_PRIVATE(c, p, col); SMJS_SET_RVAL( OBJECT_TO_JSVAL(p) ); return JS_TRUE; } @@ -1538,7 +1538,7 @@ static JSFunctionSpec connectionFuncs[] = { static void baseCI_finalize(JSContext *c, JSObject *obj) { - void *data = JS_GetPrivate(c, obj); + void *data = SMJS_GET_PRIVATE(c, obj); if (data) gf_free(data); } @@ -1546,7 +1546,7 @@ static JSBool rgb_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsv { if (!JS_InstanceOf(c, obj, &svg_rt->rgbClass, NULL) ) return JS_TRUE; if (SMJS_ID_IS_INT(id)) { - rgbCI *col = JS_GetPrivate(c, obj); + rgbCI *col = SMJS_GET_PRIVATE(c, obj); if (!col) return JS_TRUE; switch (SMJS_ID_TO_INT(id)) { case 0: *vp = INT_TO_JSVAL(col->r); return JS_TRUE; @@ -1562,7 +1562,7 @@ static JSBool rgb_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsv { if (!JS_InstanceOf(c, obj, &svg_rt->rgbClass, NULL) ) return JS_TRUE; if (SMJS_ID_IS_INT(id)) { - rgbCI *col = JS_GetPrivate(c, obj); + rgbCI *col = SMJS_GET_PRIVATE(c, obj); if (!col) return JS_TRUE; switch (SMJS_ID_TO_INT(id)) { case 0: col->r = JSVAL_TO_INT(*vp); return JS_TRUE; @@ -1579,7 +1579,7 @@ static JSBool rect_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, js { if (!JS_InstanceOf(c, obj, &svg_rt->rectClass, NULL) ) return JS_TRUE; if (SMJS_ID_IS_INT(id)) { - rectCI *rc = JS_GetPrivate(c, obj); + rectCI *rc = SMJS_GET_PRIVATE(c, obj); if (!rc) return JS_TRUE; if (rc->sg) { GF_JSAPIParam par; @@ -1604,7 +1604,7 @@ static JSBool rect_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, js if (!JS_InstanceOf(c, obj, &svg_rt->rectClass, NULL) ) return JS_TRUE; if (SMJS_ID_IS_INT(id)) { jsdouble d; - rectCI *rc = JS_GetPrivate(c, obj); + rectCI *rc = SMJS_GET_PRIVATE(c, obj); if (!rc) return JS_TRUE; JS_ValueToNumber(c, *vp, &d); switch (SMJS_ID_TO_INT(id)) { @@ -1622,7 +1622,7 @@ static JSBool point_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, j { if (!JS_InstanceOf(c, obj, &svg_rt->pointClass, NULL) ) return JS_TRUE; if (SMJS_ID_IS_INT(id)) { - pointCI *pt = JS_GetPrivate(c, obj); + pointCI *pt = SMJS_GET_PRIVATE(c, obj); if (!pt) return JS_TRUE; if (pt->sg) { GF_JSAPIParam par; @@ -1643,7 +1643,7 @@ static JSBool point_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, j if (!JS_InstanceOf(c, obj, &svg_rt->pointClass, NULL) ) return JS_TRUE; if (SMJS_ID_IS_INT(id)) { jsdouble d; - pointCI *pt = JS_GetPrivate(c, obj); + pointCI *pt = SMJS_GET_PRIVATE(c, obj); if (!pt) return JS_TRUE; JS_ValueToNumber(c, *vp, &d); switch (SMJS_ID_TO_INT(id)) { @@ -1684,7 +1684,7 @@ static JSObject *svg_new_path_object(JSContext *c, SVG_PathData *d) } } obj = JS_NewObject(c, &svg_rt->pathClass, 0, 0); - JS_SetPrivate(c, obj, p); + SMJS_SET_PRIVATE(c, obj, p); return obj; #endif } @@ -1694,7 +1694,7 @@ static JSBool pathCI_constructor(JSContext *c, JSObject *obj, uintN argc, jsval { pathCI *p; GF_SAFEALLOC(p, pathCI); - JS_SetPrivate(c, obj, p); + SMJS_SET_PRIVATE(c, obj, p); *rval = OBJECT_TO_JSVAL(obj); return JS_TRUE; } @@ -1702,7 +1702,7 @@ static JSBool pathCI_constructor(JSContext *c, JSObject *obj, uintN argc, jsval static void pathCI_finalize(JSContext *c, JSObject *obj) { - pathCI *p = JS_GetPrivate(c, obj); + pathCI *p = SMJS_GET_PRIVATE(c, obj); if (p) { if (p->pts) gf_free(p->pts); if (p->tags) gf_free(p->tags); @@ -1714,7 +1714,7 @@ static JSBool path_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, js { if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE; if (SMJS_ID_IS_INT(id)) { - pathCI *p = JS_GetPrivate(c, obj); + pathCI *p = SMJS_GET_PRIVATE(c, obj); if (!p) return JS_TRUE; switch (SMJS_ID_TO_INT(id)) { case 0: *vp = INT_TO_JSVAL(p->nb_coms); return JS_TRUE; @@ -1730,7 +1730,7 @@ static JSBool SMJS_FUNCTION(svg_path_get_segment) SMJS_OBJ SMJS_ARGS if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE; - p = JS_GetPrivate(c, obj); + p = SMJS_GET_PRIVATE(c, obj); if (!p) return JS_TRUE; if ((argc!=1) || !JSVAL_IS_INT(argv[0])) return JS_TRUE; idx = JSVAL_TO_INT(argv[0]); @@ -1757,7 +1757,7 @@ static JSBool SMJS_FUNCTION(svg_path_get_segment_param) SMJS_ARGS u32 i, idx, param_idx, pt_idx; if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE; - p = JS_GetPrivate(c, obj); + p = SMJS_GET_PRIVATE(c, obj); if (!p) return JS_TRUE; if ((argc!=2) || !JSVAL_IS_INT(argv[0]) || !JSVAL_IS_INT(argv[1])) return JS_TRUE; idx = JSVAL_TO_INT(argv[0]); @@ -1846,7 +1846,7 @@ static JSBool SMJS_FUNCTION(svg_path_move_to) SMJS_OBJ SMJS_ARGS if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE; - p = JS_GetPrivate(c, obj); + p = SMJS_GET_PRIVATE(c, obj); if (!p) return JS_TRUE; if ((argc!=2) || !JSVAL_IS_NUMBER(argv[0]) || !JSVAL_IS_NUMBER(argv[1])) return JS_TRUE; JS_ValueToNumber(c, argv[0], &x); @@ -1867,7 +1867,7 @@ static JSBool SMJS_FUNCTION(svg_path_line_to) SMJS_OBJ SMJS_ARGS if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE; - p = JS_GetPrivate(c, obj); + p = SMJS_GET_PRIVATE(c, obj); if (!p) return JS_TRUE; if ((argc!=2) || !JSVAL_IS_NUMBER(argv[0]) || !JSVAL_IS_NUMBER(argv[1])) return JS_TRUE; JS_ValueToNumber(c, argv[0], &x); @@ -1889,7 +1889,7 @@ static JSBool SMJS_FUNCTION(svg_path_quad_to) SMJS_OBJ SMJS_ARGS if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE; - p = JS_GetPrivate(c, obj); + p = SMJS_GET_PRIVATE(c, obj); if (!p) return JS_TRUE; if ((argc!=4) || !JSVAL_IS_NUMBER(argv[0]) || !JSVAL_IS_NUMBER(argv[1]) || !JSVAL_IS_NUMBER(argv[2]) || !JSVAL_IS_NUMBER(argv[3])) return JS_TRUE; JS_ValueToNumber(c, argv[0], &x1); @@ -1912,7 +1912,7 @@ static JSBool SMJS_FUNCTION(svg_path_curve_to) SMJS_OBJ SMJS_ARGS if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE; - p = JS_GetPrivate(c, obj); + p = SMJS_GET_PRIVATE(c, obj); if (!p) return JS_TRUE; if ((argc!=6) || !JSVAL_IS_NUMBER(argv[0]) || !JSVAL_IS_NUMBER(argv[1]) || !JSVAL_IS_NUMBER(argv[2]) || !JSVAL_IS_NUMBER(argv[3]) || !JSVAL_IS_NUMBER(argv[4]) || !JSVAL_IS_NUMBER(argv[5])) return JS_TRUE; JS_ValueToNumber(c, argv[0], &x1); @@ -1935,7 +1935,7 @@ static JSBool SMJS_FUNCTION(svg_path_close) pathCI *p; SMJS_OBJ if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE; - p = JS_GetPrivate(c, obj); + p = SMJS_GET_PRIVATE(c, obj); if (!p) return JS_TRUE; if (argc) return JS_TRUE; p->tags = gf_realloc(p->tags, sizeof(u8)*(p->nb_coms+1) ); @@ -1948,7 +1948,7 @@ static JSBool matrix_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, { GF_Matrix2D *mx; if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE; - mx = JS_GetPrivate(c, obj); + mx = SMJS_GET_PRIVATE(c, obj); if (!SMJS_ID_IS_INT(id)) return JS_TRUE; if (!mx) return JS_TRUE; @@ -1968,7 +1968,7 @@ static JSBool matrix_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsdouble d; GF_Matrix2D *mx; if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE; - mx = JS_GetPrivate(c, obj); + mx = SMJS_GET_PRIVATE(c, obj); if (!SMJS_ID_IS_INT(id)) return JS_TRUE; JS_ValueToNumber(c, *vp, &d); @@ -1989,7 +1989,7 @@ static JSBool SMJS_FUNCTION(svg_mx2d_get_component) SMJS_OBJ SMJS_ARGS if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE; - mx = JS_GetPrivate(c, obj); + mx = SMJS_GET_PRIVATE(c, obj); if (!mx || (argc!=1)) return JS_TRUE; if (!JSVAL_IS_INT(argv[0])) return JS_TRUE; switch (JSVAL_TO_INT(argv[0])) { @@ -2010,12 +2010,12 @@ static JSBool SMJS_FUNCTION(svg_mx2d_multiply) SMJS_OBJ SMJS_ARGS if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE; - mx1 = JS_GetPrivate(c, obj); + mx1 = SMJS_GET_PRIVATE(c, obj); if (!mx1 || (argc!=1)) return JS_TRUE; if (!JSVAL_IS_OBJECT(argv[0])) return JS_TRUE; mat = JSVAL_TO_OBJECT(argv[0]); if (!JS_InstanceOf(c, mat, &svg_rt->matrixClass, NULL) ) return JS_TRUE; - mx2 = JS_GetPrivate(c, mat); + mx2 = SMJS_GET_PRIVATE(c, mat); if (!mx2) return JS_TRUE; gf_mx2d_add_matrix(mx1, mx2); SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) ); @@ -2027,7 +2027,7 @@ static JSBool SMJS_FUNCTION(svg_mx2d_inverse) GF_Matrix2D *mx1; SMJS_OBJ if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE; - mx1 = JS_GetPrivate(c, obj); + mx1 = SMJS_GET_PRIVATE(c, obj); if (!mx1) return JS_TRUE; gf_mx2d_inverse(mx1); SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) ); @@ -2041,7 +2041,7 @@ static JSBool SMJS_FUNCTION(svg_mx2d_translate) SMJS_OBJ SMJS_ARGS if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE; - mx1 = JS_GetPrivate(c, obj); + mx1 = SMJS_GET_PRIVATE(c, obj); if (!mx1 || (argc!=2)) return JS_TRUE; JS_ValueToNumber(c, argv[0], &x); JS_ValueToNumber(c, argv[1], &y); @@ -2061,7 +2061,7 @@ static JSBool SMJS_FUNCTION(svg_mx2d_scale) SMJS_OBJ SMJS_ARGS if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE; - mx1 = JS_GetPrivate(c, obj); + mx1 = SMJS_GET_PRIVATE(c, obj); if (!mx1 || (argc!=1)) return JS_TRUE; JS_ValueToNumber(c, argv[0], &scale); gf_mx2d_init(mx2); @@ -2078,7 +2078,7 @@ static JSBool SMJS_FUNCTION(svg_mx2d_rotate) SMJS_OBJ SMJS_ARGS if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE; - mx1 = JS_GetPrivate(c, obj); + mx1 = SMJS_GET_PRIVATE(c, obj); if (!mx1 || (argc!=1)) return JS_TRUE; JS_ValueToNumber(c, argv[0], &angle); gf_mx2d_init(mx2); @@ -2097,7 +2097,7 @@ jsval svg_udom_new_rect(JSContext *c, Fixed x, Fixed y, Fixed width, Fixed heigh rc->w = FIX2FLT(width); rc->h = FIX2FLT(height); rc->sg = NULL; - JS_SetPrivate(c, r, rc); + SMJS_SET_PRIVATE(c, r, rc); return OBJECT_TO_JSVAL(r); } @@ -2108,7 +2108,7 @@ jsval svg_udom_new_point(JSContext *c, Fixed x, Fixed y) pt->x = FIX2FLT(x); pt->y = FIX2FLT(y); pt->sg = NULL; - JS_SetPrivate(c, p, pt); + SMJS_SET_PRIVATE(c, p, pt); return OBJECT_TO_JSVAL(p); } @@ -2140,7 +2140,7 @@ static void svg_init_js_api(GF_SceneGraph *scene) JS_InitStandardClasses(scene->svg_js->js_ctx, scene->svg_js->global); /*remember pointer to scene graph!!*/ - JS_SetPrivate(scene->svg_js->js_ctx, scene->svg_js->global, scene); + SMJS_SET_PRIVATE(scene->svg_js->js_ctx, scene->svg_js->global, scene); { JSPropertySpec globalClassProps[] = { {"connected", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0}, @@ -2364,10 +2364,10 @@ Bool svg_script_execute(GF_SceneGraph *sg, char *utf8_script, GF_DOM_Event *even gf_sg_lock_javascript(sg->svg_js->js_ctx, 1); - prev_event = JS_GetPrivate(sg->svg_js->js_ctx, sg->svg_js->event); - JS_SetPrivate(sg->svg_js->js_ctx, sg->svg_js->event, event); + prev_event = SMJS_GET_PRIVATE(sg->svg_js->js_ctx, sg->svg_js->event); + SMJS_SET_PRIVATE(sg->svg_js->js_ctx, sg->svg_js->event, event); ret = JS_EvaluateScript(sg->svg_js->js_ctx, sg->svg_js->global, utf8_script, strlen(utf8_script), 0, 0, &rval); - JS_SetPrivate(sg->svg_js->js_ctx, sg->svg_js->event, prev_event); + SMJS_SET_PRIVATE(sg->svg_js->js_ctx, sg->svg_js->event, prev_event); if (ret==JS_FALSE) { char *sep = strchr(utf8_script, '('); @@ -2672,13 +2672,13 @@ static Bool svg_script_execute_handler(GF_Node *node, GF_DOM_Event *event, GF_No #endif gf_sg_lock_javascript(svg_js->js_ctx, 1); - prev_event = JS_GetPrivate(svg_js->js_ctx, svg_js->event); + prev_event = SMJS_GET_PRIVATE(svg_js->js_ctx, svg_js->event); /*break loops*/ if (prev_event && (prev_event->type==event->type) && (prev_event->target==event->target)) { gf_sg_lock_javascript(svg_js->js_ctx, 0); return 0; } - JS_SetPrivate(svg_js->js_ctx, svg_js->event, event); + SMJS_SET_PRIVATE(svg_js->js_ctx, svg_js->event, event); svg_js->in_script = 1; @@ -2698,7 +2698,7 @@ static Bool svg_script_execute_handler(GF_Node *node, GF_DOM_Event *event, GF_No JSObject *evt; jsval argv[1]; evt = gf_dom_new_event(svg_js->js_ctx); - JS_SetPrivate(svg_js->js_ctx, evt, event); + SMJS_SET_PRIVATE(svg_js->js_ctx, evt, event); argv[0] = OBJECT_TO_JSVAL(evt); if (hdl->js_fun) { @@ -2725,7 +2725,7 @@ static Bool svg_script_execute_handler(GF_Node *node, GF_DOM_Event *event, GF_No JS_ClearPendingException(svg_js->js_ctx); } - JS_SetPrivate(svg_js->js_ctx, svg_js->event, prev_event); + SMJS_SET_PRIVATE(svg_js->js_ctx, svg_js->event, prev_event); if (txt && hdl) hdl->js_fun=0; while (svg_js->force_gc) { diff --git a/src/scenegraph/vrml_smjs.c b/src/scenegraph/vrml_smjs.c index f7d481c..0ec8310 100644 --- a/src/scenegraph/vrml_smjs.c +++ b/src/scenegraph/vrml_smjs.c @@ -591,7 +591,7 @@ static JSObject *node_get_binding(GF_ScriptPriv *priv, GF_Node *node, Bool is_co gf_node_register(node, NULL); obj = JS_NewObject(priv->js_ctx, &js_rt->SFNodeClass, 0, 0); - JS_SetPrivate(priv->js_ctx, obj, field); + SMJS_SET_PRIVATE(priv->js_ctx, obj, field); field->obj = obj; gf_list_add(priv->js_cache, obj); @@ -793,7 +793,7 @@ static JSBool SMJS_FUNCTION(addRoute) if (!JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFNodeClass, NULL) ) return JS_FALSE; - ptr = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])); + ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])); assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); n1 = * ((GF_Node **)ptr->field.far_ptr); if (!n1) return JS_FALSE; @@ -818,7 +818,7 @@ static JSBool SMJS_FUNCTION(addRoute) /*regular route*/ if (JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[2]), &js_rt->SFNodeClass, NULL) && JSVAL_IS_STRING(argv[3]) ) { GF_Route *r; - ptr = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[2])); + ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[2])); assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); n2 = * ((GF_Node **)ptr->field.far_ptr); if (!n2) return JS_FALSE; @@ -901,7 +901,7 @@ static JSBool SMJS_FUNCTION(deleteRoute) if (!JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFNodeClass, NULL) ) return JS_FALSE; if (JSVAL_IS_STRING(argv[1]) && JSVAL_IS_NULL(argv[2]) && JSVAL_IS_NULL(argv[3])) { - ptr = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])); + ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])); assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); n1 = * ((GF_Node **)ptr->field.far_ptr); f1 = SMJS_CHARS(c, argv[1]); @@ -918,10 +918,10 @@ static JSBool SMJS_FUNCTION(deleteRoute) if (!JSVAL_IS_OBJECT(argv[2]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[2]), &js_rt->SFNodeClass, NULL) ) return JS_FALSE; if (!JSVAL_IS_STRING(argv[1]) || !JSVAL_IS_STRING(argv[3])) return JS_FALSE; - ptr = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])); + ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])); assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); n1 = * ((GF_Node **)ptr->field.far_ptr); - ptr = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[2])); + ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[2])); assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); n2 = * ((GF_Node **)ptr->field.far_ptr); @@ -993,7 +993,7 @@ static JSBool SMJS_FUNCTION(loadURL) JS_ValueToObject(c, argv[0], &p); - f = (GF_JSField *) JS_GetPrivate(c, p); + f = (GF_JSField *) SMJS_GET_PRIVATE(c, p); if (!f || !f->js_list) return JS_FALSE; JS_GetArrayLength(c, f->js_list, &len); @@ -1259,7 +1259,7 @@ static GFINLINE void sffield_toString(char *str, void *f_ptr, u32 fieldType) static void JS_ObjectDestroyed(JSContext *c, JSObject *obj, GF_JSField *ptr, Bool is_js_call) { - JS_SetPrivate(c, obj, NULL); + SMJS_SET_PRIVATE(c, obj, NULL); if (ptr) { /*if ptr is a node, remove node binding*/ @@ -1305,7 +1305,7 @@ static JSBool SMJS_FUNCTION(field_toString) JSString *s; jsval item; SMJS_OBJ - GF_JSField *f = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *f = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); if (!f) return JS_FALSE; strcpy(str, ""); @@ -1344,7 +1344,7 @@ static JSBool SMJS_FUNCTION(field_toString) break; default: if (JSVAL_IS_OBJECT(item)) { - GF_JSField *sf = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(item)); + GF_JSField *sf = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(item)); sffield_toString(str, sf->field.far_ptr, sf->field.fieldType); } break; @@ -1377,7 +1377,7 @@ static JSBool SMJS_FUNCTION(SFNodeConstructor) field->field.fieldType = GF_SG_VRML_SFNODE; field->node = NULL; field->field.far_ptr = &field->node; - JS_SetPrivate(c, obj, field); + SMJS_SET_PRIVATE(c, obj, field); SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) ); return JS_TRUE; } @@ -1445,7 +1445,7 @@ locate_proto: } static void node_finalize_ex(JSContext *c, JSObject *obj, Bool is_js_call) { - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); JS_ObjectDestroyed(c, obj, ptr, is_js_call); @@ -1478,7 +1478,7 @@ static JSBool node_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, js GF_ScriptPriv *priv; if (! JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE; - ptr = (GF_JSField *) JS_GetPrivate(c, obj); + ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); n = * ((GF_Node **)ptr->field.far_ptr); priv = JS_GetScriptStack(c); @@ -1540,7 +1540,7 @@ static JSBool node_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, js char *fieldname; GF_JSField *ptr; if (! JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE; - ptr = (GF_JSField *) JS_GetPrivate(c, obj); + ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); /*this is the prototype*/ if (!ptr) { @@ -1596,7 +1596,7 @@ static JSBool SMJS_FUNCTION(node_toString) const char *name; SMJS_OBJ if (! JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE; - f = (GF_JSField *) JS_GetPrivate(c, obj); + f = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); if (!f) return JS_FALSE; str[0] = 0; @@ -1624,7 +1624,7 @@ static JSBool SMJS_FUNCTION(node_getTime) GF_JSField *f; SMJS_OBJ if (! JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE; - f = (GF_JSField *) JS_GetPrivate(c, obj); + f = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); if (!f) return JS_FALSE; n = * ((GF_Node **)f->field.far_ptr); @@ -1636,7 +1636,7 @@ static JSBool SMJS_FUNCTION(node_getTime) /* Generic field destructor */ static void field_finalize(JSContext *c, JSObject *obj) { - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); JS_ObjectDestroyed(c, obj, ptr, 1); if (!ptr) return; @@ -1664,7 +1664,7 @@ static GFINLINE GF_JSField *SFImage_Create(JSContext *c, JSObject *obj, u32 w, u v->pixels = (u8 *) gf_malloc(sizeof(u8) * nbComp * w * h); len = MIN(nbComp * w * h, pixels->count); for (i=0; ipixels[i] = (u8) pixels->vals[i]; - JS_SetPrivate(c, obj, field); + SMJS_SET_PRIVATE(c, obj, field); return field; } static JSBool SMJS_FUNCTION(SFImageConstructor) @@ -1679,7 +1679,7 @@ static JSBool SMJS_FUNCTION(SFImageConstructor) w = JSVAL_TO_INT(argv[0]); h = JSVAL_TO_INT(argv[1]); nbComp = JSVAL_TO_INT(argv[2]); - pixels = (MFInt32 *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[3])))->field.far_ptr; + pixels = (MFInt32 *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[3])))->field.far_ptr; SFImage_Create(c, obj, w, h, nbComp, pixels); return JS_TRUE; } @@ -1687,7 +1687,7 @@ static JSBool SMJS_FUNCTION(SFImageConstructor) static JSBool image_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp) { GF_ScriptPriv *priv = JS_GetScriptStack(c); - GF_JSField *val = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); SFImage *sfi; if (!val) return JS_FALSE; sfi = (SFImage*)val->field.far_ptr; @@ -1699,7 +1699,7 @@ static JSBool image_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, j case 3: { u32 i, len; - JSObject *an_obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFInt32Class, 0, priv->js_obj); + JSObject *an_obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFInt32Class, priv->js_obj); len = sfi->width*sfi->height*sfi->numComponents; for (i=0; ipixels[i]); @@ -1718,7 +1718,7 @@ static JSBool image_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, j { u32 ival; Bool changed = 0; - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); SFImage *sfi; /*this is the prototype*/ @@ -1753,7 +1753,7 @@ static JSBool image_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, j MFInt32 *pixels; u32 len, i; if (!JSVAL_IS_OBJECT(*vp) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(*vp), &js_rt->MFInt32Class, NULL)) return JS_FALSE; - pixels = (MFInt32 *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(*vp)))->field.far_ptr; + pixels = (MFInt32 *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)))->field.far_ptr; if (sfi->pixels) gf_free(sfi->pixels); len = sfi->width*sfi->height*sfi->numComponents; sfi->pixels = (char *) gf_malloc(sizeof(char)*len); @@ -1781,7 +1781,7 @@ static GFINLINE GF_JSField *SFVec2f_Create(JSContext *c, JSObject *obj, Fixed x, field->field.fieldType = GF_SG_VRML_SFVEC2F; v->x = x; v->y = y; - JS_SetPrivate(c, obj, field); + SMJS_SET_PRIVATE(c, obj, field); return field; } static JSBool SMJS_FUNCTION(SFVec2fConstructor) @@ -1796,7 +1796,7 @@ static JSBool SMJS_FUNCTION(SFVec2fConstructor) } static JSBool vec2f_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp) { - GF_JSField *val = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); if (SMJS_ID_IS_INT(id)) { switch (SMJS_ID_TO_INT(id)) { @@ -1813,7 +1813,7 @@ static JSBool vec2f_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, j jsdouble d; Fixed v; Bool changed = 0; - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); /*this is the prototype*/ if (!ptr) { @@ -1852,9 +1852,9 @@ static JSBool SMJS_FUNCTION(vec2f_add) if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec2fClass, NULL)) return JS_FALSE; - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - v2 = ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, JS_GetParent(c, obj)); + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, SMJS_GET_PARENT(c, obj)); SFVec2f_Create(c, pNew, v1->x + v2->x, v1->y + v2->y); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -1868,9 +1868,9 @@ static JSBool SMJS_FUNCTION(vec2f_subtract) if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec2fClass, NULL)) return JS_FALSE; - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - v2 = ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, JS_GetParent(c, obj)); + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, SMJS_GET_PARENT(c, obj)); SFVec2f_Create(c, pNew, v1->x - v2->x, v1->y - v2->y); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -1880,8 +1880,8 @@ static JSBool SMJS_FUNCTION(vec2f_negate) SFVec2f *v1; JSObject *pNew; SMJS_OBJ - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, JS_GetParent(c, obj)); + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, SMJS_GET_PARENT(c, obj)); SFVec2f_Create(c, pNew, -v1->x , -v1->y ); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -1895,8 +1895,8 @@ static JSBool SMJS_FUNCTION(vec2f_multiply) SMJS_ARGS SMJS_OBJ if (argc<=0) return JS_FALSE; - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, JS_GetParent(c, obj)); + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, SMJS_GET_PARENT(c, obj)); JS_ValueToNumber(c, argv[0], &d ); v = FLT2FIX( d); SFVec2f_Create(c, pNew, gf_mulfix(v1->x , v), gf_mulfix(v1->y, v) ); @@ -1912,8 +1912,8 @@ static JSBool SMJS_FUNCTION(vec2f_divide) SMJS_ARGS SMJS_OBJ if (argc<=0) return JS_FALSE; - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, JS_GetParent(c, obj)); + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, SMJS_GET_PARENT(c, obj)); JS_ValueToNumber(c, argv[0], &d ); v = FLT2FIX(d); SFVec2f_Create(c, pNew, gf_divfix(v1->x, v), gf_divfix(v1->y, v)); @@ -1925,7 +1925,7 @@ static JSBool SMJS_FUNCTION(vec2f_length) Double res; SFVec2f *v1; SMJS_OBJ - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; res = FIX2FLT(gf_v2d_len(v1)); SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, res) ); return JS_TRUE; @@ -1936,9 +1936,9 @@ static JSBool SMJS_FUNCTION(vec2f_normalize) Fixed res; JSObject *pNew; SMJS_OBJ - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; res = gf_v2d_len(v1); - pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, JS_GetParent(c, obj)); + pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, SMJS_GET_PARENT(c, obj)); SFVec2f_Create(c, pNew, gf_divfix(v1->x, res), gf_divfix(v1->y, res) ); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -1951,8 +1951,8 @@ static JSBool SMJS_FUNCTION(vec2f_dot) if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec2fClass, NULL)) return JS_FALSE; - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - v2 = ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT( gf_mulfix(v1->x, v2->x) + gf_mulfix(v1->y, v2->y) ) ) ); return JS_TRUE; } @@ -1970,7 +1970,7 @@ static GFINLINE GF_JSField *SFVec3f_Create(JSContext *c, JSObject *obj, Fixed x, v->x = x; v->y = y; v->z = z; - JS_SetPrivate(c, obj, field); + SMJS_SET_PRIVATE(c, obj, field); return field; } static JSBool SMJS_FUNCTION(SFVec3fConstructor) @@ -1986,7 +1986,7 @@ static JSBool SMJS_FUNCTION(SFVec3fConstructor) } static JSBool vec3f_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp) { - GF_JSField *val = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); if (SMJS_ID_IS_INT(id)) { switch (SMJS_ID_TO_INT(id)) { case 0: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFVec3f*)val->field.far_ptr)->x) ); break; @@ -2002,7 +2002,7 @@ static JSBool vec3f_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, j jsdouble d; Fixed v; Bool changed = 0; - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); /*this is the prototype*/ if (!ptr) { @@ -2043,9 +2043,9 @@ static JSBool SMJS_FUNCTION(vec3f_add) if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec3fClass, NULL)) return JS_FALSE; - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - v2 = ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj)); + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj)); SFVec3f_Create(c, pNew, v1->x + v2->x, v1->y + v2->y, v1->z + v2->z); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -2059,9 +2059,9 @@ static JSBool SMJS_FUNCTION(vec3f_subtract) if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec3fClass, NULL)) return JS_FALSE; - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - v2 = ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj)); + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj)); SFVec3f_Create(c, pNew, v1->x - v2->x, v1->y - v2->y, v1->z - v2->z); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -2071,8 +2071,8 @@ static JSBool SMJS_FUNCTION(vec3f_negate) SFVec3f *v1; JSObject *pNew; SMJS_OBJ - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj)); + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj)); SFVec3f_Create(c, pNew, -v1->x , -v1->y , -v1->z ); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -2087,8 +2087,8 @@ static JSBool SMJS_FUNCTION(vec3f_multiply) SMJS_ARGS if (argc<=0) return JS_FALSE; - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj)); + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj)); JS_ValueToNumber(c, argv[0], &d ); v = FLT2FIX(d); SFVec3f_Create(c, pNew, gf_mulfix(v1->x, v), gf_mulfix(v1->y, v), gf_mulfix(v1->z, v) ); @@ -2104,8 +2104,8 @@ static JSBool SMJS_FUNCTION(vec3f_divide) SMJS_OBJ SMJS_ARGS if (argc<=0) return JS_FALSE; - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj)); + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj)); JS_ValueToNumber(c, argv[0], &d ); v = FLT2FIX(d); SFVec3f_Create(c, pNew, gf_divfix(v1->x, v), gf_divfix(v1->y, v), gf_divfix(v1->z, v)); @@ -2117,7 +2117,7 @@ static JSBool SMJS_FUNCTION(vec3f_length) Fixed res; SFVec3f *v1; SMJS_OBJ - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; res = gf_vec_len(*v1); SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(res) ) ); return JS_TRUE; @@ -2127,9 +2127,9 @@ static JSBool SMJS_FUNCTION(vec3f_normalize) SFVec3f v1; JSObject *pNew; SMJS_OBJ - v1 = * (SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; + v1 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; gf_vec_norm(&v1); - pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj)); + pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj)); SFVec3f_Create(c, pNew, v1.x, v1.y, v1.z); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -2142,8 +2142,8 @@ static JSBool SMJS_FUNCTION(vec3f_dot) if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec3fClass, NULL)) return JS_FALSE; - v1 = *(SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - v2 = *(SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + v1 = *(SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + v2 = *(SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(gf_vec_dot(v1, v2)) ) ); return JS_TRUE; } @@ -2156,9 +2156,9 @@ static JSBool SMJS_FUNCTION(vec3f_cross) if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec3fClass, NULL)) return JS_FALSE; - v1 = * (SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - v2 = * (SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj)); + v1 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + v2 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj)); v3 = gf_vec_cross(v1, v2); SFVec3f_Create(c, pNew, v3.x, v3.y, v3.z); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); @@ -2180,7 +2180,7 @@ static GFINLINE GF_JSField *SFRotation_Create(JSContext *c, JSObject *obj, Fixed v->y = y; v->z = z; v->q = q; - JS_SetPrivate(c, obj, field); + SMJS_SET_PRIVATE(c, obj, field); return field; } static JSBool SMJS_FUNCTION(SFRotationConstructor) @@ -2208,7 +2208,7 @@ static JSBool SMJS_FUNCTION(SFRotationConstructor) if (!JSVAL_IS_OBJECT(argv[0])) return JS_FALSE; an_obj = JSVAL_TO_OBJECT(argv[0]); if (! JS_InstanceOf(c, an_obj, &js_rt->SFVec3fClass, NULL)) return JS_FALSE; - v1 = * (SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, an_obj))->field.far_ptr; + v1 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, an_obj))->field.far_ptr; if (JSVAL_IS_DOUBLE(argv[1])) { JS_ValueToNumber(c, argv[1], &a); SFRotation_Create(c, obj, v1.x, v1.y, v1.z, FLT2FIX(a)); @@ -2218,7 +2218,7 @@ static JSBool SMJS_FUNCTION(SFRotationConstructor) if (!JSVAL_IS_OBJECT(argv[1])) return JS_FALSE; an_obj = JSVAL_TO_OBJECT(argv[1]); if (!JS_InstanceOf(c, an_obj, &js_rt->SFVec3fClass, NULL)) return JS_FALSE; - v2 = * (SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, an_obj))->field.far_ptr; + v2 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, an_obj))->field.far_ptr; l1 = gf_vec_len(v1); l2 = gf_vec_len(v2); dot = gf_divfix(gf_vec_dot(v1, v2), gf_mulfix(l1, l2) ); @@ -2232,7 +2232,7 @@ static JSBool SMJS_FUNCTION(SFRotationConstructor) static JSBool rot_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp) { - GF_JSField *val = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); if (SMJS_ID_IS_INT(id)) { switch (SMJS_ID_TO_INT(id)) { case 0: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFRotation*)val->field.far_ptr)->x)); break; @@ -2249,7 +2249,7 @@ static JSBool rot_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsv jsdouble d; Fixed v; Bool changed = 0; - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); /*this is the prototype*/ if (!ptr) { @@ -2291,8 +2291,8 @@ static JSBool SMJS_FUNCTION(rot_getAxis) SFRotation r; JSObject *pNew; SMJS_OBJ - r = * (SFRotation *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj)); + r = * (SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj)); SFVec3f_Create(c, pNew, r.x, r.y, r.z); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -2302,8 +2302,8 @@ static JSBool SMJS_FUNCTION(rot_inverse) SFRotation r; JSObject *pNew; SMJS_OBJ - r = * (SFRotation *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - pNew = JS_NewObject(c, &js_rt->SFRotationClass, 0, JS_GetParent(c, obj)); + r = * (SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + pNew = JS_NewObject(c, &js_rt->SFRotationClass, 0, SMJS_GET_PARENT(c, obj)); SFRotation_Create(c, pNew, r.x, r.y, r.z, r.q-GF_PI); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -2320,14 +2320,14 @@ static JSBool SMJS_FUNCTION(rot_multiply) if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFRotationClass, NULL)) return JS_FALSE; - r1 = * (SFRotation *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - r2 = * (SFRotation *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + r1 = * (SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + r2 = * (SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; q1 = gf_quat_from_rotation(r1); q2 = gf_quat_from_rotation(r2); q1 = gf_quat_multiply(&q1, &q2); r1 = gf_quat_to_rotation(&q1); - pNew = JS_NewObject(c, &js_rt->SFRotationClass, 0, JS_GetParent(c, obj)); + pNew = JS_NewObject(c, &js_rt->SFRotationClass, 0, SMJS_GET_PARENT(c, obj)); SFRotation_Create(c, pNew, r1.x, r1.y, r1.z, r1.q); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -2345,12 +2345,12 @@ static JSBool SMJS_FUNCTION(rot_multVec) if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec3fClass, NULL)) return JS_FALSE; - r = *(SFRotation *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - v = *(SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + r = *(SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + v = *(SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; gf_mx_init(mx); gf_mx_add_rotation(&mx, r.q, r.x, r.y, r.z); gf_mx_apply_vec(&mx, &v); - pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj)); + pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj)); SFVec3f_Create(c, pNew, v.x, v.y, v.z); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -2367,10 +2367,10 @@ static JSBool SMJS_FUNCTION(rot_setAxis) if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec3fClass, NULL)) return JS_FALSE; - ptr = (GF_JSField *) JS_GetPrivate(c, obj); + ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); r = (SFRotation *) ptr->field.far_ptr; - v = *(SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + v = *(SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; r->x = v.x; r->y = v.y; @@ -2390,14 +2390,14 @@ static JSBool SMJS_FUNCTION(rot_slerp) if (!JSVAL_IS_DOUBLE(argv[1]) || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFRotationClass, NULL)) return JS_FALSE; - v1 = *(SFRotation *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; - v2 = *(SFRotation *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; + v1 = *(SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; + v2 = *(SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr; JS_ValueToNumber(c, argv[1], &d ); q1 = gf_quat_from_rotation(v1); q2 = gf_quat_from_rotation(v2); q1 = gf_quat_slerp(q1, q2, FLT2FIX( d)); res = gf_quat_to_rotation(&q1); - pNew = JS_NewObject(c, &js_rt->SFRotationClass, 0, JS_GetParent(c, obj)); + pNew = JS_NewObject(c, &js_rt->SFRotationClass, 0, SMJS_GET_PARENT(c, obj)); SFRotation_Create(c, pNew, res.x, res.y, res.z, res.q); SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) ); return JS_TRUE; @@ -2415,7 +2415,7 @@ static GFINLINE GF_JSField *SFColor_Create(JSContext *c, JSObject *obj, Fixed r, v->red = r; v->green = g; v->blue = b; - JS_SetPrivate(c, obj, field); + SMJS_SET_PRIVATE(c, obj, field); return field; } static JSBool SMJS_FUNCTION(SFColorConstructor) @@ -2431,7 +2431,7 @@ static JSBool SMJS_FUNCTION(SFColorConstructor) } static JSBool color_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp) { - GF_JSField *val = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); if (SMJS_ID_IS_INT(id)) { switch (SMJS_ID_TO_INT(id)) { case 0: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFColor*)val->field.far_ptr)->red)); break; @@ -2448,7 +2448,7 @@ static JSBool color_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, j jsdouble d; Fixed v; Bool changed = 0; - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); /*this is the prototype*/ if (!ptr) { if (! SMJS_ID_IS_STRING(id)) return JS_FALSE; @@ -2486,9 +2486,9 @@ static JSBool SMJS_FUNCTION(color_setHSV) jsdouble h, s, v; SMJS_OBJ SMJS_ARGS - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); if (argc != 3) return JS_FALSE; - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; JS_ValueToNumber( c, argv[0], &h); JS_ValueToNumber( c, argv[1], &s); JS_ValueToNumber( c, argv[2], &v); @@ -2507,7 +2507,7 @@ static JSBool SMJS_FUNCTION(color_getHSV) jsval vec[3]; JSObject *arr; SMJS_OBJ - v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; + v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; hsv = *v1; SFColor_toHSV(&hsv); vec[0] = JS_MAKE_DOUBLE(c, FIX2FLT(hsv.red)); @@ -2536,7 +2536,7 @@ static void setup_js_array(JSContext *c, JSObject *obj, GF_JSField *ptr, uintN a ptr = NewJSField(c); \ ptr->field.fieldType = _fieldType; \ setup_js_array(c, obj, ptr, (jsint) argc, argv); \ - JS_SetPrivate(c, obj, ptr); \ + SMJS_SET_PRIVATE(c, obj, ptr); \ SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) ); \ return obj == 0 ? JS_FALSE : JS_TRUE; \ @@ -2572,7 +2572,7 @@ static JSBool SMJS_FUNCTION(MFNodeConstructor) static void array_finalize_ex(JSContext *c, JSObject *obj, Bool is_js_call) { - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); JS_ObjectDestroyed(c, obj, ptr, 1); @@ -2601,7 +2601,7 @@ static void array_finalize(JSContext *c, JSObject *obj) JSBool array_getElement(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *rval) { u32 i; - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); if (SMJS_ID_IS_INT(id)) { i = SMJS_ID_TO_INT(id); if (ptr->field.fieldType==GF_SG_VRML_MFNODE) { @@ -2628,7 +2628,7 @@ JSBool array_setElement(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *rv JSString *str; char *str_val; void *sf_slot; - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); ind = SMJS_ID_TO_INT(id); ret = JS_GetArrayLength(c, ptr->js_list, &len); @@ -2668,7 +2668,7 @@ JSBool array_setElement(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *rv case GF_SG_VRML_MFVEC3F: case GF_SG_VRML_MFCOLOR: case GF_SG_VRML_MFROTATION: - a_val = OBJECT_TO_JSVAL( JS_ConstructObject(c, the_sf_class, 0, obj) ); + a_val = OBJECT_TO_JSVAL( SMJS_CONSTRUCT_OBJECT(c, the_sf_class, obj) ); break; default: a_val = INT_TO_JSVAL(0); @@ -2721,7 +2721,7 @@ JSBool array_setElement(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *rv if (!ptr->owner) return JS_TRUE; /*get new node*/ - from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(*rval)); + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*rval)); new_n = *(GF_Node**)from->field.far_ptr; #if 0 @@ -2794,19 +2794,19 @@ JSBool array_setElement(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *rv break; case GF_SG_VRML_MFVEC2F: - from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(*rval)); + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*rval)); gf_sg_vrml_field_copy(& ((MFVec2f *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType); break; case GF_SG_VRML_MFVEC3F: - from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(*rval)); + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*rval)); gf_sg_vrml_field_copy(& ((MFVec3f *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType); break; case GF_SG_VRML_MFROTATION: - from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(*rval)); + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*rval)); gf_sg_vrml_field_copy(& ((MFRotation *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType); break; case GF_SG_VRML_MFCOLOR: - from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(*rval)); + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*rval)); gf_sg_vrml_field_copy(& ((MFColor *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType); break; } @@ -2820,7 +2820,7 @@ JSBool array_setLength(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *val u32 len, i, sftype; JSBool ret; JSClass *the_sf_class; - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); if (!JSVAL_IS_INT(*val) || JSVAL_TO_INT(*val) < 0) return JS_FALSE; len = JSVAL_TO_INT(*val); @@ -2873,7 +2873,7 @@ JSBool array_setLength(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *val for (i=0; ifield.fieldType==GF_SG_VRML_MFNODE) { len = gf_node_list_get_count(*(GF_ChildNodeItem **)ptr->field.far_ptr); @@ -2924,11 +2924,11 @@ static JSBool SMJS_FUNCTION(MFVec2fConstructor) setup_js_array(c, obj, ptr, 0, 0); JS_SetArrayLength(c, ptr->js_list, argc); - JS_SetPrivate(c, obj, ptr); + SMJS_SET_PRIVATE(c, obj, ptr); for (i=0; iSFVec2fClass, NULL) ) { - item = JS_ConstructObject(c, &js_rt->SFVec2fClass, 0, obj); + item = SMJS_CONSTRUCT_OBJECT(c, &js_rt->SFVec2fClass, obj); val = OBJECT_TO_JSVAL(item); JS_SetElement(c, ptr->js_list, i, &val); } else { @@ -2953,11 +2953,11 @@ static JSBool SMJS_FUNCTION(MFVec3fConstructor) ptr->field.fieldType = GF_SG_VRML_MFVEC3F; setup_js_array(c, obj, ptr, 0, 0); JS_SetArrayLength(c, ptr->js_list, argc); - JS_SetPrivate(c, obj, ptr); + SMJS_SET_PRIVATE(c, obj, ptr); for (i=0; iSFVec3fClass, NULL) ) { - item = JS_ConstructObject(c, &js_rt->SFVec3fClass, 0, obj); + item = SMJS_CONSTRUCT_OBJECT(c, &js_rt->SFVec3fClass, obj); val = OBJECT_TO_JSVAL(item); JS_SetElement(c, ptr->js_list, i, &val); } else { @@ -2982,11 +2982,11 @@ static JSBool SMJS_FUNCTION(MFRotationConstructor) ptr->field.fieldType = GF_SG_VRML_MFROTATION; setup_js_array(c, obj, ptr, 0, 0); JS_SetArrayLength(c, ptr->js_list, argc); - JS_SetPrivate(c, obj, ptr); + SMJS_SET_PRIVATE(c, obj, ptr); for (i=0; iSFRotationClass, NULL) ) { - item = JS_ConstructObject(c, &js_rt->SFVec3fClass, 0, obj); + item = SMJS_CONSTRUCT_OBJECT(c, &js_rt->SFVec3fClass, obj); val = OBJECT_TO_JSVAL(item); JS_SetElement(c, ptr->js_list, i, &val); } else { @@ -3011,11 +3011,11 @@ static JSBool SMJS_FUNCTION(MFColorConstructor) ptr->field.fieldType = GF_SG_VRML_MFCOLOR; setup_js_array(c, obj, ptr, 0, 0); JS_SetArrayLength(c, ptr->js_list, argc); - JS_SetPrivate(c, obj, ptr); + SMJS_SET_PRIVATE(c, obj, ptr); for (i=0; iSFColorClass, NULL) ) { - item = JS_ConstructObject(c, &js_rt->SFColorClass, 0, obj); + item = SMJS_CONSTRUCT_OBJECT(c, &js_rt->SFColorClass, obj); val = OBJECT_TO_JSVAL(item); JS_SetElement(c, ptr->js_list, i, &val); } else { @@ -3038,7 +3038,7 @@ JSBool SMJS_FUNCTION(vrml_event_add_listener) GF_JSField *ptr; SMJS_OBJ if (! JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE; - ptr = (GF_JSField *) JS_GetPrivate(c, obj); + ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); node = * ((GF_Node **)ptr->field.far_ptr); @@ -3050,7 +3050,7 @@ JSBool SMJS_FUNCTION(vrml_event_remove_listener) GF_JSField *ptr; SMJS_OBJ if (! JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE; - ptr = (GF_JSField *) JS_GetPrivate(c, obj); + ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); assert(ptr->field.fieldType==GF_SG_VRML_SFNODE); node = * ((GF_Node **)ptr->field.far_ptr); @@ -3143,7 +3143,7 @@ void gf_sg_script_init_sm_api(GF_ScriptPriv *sc, GF_Node *script) JS_DefineFunctions(sc->js_ctx, sc->js_obj, globalFunctions ); } /*remember pointer to scene graph!!*/ - JS_SetPrivate(sc->js_ctx, sc->js_obj, script->sgprivate->scenegraph); + SMJS_SET_PRIVATE(sc->js_ctx, sc->js_obj, script->sgprivate->scenegraph); JS_DefineProperty(sc->js_ctx, sc->js_obj, "FALSE", BOOLEAN_TO_JSVAL(JS_FALSE), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT ); @@ -3436,7 +3436,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF case GF_SG_VRML_SFVEC2F: { if (JS_InstanceOf(c, obj, &js_rt->SFVec2fClass, NULL) ) { - p = (GF_JSField *) JS_GetPrivate(c, obj); + p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); gf_sg_vrml_field_copy(field->far_ptr, p->field.far_ptr, GF_SG_VRML_SFVEC2F); Script_FieldChanged(c, owner, parent, field); } @@ -3445,7 +3445,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF case GF_SG_VRML_SFVEC3F: { if (JS_InstanceOf(c, obj, &js_rt->SFVec3fClass, NULL) ) { - p = (GF_JSField *) JS_GetPrivate(c, obj); + p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); gf_sg_vrml_field_copy(field->far_ptr, p->field.far_ptr, GF_SG_VRML_SFVEC3F); Script_FieldChanged(c, owner, parent, field); } @@ -3454,7 +3454,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF case GF_SG_VRML_SFROTATION: { if ( JS_InstanceOf(c, obj, &js_rt->SFRotationClass, NULL) ) { - p = (GF_JSField *) JS_GetPrivate(c, obj); + p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); gf_sg_vrml_field_copy(field->far_ptr, p->field.far_ptr, GF_SG_VRML_SFROTATION); Script_FieldChanged(c, owner, parent, field); } @@ -3463,7 +3463,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF case GF_SG_VRML_SFCOLOR: { if (JS_InstanceOf(c, obj, &js_rt->SFColorClass, NULL) ) { - p = (GF_JSField *) JS_GetPrivate(c, obj); + p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); gf_sg_vrml_field_copy(field->far_ptr, p->field.far_ptr, GF_SG_VRML_SFCOLOR); Script_FieldChanged(c, owner, parent, field); } @@ -3480,7 +3480,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF if (JSVAL_IS_NULL(val)) { Script_FieldChanged(c, owner, parent, field); } else if (JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) { - GF_Node *n = * (GF_Node**) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr; + GF_Node *n = * (GF_Node**) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr; * ((GF_Node **)field->far_ptr) = n; gf_node_register(n, owner); Script_FieldChanged(c, owner, parent, field); @@ -3490,7 +3490,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF case GF_SG_VRML_SFIMAGE: { if ( JS_InstanceOf(c, obj, &js_rt->SFImageClass, NULL) ) { - p = (GF_JSField *) JS_GetPrivate(c, obj); + p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); gf_sg_vrml_field_copy(field->far_ptr, p->field.far_ptr, GF_SG_VRML_SFIMAGE); Script_FieldChanged(c, owner, parent, field); } @@ -3518,7 +3518,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF ) return; - p = (GF_JSField *) JS_GetPrivate(c, obj); + p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); JS_GetArrayLength(c, p->js_list, &len); /*special handling for MF node, reset list first*/ @@ -3535,7 +3535,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF if (!JSVAL_IS_OBJECT(item)) break; node_obj = JSVAL_TO_OBJECT(item); if ( !JS_InstanceOf(c, node_obj, &js_rt->SFNodeClass, NULL)) break; - from = (GF_JSField *) JS_GetPrivate(c, node_obj); + from = (GF_JSField *) SMJS_GET_PRIVATE(c, node_obj); child = * ((GF_Node**)from->field.far_ptr); @@ -3611,25 +3611,25 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF case GF_SG_VRML_MFVEC2F: if ( JSVAL_IS_OBJECT(item) && JS_InstanceOf(c, JSVAL_TO_OBJECT(item), &js_rt->SFVec2fClass, NULL) ) { - from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(item)); + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(item)); gf_sg_vrml_field_copy(& ((MFVec2f*)field->far_ptr)->vals[i], from->field.far_ptr, GF_SG_VRML_SFVEC2F); } break; case GF_SG_VRML_MFVEC3F: if ( JSVAL_IS_OBJECT(item) && JS_InstanceOf(c, JSVAL_TO_OBJECT(item), &js_rt->SFVec3fClass, NULL) ) { - from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(item)); + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(item)); gf_sg_vrml_field_copy(& ((MFVec3f*)field->far_ptr)->vals[i], from->field.far_ptr, GF_SG_VRML_SFVEC3F); } break; case GF_SG_VRML_MFROTATION: if ( JSVAL_IS_OBJECT(item) && JS_InstanceOf(c, JSVAL_TO_OBJECT(item), &js_rt->SFRotationClass, NULL) ) { - from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(item)); + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(item)); gf_sg_vrml_field_copy(& ((MFRotation*)field->far_ptr)->vals[i], from->field.far_ptr, GF_SG_VRML_SFROTATION); } break; case GF_SG_VRML_MFCOLOR: if ( JSVAL_IS_OBJECT(item) && JS_InstanceOf(c, JSVAL_TO_OBJECT(item), &js_rt->SFColorClass, NULL) ) { - from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(item)); + from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(item)); gf_sg_vrml_field_copy(& ((MFColor*)field->far_ptr)->vals[i], from->field.far_ptr, GF_SG_VRML_SFCOLOR); } break; @@ -3753,7 +3753,7 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj JSObject *an_obj; JS_GetElement(priv->js_ctx, jsf->js_list, (jsint) j, &newVal); an_obj = JSVAL_TO_OBJECT(newVal); - if (an_obj) slot = JS_GetPrivate(priv->js_ctx, an_obj); + if (an_obj) slot = SMJS_GET_PRIVATE(priv->js_ctx, an_obj); if (slot && (slot->node==f->node)) { gf_list_add(temp_objs, an_obj); break; @@ -3771,7 +3771,7 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj if (JS_SetArrayLength(priv->js_ctx, jsf->js_list, count) != JS_TRUE) return; for (j=0; jjs_ctx, an_obj); + slot = SMJS_GET_PRIVATE(priv->js_ctx, an_obj); newVal = OBJECT_TO_JSVAL(an_obj); JS_SetElement(priv->js_ctx, jsf->js_list, (jsint) j, &newVal); } @@ -3792,7 +3792,7 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj #define SETUP_MF_FIELD \ if (!obj) return JSVAL_NULL; \ - jsf = (GF_JSField *) JS_GetPrivate(priv->js_ctx, obj); \ + jsf = (GF_JSField *) SMJS_GET_PRIVATE(priv->js_ctx, obj); \ jsf->owner = parent; \ if (parent) gf_node_get_field(parent, field->fieldIndex, &jsf->field); \ @@ -3893,7 +3893,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No return JSVAL_NULL; obj = node_get_binding(priv, *(GF_Node**) field->far_ptr, 0); - jsf = JS_GetPrivate(priv->js_ctx, obj); + jsf = SMJS_GET_PRIVATE(priv->js_ctx, obj); if (!jsf->owner) jsf->owner = parent; else @@ -3904,7 +3904,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No case GF_SG_VRML_MFBOOL: { MFBool *f = (MFBool *) field->far_ptr; - obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFBoolClass, 0, priv->js_obj); + obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFBoolClass, priv->js_obj); SETUP_MF_FIELD for (i = 0; icount; i++) { jsval newVal = BOOLEAN_TO_JSVAL(f->vals[i]); @@ -3915,7 +3915,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No case GF_SG_VRML_MFINT32: { MFInt32 *f = (MFInt32 *) field->far_ptr; - obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFInt32Class, 0, priv->js_obj); + obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFInt32Class, priv->js_obj); SETUP_MF_FIELD for (i=0; icount; i++) { jsval newVal = INT_TO_JSVAL(f->vals[i]); @@ -3926,7 +3926,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No case GF_SG_VRML_MFFLOAT: { MFFloat *f = (MFFloat *) field->far_ptr; - obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFFloatClass, 0, priv->js_obj); + obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFFloatClass, priv->js_obj); SETUP_MF_FIELD for (i=0; icount; i++) { jsval newVal = JS_MAKE_DOUBLE(priv->js_ctx, FIX2FLT(f->vals[i])); @@ -3937,7 +3937,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No case GF_SG_VRML_MFTIME: { MFTime *f = (MFTime *) field->far_ptr; - obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFTimeClass, 0, priv->js_obj); + obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFTimeClass, priv->js_obj); SETUP_MF_FIELD for (i=0; icount; i++) { jsval newVal = JS_MAKE_DOUBLE(priv->js_ctx, f->vals[i]); @@ -3948,7 +3948,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No case GF_SG_VRML_MFSTRING: { MFString *f = (MFString *) field->far_ptr; - obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFStringClass, 0, priv->js_obj); + obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFStringClass, priv->js_obj); SETUP_MF_FIELD for (i=0; icount; i++) { s = JS_NewStringCopyZ(priv->js_ctx, f->vals[i]); @@ -3960,7 +3960,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No case GF_SG_VRML_MFURL: { MFURL *f = (MFURL *) field->far_ptr; - obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFUrlClass, 0, priv->js_obj); + obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFUrlClass, priv->js_obj); SETUP_MF_FIELD for (i=0; icount; i++) { if (f->vals[i].OD_ID > 0) { @@ -3979,7 +3979,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No case GF_SG_VRML_MFVEC2F: { MFVec2f *f = (MFVec2f *) field->far_ptr; - obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFVec2fClass, 0, priv->js_obj); + obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFVec2fClass, priv->js_obj); SETUP_MF_FIELD for (i=0; icount; i++) { JSObject *pf = JS_NewObject(priv->js_ctx, &js_rt->SFVec2fClass, 0, obj); @@ -3993,7 +3993,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No case GF_SG_VRML_MFVEC3F: { MFVec3f *f = (MFVec3f *) field->far_ptr; - obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFVec3fClass, 0, priv->js_obj); + obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFVec3fClass, priv->js_obj); SETUP_MF_FIELD for (i=0; icount; i++) { JSObject *pf = JS_NewObject(priv->js_ctx, &js_rt->SFVec3fClass, 0, obj); @@ -4007,7 +4007,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No case GF_SG_VRML_MFROTATION: { MFRotation *f = (MFRotation*) field->far_ptr; - obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFRotationClass, 0, priv->js_obj); + obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFRotationClass, priv->js_obj); SETUP_MF_FIELD for (i=0; icount; i++) { JSObject *pf = JS_NewObject(priv->js_ctx, &js_rt->SFRotationClass, 0, obj); @@ -4021,7 +4021,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No case GF_SG_VRML_MFCOLOR: { MFColor *f = (MFColor *) field->far_ptr; - obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFColorClass, 0, priv->js_obj); + obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFColorClass, priv->js_obj); SETUP_MF_FIELD for (i=0; icount; i++) { JSObject *pf = JS_NewObject(priv->js_ctx, &js_rt->SFColorClass, 0, obj); @@ -4037,7 +4037,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No { u32 size; GF_ChildNodeItem *f = * ((GF_ChildNodeItem **)field->far_ptr); - obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFNodeClass, 0, priv->js_obj); + obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFNodeClass, priv->js_obj); SETUP_MF_FIELD size = gf_node_list_get_count(f); @@ -4063,7 +4063,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No gf_sg_proto_instanciate(proto_inst); } - slot = JS_GetPrivate(priv->js_ctx, pf); + slot = SMJS_GET_PRIVATE(priv->js_ctx, pf); if (!slot->owner) slot->owner = parent; newVal = OBJECT_TO_JSVAL(pf); @@ -4083,7 +4083,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No if (!obj) return JSVAL_NULL; //store field associated with object if needed if (jsf) { - JS_SetPrivate(priv->js_ctx, obj, jsf); + SMJS_SET_PRIVATE(priv->js_ctx, obj, jsf); /*if this is the obj corresponding to an existing field/node, store it and prevent GC on object*/ if (parent) { @@ -4117,7 +4117,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No jsval item; JS_GetElement(jsf->js_ctx, jsf->js_list, (jsint) i, &item); if (JSVAL_IS_OBJECT(item)) { - GF_JSField *afield = JS_GetPrivate(jsf->js_ctx, JSVAL_TO_OBJECT(item)); + GF_JSField *afield = SMJS_GET_PRIVATE(jsf->js_ctx, JSVAL_TO_OBJECT(item)); if (afield->owner != parent) continue; if ( gf_list_find(parent->sgprivate->interact->js_binding->fields, afield) < 0) { @@ -4140,7 +4140,7 @@ static void JS_ReleaseRootObjects(GF_ScriptPriv *priv) /*we don't walk through the list since unprotecting an element could trigger GC which in turn could modify this list content*/ JSObject *obj = gf_list_last(priv->js_cache); gf_list_rem_last(priv->js_cache); - jsf = (GF_JSField *) JS_GetPrivate(priv->js_ctx, obj); + jsf = (GF_JSField *) SMJS_GET_PRIVATE(priv->js_ctx, obj); if (!jsf) continue; /* !!! WARNING !!! @@ -4559,7 +4559,7 @@ static void JSScript_NodeModified(GF_SceneGraph *sg, GF_Node *node, GF_FieldInfo count = gf_list_count(priv->js_cache); for (i=0; ijs_cache, i); - jsf = JS_GetPrivate(priv->js_ctx, obj); + jsf = SMJS_GET_PRIVATE(priv->js_ctx, obj); if (jsf->node && (jsf->node==node)) { jsf->node = NULL; /*Ivica patch*/ @@ -4640,7 +4640,7 @@ static void JSScript_NodeModified(GF_SceneGraph *sg, GF_Node *node, GF_FieldInfo jsval item; JS_GetElement(jsf->js_ctx, jsf->js_list, (jsint) j, &item); if (JSVAL_IS_OBJECT(item)) { - GF_JSField *afield = JS_GetPrivate(jsf->js_ctx, JSVAL_TO_OBJECT(item)); + GF_JSField *afield = SMJS_GET_PRIVATE(jsf->js_ctx, JSVAL_TO_OBJECT(item)); afield->owner = NULL; } } @@ -4693,7 +4693,7 @@ void gf_sg_handle_dom_event_for_vrml(GF_Node *node, GF_DOM_Event *event, GF_Node GF_LOG(GF_LOG_DEBUG, GF_LOG_INTERACT, ("[DOM Events] Executing script code from VRML handler\n")); priv = JS_GetScriptStack(hdl->js_context); - prev_event = JS_GetPrivate(priv->js_ctx, priv->event); + prev_event = SMJS_GET_PRIVATE(priv->js_ctx, priv->event); /*break loops*/ if (prev_event && (prev_event->type==event->type) && (prev_event->target==event->target)) return; @@ -4709,10 +4709,10 @@ void gf_sg_handle_dom_event_for_vrml(GF_Node *node, GF_DOM_Event *event, GF_Node prev_type = event->is_vrml; event->is_vrml = 1; - JS_SetPrivate(priv->js_ctx, priv->event, event); + SMJS_SET_PRIVATE(priv->js_ctx, priv->event, event); - JS_SetPrivate(priv->js_ctx, evt, event); + SMJS_SET_PRIVATE(priv->js_ctx, evt, event); argv[0] = OBJECT_TO_JSVAL(evt); if (hdl->js_fun_val) { @@ -4729,7 +4729,7 @@ void gf_sg_handle_dom_event_for_vrml(GF_Node *node, GF_DOM_Event *event, GF_Node } event->is_vrml = prev_type; - JS_SetPrivate(priv->js_ctx, priv->event, prev_event); + SMJS_SET_PRIVATE(priv->js_ctx, priv->event, prev_event); gf_sg_lock_javascript(priv->js_ctx, 0); @@ -4763,7 +4763,7 @@ GF_Node *gf_sg_js_get_node(JSContext *c, JSObject *obj) { #ifndef GPAC_DISABLE_VRML if (js_rt && JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) { - GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj); + GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj); if (ptr->field.fieldType==GF_SG_VRML_SFNODE) return * ((GF_Node **)ptr->field.far_ptr); } #endif diff --git a/src/terminal/media_memory.c b/src/terminal/media_memory.c index 4c8741e..9a538b5 100644 --- a/src/terminal/media_memory.c +++ b/src/terminal/media_memory.c @@ -333,10 +333,6 @@ void gf_cm_unlock_input(GF_CompositionMemory *cb, GF_CMUnit *cu, u32 cu_size, Bo } gf_odm_lock(cb->odm, 1); - if (cu->TS < cb->input->TS) - cu = cu; - - if (codec_reordering) { cb->input = cb->input->next; } else { diff --git a/src/terminal/object_manager.c b/src/terminal/object_manager.c index 938811b..c0467ed 100644 --- a/src/terminal/object_manager.c +++ b/src/terminal/object_manager.c @@ -626,9 +626,10 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv) e = ODM_ValidateOD(odm, &hasInline); if (e) { - gf_term_message(odm->term, odm->net_service->url, "MPEG-4 Service Error", e); + GF_Terminal *term = odm->term; + gf_term_message(term, odm->net_service->url, "MPEG-4 Service Error", e); gf_odm_disconnect(odm, 1); - gf_term_lock_net(odm->term, 0); + gf_term_lock_net(term, 0); return; } @@ -760,7 +761,7 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv) } if (odm->parentscene==odm->term->root_scene) { gf_term_lock_net(odm->term, 0); - gf_mx_v(odm->term->net_mx); + evt.type = GF_EVENT_STREAMLIST; gf_term_send_event(odm->term,&evt); @@ -823,12 +824,12 @@ GF_Err gf_odm_setup_es(GF_ObjectManager *odm, GF_ESD *esd, GF_ClientService *ser if (ck) break; - odm_par = odm->parentscene->root_od->parentscene ? odm->parentscene->root_od->parentscene->root_od : NULL; + odm_par = (odm_par->parentscene && odm_par->parentscene->root_od->parentscene ) ? odm_par->parentscene->root_od->parentscene->root_od : NULL; } } if (ck) goto clock_setup; - GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[ODM] Cannot inherit timeline from parent scene for scene %s\n", odm->net_service->url)); + GF_LOG(GF_LOG_WARNING, GF_LOG_MEDIA, ("[ODM] Cannot inherit timeline from parent scene for scene %s - new clock will be created\n", odm->net_service->url)); } /*get clocks namespace (eg, parent scene)*/ @@ -883,6 +884,10 @@ GF_Err gf_odm_setup_es(GF_ObjectManager *odm, GF_ESD *esd, GF_ClientService *ser ck = gf_clock_attach(ck_namespace, scene, clockID, esd->ESID, flag); if (!ck) return GF_OUT_OF_MEM; esd->OCRESID = ck->clockID; + /*special case for non-dynamic scenes forcing clock share of all subscene, we assign the + parent scene clock to the first clock created in the sunscenes*/ + if (scene->root_od->parentscene && scene->root_od->parentscene->force_single_timeline && !scene->root_od->parentscene->dyn_ck) + scene->root_od->parentscene->dyn_ck = ck; clock_setup: /*create a channel for this stream*/ diff --git a/src/terminal/scene.c b/src/terminal/scene.c index f28c221..ef8e6b3 100644 --- a/src/terminal/scene.c +++ b/src/terminal/scene.c @@ -332,6 +332,7 @@ static void gf_scene_insert_object(GF_Scene *scene, GF_MediaObject *mo, Bool loc odm->parentscene = scene; odm->term = scene->root_od->term; root_od = scene->root_od; + if (scene->force_single_timeline) lock_timelines = 1; url = mo->URLs.vals[0].url; if (url) { @@ -673,6 +674,10 @@ GF_MediaObject *gf_scene_get_media_object_ex(GF_Scene *scene, MFURL *url, u32 ob gf_term_lock_net(scene->root_od->term, 1); + /*we may have overriden the time lines in parent scene, thus all objects in this scene have the same clock*/ + if (scene->root_od->parentscene && scene->root_od->parentscene->force_single_timeline) + lock_timelines = 1; + /*the first pass is needed to detect objects already inserted and registered with the given nodes, regardless of the force_new_if_not_attached flag. This ty^pically occurs when a resource is first created then linked to an animation/inline*/ restart: @@ -1542,6 +1547,7 @@ GF_SceneGraph *gf_scene_enum_extra_scene(GF_SceneGraph *sg, u32 *i) void gf_scene_generate_views(GF_Scene *scene, char *url) { + char *url_search; GF_Node *n1, *switcher; #if USE_TEXTURES GF_Node *n2; @@ -1551,7 +1557,8 @@ void gf_scene_generate_views(GF_Scene *scene, char *url) #endif GF_Event evt; gf_sg_reset(scene->graph); - + + scene->force_single_timeline = 1; n1 = is_create_node(scene->graph, TAG_MPEG4_OrderedGroup, NULL); gf_sg_set_root_node(scene->graph, n1); gf_node_register(n1, NULL); @@ -1561,8 +1568,15 @@ void gf_scene_generate_views(GF_Scene *scene, char *url) gf_node_list_add_child( &((GF_ParentNode *)n1)->children, switcher); ((M_Switch*)switcher)->whichChoice = -2; + url_search = url; while (1) { - char *sep = strchr(url, ':'); + char *sep = strchr(url_search, ':'); + /*if :// or :\ is found, skip it*/ + if (sep && ( ((sep[1] == '/') && (sep[2] == '/')) || (sep[1] == '\\') ) ) { + url_search = sep+1; + continue; + } + if (sep) sep[0] = 0; #if USE_TEXTURES /*create a shape and bitmap node*/ @@ -1600,6 +1614,7 @@ void gf_scene_generate_views(GF_Scene *scene, char *url) if (!sep) break; sep[0] = ':'; url = sep+1; + url_search = url; } gf_sc_set_option(scene->root_od->term->compositor, GF_OPT_USE_OPENGL, 1); -- 2.30.2