From: Alessio Treglia Date: Fri, 6 Apr 2012 08:31:40 +0000 (+0200) Subject: Imported Upstream version 0.4.5+svn4002~dfsg0 X-Git-Tag: archive/raspbian/1.0.1+dfsg1-4+rpi1~1^2~15^2~19 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=52fbf587775bffe6ef0c84fc97b8c504bf7cf744;p=gpac.git Imported Upstream version 0.4.5+svn4002~dfsg0 --- diff --git a/applications/Makefile b/applications/Makefile index e93a736..4683ad5 100644 --- a/applications/Makefile +++ b/applications/Makefile @@ -5,9 +5,11 @@ APPDIRS=mp4client ifeq ($(DISABLE_ISOFF), no) APPDIRS+=mp4box ifeq ($(DISABLE_M2TS), no) +ifeq ($(DISABLE_SENG), no) APPDIRS+=mp42ts endif endif +endif V4STUDIODIR= INSTDIRS=mp4client diff --git a/applications/mp42ts/main.c b/applications/mp42ts/main.c index 80b2245..57e1c48 100644 --- a/applications/mp42ts/main.c +++ b/applications/mp42ts/main.c @@ -34,7 +34,13 @@ #error "Cannot compile MP42TS if GPAC is not built with ISO File Format support" -#else +#endif + +#ifdef GPAC_DISABLE_MPEG2TS_MUX + +#error "Cannot compile MP42TS if GPAC is not built with MPEG2-TS Muxing support" + +#endif #define DEFAULT_PCR_OFFSET 18000 @@ -440,6 +446,7 @@ static GF_Err seng_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) return GF_OK; } +#ifndef GPAC_DISABLE_STREAMING typedef struct { /*RTP channel*/ @@ -497,6 +504,7 @@ static GF_Err rtp_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) } return GF_OK; } +#endif static GF_Err void_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param) { @@ -732,7 +740,6 @@ static Bool seng_output(void *param) { GF_Err e; u64 last_src_modif, mod_time; - Bool has_carousel=0; M2TSProgram *prog = (M2TSProgram *)param; GF_SceneEngine *seng = prog->seng; GF_SimpleDataDescriptor *audio_desc; @@ -741,9 +748,6 @@ static Bool seng_output(void *param) u32 period, ts_delta; u16 es_id, aggregate_on_stream; e = GF_OK; - if (prog->rate){ - has_carousel = 1; - } gf_sleep(2000); /*TODO: events instead? What are we waiting for?*/ gf_seng_encode_context(seng, SampleCallBack); @@ -911,7 +915,7 @@ static Bool seng_output(void *param) return e ? 1 : 0; } - +#ifndef GPAC_DISABLE_STREAMING static void rtp_sl_packet_cbk(void *udta, char *payload, u32 size, GF_SLHeader *hdr, GF_Err e) { GF_ESIRTP *rtp = (GF_ESIRTP*)udta; @@ -1027,6 +1031,7 @@ static void fill_rtp_es_ifce(GF_ESInterface *ifce, GF_SDPMedia *media, GF_SDPInf } fprintf(stderr, "RTP interface initialized\n"); } +#endif /*GPAC_DISABLE_STREAMING*/ void fill_seng_es_ifce(GF_ESInterface *ifce, u32 i, GF_SceneEngine *seng, u32 period) { @@ -1060,7 +1065,9 @@ void fill_seng_es_ifce(GF_ESInterface *ifce, u32 i, GF_SceneEngine *seng, u32 pe static Bool open_program(M2TSProgram *prog, char *src, u32 carousel_rate, u32 mpeg4_signaling, char *update, char *audio_input_ip, u16 audio_input_port, char *video_buffer, Bool force_real_time, u32 bifs_use_pes) { +#ifndef GPAC_DISABLE_STREAMING GF_SDPInfo *sdp; +#endif u32 i; GF_Err e; @@ -1212,6 +1219,7 @@ static Bool open_program(M2TSProgram *prog, char *src, u32 carousel_rate, u32 mp return 1; } +#ifndef GPAC_DISABLE_STREAMING /*open SDP file*/ if (strstr(src, ".sdp")) { GF_X_Attribute *att; @@ -1280,8 +1288,9 @@ static Bool open_program(M2TSProgram *prog, char *src, u32 carousel_rate, u32 mp gf_sdp_info_del(sdp); return 2; - } - else if (strstr(src, ".bt")) //open .bt file + } else +#endif /*GPAC_DISABLE_STREAMING*/ + if (strstr(src, ".bt")) //open .bt file { u32 load_type=0; prog->seng = gf_seng_init(prog, src, load_type, NULL, (load_type == GF_SM_LOAD_DIMS) ? 1 : 0); @@ -1789,9 +1798,11 @@ int main(int argc, char **argv) char *ts_out = NULL, *udp_out = NULL, *rtp_out = NULL, *audio_input_ip = NULL; FILE *ts_output_file = NULL; GF_Socket *ts_output_udp_sk = NULL, *audio_input_udp_sk = NULL; +#ifndef GPAC_DISABLE_STREAMING GF_RTPChannel *ts_output_rtp = NULL; GF_RTSPTransport tr; GF_RTPHeader hdr; +#endif char *video_buffer; u32 video_buffer_size; u16 output_port = 0, audio_input_port = 0; @@ -1823,11 +1834,13 @@ int main(int argc, char **argv) last_video_time = 0; audio_input_type = 0; ts_output_udp_sk = NULL; - ts_output_rtp = NULL; - src_name = NULL; - ts_out = NULL; udp_out = NULL; +#ifndef GPAC_DISABLE_STREAMING + ts_output_rtp = NULL; rtp_out = NULL; +#endif + ts_out = NULL; + src_name = NULL; nb_progs = 0; mux_rate = 0; run_time = 0; @@ -1913,6 +1926,7 @@ int main(int argc, char **argv) goto exit; } } +#ifndef GPAC_DISABLE_STREAMING if (rtp_out != NULL) { ts_output_rtp = gf_rtp_new(); gf_rtp_set_ports(ts_output_rtp, output_port); @@ -1948,6 +1962,7 @@ int main(int argc, char **argv) hdr.SSRC = tr.SSRC; hdr.Marker = 0; } +#endif /*GPAC_DISABLE_STREAMING*/ /************************************/ /* create streaming audio input */ @@ -2108,6 +2123,7 @@ int main(int argc, char **argv) fprintf(stderr, "Error %s sending UDP packet\n", gf_error_to_string(e)); } } +#ifndef GPAC_DISABLE_STREAMING if (ts_output_rtp != NULL) { hdr.SequenceNumber++; /*muxer clock at 90k*/ @@ -2120,6 +2136,7 @@ int main(int argc, char **argv) fprintf(stderr, "Error %s sending RTP packet\n", gf_error_to_string(e)); } } +#endif if (status>=GF_M2TS_STATE_PADDING) { break; } @@ -2173,13 +2190,17 @@ exit: } if (ts_output_file) fclose(ts_output_file); if (ts_output_udp_sk) gf_sk_del(ts_output_udp_sk); +#ifndef GPAC_DISABLE_STREAMING if (ts_output_rtp) gf_rtp_del(ts_output_rtp); +#endif if (ts_out) gf_free(ts_out); if (audio_input_udp_sk) gf_sk_del(audio_input_udp_sk); if (audio_input_buffer) gf_free (audio_input_buffer); if (video_buffer) gf_free(video_buffer); if (udp_out) gf_free(udp_out); +#ifndef GPAC_DISABLE_STREAMING if (rtp_out) gf_free(rtp_out); +#endif if (aac_reader) AAC_Reader_del(aac_reader); if (muxer) gf_m2ts_mux_del(muxer); @@ -2208,4 +2229,3 @@ exit: return 1; } -#endif /*GPAC_DISABLE_ISOM*/ diff --git a/applications/mp4box/fileimport.c b/applications/mp4box/fileimport.c index 7b180e5..4d2b77b 100644 --- a/applications/mp4box/fileimport.c +++ b/applications/mp4box/fileimport.c @@ -932,6 +932,9 @@ GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, /*track done*/ if ((tki->stop_state==2) || (!is_last && (tki->sample_count == tki->last_sample)) ) { if (tki->has_non_raps) last_rap_sample_time = 0; + time = (Double) (s64) ( gf_isom_get_sample_dts(mp4, tki->tk, tki->last_sample+1) - tki->firstDTS); + time /= tki->time_scale; + if (file_split_dur==(Double)GF_MAX_FLOAT || file_split_dursequenceParameterSets); k++) { GF_AVCConfigSlot *slc = gf_list_get(avccfg2->sequenceParameterSets, k); gf_avc_get_sps_info(slc->data, slc->size, &sps_id1, NULL, NULL, NULL, NULL); @@ -3227,6 +3231,7 @@ int mp4boxMain(int argc, char **argv) } } } +#endif /*no conflicts in SPS ids, merge all SPS in a single sample desc*/ if (do_merge) { while (gf_list_count(avccfg1->sequenceParameterSets)) { @@ -3363,7 +3368,7 @@ int mp4boxMain(int argc, char **argv) } if (e) goto err_exit; -#ifndef GPAC_DISABLE_ISOM_HINTING +#if !defined(GPAC_DISABLE_ISOM_HINTING) && !defined(GPAC_DISABLE_SENG) for (i=0; ipixel_format==GF_PIXEL_GREYSCALE) sprintf(str, "%s_%d_depth.bmp", rad_name, img_num); else sprintf(str, "%s_%d.bmp", rad_name, img_num); @@ -259,7 +256,6 @@ void write_depthfile(GF_VideoSurface *fb, char *rad_name, u32 img_num) { FILE *fout; u32 i, j; - char val; unsigned char *depth; depth = (unsigned char *) fb->video_buffer; @@ -270,10 +266,10 @@ void write_depthfile(GF_VideoSurface *fb, char *rad_name, u32 img_num) for (i=0;iwidth; i++) { #ifdef GPAC_USE_TINYGL - val = fputc(depth[2*i+j*fb->width*sizeof(unsigned short)], fout); - val = fputc(depth[2*i+j*fb->width*sizeof(unsigned short) + 1], fout); + fputc(depth[2*i+j*fb->width*sizeof(unsigned short)], fout); + fputc(depth[2*i+j*fb->width*sizeof(unsigned short) + 1], fout); #else - val = fputc(depth[i+j*fb->width], fout); + fputc(depth[i+j*fb->width], fout); #endif } } @@ -285,7 +281,6 @@ void write_texture_file(GF_VideoSurface *fb, char *rad_name, u32 img_num, u32 du FILE *fout; u32 i, j; - char val; unsigned char *buf; buf = (unsigned char *) fb->video_buffer; @@ -297,7 +292,7 @@ void write_texture_file(GF_VideoSurface *fb, char *rad_name, u32 img_num, u32 du if (!fout) return; for (j=0; jheight; j++) { for (i=0;iwidth*4; i++) { - val = fputc(buf[i+j*fb->pitch_y], fout); + fputc(buf[i+j*fb->pitch_y], fout); } } fclose(fout); diff --git a/applications/mp4client/main.c b/applications/mp4client/main.c index f43d16b..a2d0ec0 100644 --- a/applications/mp4client/main.c +++ b/applications/mp4client/main.c @@ -1186,7 +1186,7 @@ int main (int argc, char **argv) if (!strcmp(str, "Raw Video Output")) fprintf(stdout, "WARNING: using raw output video (memory only) - no display used\n"); /*check audio output*/ str = gf_cfg_get_key(cfg_file, "Audio", "DriverName"); - if (!str || !strcmp(str, "No Audio Output Available")) fprintf(stdout, "WARNING: no audio output availble - make sure no other program is locking the sound card\n"); + if (!str || !strcmp(str, "No Audio Output Available")) fprintf(stdout, "WARNING: no audio output available - make sure no other program is locking the sound card\n"); str = gf_cfg_get_key(cfg_file, "General", "NoMIMETypeFetch"); no_mime_check = (str && !stricmp(str, "yes")) ? 1 : 0; diff --git a/configure b/configure index d08a25d..22c9fa6 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 > $TMPCPP << EOF #include int main( void ) { JSContext *cx; jsval *rp; return JS_AddValueRoot(cx, rp); } EOF @@ -692,9 +692,13 @@ 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 -lnss3" + js_lib="-L/usr/lib/$i/ -lxul -lmozsqlite3 -lmozalloc -lnssutil3 -lnss3" if $cpp -o $TMPO $TMPCPP $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 + #firefox 11 compatibility + has_js="$i" + js_lib="-lnssutil3 $js_lib -lssl3" fi fi done @@ -816,18 +820,21 @@ if test "$has_js" != "no" ; then #if the lib has been compiled with or without the macro. We currently just decide that if the macro is present #in the header, it was enabled in the build if test "$new_js_api" = "no" ; then - if grep MOZILLA_1_8_BRANCH $js_inc/jsapi.h > /dev/null 2>&1 ; then - js_flags="-DMOZILLA_1_8_BRANCH $js_flags" - echo "WARNING: Turning on MOZILLA_1_8_BRANCH SpiderMonkey macro" - echo "If you have troubles with scripts in GPAC, disable this macro and recompile" - fi + if grep MOZILLA_1_8_BRANCH $js_inc/jsapi.h > /dev/null 2>&1 ; then + js_flags="-DMOZILLA_1_8_BRANCH $js_flags" + echo "WARNING: Turning on MOZILLA_1_8_BRANCH SpiderMonkey macro" + echo "If you have troubles with scripts in GPAC, disable this macro and recompile" + fi else - #check presence of ***RuntimeThread - if grep RuntimeThread $js_inc/jsapi.h > /dev/null 2>&1 ; then - js_flags="$js_flags" - else - js_flags="-DNO_JS_RUNTIMETHREAD $js_flags" - fi +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 fi fi fi @@ -1422,7 +1429,7 @@ IN6_IS_ADDR_MULTICAST( (struct in6_addr *) 0); } EOF -if $cc -o $TMPE $TMPC $LDFLAGS > /dev/null 2>&1 ; then +if $cc -o $TMPE $TMPC $LDFLAGS $extralibs > /dev/null 2>&1 ; then has_ipv6="yes" fi @@ -1888,16 +1895,27 @@ EOF if $cc -o $TMPO $TMPCPP -I$xulsdk_path $LDFLAGS 2> /dev/null ; then has_xul="system" xul_flags="-I$xulsdk_path $xul_flags" -else +fi + +if test "$has_xul" = "no" ; then + if $pkg_config --exists libxul 2> /dev/null ; then + if $cpp -o $TMPO $TMPCPP `$pkg_config --cflags libxul` `$pkg_config --libs libxul` ; then + has_xul="system" + xul_flags="`$pkg_config --cflags libxul` `$pkg_config --libs libxul`" + fi + fi +fi + +if test "$has_xul" = "no" ; then if $cc -o $TMPO $TMPCPP $xul_flags -I$local_inc/gecko-sdk/include $LDFLAGS 2> /dev/null ; then has_xul="local" xul_flags="-I$local_inc/gecko-sdk/include $xul_flags" else - #xulrunner directories are sometimes included through js packages - if test "$has_js" = "system" ;then - if $cpp -o $TMPO $TMPCPP $js_flags $js_lib_pkg $LDFLAGS 2> /dev/null ; then + #xulrunner directories are sometimes included through js/xul/ff packages + if test ! "$has_js" = "no" -a ! "$has_js" = "local" ; then + if $cc -o $TMPO $TMPCPP $js_flags $js_lib_pkg $LDFLAGS 2> /dev/null ; then xul_flags=`$pkg_config --cflags mozilla-js` - has_xul="system" + has_xul="$has_js" fi fi fi @@ -2335,8 +2353,8 @@ if test "$darwin" = "yes" ; then fi ldir=`pwd` -CFLAGS="$CFLAGS -DGPAC_HAVE_CONFIG_H -I\"$ldir\"" -CPPFLAGS="$CPPFLAGS -DGPAC_HAVE_CONFIG_H -I\"$ldir\"" +CFLAGS="$CFLAGS -fvisibility=\"hidden\" -DGPAC_HAVE_CONFIG_H -I\"$ldir\"" +CPPFLAGS="$CPPFLAGS" echo "Creating config.mak" @@ -2502,11 +2520,17 @@ if test "$has_libxml2" = "yes"; then echo "XML2_CFLAGS=$libxml2_cflags" >> config.mak echo "XML2_LIBS=$libxml2_lib_flags" >> config.mak fi +if test "$disable_parsers" = "yes" ; then + disable_m2ts_mux="yes" +fi if test "$disable_m2ts_mux" = "yes" -o "$disable_m2ts" = "yes" ; then echo "DISABLE_M2TS=yes" >> config.mak else echo "DISABLE_M2TS=no" >> config.mak fi +if test "$disable_beng" = "no"; then + echo "DISABLE_SENG=no" >> config.mak +fi echo "GPAC_USE_TINYGL=$has_tinygl" >> config.mak echo "OGL_INCLS=$INCL3D" >> config.mak diff --git a/gui/iphone_wm_gui.js b/gui/iphone_wm_gui.js index d9cb1a9..1e0d22d 100644 --- a/gui/iphone_wm_gui.js +++ b/gui/iphone_wm_gui.js @@ -1,1636 +1,1651 @@ // 01122011 AMD1 startWidget listWidgets getWidget implemented - -var iphone_wm_gui = (function () { - - // to make sure the initialization is done only once - var init = true; - - // constant - var xlinkns = 'http://www.w3.org/1999/xlink'; - //var evns = 'http://www.w3.org/2001/xml-events'; - - // state of the widget manager: displays homepage (value=home) or executes widget (value="exec") - var state = 'home'; - - // convenience variables for SVG elements - var homepage = null, arrows = null, icons = null, widgetContainer = null, homebar = null, execbar = null; - - // where is the index into pages of icons on the home page - var where = 0,maxwhere = 0,whereW = 0; - - // array of activated widgets - var activatedWidgets = new Array(); - var numActivatedWidgets = 0; - - // variables for flexible layout - // variables for flexible layout - var totalWidth = 0,totalHeight = 0,iconNbHoriz = 0,iconNbVert = 0,iconsPerPage = 0; - - //previous size - var previousWidth = 0,previousHeight = 0; - - // to differentiate between install icon and scan dir for icons - var isThisAScan = null; - - // preferred icon type - var preferredIconType = '.svg'; - - // adapt layout to the size of the screen - function adaptLayoutToSize() { - if (l_deb < log_level) { - alert("[UI] adaptLayoutToSize"); - } - var tmpObject, tmpObj2; - // get size to adapt to - totalWidth = document.documentElement.viewport.width; - totalHeight = document.documentElement.viewport.height; - if (totalWidth == 0) { - totalWidth = 160; - } - if (totalHeight == 0) { - totalHeight = 280; - } - while (totalWidth < 160 || totalHeight < 280) { - totalWidth *= 4; - totalHeight *= 4; - } - // min size is 160 by 280 - if (totalWidth < 160) { - totalWidth = 160; - } - if (totalHeight < 280) { - totalHeight = 280; - } - // round to lower multiple of 80 - totalWidth -= totalWidth % 80; - var iconHeight = totalHeight - 120; - iconHeight -= iconHeight % 80; - // how many lines and columns of icons - iconNbHoriz = totalWidth / 80; - iconNbVert = iconHeight / 80; - totalHeight = iconHeight + 120; - // 120 is upper bar (60) + lower bar (60) - iconsPerPage = iconNbHoriz * iconNbVert; - // fix svg viewbox - document.getElementById("svg").setAttribute("viewBox", "0 0 " + totalWidth + " " + totalHeight); - // fix odd line - tmpObj2 = document.getElementById("odd"); - var i, already = tmpObj2.getElementsByTagName("use").length; - //alert("odd line "+already+" "+iconNbHoriz); - for (i = already; i < iconNbHoriz; i++) { - tmpObject = document.createElement("use"); - tmpObject.setAttribute("x", i * 80); - tmpObject.setAttributeNS(xlinkns, "href", (((i % 2) == 0) ? "#lightRect" : "#darkRect" )); - tmpObj2.appendChild(tmpObject); - } - // fix even line - tmpObj2 = document.getElementById("even"); - already = tmpObj2.getElementsByTagName("use").length; - //alert("even line "+already+" "+iconNbHoriz); - for (i = already; i < iconNbHoriz; i++) { - tmpObject = document.createElement("use"); - tmpObject.setAttribute("x", i * 80); - tmpObject.setAttributeNS(xlinkns, "href", (((i % 2) == 0) ? "#darkRect" : "#lightRect" )); - tmpObj2.appendChild(tmpObject); - } - // fix frame (black with rounded corners) - tmpObject = document.getElementById("frame"); - tmpObject.setAttribute("width", totalWidth); - tmpObject.setAttribute("height", totalHeight); - tmpObject = document.getElementById("frame2"); - tmpObject.setAttribute("width", totalWidth); - tmpObject.setAttribute("height", totalHeight); - // fix screen (white) - tmpObject = document.getElementById("screen"); - tmpObject.setAttribute("width", totalWidth); - tmpObject.setAttribute("height", totalHeight - 120); - // fix grid back (gray) - tmpObject = document.getElementById("gridback"); - tmpObject.setAttribute("width", totalWidth); - tmpObject.setAttribute("height", totalHeight - 120); - // fix icon background grid - tmpObject = document.getElementById("grid"); - already = tmpObject.getElementsByTagName("use").length; - for (i = already; i < iconNbVert; i++) { - tmpObj2 = document.createElement("use"); - tmpObj2.setAttribute("y", i * 80); - tmpObj2.setAttributeNS(xlinkns, "href", (((i % 2) == 0) ? "#odd" : "#even" )); - tmpObject.appendChild(tmpObj2); - } - // if there are already too many lines, remove the extra ones otherwise they are rendered on top of the lower - // part of the decoration - if (already > iconNbVert) { - while (already-- > iconNbVert) { - tmpObject.removeChild(tmpObject.lastChild); - } - } - // fix commands (lower bar) - document.getElementById("commands").setAttribute("transform", "translate(0, " + (totalHeight - 60) + ")"); - document.getElementById("homeButton").setAttribute("transform", "translate(" + (totalWidth / 2) + ", 30)"); - document.getElementById("right").setAttribute("transform", "translate(" + (totalWidth - 50) + ", 10)"); - document.getElementById("rightW").setAttribute("transform", "translate(" + (totalWidth - 50) + ", 10)"); - // fix the cuts (white rects left and right because we have no clipping) - tmpObject = document.getElementById("leftCut"); - tmpObject.setAttribute("width", totalWidth); - tmpObject.setAttribute("height", totalHeight); - tmpObject.setAttribute("x", -1 - totalWidth); - tmpObject = document.getElementById("rightCut"); - tmpObject.setAttribute("width", totalWidth); - tmpObject.setAttribute("height", totalHeight); - tmpObject.setAttribute("x", 1 + totalWidth); - // respace executing widgets if any - tmpObject = widgetContainer.getElementsByTagName("g"); - for (i = 0; i < tmpObject.length; i++) { - var gg = tmpObject.item(i); - gg.setAttribute("transform", "translate(" + (totalWidth * (i - 1)) + ", 0)"); - if (gg.firstElementChild != null) { - gg.firstElementChild.setAttribute("width", totalWidth); - gg.firstElementChild.setAttribute("height", totalHeight - 120); - } +/* wrapper as a module + var iphone_wm_gui = (function () { + */ +// to make sure the initialization is done only once +var init = true; + +// constant +var xlinkns = 'http://www.w3.org/1999/xlink'; +//var evns = 'http://www.w3.org/2001/xml-events'; + +// state of the widget manager: displays homepage (value=home) or executes widget (value="exec") +var state = 'home'; + +// convenience variables for SVG elements +var homepage = null, arrows = null, icons = null, widgetContainer = null, homebar = null, execbar = null; + +// where is the index into pages of icons on the home page +var where = 0,maxwhere = 0,whereW = 0; + +// array of activated widgets +var activatedWidgets = new Array(); +var numActivatedWidgets = 0; + +// variables for flexible layout +// variables for flexible layout +var totalWidth = 0,totalHeight = 0,iconNbHoriz = 0,iconNbVert = 0,iconsPerPage = 0; + +//previous size +var previousWidth = 0,previousHeight = 0; + +// to differentiate between install icon and scan dir for icons +var isThisAScan = null; + +// preferred icon type +var preferredIconType = '.svg'; + +// adapt layout to the size of the screen +function adaptLayoutToSize() { + if (l_deb < log_level) { + alert("[UI] adaptLayoutToSize"); + } + display_width = parseInt( gpac.getOption('General', 'LastWidth') ); + display_height = parseInt( gpac.getOption('General', 'LastHeight') ); + alert("display "+display_width+" "+display_height); + if (!gpac.fullscreen && display_width && display_height) { + gpac.set_size(display_width, display_height); + } + var tmpObject, tmpObj2; + // get size to adapt to + totalWidth = document.documentElement.viewport.width; + totalHeight = document.documentElement.viewport.height; + if (totalWidth == 0) { + totalWidth = 160; + } + if (totalHeight == 0) { + totalHeight = 280; + } + while (totalWidth < 160 || totalHeight < 280) { + totalWidth *= 4; + totalHeight *= 4; + } + // min size is 160 by 280 + if (totalWidth < 160) { + totalWidth = 160; + } + if (totalHeight < 280) { + totalHeight = 280; + } + // round to lower multiple of 80 + totalWidth -= totalWidth % 80; + var iconHeight = totalHeight - 120; + iconHeight -= iconHeight % 80; + // how many lines and columns of icons + iconNbHoriz = totalWidth / 80; + iconNbVert = iconHeight / 80; + totalHeight = iconHeight + 120; + // 120 is upper bar (60) + lower bar (60) + iconsPerPage = iconNbHoriz * iconNbVert; + // fix svg viewbox + document.getElementById("svg").setAttribute("viewBox", "0 0 " + totalWidth + " " + totalHeight); + // fix odd line + tmpObj2 = document.getElementById("odd"); + var i, already = tmpObj2.getElementsByTagName("use").length; + //alert("odd line "+already+" "+iconNbHoriz); + for (i = already; i < iconNbHoriz; i++) { + tmpObject = document.createElement("use"); + tmpObject.setAttribute("x", i * 80); + tmpObject.setAttributeNS(xlinkns, "href", (((i % 2) == 0) ? "#lightRect" : "#darkRect" )); + tmpObj2.appendChild(tmpObject); + } + // fix even line + tmpObj2 = document.getElementById("even"); + already = tmpObj2.getElementsByTagName("use").length; + //alert("even line "+already+" "+iconNbHoriz); + for (i = already; i < iconNbHoriz; i++) { + tmpObject = document.createElement("use"); + tmpObject.setAttribute("x", i * 80); + tmpObject.setAttributeNS(xlinkns, "href", (((i % 2) == 0) ? "#darkRect" : "#lightRect" )); + tmpObj2.appendChild(tmpObject); + } + // fix frame (black with rounded corners) + tmpObject = document.getElementById("frame"); + tmpObject.setAttribute("width", totalWidth); + tmpObject.setAttribute("height", totalHeight); + tmpObject = document.getElementById("frame2"); + tmpObject.setAttribute("width", totalWidth); + tmpObject.setAttribute("height", totalHeight); + // fix screen (white) + tmpObject = document.getElementById("screen"); + tmpObject.setAttribute("width", totalWidth); + tmpObject.setAttribute("height", totalHeight - 120); + // fix grid back (gray) + tmpObject = document.getElementById("gridback"); + tmpObject.setAttribute("width", totalWidth); + tmpObject.setAttribute("height", totalHeight - 120); + // fix icon background grid + tmpObject = document.getElementById("grid"); + already = tmpObject.getElementsByTagName("use").length; + for (i = already; i < iconNbVert; i++) { + tmpObj2 = document.createElement("use"); + tmpObj2.setAttribute("y", i * 80); + tmpObj2.setAttributeNS(xlinkns, "href", (((i % 2) == 0) ? "#odd" : "#even" )); + tmpObject.appendChild(tmpObj2); + } + // if there are already too many lines, remove the extra ones otherwise they are rendered on top of the lower + // part of the decoration + if (already > iconNbVert) { + while (already-- > iconNbVert) { + tmpObject.removeChild(tmpObject.lastChild); + } + } + // fix commands (lower bar) + document.getElementById("commands").setAttribute("transform", "translate(0, " + (totalHeight - 60) + ")"); + document.getElementById("homeButton").setAttribute("transform", "translate(" + (totalWidth / 2) + ", 30)"); + document.getElementById("right").setAttribute("transform", "translate(" + (totalWidth - 50) + ", 10)"); + document.getElementById("rightW").setAttribute("transform", "translate(" + (totalWidth - 50) + ", 10)"); + // fix the cuts (white rects left and right because we have no clipping) + tmpObject = document.getElementById("leftCut"); + tmpObject.setAttribute("width", totalWidth); + tmpObject.setAttribute("height", totalHeight); + tmpObject.setAttribute("x", -1 - totalWidth); + tmpObject = document.getElementById("rightCut"); + tmpObject.setAttribute("width", totalWidth); + tmpObject.setAttribute("height", totalHeight); + tmpObject.setAttribute("x", 1 + totalWidth); + // respace executing widgets if any + tmpObject = widgetContainer.getElementsByTagName("g"); + for (i = 0; i < tmpObject.length; i++) { + var gg = tmpObject.item(i); + gg.setAttribute("transform", "translate(" + (totalWidth * (i - 1)) + ", 0)"); + if (gg.firstElementChild != null) { + gg.firstElementChild.setAttribute("width", totalWidth); + gg.firstElementChild.setAttribute("height", totalHeight - 120); } } +} - // - // widget close on click at "Kill" button - // - function on_kill_widget() { - if (state == 'exec') { - widget_close(activatedWidgets[whereW]); - } +// +// widget close on click at "Kill" button +// +function on_kill_widget() { + if (state == 'exec') { + widget_close(activatedWidgets[whereW]); } +} - // - // widget get on click at "GetW" button - // - function on_get_widget() { - alert("on_get_widget "+WidgetManager.MPEGUStandardServiceProviders.length); - if (WidgetManager.MPEGUStandardServiceProviders.length != 0) { - upnp_renders = selector_window1(); - upnp_renders.on_select = function(item) { - upnp_renders.unregister(root); - upnp_renders = null; - if (item == -1) { - return; - } - alert("upnp_renders.on_select(" + item + ")"); - var device = WidgetManager.MPEGUStandardServiceProviders[item]; - device.standardService.SetActionListener("listWidgets", get_widget_callback(device), true); - device.standardService.CallAction("listWidgets", new Array()); +// +// widget get on click at "GetW" button +// +function on_get_widget() { + alert("on_get_widget " + WidgetManager.MPEGUStandardServiceProviders.length); + if (WidgetManager.MPEGUStandardServiceProviders.length != 0) { + upnp_renders = selector_window1(); + upnp_renders.on_select = function(item) { + upnp_renders.unregister(root); + upnp_renders = null; + if (item == -1) { + return; } - upnp_renders.register(root); + alert("upnp_renders.on_select(" + item + ")"); + var device = WidgetManager.MPEGUStandardServiceProviders[item]; + device.standardService.SetActionListener("listWidgets", get_widget_callback(device), true); + device.standardService.CallAction("listWidgets", new Array()); } + upnp_renders.register(root); } +} - function get_widget_callback(device) { - return function() { - //alert("get_widget_callback"); - // msgHandler is the first argument, the next arguments are from the reply to listWidgets - var act = arguments[0]; - var act1 = act.GetArgumentValue("widgetCodes"); - var act2 = act.GetArgumentValue("widgetNames"); - //alert(act1+" "+act2); - target_widgets = selector_window2(act1.split(" "), act2.split(" ")); - target_widgets.on_select = function(item) { - alert("target_widgets.on_select"); - target_widgets.unregister(root); - target_widgets = null; - if (item == -1) { - return; - } - alert("target_widgets.on_select(" + item + ")"); - var args = new Array(); - args[0] = "widgetCode"; - args[1] = item; - device.standardService.CallAction("getWidget", args); +function get_widget_callback(device) { + return function() { + //alert("get_widget_callback"); + // msgHandler is the first argument, the next arguments are from the reply to listWidgets + var act = arguments[0]; + var act1 = act.GetArgumentValue("widgetCodes"); + var act2 = act.GetArgumentValue("widgetNames"); + //alert(act1+" "+act2); + target_widgets = selector_window2(act1.split(" "), act2.split(" ")); + target_widgets.on_select = function(item) { + alert("target_widgets.on_select"); + target_widgets.unregister(root); + target_widgets = null; + if (item == -1) { + return; } - target_widgets.register(root); + alert("target_widgets.on_select(" + item + ")"); + var args = new Array(); + args[0] = "widgetCode"; + args[1] = item; + device.standardService.SetActionListener("getWidget", get_widget_callback2, true); + device.standardService.CallAction("getWidget", args); } + target_widgets.register(root); } +} - // - // creates the menu of available targets for pushing a widget elsewhere - // - function selector_window1() { - var i, count, render; - var selector = document.createElement('g'), obj, child; - selector.setAttribute('transform', 'translate(10,10)'); - count = WidgetManager.MPEGUStandardServiceProviders.length; - selector.appendChild(rect(0, 0, 300, 20 * (count + 1), 'white', 'black')); - for (i = 0; i < count; i++) { - render = WidgetManager.MPEGUStandardServiceProviders[i]; - obj = createtext(render.Name, 'black', 5, 17 + (20 * i), 15, 'sans-serif'); - obj.setAttribute('id', "select" + i); - selector.appendChild(obj); - obj.addEventListener('mouseover', sw1("select" + i), false); - obj.addEventListener('mouseout', sw2("select" + i), false); - obj.addEventListener('click', sw4(i), false); - } - obj = createtext('Cancel', 'rgb(0,0,120)', 55, 17 + (20 * i), 15, 'sans-serif'); - obj.setAttribute('id', "canc"); +function get_widget_callback2() { + // msgHandler is the first argument, the next arguments are from the reply to listWidgets + alert("callback2-1"); + var act = arguments[0]; + var act1 = act.GetArgumentValue("widgetUrl"); + var act2 = act.GetArgumentValue("widgetContext"); + alert("callback2-2 " + act1 + " " + act2); + var wid = WidgetManager.load(act1, null, act2); + WidgetManager.on_widget_add(wid); +} + +// +// creates the menu of available targets for pushing a widget elsewhere +// +function selector_window1() { + var i, count, render; + var selector = document.createElement('g'), obj, child; + selector.setAttribute('transform', 'translate(10,10)'); + count = WidgetManager.MPEGUStandardServiceProviders.length; + selector.appendChild(rect(0, 0, 300, 20 * (count + 1), 'white', 'black', null)); + for (i = 0; i < count; i++) { + render = WidgetManager.MPEGUStandardServiceProviders[i]; + obj = createtext(render.Name, 'black', 5, 17 + (20 * i), 15, 'sans-serif'); + obj.setAttribute('id', "select" + i); selector.appendChild(obj); - obj.addEventListener('mouseover', function(evt) { document.getElementById("canc").setAttribute("fill", "red"); }, false); - obj.addEventListener('mouseout', function(evt) { document.getElementById("canc").setAttribute("fill", "black"); }, false); - obj.addEventListener('click', function(evt) { upnp_renders.on_select(-1); }, false); - selector.register = function(disp) { - disp.appendChild(this); - }; - selector.unregister = function(disp) { - disp.removeChild(this); - }; - return selector; - } + obj.addEventListener('mouseover', sw1("select" + i), false); + obj.addEventListener('mouseout', sw2("select" + i), false); + obj.addEventListener('click', sw4(i), false); + } + obj = createtext('Cancel', 'rgb(0,0,120)', 55, 17 + (20 * i), 15, 'sans-serif'); + obj.setAttribute('id', "canc"); + selector.appendChild(obj); + obj.addEventListener('mouseover', function() { document.getElementById("canc").setAttribute("fill", "red"); }, false); + obj.addEventListener('mouseout', function() { document.getElementById("canc").setAttribute("fill", "black"); }, false); + obj.addEventListener('click', function() { upnp_renders.on_select(-1); }, false); + selector.register = function(disp) { + disp.appendChild(this); + }; + selector.unregister = function(disp) { + disp.removeChild(this); + }; + return selector; +} - // - // creates the menu of available targets for pushing a widget elsewhere - // - function selector_window2(codes, names) { - alert("selector_window2"); - var i, count, render; - var selector = document.createElement('g'), obj, child; - selector.setAttribute('transform', 'translate(10,10)'); - count = codes.length; - selector.appendChild(rect(0, 0, 300, 20 * (count + 1), 'white', 'black')); - for (i = 0; i < count; i++) { - render = names[i]; - obj = createtext(render, 'black', 5, 17 + (20 * i), 15, 'sans-serif'); - obj.setAttribute('id', "selecto" + i); - selector.appendChild(obj); - obj.addEventListener('mouseover', sw1("selecto" + i), false); - obj.addEventListener('mouseout', sw2("selecto" + i), false); - obj.addEventListener('click', sw5(i), false); - } - obj = createtext('Cancel', 'rgb(0,0,120)', 55, 17 + (20 * i), 15, 'sans-serif'); - obj.setAttribute('id', "cance"); +// +// creates the menu of available targets for pushing a widget elsewhere +// +function selector_window2(codes, names) { + alert("selector_window2"); + var i, count, render; + var selector = document.createElement('g'), obj, child; + selector.setAttribute('transform', 'translate(10,10)'); + count = codes.length; + selector.appendChild(rect(0, 0, 300, 20 * (count + 1), 'white', 'black', null)); + for (i = 0; i < count; i++) { + render = names[i]; + obj = createtext(render, 'black', 5, 17 + (20 * i), 15, 'sans-serif'); + obj.setAttribute('id', "selecto" + i); selector.appendChild(obj); - obj.addEventListener('mouseover', function(evt) { document.getElementById("cance").setAttribute("fill", "red"); }, false); - obj.addEventListener('mouseout', function(evt) { document.getElementById("cance").setAttribute("fill", "black"); }, false); - obj.addEventListener('click', function(evt) { target_widgets.on_select(-1); }, false); - selector.register = function(disp) { - disp.appendChild(this); - }; - selector.unregister = function(disp) { - disp.removeChild(this); - }; - return selector; - } + obj.addEventListener('mouseover', sw1("selecto" + i), false); + obj.addEventListener('mouseout', sw2("selecto" + i), false); + obj.addEventListener('click', sw5(i), false); + } + obj = createtext('Cancel', 'rgb(0,0,120)', 55, 17 + (20 * i), 15, 'sans-serif'); + obj.setAttribute('id', "cance"); + selector.appendChild(obj); + obj.addEventListener('mouseover', function() { document.getElementById("cance").setAttribute("fill", "red"); }, false); + obj.addEventListener('mouseout', function() { document.getElementById("cance").setAttribute("fill", "black"); }, false); + obj.addEventListener('click', function() { target_widgets.on_select(-1); }, false); + selector.register = function(disp) { + disp.appendChild(this); + }; + selector.unregister = function(disp) { + disp.removeChild(this); + }; + return selector; +} - function sw4(si) { - return function(evt) { upnp_renders.on_select(si); }; - } +function sw4(si) { + return function() { upnp_renders.on_select(si); }; +} - function sw5(si) { - return function(evt) { target_widgets.on_select(si); }; - } +function sw5(si) { + return function() { target_widgets.on_select(si); }; +} - // - // when deleting an executing widgets, all executing widgets to its right are moved to the left - // - function recurseMoveAfterDelete(target) { - if (target != null && target.nextElementSibling != null) { - var v = target.nextElementSibling; - recurseMoveAfterDelete(v); - v.setAttribute("transform", target.getAttribute("transform")); - } +// +// when deleting an executing widgets, all executing widgets to its right are moved to the left +// +function recurseMoveAfterDelete(target) { + if (target != null && target.nextElementSibling != null) { + var v = target.nextElementSibling; + recurseMoveAfterDelete(v); + v.setAttribute("transform", target.getAttribute("transform")); } +} - // - // click on home button to switch from icons to executing widgets - // - function home_button(evt) { - if (l_deb < log_level) { - alert("[UI] home_button"); - } - if (state != 'home') { - state = 'home'; - widgetContainer.setAttribute('display', 'none'); - homepage.setAttribute('display', 'inline'); - homebar.setAttribute('display', 'inline'); - execbar.setAttribute('display', 'none'); - arrows.setAttribute('display', 'inline'); - arrowsW.setAttribute('display', 'none'); - widgetAddList.setAttribute('display', 'none'); - } else { - state = 'exec'; - widgetContainer.setAttribute('display', 'inline'); - homepage.setAttribute('display', 'none'); - homebar.setAttribute('display', 'none'); - execbar.setAttribute('display', 'inline'); - arrows.setAttribute('display', 'none'); - arrowsW.setAttribute('display', 'inline'); - widgetAddList.setAttribute('display', 'none'); - } +// +// click on home button to switch from icons to executing widgets +// +function home_button(evt) { + if (l_deb < log_level) { + alert("[UI] home_button"); } + if (state != 'home') { + state = 'home'; + widgetContainer.setAttribute('display', 'none'); + homepage.setAttribute('display', 'inline'); + homebar.setAttribute('display', 'inline'); + execbar.setAttribute('display', 'none'); + arrows.setAttribute('display', 'inline'); + arrowsW.setAttribute('display', 'none'); + widgetAddList.setAttribute('display', 'none'); + } else { + state = 'exec'; + widgetContainer.setAttribute('display', 'inline'); + homepage.setAttribute('display', 'none'); + homebar.setAttribute('display', 'none'); + execbar.setAttribute('display', 'inline'); + arrows.setAttribute('display', 'none'); + arrowsW.setAttribute('display', 'inline'); + widgetAddList.setAttribute('display', 'none'); + } +} - // constants - var adjustFrom = "0,0"; - var animDue = true; +// constants +var adjustFrom = "0,0"; +var animDue = true; + +// +// after each change of icon page, this function adjusts the visibility of arrows in the lower bar +// +function adjustwhere(animDue) { + if (l_deb < log_level) { + alert("[UI] adjust " + where + " 0 " + maxwhere); + } + document.getElementById("left").setAttribute("display", ((where > 0) ? "inline" : "none")); + document.getElementById("right").setAttribute("display", ((where < maxwhere) ? "inline" : "none")); + if (!animDue) { + icons.setAttribute("transform", 'translate(' + (-80 * iconNbHoriz * where) + ',0)'); + } else { + var aw = document.createElement("animateTransform"); + aw.setAttribute("attributeName", "transform"); + aw.setAttribute("type", "translate"); + //alert('time '+document.documentElement.getCurrentTime()); + aw.setAttribute("begin", document.documentElement.getCurrentTime()); + aw.setAttribute("dur", "1s"); + aw.setAttribute("fill", "freeze"); + aw.setAttributeNS(xlinkns, "href", "#icons"); + aw.setAttribute("from", adjustFrom); + aw.setAttribute("to", (-80 * iconNbHoriz * where) + ",0"); + document.documentElement.appendChild(aw); + } + adjustFrom = (-80 * iconNbHoriz * where) + ",0"; +} - // - // after each change of icon page, this function adjusts the visibility of arrows in the lower bar - // - function adjustwhere(animDue) { - if (l_deb < log_level) { - alert("[UI] adjust " + where + " 0 " + maxwhere); - } - document.getElementById("left").setAttribute("display", ((where > 0) ? "inline" : "none")); - document.getElementById("right").setAttribute("display", ((where < maxwhere) ? "inline" : "none")); - if (!animDue) { - icons.setAttribute("transform", 'translate(' + (-80 * iconNbHoriz * where) + ',0)'); - } else { - var aw = document.createElement("animateTransform"); - aw.setAttribute("attributeName", "transform"); - aw.setAttribute("type", "translate"); - //alert('time '+document.documentElement.getCurrentTime()); - aw.setAttribute("begin", document.documentElement.getCurrentTime()); - aw.setAttribute("dur", "1s"); - aw.setAttribute("fill", "freeze"); - aw.setAttributeNS(xlinkns, "href", "#icons"); - aw.setAttribute("from", adjustFrom); - aw.setAttribute("to", (-80 * iconNbHoriz * where) + ",0"); - document.documentElement.appendChild(aw); - } - adjustFrom = (-80 * iconNbHoriz * where) + ",0"; +// +// action of the left button on the lower bar +// +function left_button() { + if (l_deb < log_level) { + alert("[UI] left button " + where + " 0"); } - - // - // action of the left button on the lower bar - // - function left_button() { - if (l_deb < log_level) { - alert("[UI] left button " + where + " 0"); - } - if (where > 0) { - where--; - adjustwhere(true); - } + if (where > 0) { + where--; + adjustwhere(true); } +} - // - // action of the right button of the lower bar - // - function right_button() { - if (l_deb < log_level) { - alert("[UI] right button " + where + " " + maxwhere); - } - if (where < maxwhere) { - where++; - adjustwhere(true); - } +// +// action of the right button of the lower bar +// +function right_button() { + if (l_deb < log_level) { + alert("[UI] right button " + where + " " + maxwhere); } - - var adjustFromW = "0,0"; - var oldwhereW = -1; - - // - // after each change of icon page, this function adjusts the visibility of arrows in the lower bar - // - function adjustWhereWidgets(animDue) { - if (oldwhereW != whereW) { - // hide oldwhereW - if (oldwhereW >= 0 && activatedWidgets[oldwhereW] != null) { - WidgetManager.corein_message(activatedWidgets[oldwhereW], "hide"); - } - } - if (l_deb < log_level) { - alert("[UI] adjustW " + whereW + " 0 " + (numActivatedWidgets - 1)); - } - document.getElementById("leftW").setAttribute("display", ((whereW > 0) ? "inline" : "none")); - document.getElementById("rightW").setAttribute("display", ((whereW < (numActivatedWidgets - 1)) ? "inline" : "none")); - if (!animDue) { - widgetContainer.setAttribute("transform", "translate(" + (-totalWidth * whereW) + ",0)"); - } else { - var aw = document.createElement("animateTransform"); - aw.setAttribute("attributeName", "transform"); - aw.setAttribute("type", "translate"); - aw.setAttribute("begin", document.documentElement.getCurrentTime()); - aw.setAttribute("dur", "1s"); - aw.setAttribute("fill", "freeze"); - aw.setAttributeNS(xlinkns, "href", "#widget"); - aw.setAttribute("from", adjustFromW); - aw.setAttribute("to", (-totalWidth * whereW) + ",0"); - document.documentElement.appendChild(aw); - } - adjustFromW = (-totalWidth * whereW) + ",0"; - document.getElementById("widgetName").textContent = - (whereW >= 0 && activatedWidgets[whereW] != null ? activatedWidgets[whereW].shortName : '-'); - if (oldwhereW != whereW) { - // show whereW - if (whereW >= 0 && activatedWidgets[whereW] != null) { - WidgetManager.corein_message(activatedWidgets[whereW], "show"); - } - oldwhereW = whereW; - } + if (where < maxwhere) { + where++; + adjustwhere(true); } +} - // - // action of the left button on the lower bar - // - function left_buttonW() { - if (l_deb < log_level) { - alert("[UI] left button " + whereW); - } - if (whereW > 0) { - whereW--; - adjustWhereWidgets(animDue); - } +var adjustFromW = "0,0"; +var oldwhereW = -1; + +// +// after each change of icon page, this function adjusts the visibility of arrows in the lower bar +// +function adjustWhereWidgets(animDue) { + if (oldwhereW != whereW) { + // hide oldwhereW + if (oldwhereW >= 0 && activatedWidgets[oldwhereW] != null) { + WidgetManager.corein_message(activatedWidgets[oldwhereW], "hide"); + } + } + if (l_deb < log_level) { + alert("[UI] adjustW " + whereW + " 0 " + (numActivatedWidgets - 1)); + } + document.getElementById("leftW").setAttribute("display", ((whereW > 0) ? "inline" : "none")); + document.getElementById("rightW").setAttribute("display", ((whereW < (numActivatedWidgets - 1)) ? "inline" : "none")); + if (!animDue) { + widgetContainer.setAttribute("transform", "translate(" + (-totalWidth * whereW) + ",0)"); + } else { + var aw = document.createElement("animateTransform"); + aw.setAttribute("attributeName", "transform"); + aw.setAttribute("type", "translate"); + aw.setAttribute("begin", document.documentElement.getCurrentTime()); + aw.setAttribute("dur", "1s"); + aw.setAttribute("fill", "freeze"); + aw.setAttributeNS(xlinkns, "href", "#widget"); + aw.setAttribute("from", adjustFromW); + aw.setAttribute("to", (-totalWidth * whereW) + ",0"); + document.documentElement.appendChild(aw); + } + adjustFromW = (-totalWidth * whereW) + ",0"; + document.getElementById("widgetName").textContent = + (whereW >= 0 && activatedWidgets[whereW] != null ? activatedWidgets[whereW].shortName : '-'); + if (oldwhereW != whereW) { + // show whereW + if (whereW >= 0 && activatedWidgets[whereW] != null) { + WidgetManager.corein_message(activatedWidgets[whereW], "show"); + } + oldwhereW = whereW; } +} - // - // action of the right button of the lower bar - // - function right_buttonW() { - if (l_deb < log_level) { - alert("[UI] right button " + whereW + " " + (numActivatedWidgets - 1)); - } - if (whereW < (numActivatedWidgets - 1)) { - whereW++; - adjustWhereWidgets(animDue); - } +// +// action of the left button on the lower bar +// +function left_buttonW() { + if (l_deb < log_level) { + alert("[UI] left button " + whereW); } - - // - // action of each icon, starting the matching widget - // - function activating_widget(w) { - if (l_deb < log_level) { - alert("[UI] activating widget: " + w.name); - } - widget_add(w); + if (whereW > 0) { + whereW--; + adjustWhereWidgets(animDue); } +} - // - // main initialization function - // init variables, then init the widget manager C code, then inits UPnP - // - function initialize() { - if (l_deb < log_level) { - alert("[UI] initialize"); - } - init = false; - var display_width = parseInt(gpac.getOption('Widgets', 'LastWMWidth')); - var display_height = parseInt(gpac.getOption('Widgets', 'LastWMHeight')); - if (display_width && display_height) { - gpac.set_size(display_width, display_height); - } - root = document.documentElement; - homepage = document.getElementById('homepage'); - homebar = document.getElementById('homebar'); - execbar = document.getElementById('execbar'); - arrows = document.getElementById('arrows'); - arrowsW = document.getElementById('arrowsW'); - icons = document.getElementById('icons'); - widgetContainer = document.getElementById('widget'); - widgetAddList = document.getElementById('widgetAddList'); - /* Setup the GPAC Widget Manager - this will also scan the available widgets */ - log_level = l_inf; - widget_manager_init(); - WidgetManager.on_widget_remove = widget_remove; - WidgetManager.on_widget_add = widget_add; - /* register the callback to be notified of incoming widgets */ - has_upnp = (typeof UPnP != 'undefined'); - if (has_upnp) { - /* setting the callback to allow other devices to push their widgets */ - UPnP.onMediaConnect = onMediaConnect; - /* Tell GPAC that the calls to the main Renderer (like open, ...) must be forwared to this scene */ - UPnP.BindRenderer(); - } - WidgetManager.coreOutShow = coreOutShowImplementation; - WidgetManager.coreOutGetAttention = coreOutGetAttentionImplementation; - WidgetManager.coreOutHide = coreOutHideImplementation; - WidgetManager.coreOutRequestDeactivate = coreOutRequestDeactivateImplementation; - WidgetManager.coreOutInstallWidget = coreOutInstallWidgetImplementation; - WidgetManager.coreOutActivateTemporaryWidget = coreOutActivateTemporaryWidgetImplementation; - WidgetManager.coreOutMigrateComponent = coreOutMigrateComponentImplementation; - WidgetManager.coreOutRequestMigrationTargets = coreOutRequestMigrationTargetsImplementation; +// +// action of the right button of the lower bar +// +function right_buttonW() { + if (l_deb < log_level) { + alert("[UI] right button " + whereW + " " + (numActivatedWidgets - 1)); } - - // - // implementation of core:out install widget - // - function coreOutInstallWidgetImplementation(wid, args) { - var w = widgetInstall(args[0], true, false, wid); - var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); - if (ifce != null) { - wmjs_core_out_invoke_reply(coreOut.installWidgetMessage, ifce.get_message("installWidget"), - wid, (w != null ? 1 : 0)); // send return code 1 = success - } + if (whereW < (numActivatedWidgets - 1)) { + whereW++; + adjustWhereWidgets(animDue); } +} - // - // implementation of core:out activate temporary widget - // - function coreOutActivateTemporaryWidgetImplementation(wid, args) { - var w = widgetInstall(args[0], true, true, null); - if (w != null) { - activating_widget(w); - } - var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); - if (ifce != null) { - wmjs_core_out_invoke_reply(coreOut.activateTemporaryWidgetMessage, ifce.get_message("activateTemporaryWidget"), - wid, (w != null ? 1 : 0)); // send return code 1 = success - } +// +// action of each icon, starting the matching widget +// +function activating_widget(w) { + if (l_deb < log_level) { + alert("[UI] activating widget: " + w.name); } + widget_add(w); +} - // - // implementation of core:out migrate component - // - function coreOutMigrateComponentImplementation(wid, args) { - //alert("coreOutMigrateComponent "+wid.name+" "+args.length); - var comp = wid.get_component(args[0], true); - var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); - if (comp == null) { - log(l_err, 'Component ' + args[0] + ' cannot be found in widget ' + wid.name); - if (ifce != null) { - wmjs_core_out_invoke_reply(coreOut.migrateComponentMessage, ifce.get_message("migrateComponent"), wid, 0); - } - return; - } - if (args.length > 1 && args[1] != null) { - //WidgetManager.migrate_widget(UPnP.GetMediaRenderer(parseInt(args[1])), comp); - WidgetManager.migrate_widget(WidgetManager.get_mpegu_service_providers(parseInt(args[1])), comp); - widget_close(comp); - } else { - upnp_renders = selector_window(comp); - upnp_renders.on_select = function(item, wid) { - upnp_renders.unregister(root); - upnp_renders = null; - if (item == -1) { - return; - } - if (comp != null) { - alert("upnp_renders.on_select(" + item + "," + comp.name + ")"); - //WidgetManager.migrate_widget(UPnP.GetMediaRenderer(item), comp); - WidgetManager.migrate_widget(WidgetManager.get_mpegu_service_providers(item), comp); - widget_close(comp); - } - }; - upnp_renders.register(root); - } - if (ifce != null) { - wmjs_core_out_invoke_reply(coreOut.migrateComponentMessage, ifce.get_message("migrateComponent"), wid, 1); // send return code 1 = success - } - } +// +// main initialization function +// init variables, then init the widget manager C code, then inits UPnP +// +function initialize() { + if (l_deb < log_level) { + alert("[UI] initialize"); + } + init = false; + var display_width = parseInt(gpac.getOption('Widgets', 'LastWMWidth')); + var display_height = parseInt(gpac.getOption('Widgets', 'LastWMHeight')); + if (display_width && display_height) { + gpac.set_size(display_width, display_height); + } + root = document.documentElement; + homepage = document.getElementById('homepage'); + homebar = document.getElementById('homebar'); + execbar = document.getElementById('execbar'); + arrows = document.getElementById('arrows'); + arrowsW = document.getElementById('arrowsW'); + icons = document.getElementById('icons'); + widgetContainer = document.getElementById('widget'); + widgetAddList = document.getElementById('widgetAddList'); + /* Setup the GPAC Widget Manager - this will also scan the available widgets */ + log_level = l_inf; + widget_manager_init(); + WidgetManager.on_widget_remove = widget_remove; + WidgetManager.on_widget_add = widget_add; + /* register the callback to be notified of incoming widgets */ + has_upnp = (typeof UPnP != 'undefined'); + if (has_upnp) { + /* setting the callback to allow other devices to push their widgets */ + UPnP.onMediaConnect = onMediaConnect; + /* Tell GPAC that the calls to the main Renderer (like open, ...) must be forwared to this scene */ + UPnP.BindRenderer(); + } + WidgetManager.coreOutShow = coreOutShowImplementation; + WidgetManager.coreOutGetAttention = coreOutGetAttentionImplementation; + WidgetManager.coreOutHide = coreOutHideImplementation; + WidgetManager.coreOutRequestDeactivate = coreOutRequestDeactivateImplementation; + WidgetManager.coreOutInstallWidget = coreOutInstallWidgetImplementation; + WidgetManager.coreOutActivateTemporaryWidget = coreOutActivateTemporaryWidgetImplementation; + WidgetManager.coreOutMigrateComponent = coreOutMigrateComponentImplementation; + WidgetManager.coreOutRequestMigrationTargets = coreOutRequestMigrationTargetsImplementation; +} - // - // implementation of core:out request migration targets - // - function coreOutRequestMigrationTargetsImplementation(wid, args) { - var count = UPnP.MediaRenderersCount, codes = new Array(), names = new Array(), descriptions = new Array(), i; - for (i = 0; i < count; i++) { - var render = UPnP.GetMediaRenderer(i); - codes.push("" + i); - names.push(render.Name); - descriptions.push(render.HostName + " " + render.UUID); - } - i = null; - var ifce_count = wid.num_interfaces, j; - for (j = 0; j < ifce_count; j++) { - var ifce = wid.get_interface(j); - if (ifce.type == "urn:mpeg:mpegu:schema:widgets:core:out:2010") { - i = ifce; - break; - } - } - if (i != null) { - wmjs_core_out_invoke_reply(coreOut.requestMigrationTargetsMessage, i.get_message("requestMigrationTargets"), - wid, codes, names, descriptions); - } +// +// implementation of core:out install widget +// +function coreOutInstallWidgetImplementation(wid, args) { + var w = widgetInstall(args[0], true, false, wid); + var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); + if (ifce != null) { + wmjs_core_out_invoke_reply(coreOut.installWidgetMessage, ifce.get_message("installWidget"), + wid, (w != null ? 1 : 0)); // send return code 1 = success } +} - // - // implementation of core:out Show message - // this is a request by the widget to be shown - // - function coreOutShowImplementation(wid, args) { - //alert("core:out show "+wid.name); - var target = widgetContainer.firstElementChild; - var i; - for (i = 0; i < numActivatedWidgets; i++) { - //alert("is it "+activatedWidgets[i].name); - if (activatedWidgets[i] == wid) { - break; - } - target = target.nextElementSibling; - } - // here, i is the index of the current widget - //alert(" "+i+" "+numActivatedWidgets); - if (i < numActivatedWidgets) { - whereW = i; - adjustWhereWidgets(false); - } - var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); - if (ifce != null) { - wmjs_core_out_invoke_reply(coreOut.showMessage, ifce.get_message("show"), wid, 1); // send return code 1 = success - } +// +// implementation of core:out activate temporary widget +// +function coreOutActivateTemporaryWidgetImplementation(wid, args) { + var w = widgetInstall(args[0], true, true, null); + if (w != null) { + activating_widget(w); } - - // - // implementation of core:out GetAttention message - // this is a request by the widget to be shown and some special signal is given - // - function coreOutGetAttentionImplementation(wid, args) { - //alert("core:out getAttention "+wid.name); - var target = widgetContainer.firstElementChild; - var i; - for (i = 0; i < numActivatedWidgets; i++) { - //alert("is it "+activatedWidgets[i].name); - if (activatedWidgets[i] == wid) { - break; - } - target = target.nextElementSibling; - } - // here, i is the index of the current widget - //alert(" "+i+" "+numActivatedWidgets); - if (i < numActivatedWidgets) { - whereW = i; - adjustWhereWidgets(false); - } - document.getElementById("getAttention").beginElement(); - var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); - if (ifce != null) { - wmjs_core_out_invoke_reply(coreOut.getAttentionMessage, ifce.get_message("getAttention"), wid, 1); // send return code 1 = success - } + var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); + if (ifce != null) { + wmjs_core_out_invoke_reply(coreOut.activateTemporaryWidgetMessage, ifce.get_message("activateTemporaryWidget"), + wid, (w != null ? 1 : 0)); // send return code 1 = success } +} - // - // implementation of core:out hide message - // this is a request by the widget to be hidden (some other widget (if any) is shown) - // - function coreOutHideImplementation(wid, args) { - //alert("core:out hide "+wid.name); - var target = widgetContainer.firstElementChild; - var i; - for (i = 0; i < numActivatedWidgets; i++) { - //alert("is it "+activatedWidgets[i].name); - if (activatedWidgets[i] == wid) { - break; - } - target = target.nextElementSibling; - } - // here, i is the index of the current widget - //alert("hide "+i+" "+numActivatedWidgets); - if (i < numActivatedWidgets) { - if (whereW > 0) { - whereW--; - } - else if (whereW < numActivatedWidgets - 1) { - whereW++; - } - else { - return; - } - adjustWhereWidgets(false); - } - var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); +// +// implementation of core:out migrate component +// +function coreOutMigrateComponentImplementation(wid, args) { + //alert("coreOutMigrateComponent "+wid.name+" "+args.length); + var comp = wid.get_component(args[0], true); + var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); + if (comp == null) { + log(l_err, 'Component ' + args[0] + ' cannot be found in widget ' + wid.name); if (ifce != null) { - wmjs_core_out_invoke_reply(coreOut.hideMessage, ifce.get_message("hide"), wid, 1); // send return code 1 = success - } - } - - // - // implementation of core:out requestDeactivate message - // this is a request by the widget to be stopped - // - function coreOutRequestDeactivateImplementation(wid, args) { - //alert("core:out hide "+wid.name); - var target = widgetContainer.firstElementChild; - var i; - for (i = 0; i < numActivatedWidgets; i++) { - //alert("is it "+activatedWidgets[i].name); - if (activatedWidgets[i] == wid) { - break; + wmjs_core_out_invoke_reply(coreOut.migrateComponentMessage, ifce.get_message("migrateComponent"), wid, 0); + } + return; + } + if (args.length > 1 && args[1] != null) { + //WidgetManager.migrate_widget(UPnP.GetMediaRenderer(parseInt(args[1])), comp); + WidgetManager.migrate_widget(WidgetManager.get_mpegu_service_providers(parseInt(args[1])), comp); + widget_close(comp); + } else { + upnp_renders = selector_window(comp); + upnp_renders.on_select = function(item, wid) { + upnp_renders.unregister(root); + upnp_renders = null; + if (item == -1) { + return; } - target = target.nextElementSibling; - } - // here, i is the index of the current widget - //alert("hide "+i+" "+numActivatedWidgets); - if (i < numActivatedWidgets) { - widget_close(activatedWidgets[i]); - } - var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); - if (ifce != null) { - wmjs_core_out_invoke_reply(coreOut.requestDeactivateMessage, ifce.get_message("requestDeactivate"), wid, 1); // send return code 1 = success - } - } - - // - // WM callback for when a component is activated by its parent - // - function widget_add(w) { - log(l_inf, "widget add " + w.name); - if (!w.activated) { - if (sameFileIgnoringSVGView(w.icon, w.main)) { - // same file in icon and main - } else { - widget_launch(w, document.createElement("animation")); + if (comp != null) { + alert("upnp_renders.on_select(" + item + "," + comp.name + ")"); + //WidgetManager.migrate_widget(UPnP.GetMediaRenderer(item), comp); + WidgetManager.migrate_widget(WidgetManager.get_mpegu_service_providers(item), comp); + widget_close(comp); } - } else if (w.multipleInstances) { - var newwid = WidgetManager.open(w.manifest, null); - widget_launch(newwid, document.createElement("animation")); - } else return false; - state = 'exec'; - widgetContainer.setAttribute('display', 'inline'); - homepage.setAttribute('display', 'none'); - homebar.setAttribute('display', 'none'); - execbar.setAttribute('display', 'inline'); - arrows.setAttribute('display', 'none'); - arrowsW.setAttribute('display', 'inline'); - widgetAddList.setAttribute('display', 'none'); - return true; + }; + upnp_renders.register(root); } - - function sameFileIgnoringSVGView(name1, name2) { - if (name1 == name2) { - return true; - } - if (name1 == null) { - return false; - } - var i1 = name1.indexOf("#"); - var i2 = name2.indexOf("#"); - if (i1 < 0) { - i1 = name1.length; - } - else { - i1--; - } - if (i2 < 0) { - i2 = name2.length; - } - else { - i2--; - } - return name1.substring(0, i1) == name2.substring(0, i2); + if (ifce != null) { + wmjs_core_out_invoke_reply(coreOut.migrateComponentMessage, ifce.get_message("migrateComponent"), wid, 1); // send return code 1 = success } +} - // - // recompute the number of widgets loaded currently - // - function getNbWidgets() { - var i, nbWidgets = 0; - for (i = 0; i < WidgetManager.num_widgets; i++) { - var w = WidgetManager.get(i); - if (w != null && w.loaded) { - nbWidgets++; - } - } - return nbWidgets; +// +// implementation of core:out request migration targets +// +function coreOutRequestMigrationTargetsImplementation(wid, args) { + var count = UPnP.MediaRenderersCount, codes = new Array(), names = new Array(), descriptions = new Array(), i; + for (i = 0; i < count; i++) { + var render = UPnP.GetMediaRenderer(i); + codes.push("" + i); + names.push(render.Name); + descriptions.push(render.HostName + " " + render.UUID); + } + i = null; + var ifce_count = wid.num_interfaces, j; + for (j = 0; j < ifce_count; j++) { + var ifce = wid.get_interface(j); + if (ifce.type == "urn:mpeg:mpegu:schema:widgets:core:out:2010") { + i = ifce; + break; + } + } + if (i != null) { + wmjs_core_out_invoke_reply(coreOut.requestMigrationTargetsMessage, i.get_message("requestMigrationTargets"), + wid, codes, names, descriptions); } +} - // - // just resize the window and viewport, and initialize the first time this is called - // - function resize() { - if (init) { - initialize(); - } - if (document.documentElement.viewport.width == previousWidth && document.documentElement.viewport.height == previousHeight) { - return; - } - if (l_deb < log_level) { - alert("[UI] start initialize() w:" + document.documentElement.viewport.width + " h:" + document.documentElement.viewport.height); - } - adaptLayoutToSize(); - // start by filling the "home page" with known icons - where = 0; - var nbWidgets = getNbWidgets(); - maxwhere = ((nbWidgets - 1) - ((nbWidgets - 1) % iconsPerPage)) / iconsPerPage; - var wid; - var iconIterator = document.getElementById("icons").firstElementChild; - var position = 0; - for (i = 1; i <= WidgetManager.num_widgets; i++) { - wid = WidgetManager.get(i - 1); - // alert("build:"+wid.main+" "+wid.loaded); - if (wid.loaded) { - insert_icon(wid, position, i - 1, iconIterator); - WidgetManager.corein_message(wid, 'setSize', 'width', totalWidth, 'height', totalHeight - 120, 'dpi', 96); - position++; - if (iconIterator != null) { - iconIterator = iconIterator.nextElementSibling; - } - } - } - adjustwhere(false); +// +// implementation of core:out Show message +// this is a request by the widget to be shown +// +function coreOutShowImplementation(wid, args) { + //alert("core:out show "+wid.name); + var target = widgetContainer.firstElementChild; + var i; + for (i = 0; i < numActivatedWidgets; i++) { + //alert("is it "+activatedWidgets[i].name); + if (activatedWidgets[i] == wid) { + break; + } + target = target.nextElementSibling; + } + // here, i is the index of the current widget + //alert(" "+i+" "+numActivatedWidgets); + if (i < numActivatedWidgets) { + whereW = i; adjustWhereWidgets(false); - previousWidth = document.documentElement.viewport.width; - previousHeight = document.documentElement.viewport.height; - gpac.setOption("Widgets", "LastWMWidth", '' + previousWidth); - gpac.setOption("Widgets", "LastWMHeight", '' + previousHeight); - } - - // - // function inserting an icon on the home page - // - function insert_icon(widget, position, widgetIndex, previousIcon) { - if (l_deb < log_level) { - alert("[UI] insert_icon: " + widget.shortName + " " + position + " " + widgetIndex + " WMnw:" + WidgetManager.num_widgets); - } - widget.loaded = true; - if (l_deb < log_level) { - alert("[UI] widget name: " + widget.name); - } - var icon = null, original = null; - for (var i = 0; i < widget.icons.length; i++) { - // default to the first icon even if not of the preferred type - if (i == 0) { - icon = widget.icons[0].relocated_src; - //original = widget.icons[0].original; - // alert("choosing default icon " + icon); - } - // check for preferred type - if (widget.icons[i].relocated_src.indexOf(preferredIconType) > 0) { - icon = widget.icons[i].relocated_src; - //original = widget.icons[i].original; - break; - } - } - var shortName = widget.shortName; - if (typeof shortName == 'undefined') { - shortName = widget.name.substring(0, 9); - } - createIconSVGdecoration(previousIcon, widget, (((position % iconNbHoriz) * 80) + ((80 * (position - (position % iconsPerPage))) / iconNbVert)), - ((((position % iconsPerPage) - (position % iconNbHoriz)) / iconNbHoriz) * 80), "icons", icon, - shortName, widgetIndex); } - - /*function restoreFragmentOnURL(iconUrl, original) { - var l = original.indexOf('#'); - if (l >= 0) { - return iconUrl + original.substring(l); - } - return iconUrl; - }*/ - - // constant - // const corein = "urn:mpeg:mpegu:schema:widgets:core:in:2010"; - - // - // commodity method to empty a list of children - // - function removeAllChildren(o) { - if (o != null && o.hasChildNodes()) { - while (o.childNodes.length >= 1) { - o.removeChild(o.firstChild); - } - } + var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); + if (ifce != null) { + wmjs_core_out_invoke_reply(coreOut.showMessage, ifce.get_message("show"), wid, 1); // send return code 1 = success } +} - // - // create the home page icon with all its behaviours - // - function createIconSVGdecoration(previousIcon, widget, x, y, fatherId, iconUrl, name, widIndex) { - var g, g2; - if (l_inf < log_level) { - alert("[UI] createIconSVGdecoration " + iconUrl + " " + x + " " + y); - } - if (previousIcon != null) { - g = previousIcon; - } else { - g = document.createElement("g"); - document.getElementById(fatherId).appendChild(g); - } - g.setAttribute("transform", 'translate(' + x + ',' + y + ')'); - if (previousIcon != null) { - g2 = g.firstElementChild; - } else { - g2 = document.createElement("g"); - g2.setAttribute("transform", 'translate(15,10)'); - g.appendChild(g2); - } - if (iconUrl == null || iconUrl == "") { - iconUrl = "icons/face-surprise.svg"; - } - // - // process differently cases where widget.icon == widget.main - // - var container; - if (sameFileIgnoringSVGView(iconUrl, widget.main) && widget.main.indexOf('.svg') >= 0) { - // see if the animation already exists - container = document.getElementById(name); - if (container == null) { - // if the animation does not exist yet, create it - container = media('animation', iconUrl, 50, 50); - // store the animation in the main defs - document.getElementById("mainDefs").appendChild(container); - container.setAttribute('id', name); - } - if (previousIcon == null) { - // put the container in a use - var use = document.createElement("use"); - use.setAttribute('id', 'iconContainer' + name); - use.setAttributeNS(xlinkns, 'href', '#' + name); - g2.appendChild(use); - } - } else { - if (previousIcon == null) { - container = appropriateElementForMedia(iconUrl, 50, 50); - container.setAttribute('id', name); - g2.appendChild(container); - } - } - if (previousIcon == null) { - g2 = document.createElement("g"); - g2.setAttribute("transform", 'translate(40,70)'); - g.appendChild(g2); - var anim = createtext(name, 'white', 0, 0, 14, 'Arial Unicode MS'); - anim.setAttribute("text-anchor", "middle"); - anim.setAttribute("display-align", "center"); - g2.appendChild(anim); - var rect = invisible_rect(80, 80); - g.appendChild(rect); - rect.addEventListener("click", csi(widget), false); - } +// +// implementation of core:out GetAttention message +// this is a request by the widget to be shown and some special signal is given +// +function coreOutGetAttentionImplementation(wid, args) { + //alert("core:out getAttention "+wid.name); + var target = widgetContainer.firstElementChild; + var i; + for (i = 0; i < numActivatedWidgets; i++) { + //alert("is it "+activatedWidgets[i].name); + if (activatedWidgets[i] == wid) { + break; + } + target = target.nextElementSibling; + } + // here, i is the index of the current widget + //alert(" "+i+" "+numActivatedWidgets); + if (i < numActivatedWidgets) { + whereW = i; + adjustWhereWidgets(false); } - - function csi(widget) { - return function(evt) { activating_widget(widget);}; + document.getElementById("getAttention").beginElement(); + var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); + if (ifce != null) { + wmjs_core_out_invoke_reply(coreOut.getAttentionMessage, ifce.get_message("getAttention"), wid, 1); // send return code 1 = success } +} - // - // widget closing action (WM callback) - // - function widget_close(wid) { - if (wid == null) { - return; - } - if (l_inf <= log_level) { - alert('[UI] widget_close:' + wid.name); +// +// implementation of core:out hide message +// this is a request by the widget to be hidden (some other widget (if any) is shown) +// +function coreOutHideImplementation(wid, args) { + //alert("core:out hide "+wid.name); + var target = widgetContainer.firstElementChild; + var i; + for (i = 0; i < numActivatedWidgets; i++) { + //alert("is it "+activatedWidgets[i].name); + if (activatedWidgets[i] == wid) { + break; + } + target = target.nextElementSibling; + } + // here, i is the index of the current widget + //alert("hide "+i+" "+numActivatedWidgets); + if (i < numActivatedWidgets) { + if (whereW > 0) { + whereW--; } - // maybe inform the widget that it is going to be deactivated - WidgetManager.corein_message(wid, "deactivate"); - var target = widgetContainer.firstElementChild; - var i; - for (i = 0; i < numActivatedWidgets; i++) { - if (activatedWidgets[i] == wid) { - break; - } - target = target.nextElementSibling; + else if (whereW < numActivatedWidgets - 1) { + whereW++; } - if (target != null) { - // move next widgets back one slot - recurseMoveAfterDelete(target); - // stop the subscene - if (target.firstElementChild != null) { - target.firstElementChild.setAttributeNS(xlinkns, "href", ""); - } - // end trying - widgetContainer.removeChild(target); + else { + return; } - wid.deactivate(); - wid.activated = false; - activatedWidgets.splice(i, 1); - numActivatedWidgets--; - whereW = (whereW >= i ? (whereW > 0 ? whereW - 1 : 0) : whereW); adjustWhereWidgets(false); - // if no more widgets, go back to the icons - if (numActivatedWidgets == 0) { - state = 'home'; - widgetContainer.setAttribute('display', 'none'); - homepage.setAttribute('display', 'inline'); - homebar.setAttribute('display', 'inline'); - execbar.setAttribute('display', 'none'); - arrows.setAttribute('display', 'inline'); - arrowsW.setAttribute('display', 'none'); - widgetAddList.setAttribute('display', 'none'); - } - if (!wid.permanent) { - WidgetManager.unload(wid, false); - } } - - // - // widget unloading action (WM callback) - // - function widget_remove(wid) { - if (l_deb <= log_level) { - alert('[UI] widget_remove:' + wid.name); - } - widget_close(wid); - WidgetManager.unload(wid, false); + var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); + if (ifce != null) { + wmjs_core_out_invoke_reply(coreOut.hideMessage, ifce.get_message("hide"), wid, 1); // send return code 1 = success } +} - // - // widget launcher action - // - function widget_launch(wid, scene_container) { - if (l_inf <= log_level) { - alert('[UI] widget_launch:' + wid.name); - } - var tmp = document.createElement("g"); - tmp.setAttribute("transform", "translate(" + (totalWidth * numActivatedWidgets) + ", 0)"); - widgetContainer.appendChild(tmp); - var icon = null; - alert("wid: " + wid.name + "|" + wid.shortName); - if (typeof wid.shortName != 'undefined') { - var container = document.getElementById(wid.shortName); - if (container != null) { - icon = container.getAttributeNS(xlinkns, 'href'); - } - } - if (icon != null && - sameFileIgnoringSVGView(icon, wid.main) && - endsWith(wid.main, '.svg')) { - // get the animation with id=shortName stored in mainDefs - scene_container = document.getElementById(wid.shortName); - // get the original use on it, used in the icon - var iconContainer = document.getElementById('iconContainer' + wid.shortName); - // create a new use - var use = document.createElement('use'); - // point to the animation - use.setAttributeNS(xlinkns, 'href', '#' + wid.shortName); - // resize the animation - scene_container.setAttribute("width", totalWidth); - scene_container.setAttribute("height", totalHeight - 120); - // resize the original use //TODO fix the aspect ratio conservation - var m, t = Math.abs(totalHeight - 120 - totalWidth) / 2; - if (totalWidth > totalHeight - 120) { - m = 50 / (totalHeight - 120); - iconContainer.setAttribute('transform', 'scale(' + m + ',' + m + ') translate(' + (-t) + ',0)'); - } else { - m = 50 / totalWidth; - iconContainer.setAttribute('transform', 'scale(' + m + ',' + m + ') translate(0,' + (-t) + ') '); - } - // add the new use as widget execution container - tmp.appendChild(use); - wid.activate(scene_container); - } else { - scene_container.setAttribute("width", totalWidth); - scene_container.setAttribute("height", totalHeight - 120); - tmp.appendChild(scene_container); - scene_container.setAttributeNS(xlinkns, 'href', wid.main); - wid.activate(scene_container); - } - wid.activated = true; - activatedWidgets.splice(numActivatedWidgets, 0, wid); - whereW = numActivatedWidgets; - numActivatedWidgets++; - adjustWhereWidgets(false); - wid.load_component = widget_load_component; - wid.permanent = true; - wid.on_load = function () { - WidgetManager.corein_message(this, 'setSize', 'width', totalWidth, 'height', totalHeight - 120, 'dpi', 96); - }; - // - if (log_level > l_inf) { - var i = 0; - alert(">>>>>>>>>>>>> " + wid.name + " interfaces:"); - for (; i < wid.num_interfaces; i++) { - alert("" + wid.get_interface(i).type); - } - } - // +// +// implementation of core:out requestDeactivate message +// this is a request by the widget to be stopped +// +function coreOutRequestDeactivateImplementation(wid, args) { + //alert("core:out hide "+wid.name); + var target = widgetContainer.firstElementChild; + var i; + for (i = 0; i < numActivatedWidgets; i++) { + //alert("is it "+activatedWidgets[i].name); + if (activatedWidgets[i] == wid) { + break; + } + target = target.nextElementSibling; + } + // here, i is the index of the current widget + //alert("hide "+i+" "+numActivatedWidgets); + if (i < numActivatedWidgets) { + widget_close(activatedWidgets[i]); + } + var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010"); + if (ifce != null) { + wmjs_core_out_invoke_reply(coreOut.requestDeactivateMessage, ifce.get_message("requestDeactivate"), wid, 1); // send return code 1 = success } +} - // - // widget load component (WM callback) - // - function widget_load_component(comp, is_unload) { - if (l_deb <= log_level) { - alert('[UI] widget_load_component:' + comp.name); - } - if (is_unload) { - widget_close(comp); - comp.parent = null; +// +// WM callback for when a component is activated by its parent +// +function widget_add(w) { + log(l_inf, "widget add " + w.name); + if (!w.activated) { + if (sameFileIgnoringSVGView(w.icon, w.main)) { + // same file in icon and main } else { - widget_add(comp); - comp.permanent = false; - comp.parent = this; + widget_launch(w, document.createElement("animation")); } + } else if (w.multipleInstances) { + var newwid = WidgetManager.open(w.manifest, null); + widget_launch(newwid, document.createElement("animation")); + } else { + return false; } + state = 'exec'; + widgetContainer.setAttribute('display', 'inline'); + homepage.setAttribute('display', 'none'); + homebar.setAttribute('display', 'none'); + execbar.setAttribute('display', 'inline'); + arrows.setAttribute('display', 'none'); + arrowsW.setAttribute('display', 'inline'); + widgetAddList.setAttribute('display', 'none'); + return true; +} - var upnp_renders = null, target_widgets = null; +function sameFileIgnoringSVGView(name1, name2) { + if (name1 == name2) { + return true; + } + if (name1 == null) { + return false; + } + var i1 = name1.indexOf("#"); + var i2 = name2.indexOf("#"); + if (i1 < 0) { + i1 = name1.length; + } + else { + i1--; + } + if (i2 < 0) { + i2 = name2.length; + } + else { + i2--; + } + return name1.substring(0, i1) == name2.substring(0, i2); +} - // - // widget remoting function - // - function on_widget_remote() { - if (WidgetManager.MPEGUStandardServiceProviders.length != 0 && numActivatedWidgets > 0) { - upnp_renders = selector_window(activatedWidgets[whereW]); - upnp_renders.on_select = function(item, wid) { - upnp_renders.unregister(root); - upnp_renders = null; - if (item == -1) { - return; - } - if (wid != null) { - alert("upnp_renders.on_select(" + item + "," + wid.name + ")"); - //WidgetManager.migrate_widget(UPnP.GetMediaRenderer(item), wid); - WidgetManager.migrate_widget(WidgetManager.get_mpegu_service_providers(item), wid); - widget_close(wid); - } - }; - upnp_renders.register(root); +// +// recompute the number of widgets loaded currently +// +function getNbWidgets() { + var i, nbWidgets = 0; + for (i = 0; i < WidgetManager.num_widgets; i++) { + var w = WidgetManager.get(i); + if (w != null && w.loaded) { + nbWidgets++; } } + return nbWidgets; +} - // - // creates the menu of available targets for pushing a widget elsewhere - // - function selector_window(widget) { - var i, count, render; - var selector = document.createElement('g'), obj, child; - selector.setAttribute('transform', 'translate(10,10)'); - count = WidgetManager.MPEGUStandardServiceProviders.length; - selector.appendChild(rect(0, 0, 300, 20 * (count + 1), 'white', 'black')); - for (i = 0; i < count; i++) { - render = WidgetManager.MPEGUStandardServiceProviders[i]; - obj = createtext(render.Name, 'black', 5, 17 + (20 * i), 15, 'sans-serif'); - obj.setAttribute('id', "selector" + i); - selector.appendChild(obj); - obj.addEventListener('mouseover', sw1("selector" + i), false); - obj.addEventListener('mouseout', sw2("selector" + i), false); - obj.addEventListener('click', sw3(i, widget), false); +// +// just resize the window and viewport, and initialize the first time this is called +// +function resize() { + if (init) { + initialize(); + } + if (document.documentElement.viewport.width == previousWidth && document.documentElement.viewport.height == previousHeight) { + return; + } + if (l_deb < log_level) { + alert("[UI] start initialize() w:" + document.documentElement.viewport.width + " h:" + document.documentElement.viewport.height); + } + adaptLayoutToSize(); + // start by filling the "home page" with known icons + where = 0; + var nbWidgets = getNbWidgets(); + maxwhere = ((nbWidgets - 1) - ((nbWidgets - 1) % iconsPerPage)) / iconsPerPage; + var wid; + var iconIterator = document.getElementById("icons").firstElementChild; + var position = 0; + for (i = 1; i <= WidgetManager.num_widgets; i++) { + wid = WidgetManager.get(i - 1); + // alert("build:"+wid.main+" "+wid.loaded); + if (wid.loaded) { + insert_icon(wid, position, i - 1, iconIterator); + WidgetManager.corein_message(wid, 'setSize', 'width', totalWidth, 'height', totalHeight - 120, 'dpi', 96); + position++; + if (iconIterator != null) { + iconIterator = iconIterator.nextElementSibling; + } } - obj = createtext('Cancel', 'rgb(0,0,120)', 55, 17 + (20 * i), 15, 'sans-serif'); - obj.setAttribute('id', "cancel"); - selector.appendChild(obj); - obj.addEventListener('mouseover', function(evt) { document.getElementById("cancel").setAttribute("fill", "red"); }, false); - obj.addEventListener('mouseout', function(evt) { document.getElementById("cancel").setAttribute("fill", "black"); }, false); - obj.addEventListener('click', function(evt) { upnp_renders.on_select(-1, null); }, false); - selector.register = function(disp) { - disp.appendChild(this); - }; - selector.unregister = function(disp) { - disp.removeChild(this); - }; - return selector; } + adjustwhere(false); + adjustWhereWidgets(false); + previousWidth = document.documentElement.viewport.width; + previousHeight = document.documentElement.viewport.height; + gpac.setOption("Widgets", "LastWMWidth", '' + previousWidth); + gpac.setOption("Widgets", "LastWMHeight", '' + previousHeight); +} - function sw1(s) { - return function(evt) { document.getElementById(s).setAttribute("fill", "blue"); }; - } +// +// function inserting an icon on the home page +// +function insert_icon(widget, position, widgetIndex, previousIcon) { + if (l_deb < log_level) { + alert("[UI] insert_icon: " + widget.shortName + " " + position + " " + widgetIndex + " WMnw:" + WidgetManager.num_widgets); + } + widget.loaded = true; + if (l_deb < log_level) { + alert("[UI] widget name: " + widget.name); + } + var icon = null, original = null; + for (var i = 0; i < widget.icons.length; i++) { + // default to the first icon even if not of the preferred type + if (i == 0) { + icon = widget.icons[0].relocated_src; + //original = widget.icons[0].original; + // alert("choosing default icon " + icon); + } + // check for preferred type + if (widget.icons[i].relocated_src.indexOf(preferredIconType) > 0) { + icon = widget.icons[i].relocated_src; + //original = widget.icons[i].original; + break; + } + } + var shortName = widget.shortName; + if (typeof shortName == 'undefined') { + shortName = widget.name.substring(0, 9); + } + createIconSVGdecoration(previousIcon, widget, (((position % iconNbHoriz) * 80) + ((80 * (position - (position % iconsPerPage))) / iconNbVert)), + ((((position % iconsPerPage) - (position % iconNbHoriz)) / iconNbHoriz) * 80), "icons", icon, + shortName, widgetIndex); +} - function sw2(s) { - return function(evt) { document.getElementById(s).setAttribute("fill", "black"); }; - } +// constant +// const corein = "urn:mpeg:mpegu:schema:widgets:core:in:2010"; - function sw3(si, widget) { - return function(evt) { upnp_renders.on_select(si, widget); }; +// +// commodity method to empty a list of children +// +function removeAllChildren(o) { + if (o != null && o.hasChildNodes()) { + while (o.childNodes.length >= 1) { + o.removeChild(o.firstChild); + } } +} - // - // when a widget is pushed to here, install the widget and execute it - // - function onMediaConnect(url, src_ip) { - if (l_inf <= log_level) { - alert('[UI] onMediaConnect :\"' + url + '\"'); +// +// create the home page icon with all its behaviours +// +function createIconSVGdecoration(previousIcon, widget, x, y, fatherId, iconUrl, name, widIndex) { + var g, g2; + if (l_inf < log_level) { + alert("[UI] createIconSVGdecoration " + iconUrl + " " + x + " " + y); + } + if (previousIcon != null) { + g = previousIcon; + } else { + g = document.createElement("g"); + document.getElementById(fatherId).appendChild(g); + } + g.setAttribute("transform", 'translate(' + x + ',' + y + ')'); + if (previousIcon != null) { + g2 = g.firstElementChild; + } else { + g2 = document.createElement("g"); + g2.setAttribute("transform", 'translate(15,10)'); + g.appendChild(g2); + } + if (iconUrl == null || iconUrl == "") { + iconUrl = "icons/face-surprise.svg"; + } + // + // process differently cases where widget.icon == widget.main + // + var container; + if (sameFileIgnoringSVGView(iconUrl, widget.main) && widget.main.indexOf('.svg') >= 0) { + // see if the animation already exists + container = document.getElementById(name); + if (container == null) { + // if the animation does not exist yet, create it + container = media('animation', iconUrl, 50, 50); + // store the animation in the main defs + document.getElementById("mainDefs").appendChild(container); + container.setAttribute('id', name); } - if (WidgetManager.probe(url)) { - var w = WidgetManager.open(url, src_ip); - if (w == null) { - return; - } - widget_add(w); - adjustWhereWidgets(false); - w.permanent = false; + if (previousIcon == null) { + // put the container in a use + var use = document.createElement("use"); + use.setAttribute('id', 'iconContainer' + name); + use.setAttributeNS(xlinkns, 'href', '#' + name); + g2.appendChild(use); } + } else { + if (previousIcon == null) { + container = appropriateElementForMedia(iconUrl, 50, 50); + container.setAttribute('id', name); + g2.appendChild(container); + } + } + if (previousIcon == null) { + g2 = document.createElement("g"); + g2.setAttribute("transform", 'translate(40,70)'); + g.appendChild(g2); + var anim = createtext(name, 'white', 0, 0, 14, 'Arial Unicode MS'); + anim.setAttribute("text-anchor", "middle"); + anim.setAttribute("display-align", "center"); + g2.appendChild(anim); + var rect = invisible_rect(80, 80); + g.appendChild(rect); + rect.addEventListener("click", csi(widget), false); } +} - // - // file list vars - // - var flstart = 0,fllist = null,maxFileNames = 14; +function csi(widget) { + return function(evt) { activating_widget(widget);}; +} - // - // create a file menu in the main screen, allowing to navigate directories and choose widget config files - // - function on_widget_add_menu() { - state = 'list'; +// +// widget closing action (WM callback) +// +function widget_close(wid) { + if (wid == null) { + return; + } + if (l_inf <= log_level) { + alert('[UI] widget_close:' + wid.name); + } + // maybe inform the widget that it is going to be deactivated + WidgetManager.corein_message(wid, "deactivate"); + var target = widgetContainer.firstElementChild; + var i; + for (i = 0; i < numActivatedWidgets; i++) { + if (activatedWidgets[i] == wid) { + break; + } + target = target.nextElementSibling; + } + if (target != null) { + // move next widgets back one slot + recurseMoveAfterDelete(target); + // stop the subscene + if (target.firstElementChild != null) { + target.firstElementChild.setAttributeNS(xlinkns, "href", ""); + } + // end trying + widgetContainer.removeChild(target); + } + wid.deactivate(); + wid.activated = false; + activatedWidgets.splice(i, 1); + numActivatedWidgets--; + whereW = (whereW >= i ? (whereW > 0 ? whereW - 1 : 0) : whereW); + adjustWhereWidgets(false); + // if no more widgets, go back to the icons + if (numActivatedWidgets == 0) { + state = 'home'; widgetContainer.setAttribute('display', 'none'); - homepage.setAttribute('display', 'none'); - homebar.setAttribute('display', 'none'); - execbar.setAttribute('display', 'inline'); - arrows.setAttribute('display', 'none'); + homepage.setAttribute('display', 'inline'); + homebar.setAttribute('display', 'inline'); + execbar.setAttribute('display', 'none'); + arrows.setAttribute('display', 'inline'); arrowsW.setAttribute('display', 'none'); - widgetAddList.setAttribute('display', 'inline'); - maxFileNames = Math.round(((iconNbVert * 80) / 25) - 1.4); - isThisAScan = false; - refillWidgetAddList(false); + widgetAddList.setAttribute('display', 'none'); + } + if (!wid.permanent) { + WidgetManager.unload(wid, false); } +} - // - // create a file menu in the main screen, allowing to navigate directories and choose a directory to scan for widgets - // and load all their icons - // - function on_dir_scan() { - state = 'list'; - widgetContainer.setAttribute('display', 'none'); - homepage.setAttribute('display', 'none'); - homebar.setAttribute('display', 'none'); - execbar.setAttribute('display', 'inline'); - arrows.setAttribute('display', 'none'); - arrowsW.setAttribute('display', 'none'); - widgetAddList.setAttribute('display', 'inline'); - maxFileNames = Math.round(((iconNbVert * 80) / 25) - 1.4); - isThisAScan = true; - refillWidgetAddList(true); +// +// widget unloading action (WM callback) +// +function widget_remove(wid) { + if (l_deb <= log_level) { + alert('[UI] widget_remove:' + wid.name); } + widget_close(wid); + WidgetManager.unload(wid, false); +} +// +// widget launcher action +// +function widget_launch(wid, scene_container) { + if (l_inf <= log_level) { + alert('[UI] widget_launch:' + wid.name); + } + var tmp = document.createElement("g"); + tmp.setAttribute("transform", "translate(" + (totalWidth * numActivatedWidgets) + ", 0)"); + widgetContainer.appendChild(tmp); + var icon = null; + alert("wid: " + wid.name + "|" + wid.shortName); + if (typeof wid.shortName != 'undefined') { + var container = document.getElementById(wid.shortName); + if (container != null) { + icon = container.getAttributeNS(xlinkns, 'href'); + } + } + if (icon != null && + sameFileIgnoringSVGView(icon, wid.main) && + endsWith(wid.main, '.svg')) { + // get the animation with id=shortName stored in mainDefs + scene_container = document.getElementById(wid.shortName); + // get the original use on it, used in the icon + var iconContainer = document.getElementById('iconContainer' + wid.shortName); + // create a new use + var use = document.createElement('use'); + // point to the animation + use.setAttributeNS(xlinkns, 'href', '#' + wid.shortName); + // resize the animation + scene_container.setAttribute("width", totalWidth); + scene_container.setAttribute("height", totalHeight - 120); + // resize the original use + //should do: fix the aspect ratio conservation + var m, t = Math.abs(totalHeight - 120 - totalWidth) / 2; + if (totalWidth > totalHeight - 120) { + m = 50 / (totalHeight - 120); + iconContainer.setAttribute('transform', 'scale(' + m + ',' + m + ') translate(' + (-t) + ',0)'); + } else { + m = 50 / totalWidth; + iconContainer.setAttribute('transform', 'scale(' + m + ',' + m + ') translate(0,' + (-t) + ') '); + } + // add the new use as widget execution container + tmp.appendChild(use); + wid.activate(scene_container); + } else { + scene_container.setAttribute("width", totalWidth); + scene_container.setAttribute("height", totalHeight - 120); + tmp.appendChild(scene_container); + scene_container.setAttributeNS(xlinkns, 'href', wid.main); + wid.activate(scene_container); + } + wid.activated = true; + activatedWidgets.splice(numActivatedWidgets, 0, wid); + whereW = numActivatedWidgets; + numActivatedWidgets++; + adjustWhereWidgets(false); + wid.load_component = widget_load_component; + wid.permanent = true; + wid.on_load = function () { + WidgetManager.corein_message(this, 'setSize', 'width', totalWidth, 'height', totalHeight - 120, 'dpi', 96); + }; + // + if (log_level > l_inf) { + var i = 0; + alert(">>>>>>>>>>>>> " + wid.name + " interfaces:"); + for (; i < wid.num_interfaces; i++) { + alert("" + wid.get_interface(i).type); + } + } // - // remove all installed icons - // - function on_clean_up() { - var i; - //if (l_inf <= log_level) alert('[UI] unloading ' + WidgetManager.num_widgets + ' widgets'); - for (i = WidgetManager.num_widgets - 1; i >= 0; i--) { - var w = WidgetManager.get(i); - if (w.loaded) { - alert("unloading " + w.name); - w.loaded = false; - WidgetManager.unload(w, false); +} + +// +// widget load component (WM callback) +// +function widget_load_component(comp, is_unload) { + if (l_deb <= log_level) { + alert('[UI] widget_load_component:' + comp.name); + } + if (is_unload) { + widget_close(comp); + comp.parent = null; + } else { + widget_add(comp); + comp.permanent = false; + comp.parent = this; + } +} + +var upnp_renders = null, target_widgets = null; + +// +// widget remoting function +// +function on_widget_remote() { + if (WidgetManager.MPEGUStandardServiceProviders.length != 0 && numActivatedWidgets > 0) { + upnp_renders = selector_window(activatedWidgets[whereW]); + upnp_renders.on_select = function(item, wid) { + upnp_renders.unregister(root); + upnp_renders = null; + if (item == -1) { + return; + } + if (wid != null) { + alert("upnp_renders.on_select(" + item + "," + wid.name + ")"); + //WidgetManager.migrate_widget(UPnP.GetMediaRenderer(item), wid); + WidgetManager.migrate_widget(WidgetManager.get_mpegu_service_providers(item), wid); + widget_close(wid); } + }; + upnp_renders.register(root); + } +} + +// +// creates the menu of available targets for pushing a widget elsewhere +// +function selector_window(widget) { + var i, count, render; + var selector = document.createElement('g'), obj, child; + selector.setAttribute('transform', 'translate(10,10)'); + count = WidgetManager.MPEGUStandardServiceProviders.length; + selector.appendChild(rect(0, 0, 300, 20 * (count + 1), 'white', 'black')); + for (i = 0; i < count; i++) { + render = WidgetManager.MPEGUStandardServiceProviders[i]; + obj = createtext(render.Name, 'black', 5, 17 + (20 * i), 15, 'sans-serif'); + obj.setAttribute('id', "selector" + i); + selector.appendChild(obj); + obj.addEventListener('mouseover', sw1("selector" + i), false); + obj.addEventListener('mouseout', sw2("selector" + i), false); + obj.addEventListener('click', sw3(i, widget), false); + } + obj = createtext('Cancel', 'rgb(0,0,120)', 55, 17 + (20 * i), 15, 'sans-serif'); + obj.setAttribute('id', "cancel"); + selector.appendChild(obj); + obj.addEventListener('mouseover', function(evt) { document.getElementById("cancel").setAttribute("fill", "red"); }, false); + obj.addEventListener('mouseout', function(evt) { document.getElementById("cancel").setAttribute("fill", "black"); }, false); + obj.addEventListener('click', function(evt) { upnp_renders.on_select(-1, null); }, false); + selector.register = function(disp) { + disp.appendChild(this); + }; + selector.unregister = function(disp) { + disp.removeChild(this); + }; + return selector; +} + +function sw1(s) { + return function(evt) { document.getElementById(s).setAttribute("fill", "blue"); }; +} + +function sw2(s) { + return function(evt) { document.getElementById(s).setAttribute("fill", "black"); }; +} + +function sw3(si, widget) { + return function(evt) { upnp_renders.on_select(si, widget); }; +} + +// +// when a widget is pushed to here, install the widget and execute it +// +function onMediaConnect(url, src_ip) { + if (l_inf <= log_level) { + alert('[UI] onMediaConnect :\"' + url + '\"'); + } + if (WidgetManager.probe(url)) { + var w = WidgetManager.open(url, src_ip); + if (w == null) { + return; } - where = 0; - maxwhere = 0; - removeAllChildren(document.getElementById("icons")); - adjustwhere(false); + widget_add(w); + adjustWhereWidgets(false); + w.permanent = false; } +} - // - // install, but do not launch, the widget whose config.xml has been chosen, and return to the home page - // - function widgetInstall(uri, manual, temporary, parent_wid) { - var wid, j, count = WidgetManager.num_widgets, nbWidgets = getNbWidgets(); - for (j = 0; j < count; j++) { - wid = WidgetManager.get(j); - if (wid.url == uri) { - if (wid.loaded) { - break; - } - if (temporary) { - wid.permanent = false; - } - else { - insert_icon(wid, nbWidgets, nbWidgets); - } +// +// file list vars +// +var flstart = 0,fllist = null,maxFileNames = 14; + +// +// create a file menu in the main screen, allowing to navigate directories and choose widget config files +// +function on_widget_add_menu() { + state = 'list'; + widgetContainer.setAttribute('display', 'none'); + homepage.setAttribute('display', 'none'); + homebar.setAttribute('display', 'none'); + execbar.setAttribute('display', 'inline'); + arrows.setAttribute('display', 'none'); + arrowsW.setAttribute('display', 'none'); + widgetAddList.setAttribute('display', 'inline'); + maxFileNames = Math.round(((iconNbVert * 80) / 25) - 1.4); + isThisAScan = false; + refillWidgetAddList(false); +} + +// +// create a file menu in the main screen, allowing to navigate directories and choose a directory to scan for widgets +// and load all their icons +// +function on_dir_scan() { + state = 'list'; + widgetContainer.setAttribute('display', 'none'); + homepage.setAttribute('display', 'none'); + homebar.setAttribute('display', 'none'); + execbar.setAttribute('display', 'inline'); + arrows.setAttribute('display', 'none'); + arrowsW.setAttribute('display', 'none'); + widgetAddList.setAttribute('display', 'inline'); + maxFileNames = Math.round(((iconNbVert * 80) / 25) - 1.4); + isThisAScan = true; + refillWidgetAddList(true); +} + +// +// remove all installed icons +// +function on_clean_up() { + var i; + //if (l_inf <= log_level) alert('[UI] unloading ' + WidgetManager.num_widgets + ' widgets'); + for (i = WidgetManager.num_widgets - 1; i >= 0; i--) { + var w = WidgetManager.get(i); + if (w.loaded) { + alert("unloading " + w.name); + w.loaded = false; + WidgetManager.unload(w, false); + } + } + where = 0; + maxwhere = 0; + removeAllChildren(document.getElementById("icons")); + adjustwhere(false); +} + +// +// install, but do not launch, the widget whose config.xml has been chosen, and return to the home page +// +function widgetInstall(uri, manual, temporary, parent_wid) { + var wid, j, count = WidgetManager.num_widgets, nbWidgets = getNbWidgets(); + for (j = 0; j < count; j++) { + wid = WidgetManager.get(j); + if (wid.url == uri) { + if (wid.loaded) { + break; } - } - if (j == count) { - wid = WidgetManager.open(uri, null, parent_wid); - if (wid != null) { - if (temporary) { - wid.permanent = false; - } - else { - insert_icon(wid, nbWidgets, nbWidgets); - } + if (temporary) { + wid.permanent = false; + } + else { + insert_icon(wid, nbWidgets, nbWidgets); } } - if (manual) { - return wid; + } + if (j == count) { + wid = WidgetManager.open(uri, null, parent_wid); + if (wid != null) { + if (temporary) { + wid.permanent = false; + } + else { + insert_icon(wid, nbWidgets, nbWidgets); + } } - state = 'home'; - widgetContainer.setAttribute('display', 'none'); - homepage.setAttribute('display', 'inline'); - homebar.setAttribute('display', 'inline'); - execbar.setAttribute('display', 'none'); - arrows.setAttribute('display', 'inline'); - arrowsW.setAttribute('display', 'none'); - removeAllChildren(widgetAddList); - maxwhere = ((nbWidgets - 1) - ((nbWidgets - 1) % iconsPerPage)) / iconsPerPage; - where = maxwhere; - adjustwhere(false); + } + if (manual) { return wid; } + state = 'home'; + widgetContainer.setAttribute('display', 'none'); + homepage.setAttribute('display', 'inline'); + homebar.setAttribute('display', 'inline'); + execbar.setAttribute('display', 'none'); + arrows.setAttribute('display', 'inline'); + arrowsW.setAttribute('display', 'none'); + removeAllChildren(widgetAddList); + maxwhere = ((nbWidgets - 1) - ((nbWidgets - 1) % iconsPerPage)) / iconsPerPage; + where = maxwhere; + adjustwhere(false); + return wid; +} - // - // clean up file list space and refill it - // - function refillWidgetAddList(flag) { - removeAllChildren(widgetAddList); - fllist = null; - flstart = 0; - fllist = gpac.enum_directory(gpac.last_working_directory, "", false); - fillWidgetAddList(flag); - } +// +// clean up file list space and refill it +// +function refillWidgetAddList(flag) { + removeAllChildren(widgetAddList); + fllist = null; + flstart = 0; + fllist = gpac.enum_directory(gpac.last_working_directory, "", false); + fillWidgetAddList(flag); +} - // - // go to parent directory - // - function flUpDir(evt) { - var s = gpac.last_working_directory; - if (l_inf <= log_level) { - alert("[UI] lwd:" + gpac.last_working_directory); - } - var index = s.lastIndexOf("\\"); +// +// go to parent directory +// +function flUpDir(evt) { + var s = gpac.last_working_directory; + if (l_inf <= log_level) { + alert("[UI] lwd:" + gpac.last_working_directory); + } + var index = s.lastIndexOf("\\"); + if (index != -1) { + gpac.last_working_directory = s.substring(0, index); + refillWidgetAddList(isThisAScan); + } else { + index = s.lastIndexOf("/"); if (index != -1) { gpac.last_working_directory = s.substring(0, index); refillWidgetAddList(isThisAScan); } else { - index = s.lastIndexOf("/"); - if (index != -1) { - gpac.last_working_directory = s.substring(0, index); - refillWidgetAddList(isThisAScan); - } else { - gpac.last_working_directory = "/"; - refillWidgetAddList(isThisAScan); - } + gpac.last_working_directory = "/"; + refillWidgetAddList(isThisAScan); } } +} - // - // go to a named directory - // - function flGoTo(newDir) { - //alert("goto "+newDir); - var s = gpac.last_working_directory; - if (s == "/") { - gpac.last_working_directory = newDir; - } else { - var c = s.charAt(s.length - 1); - if (c != '\\' && c != '/') { - s += "/"; - } - gpac.last_working_directory = s + newDir; - } - //alert(gpac.last_working_directory); - refillWidgetAddList(isThisAScan); - } +// +// go to a named directory +// +function flGoTo(newDir) { + //alert("goto "+newDir); + var s = gpac.last_working_directory; + if (s == "/") { + gpac.last_working_directory = newDir; + } else { + var c = s.charAt(s.length - 1); + if (c != '\\' && c != '/') { + s += "/"; + } + gpac.last_working_directory = s + newDir; + } + //alert(gpac.last_working_directory); + refillWidgetAddList(isThisAScan); +} - // - // if the directory contains more files that can be shown, show previous page of file names - // - function flPrevFiles(evt) { - if (flstart == 0) { - return; - } - flstart -= maxFileNames; - if (flstart < 0) { - flstart = 0; - } - removeAllChildren(widgetAddList); - fillWidgetAddList(isThisAScan); +// +// if the directory contains more files that can be shown, show previous page of file names +// +function flPrevFiles(evt) { + if (flstart == 0) { + return; } - - // - // if the directory contains more files that can be shown, show next page of file names - // - function flNextFiles(evt) { - if (flstart + maxFileNames < fllist.length) { - flstart += maxFileNames; - removeAllChildren(widgetAddList); - fillWidgetAddList(isThisAScan); - } + flstart -= maxFileNames; + if (flstart < 0) { + flstart = 0; } + removeAllChildren(widgetAddList); + fillWidgetAddList(isThisAScan); +} - // - // scan the current directory recursively for widgets, clean up and return to home page - // - function flScanDir(evt) { - scan_directory(gpac.last_working_directory); - state = 'home'; - var nbWidgets = getNbWidgets(); - widgetContainer.setAttribute('display', 'none'); - homepage.setAttribute('display', 'inline'); - homebar.setAttribute('display', 'inline'); - execbar.setAttribute('display', 'none'); - arrows.setAttribute('display', 'inline'); - arrowsW.setAttribute('display', 'none'); +// +// if the directory contains more files that can be shown, show next page of file names +// +function flNextFiles(evt) { + if (flstart + maxFileNames < fllist.length) { + flstart += maxFileNames; removeAllChildren(widgetAddList); - maxwhere = ((nbWidgets - 1) - ((nbWidgets - 1) % iconsPerPage)) / iconsPerPage; - where = maxwhere; - adjustwhere(false); + fillWidgetAddList(isThisAScan); } +} - // - // scanning - // - function scan_directory(dir) { - var ii, j, count, list, w, uri, loadedWidgets = 0; - list = gpac.enum_directory(dir, '.xml;.wgt', 0); - for (ii = 0; ii < list.length; ii++) { - uri = list[ii].path + list[ii].name; - if (list[ii].directory) { - scan_directory(uri); - } else { - count = WidgetManager.num_widgets; - for (j = 0; j < count; j++) { - var wid = WidgetManager.get(j); +// +// scan the current directory recursively for widgets, clean up and return to home page +// +function flScanDir(evt) { + scan_directory(gpac.last_working_directory); + state = 'home'; + var nbWidgets = getNbWidgets(); + widgetContainer.setAttribute('display', 'none'); + homepage.setAttribute('display', 'inline'); + homebar.setAttribute('display', 'inline'); + execbar.setAttribute('display', 'none'); + arrows.setAttribute('display', 'inline'); + arrowsW.setAttribute('display', 'none'); + removeAllChildren(widgetAddList); + maxwhere = ((nbWidgets - 1) - ((nbWidgets - 1) % iconsPerPage)) / iconsPerPage; + where = maxwhere; + adjustwhere(false); +} + +// +// scanning +// +function scan_directory(dir) { + var ii, j, count, list, w, uri, loadedWidgets = 0; + list = gpac.enum_directory(dir, '.xml;.wgt', 0); + for (ii = 0; ii < list.length; ii++) { + uri = list[ii].path + list[ii].name; + if (list[ii].directory) { + scan_directory(uri); + } else { + count = WidgetManager.num_widgets; + for (j = 0; j < count; j++) { + var wid = WidgetManager.get(j); + if (wid.loaded) { + loadedWidgets++; + } + if (wid.url == uri) { if (wid.loaded) { - loadedWidgets++; - } - if (wid.url == uri) { - if (wid.loaded) { - break; - } - insert_icon(wid, getNbWidgets(), j); break; } + insert_icon(wid, getNbWidgets(), j); + break; } - if (j == count) { - w = WidgetManager.open(uri, null); - if (w != null) { - insert_icon(w, loadedWidgets, WidgetManager.num_widgets - 1); - } + } + if (j == count) { + w = WidgetManager.open(uri, null); + if (w != null) { + insert_icon(w, loadedWidgets, WidgetManager.num_widgets - 1); } } } } +} - // - // create the up, prev, next button, show current directory and as many file names as possible - // the file names are active: clicking on a directory name goes to that directory - // clicking on a file tries to load that file as a widget - // - function fillWidgetAddList(flag) { - if (flag) { - widgetAddList.appendChild(use("cartoucheflag")); - document.getElementById("dirflag").textContent = gpac.last_working_directory; - } else { - widgetAddList.appendChild(use("cartouche")); - document.getElementById("dir").textContent = gpac.last_working_directory; - } - // next lines are file names - var obj; - for (i = 0; i < (fllist.length - flstart) && i < maxFileNames; i++) { - obj = use("fileMenuElement" + i); - obj.setAttribute('transform', 'translate(0,' + (25 * (i + 1)) + ')'); - widgetAddList.appendChild(obj); - document.getElementById("fileMenuElement" + i + "u").setAttributeNS(xlinkns, 'href', "#" + (fllist[i + flstart].directory ? 'folder' : 'new')); - document.getElementById("fileMenuElement" + i + "t").textContent = fllist[i + flstart].name; - if (obj.listener != null) { - obj.removeEventListener("click", obj.listener); - } - if (fllist[i + flstart].directory) { - obj.listener = createGoto(escaping(fllist[i + flstart].name)); - obj.addEventListener("click", obj.listener, false); - } else if (isWidgetFileName(fllist[i + flstart].name)) { - obj.listener = createWidgetInstall(escaping(gpac.last_working_directory + '/' + fllist[i + flstart].name)); - obj.addEventListener("click", obj.listener, false); - } +// +// create the up, prev, next button, show current directory and as many file names as possible +// the file names are active: clicking on a directory name goes to that directory +// clicking on a file tries to load that file as a widget +// +function fillWidgetAddList(flag) { + if (flag) { + widgetAddList.appendChild(use("cartoucheflag")); + document.getElementById("dirflag").textContent = gpac.last_working_directory; + } else { + widgetAddList.appendChild(use("cartouche")); + document.getElementById("dir").textContent = gpac.last_working_directory; + } + // next lines are file names + var obj; + for (i = 0; i < (fllist.length - flstart) && i < maxFileNames; i++) { + obj = use("fileMenuElement" + i); + obj.setAttribute('transform', 'translate(0,' + (25 * (i + 1)) + ')'); + widgetAddList.appendChild(obj); + document.getElementById("fileMenuElement" + i + "u").setAttributeNS(xlinkns, 'href', "#" + (fllist[i + flstart].directory ? 'folder' : 'new')); + document.getElementById("fileMenuElement" + i + "t").textContent = fllist[i + flstart].name; + if (obj.listener != null) { + obj.removeEventListener("click", obj.listener); + } + if (fllist[i + flstart].directory) { + obj.listener = createGoto(escaping(fllist[i + flstart].name)); + obj.addEventListener("click", obj.listener, false); + } else if (isWidgetFileName(fllist[i + flstart].name)) { + obj.listener = createWidgetInstall(escaping(gpac.last_working_directory + '/' + fllist[i + flstart].name)); + obj.addEventListener("click", obj.listener, false); } } +} - function createGoto(s) { - return function () { - flGoTo(s); - }; - } +function createGoto(s) { + return function () { + flGoTo(s); + }; +} - function createWidgetInstall(s) { - return function () { - widgetInstall(s, false, false, null); - }; - } +function createWidgetInstall(s) { + return function () { + widgetInstall(s, false, false, null); + }; +} - // // // // // // // // // // // // // // // - // function library - // // // // // // // // // // // // // // // +// // // // // // // // // // // // // // // +// function library +// // // // // // // // // // // // // // // - function isWidgetFileName(s) { - if (endsWith(s, 'config.xml')) { - return true; - } - if (endsWith(s, '.wgt')) { - return true; - } - return false; +function isWidgetFileName(s) { + if (endsWith(s, 'config.xml')) { + return true; } - - // - // replace globally \ with / in a string - // - function escaping(s) { - s = s.replace(/\\/g, '/'); - return s; + if (endsWith(s, '.wgt')) { + return true; } + return false; +} - // - // create rect - // - function rect(x, y, w, h, fill, stroke, id) { - var child = document.createElement('rect'); - if (id != null) { - child.setAttribute('id', id); - } - child.setAttribute('x', x); - child.setAttribute('y', y); - child.setAttribute('width', w); - child.setAttribute('height', h); - child.setAttribute('fill', fill); - child.setAttribute('stroke', stroke); - return child; - } +// +// replace globally \ with / in a string +// +function escaping(s) { + s = s.replace(/\\/g, '/'); + return s; +} - // - // create text - // - function createtext(content, fill, x, y, size, family) { - var child = document.createElement('text'); - child.setAttribute('fill', fill); - child.textContent = content; - child.setAttribute('x', x); - child.setAttribute('y', y); - child.setAttribute('font-size', size); - child.setAttribute('font-family', family); - return child; - } +// +// create rect +// +function rect(x, y, w, h, fill, stroke, id) { + var child = document.createElement('rect'); + if (id != null) { + child.setAttribute('id', id); + } + child.setAttribute('x', x); + child.setAttribute('y', y); + child.setAttribute('width', w); + child.setAttribute('height', h); + child.setAttribute('fill', fill); + child.setAttribute('stroke', stroke); + return child; +} - // - // create invisible rect getting all events - // - function invisible_rect(w, h) { - var child = document.createElement('rect'); - child.setAttribute('width', w); - child.setAttribute('height', h); - child.setAttribute('fill', 'none'); - child.setAttribute('stroke', 'none'); - child.setAttribute('pointer-events', 'all'); - return child; - } +// +// create text +// +function createtext(content, fill, x, y, size, family) { + var child = document.createElement('text'); + child.setAttribute('fill', fill); + child.textContent = content; + child.setAttribute('x', x); + child.setAttribute('y', y); + child.setAttribute('font-size', size); + child.setAttribute('font-family', family); + return child; +} - // - // create animation - // - function media(etype, uri, w, h) { - var child = document.createElement(etype); - child.setAttributeNS(xlinkns, 'href', uri); - child.setAttribute('width', w); - child.setAttribute('height', h); - if (etype == 'animation') { - child.setAttributeNS('http://gpac.sourceforge.net/svg-extensions', 'use-as-primary', 'false'); - } - return child; - } +// +// create invisible rect getting all events +// +function invisible_rect(w, h) { + var child = document.createElement('rect'); + child.setAttribute('width', w); + child.setAttribute('height', h); + child.setAttribute('fill', 'none'); + child.setAttribute('stroke', 'none'); + child.setAttribute('pointer-events', 'all'); + return child; +} - // - // create use - // - function use(uri) { - var child = document.createElement('use'); - child.setAttributeNS(xlinkns, 'href', '#' + uri); - return child; - } +// +// create animation +// +function media(etype, uri, w, h) { + var child = document.createElement(etype); + child.setAttributeNS(xlinkns, 'href', uri); + child.setAttribute('width', w); + child.setAttribute('height', h); + if (etype == 'animation') { + child.setAttributeNS('http://gpac.sourceforge.net/svg-extensions', 'use-as-primary', 'false'); + } + return child; +} - // - // create appropriate element for media reference by the given uri - // - function appropriateElementForMedia(uri, w, h) { - if (uri.indexOf('#') != -1) { - return media('animation', uri, w, h); - } - if (endsWith(uri, '.svg')) { - return media('animation', uri, w, h); - } - if (endsWith(uri, '.bt')) { - return media('animation', uri, w, h); - } - if (endsWith(uri, '.png')) { - return media('image', uri, w, h); - } - if (endsWith(uri, '.jpg')) { - return media('image', uri, w, h); - } - if (endsWith(uri, '.gif')) { - return media('image', uri, w, h); - } - if (l_war <= log_level) { - alert("[UI] WARNING: bad suffix for an icon URI: " + uri); - } +// +// create use +// +function use(uri) { + var child = document.createElement('use'); + child.setAttributeNS(xlinkns, 'href', '#' + uri); + return child; +} + +// +// create appropriate element for media reference by the given uri +// +function appropriateElementForMedia(uri, w, h) { + if (uri.indexOf('#') != -1) { + return media('animation', uri, w, h); + } + if (endsWith(uri, '.svg')) { + return media('animation', uri, w, h); + } + if (endsWith(uri, '.bt')) { + return media('animation', uri, w, h); + } + if (endsWith(uri, '.png')) { + return media('image', uri, w, h); + } + if (endsWith(uri, '.jpg')) { + return media('image', uri, w, h); + } + if (endsWith(uri, '.gif')) { return media('image', uri, w, h); } + if (l_war <= log_level) { + alert("[UI] WARNING: bad suffix for an icon URI: " + uri); + } + return media('image', uri, w, h); +} - // - // substitute for the useful predefined function endsWith - // - function endsWith(s1, s2) { - return s1.toLowerCase().substring(s1.length - s2.length) == s2; - } - - // export the resize function as the resize member of iphone_wm_gui, as well as other functions - return { - resize: resize, - left_button: left_button, - right_button: right_button, - left_buttonW: left_buttonW, - right_buttonW: right_buttonW, - home_button: home_button, - on_dir_scan: on_dir_scan, - on_clean_up: on_clean_up, - on_widget_add_menu: on_widget_add_menu, - on_kill_widget: on_kill_widget, - on_get_widget: on_get_widget, - on_widget_remote: on_widget_remote, - flUpDir: flUpDir, - flPrevFiles: flPrevFiles, - flNextFiles: flNextFiles, - flScanDir: flScanDir - } - -}()); +// +// substitute for the useful predefined function endsWith +// +function endsWith(s1, s2) { + return s1.toLowerCase().substring(s1.length - s2.length) == s2; +} + +/* wrapper as a module + // export the resize function as the resize member of iphone_wm_gui, as well as other functions + return { + resize: resize, + left_button: left_button, + right_button: right_button, + left_buttonW: left_buttonW, + right_buttonW: right_buttonW, + home_button: home_button, + on_dir_scan: on_dir_scan, + on_clean_up: on_clean_up, + on_widget_add_menu: on_widget_add_menu, + on_kill_widget: on_kill_widget, + on_get_widget: on_get_widget, + on_widget_remote: on_widget_remote, + flUpDir: flUpDir, + flPrevFiles: flPrevFiles, + flNextFiles: flNextFiles, + flScanDir: flScanDir, + get_widget_callback2: get_widget_callback2 + } + + }());*/ function widget_activated_and_bound(wid) { WidgetManager.corein_message(wid, "activate"); } function printAllFieldsOf(obj, printableName) { - var details = "fields of "+printableName+":\n"; + var details = "fields of " + printableName + ":\n"; for (var field in obj) { - fieldContents = obj[field]; - if (typeof(fieldContents) == "function") { - fieldContents = "(function)"; - } - details += " " + field + ": " + fieldContents + "\n"; + fieldContents = obj[field]; + if (typeof(fieldContents) == "function") { + fieldContents = "(function)"; + } + details += " " + field + ": " + fieldContents + "\n"; } alert(details); } diff --git a/gui/iphone_wm_gui.svg b/gui/iphone_wm_gui.svg index 80df4a5..63551da 100644 --- a/gui/iphone_wm_gui.svg +++ b/gui/iphone_wm_gui.svg @@ -482,6 +482,11 @@ Scan on_dir_scan(); + + + GetW + on_get_widget(); + diff --git a/include/gpac/internal/compositor_dev.h b/include/gpac/internal/compositor_dev.h index c1b6a6e..ef3cea0 100644 --- a/include/gpac/internal/compositor_dev.h +++ b/include/gpac/internal/compositor_dev.h @@ -1335,6 +1335,7 @@ typedef struct void (*on_audio_reconfig)(void *udta, u32 samplerate, u32 bits_per_sample, u32 nb_channel, u32 channel_cfg); } GF_AudioListener; +/*adds a new audio listener - the on_audio_reconfig callback will be called before this function returns*/ GF_Err gf_sc_add_audio_listener(GF_Compositor *compositor, GF_AudioListener *al); GF_Err gf_sc_remove_audio_listener(GF_Compositor *compositor, GF_AudioListener *al); diff --git a/include/gpac/internal/isomedia_dev.h b/include/gpac/internal/isomedia_dev.h index fa6e92e..4050327 100644 --- a/include/gpac/internal/isomedia_dev.h +++ b/include/gpac/internal/isomedia_dev.h @@ -2039,6 +2039,9 @@ GF_Err gf_isom_datamap_add_data(GF_DataMap *ptr, char *data, u32 dataSize); #define GF_ISOM_GET_FRAG_SYNC(flag) ( ! ( ( (flag) >> 16) & 0x1)) #define GF_ISOM_GET_FRAG_DEG(flag) (flag) & 0x7FFF +#define GF_ISOM_GET_FRAG_DEPEND_FLAGS(lead, depends, depended, redundant) ( (lead<<26) | (depends<<24) | (depended<<22) | (redundant<<20) ) +#define GF_ISOM_RESET_FRAG_DEPEND_FLAGS(flags) flags = flags & 0xFFFFF + GF_TrackExtendsBox *GetTrex(GF_MovieBox *moov, u32 TrackID); #endif diff --git a/include/gpac/setup.h b/include/gpac/setup.h index 7c7c0a4..59dd39f 100644 --- a/include/gpac/setup.h +++ b/include/gpac/setup.h @@ -411,9 +411,13 @@ void gf_memory_print(void); /*prints the state of current allocations*/ #ifndef GF_EXPORT +#if defined(__GNUC__) && __GNUC__ >= 4 +#define GF_EXPORT __attribute__((visibility("default"))) +#else /*use def files for windows or let compiler decide*/ #define GF_EXPORT #endif +#endif diff --git a/include/gpac/tools.h b/include/gpac/tools.h index 11af405..7f74223 100644 --- a/include/gpac/tools.h +++ b/include/gpac/tools.h @@ -62,8 +62,8 @@ extern "C" { * SONAME versions must be digits (not strings) */ #define GPAC_VERSION "0.4.6-DEV" -#define GPAC_VERSION_MAJOR 1 -#define GPAC_VERSION_MINOR 1 +#define GPAC_VERSION_MAJOR 2 +#define GPAC_VERSION_MINOR 0 #define GPAC_VERSION_MICRO 0 #include diff --git a/modules/aac_in/aac_in.c b/modules/aac_in/aac_in.c index dcd70a4..3a74968 100644 --- a/modules/aac_in/aac_in.c +++ b/modules/aac_in/aac_in.c @@ -928,6 +928,7 @@ void AAC_Delete(void *ifce) gf_free(plug); } +#endif #endif #ifndef DONT_USE_TERMINAL_MODULE_API @@ -982,4 +983,3 @@ void ShutdownInterface(GF_BaseInterface *ifce) } } #endif -#endif diff --git a/modules/alsa/alsa.c b/modules/alsa/alsa.c index b7ba4be..2f5f809 100644 --- a/modules/alsa/alsa.c +++ b/modules/alsa/alsa.c @@ -350,6 +350,7 @@ void DeleteALSAOutput(void *ifce) * ******************************************************************** * interface */ +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -359,6 +360,7 @@ const u32 *QueryInterfaces() return si; } +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) @@ -366,6 +368,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) return NULL; } +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { if (ifce->InterfaceType==GF_AUDIO_OUTPUT_INTERFACE) diff --git a/modules/amr_dec/amr_dec.c b/modules/amr_dec/amr_dec.c index 6c1a755..15f1146 100644 --- a/modules/amr_dec/amr_dec.c +++ b/modules/amr_dec/amr_dec.c @@ -304,6 +304,7 @@ const u32 *QueryInterfaces() GF_InputService *NewAESReader(); void DeleteAESReader(void *ifce); +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { switch (InterfaceType) { @@ -313,6 +314,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) } } +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/amr_float_dec/amr_float_dec.c b/modules/amr_float_dec/amr_float_dec.c index 67a8dfd..682d205 100644 --- a/modules/amr_float_dec/amr_float_dec.c +++ b/modules/amr_float_dec/amr_float_dec.c @@ -323,6 +323,7 @@ const u32 *QueryInterfaces() return si; } +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { switch (InterfaceType) { @@ -332,6 +333,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) } } +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/audio_filter/audio_filter.c b/modules/audio_filter/audio_filter.c index b68034a..b1830cc 100644 --- a/modules/audio_filter/audio_filter.c +++ b/modules/audio_filter/audio_filter.c @@ -260,6 +260,7 @@ void DeleteAudioFilter(void *ifce) * ******************************************************************** * interface */ +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -269,6 +270,7 @@ const u32 *QueryInterfaces() return si; } +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_AUDIO_FILTER_INTERFACE) @@ -276,6 +278,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) return NULL; } +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { if (ifce->InterfaceType==GF_AUDIO_FILTER_INTERFACE) diff --git a/modules/directfb_out/directfb_out.c b/modules/directfb_out/directfb_out.c index a194bdf..174f934 100755 --- a/modules/directfb_out/directfb_out.c +++ b/modules/directfb_out/directfb_out.c @@ -364,6 +364,7 @@ void DirectFBDeleteVideo(void *ifce) /*interface query*/ +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -375,6 +376,7 @@ const u32 *QueryInterfaces() /*interface create*/ +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return DirectFBNewVideo(); @@ -383,6 +385,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) /*interface destroy*/ +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/droid_audio/droidaudio.c b/modules/droid_audio/droidaudio.c index b0b6c4f..1b9def0 100644 --- a/modules/droid_audio/droidaudio.c +++ b/modules/droid_audio/droidaudio.c @@ -427,6 +427,7 @@ void DeleteWAVRender(void *ifce) gf_free(dr); } //---------------------------------------------------------------------- +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -436,12 +437,14 @@ const u32 *QueryInterfaces() return si; } +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) return NewWAVRender(); return NULL; } +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/droid_mpegv/droid_mpegv.c b/modules/droid_mpegv/droid_mpegv.c index e0bf366..b4d6797 100644 --- a/modules/droid_mpegv/droid_mpegv.c +++ b/modules/droid_mpegv/droid_mpegv.c @@ -369,13 +369,17 @@ const u32 *QueryInterfaces() }; return si; } + /*interface create*/ +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_INPUT_DEVICE_INTERFACE) return (GF_BaseInterface *) NewMPEGVSInputSesor(); return NULL; } + /*interface destroy*/ +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/droid_out/droid_vout-bitmap.c b/modules/droid_out/droid_vout-bitmap.c index 09933c1..c177145 100644 --- a/modules/droid_out/droid_vout-bitmap.c +++ b/modules/droid_out/droid_vout-bitmap.c @@ -200,12 +200,14 @@ const u32 *QueryInterfaces() return si; } /*interface create*/ +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return (GF_BaseInterface *) NewRawVideoOutput(); return NULL; } /*interface destroy*/ +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/droid_out/droid_vout.c b/modules/droid_out/droid_vout.c index ac199e9..f63e9ab 100644 --- a/modules/droid_out/droid_vout.c +++ b/modules/droid_out/droid_vout.c @@ -648,12 +648,14 @@ const u32 *QueryInterfaces() return si; } /*interface create*/ +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return (GF_BaseInterface *) NewRawVideoOutput(); return NULL; } /*interface destroy*/ +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/dx_hw/dx_video.c b/modules/dx_hw/dx_video.c index 2ccce39..ee119d6 100644 --- a/modules/dx_hw/dx_video.c +++ b/modules/dx_hw/dx_video.c @@ -721,6 +721,7 @@ const u32 *QueryInterfaces() return si; } /*interface create*/ +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return NewDXVideoOutput(); @@ -728,6 +729,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) return NULL; } /*interface destroy*/ +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/epoc_hw/epoc_vout.cpp b/modules/epoc_hw/epoc_vout.cpp index eac6f09..5e748a8 100644 --- a/modules/epoc_hw/epoc_vout.cpp +++ b/modules/epoc_hw/epoc_vout.cpp @@ -495,6 +495,7 @@ const u32 *QueryInterfaces() }; return si; } + /*interface create*/ GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) @@ -504,6 +505,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) if (InterfaceType == GF_MEDIA_DECODER_INTERFACE) return (GF_BaseInterface *) EPOC_codec_new(); return NULL; } + /*interface destroy*/ GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) diff --git a/modules/ffmpeg_in/Makefile b/modules/ffmpeg_in/Makefile index c561bd6..bcff766 100644 --- a/modules/ffmpeg_in/Makefile +++ b/modules/ffmpeg_in/Makefile @@ -2,7 +2,7 @@ include ../../config.mak vpath %.c $(SRC_PATH)/modules/ffmpeg_in -CFLAGS=$(OPTFLAGS) -I"$(SRC_PATH)/include" $(ffmpeg_cflags) +CFLAGS=$(OPTFLAGS) -Wno-deprecated-declarations -I"$(SRC_PATH)/include" $(ffmpeg_cflags) ifeq ($(DEBUGBUILD), yes) CFLAGS+=-g diff --git a/modules/ffmpeg_in/ffmpeg_demux.c b/modules/ffmpeg_in/ffmpeg_demux.c index 9e801f9..0f8ee50 100644 --- a/modules/ffmpeg_in/ffmpeg_demux.c +++ b/modules/ffmpeg_in/ffmpeg_demux.c @@ -478,6 +478,7 @@ static void FFD_SetupObjects(FFDemux *ffd) } } +#ifdef USE_PRE_0_7 static int ff_url_read(void *h, unsigned char *buf, int size) { u32 retry = 10; @@ -528,6 +529,7 @@ static int ff_url_read(void *h, unsigned char *buf, int size) #endif return full_size ? (int) full_size : -1; } +#endif /*USE_PRE_0_7*/ static GF_Err FFD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const char *url) diff --git a/modules/gapi/gapi.cpp b/modules/gapi/gapi.cpp index 32e8d47..37231fd 100644 --- a/modules/gapi/gapi.cpp +++ b/modules/gapi/gapi.cpp @@ -1482,6 +1482,7 @@ extern "C" { /*interface query*/ +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -1490,13 +1491,17 @@ const u32 *QueryInterfaces() }; return si; } + /*interface create*/ +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return (GF_BaseInterface *) NewGAPIVideoOutput(); return NULL; } + /*interface destroy*/ +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { GF_VideoOutput *dd = (GF_VideoOutput *)ifce; diff --git a/modules/gdip_raster/gdip_font.cpp b/modules/gdip_raster/gdip_font.cpp index 66902cb..343a748 100644 --- a/modules/gdip_raster/gdip_font.cpp +++ b/modules/gdip_raster/gdip_font.cpp @@ -364,6 +364,7 @@ void gdip_delete_font_driver(GF_FontReader *dr) extern "C" { #endif +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -374,6 +375,7 @@ const u32 *QueryInterfaces() return si; } +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType==GF_FONT_READER_INTERFACE) return (GF_BaseInterface *)gdip_new_font_driver(); @@ -381,6 +383,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) return NULL; } +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/gpac_js/gpac_js.c b/modules/gpac_js/gpac_js.c index 10937c1..6f90742 100644 --- a/modules/gpac_js/gpac_js.c +++ b/modules/gpac_js/gpac_js.c @@ -762,7 +762,8 @@ static JSBool SMJS_FUNCTION(gpac_set_event_filter) SMJS_ARGS GF_GPACJSExt *gjs = (GF_GPACJSExt *)JS_GetPrivate(c, obj); if (!argc || !JSVAL_IS_OBJECT(argv[0])) return JS_FALSE; - if (JSVAL_IS_NULL(gjs->evt_fun) ) return JS_TRUE; + + if (! JSVAL_IS_NULL(gjs->evt_fun) ) return JS_TRUE; gjs->evt_fun = argv[0]; gjs->evt_filter_obj = obj; @@ -893,8 +894,10 @@ static void gjs_load(GF_JSUserExtension *jsext, GF_SceneGraph *scene, JSContext /*nothing to do on unload*/ if (unload) { gjs->nb_loaded--; - if (!gjs->nb_loaded && gjs->evt_filter.udta) { + /*if we destroy the script context holding the gpac event filter (only one for the time being), remove the filter*/ + if ((gjs->c==c) && gjs->evt_filter.udta) { gf_term_remove_event_filter(gjs->term, &gjs->evt_filter); + gjs->evt_filter.udta = NULL; } return; } @@ -957,6 +960,8 @@ static void gjs_load(GF_JSUserExtension *jsext, GF_SceneGraph *scene, JSContext JS_SETUP_CLASS(gjs->anyClass, "GPACOBJECT", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub); JS_InitClass(c, global, 0, &gjs->anyClass, 0, 0, 0, 0, 0, 0); + + gjs->evt_fun = JSVAL_NULL; } } diff --git a/modules/jack/Makefile b/modules/jack/Makefile index 05ae8fe..0037f67 100644 --- a/modules/jack/Makefile +++ b/modules/jack/Makefile @@ -2,7 +2,7 @@ include ../../config.mak vpath %.c $(SRC_PATH)/modules/jack -CFLAGS= $(OPTFLAGS) -I"$(SRC_PATH)/include" $(OSS_CFLAGS) +CFLAGS= $(OPTFLAGS) -I"$(SRC_PATH)/include" $(OSS_CFLAGS) -Wno-deprecated-declarations ifeq ($(DEBUGBUILD), yes) CFLAGS+=-g diff --git a/modules/jack/jack.c b/modules/jack/jack.c index 0d92b7b..3eb5891 100644 --- a/modules/jack/jack.c +++ b/modules/jack/jack.c @@ -545,6 +545,7 @@ DeleteJackOutput (void *ifce) * interface */ +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -554,8 +555,8 @@ const u32 *QueryInterfaces() return si; } -GF_BaseInterface * -LoadInterface (u32 InterfaceType) +GF_EXPORT +GF_BaseInterface *LoadInterface (u32 InterfaceType) { if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) { @@ -564,8 +565,8 @@ LoadInterface (u32 InterfaceType) return NULL; } -void -ShutdownInterface (GF_BaseInterface * ifce) +GF_EXPORT +void ShutdownInterface (GF_BaseInterface * ifce) { if (ifce->InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) DeleteJackOutput ((GF_AudioOutput *) ifce); diff --git a/modules/mpegts_in/mpegts_in.c b/modules/mpegts_in/mpegts_in.c index bb512c6..b8b7777 100644 --- a/modules/mpegts_in/mpegts_in.c +++ b/modules/mpegts_in/mpegts_in.c @@ -1195,6 +1195,7 @@ const u32 *QueryInterfaces() return si; } +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { switch (InterfaceType) { @@ -1205,6 +1206,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) } } +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/ogg/ogg_load.c b/modules/ogg/ogg_load.c index fa7783a..c32c916 100644 --- a/modules/ogg/ogg_load.c +++ b/modules/ogg/ogg_load.c @@ -107,6 +107,7 @@ void DeleteOGGDecoder(GF_BaseDecoder *ifcd) } +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -119,6 +120,7 @@ const u32 *QueryInterfaces() return si; } +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { #if !defined(GPAC_DISABLE_AV_PARSERS) && !defined(GPAC_DISABLE_OGG) @@ -128,6 +130,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) return NULL; } +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/opensvc_dec/opensvc_dec.c b/modules/opensvc_dec/opensvc_dec.c index 02a12e7..041bb06 100644 --- a/modules/opensvc_dec/opensvc_dec.c +++ b/modules/opensvc_dec/opensvc_dec.c @@ -81,10 +81,12 @@ static GF_Err OSVC_AttachStream(GF_BaseDecoder *ifcg, GF_ESD *esd) count = gf_list_count(cfg->sequenceParameterSets); SetCommandLayer(Layer, 255, 0, &i, 0);//bufindex can be reset without pb for (i=0; isequenceParameterSets, i); +#ifndef GPAC_DISABLE_AV_PARSERS gf_avc_get_sps_info(slc->data, slc->size, &slc->id, &w, &h, &par_n, &par_d); +#endif /*by default use the base layer*/ if (!i) { if ((ctx->widthheightInterfaceType) { diff --git a/modules/oss_audio/oss.c b/modules/oss_audio/oss.c index f1f338f..ff6a5b6 100644 --- a/modules/oss_audio/oss.c +++ b/modules/oss_audio/oss.c @@ -257,6 +257,7 @@ void DeleteOSSRender(void *ifce) * ******************************************************************** * interface */ +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -266,6 +267,7 @@ const u32 *QueryInterfaces() return si; } +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) @@ -273,6 +275,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) return NULL; } +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { if (ifce->InterfaceType==GF_AUDIO_OUTPUT_INTERFACE) diff --git a/modules/platinum/GPACMediaRenderer.cpp b/modules/platinum/GPACMediaRenderer.cpp index 21caa1c..6feb58e 100644 --- a/modules/platinum/GPACMediaRenderer.cpp +++ b/modules/platinum/GPACMediaRenderer.cpp @@ -120,14 +120,18 @@ GPAC_MediaRenderer::SetupServices(PLT_DeviceData& data) m_pAVService->SetStateVariable("AbsoluteCounterPosition", "2147483647"); // means NOT_IMPLEMENTED // disable indirect eventing for certain state variables - PLT_StateVariable* var; - var = m_pAVService->FindStateVariable("RelativeTimePosition"); + //PLT_StateVariable* var; + //var = + m_pAVService->FindStateVariable("RelativeTimePosition"); //if (var) var->DisableIndirectEventing(); - var = m_pAVService->FindStateVariable("AbsoluteTimePosition"); + //var = + m_pAVService->FindStateVariable("AbsoluteTimePosition"); //if (var) var->DisableIndirectEventing(); - var = m_pAVService->FindStateVariable("RelativeCounterPosition"); + //var = + m_pAVService->FindStateVariable("RelativeCounterPosition"); //if (var) var->DisableIndirectEventing(); - var = m_pAVService->FindStateVariable("AbsoluteCounterPosition"); + //var = + m_pAVService->FindStateVariable("AbsoluteCounterPosition"); //if (var) var->DisableIndirectEventing(); // GetTransportInfo diff --git a/modules/platinum/GPACPlatinum.cpp b/modules/platinum/GPACPlatinum.cpp index e1286a2..667d00e 100644 --- a/modules/platinum/GPACPlatinum.cpp +++ b/modules/platinum/GPACPlatinum.cpp @@ -262,7 +262,6 @@ Bool GF_UPnP::ProcessEvent(GF_Event *evt) case GF_EVENT_METADATA: if (m_pTerm->root_scene) { char szName[1024]; - const char *artist; NetInfoCommand com; memset(&com, 0, sizeof(NetInfoCommand)); @@ -272,12 +271,12 @@ Bool GF_UPnP::ProcessEvent(GF_Event *evt) if (com.name) { strcat(szName, com.name); strcat(szName, " "); } if (com.album) { strcat(szName, "("); strcat(szName, com.album); strcat(szName, ")"); } - artist = "Unknown"; + /*const char *artist = "Unknown"; if (com.artist) artist = com.artist; else if (com.writer) artist = com.writer; else if (com.composer) artist = com.composer; - //MRSetMediaInfo(0, szName, com.artist ? com.artist : "Unknown"); + MRSetMediaInfo(0, szName, com.artist ? com.artist : "Unknown");*/ } } break; diff --git a/modules/pulseaudio/pulseaudio.c b/modules/pulseaudio/pulseaudio.c index 517a12e..073fcc4 100644 --- a/modules/pulseaudio/pulseaudio.c +++ b/modules/pulseaudio/pulseaudio.c @@ -320,6 +320,7 @@ DeletePulseAudioOutput (void *ifce) * ******************************************************************** * interface */ +GF_EXPORT const u32 *QueryInterfaces(u32 InterfaceType) { static u32 si [] = { @@ -329,16 +330,16 @@ const u32 *QueryInterfaces(u32 InterfaceType) return si; } -GF_BaseInterface * -LoadInterface (u32 InterfaceType) +GF_EXPORT +GF_BaseInterface *LoadInterface (u32 InterfaceType) { if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) return NewPulseAudioOutput (); return NULL; } -void -ShutdownInterface (GF_BaseInterface * ifce) +GF_EXPORT +void ShutdownInterface (GF_BaseInterface * ifce) { if (ifce->InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) DeletePulseAudioOutput ((GF_AudioOutput *) ifce); diff --git a/modules/raw_out/raw_video.c b/modules/raw_out/raw_video.c index 1f27436..ad73a88 100644 --- a/modules/raw_out/raw_video.c +++ b/modules/raw_out/raw_video.c @@ -152,13 +152,17 @@ const u32 *QueryInterfaces() }; return si; } + /*interface create*/ +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return (GF_BaseInterface *) NewRawVideoOutput(); return NULL; } + /*interface destroy*/ +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/rvc_dec/rvc_dec.c b/modules/rvc_dec/rvc_dec.c index 3649c02..a4ec5c8 100644 --- a/modules/rvc_dec/rvc_dec.c +++ b/modules/rvc_dec/rvc_dec.c @@ -416,6 +416,7 @@ void DeleteRVCDec(GF_BaseDecoder *ifcg) gf_free(ifcg); } +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -427,6 +428,7 @@ const u32 *QueryInterfaces() return si; } +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { #ifndef GPAC_DISABLE_AV_PARSERS @@ -435,6 +437,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) return NULL; } +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/sdl_out/sdl_out.c b/modules/sdl_out/sdl_out.c index 56fb7bb..1be2a12 100644 --- a/modules/sdl_out/sdl_out.c +++ b/modules/sdl_out/sdl_out.c @@ -50,6 +50,7 @@ void SDLOUT_CloseSDL() /*interface query*/ +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -59,14 +60,18 @@ const u32 *QueryInterfaces() }; return si; } + /*interface create*/ +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return SDL_NewVideo(); if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) return SDL_NewAudio(); return NULL; } + /*interface destroy*/ +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/wav_out/wav_out.c b/modules/wav_out/wav_out.c index 321fef5..3e243f1 100644 --- a/modules/wav_out/wav_out.c +++ b/modules/wav_out/wav_out.c @@ -464,6 +464,7 @@ void DeleteWAVRender(void *ifce) gf_free(dr); } +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -473,12 +474,14 @@ const u32 *QueryInterfaces() return si; } +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) return NewWAVRender(); return NULL; } +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/widgetman/unzip.c b/modules/widgetman/unzip.c index c3feb08..71f0e69 100644 --- a/modules/widgetman/unzip.c +++ b/modules/widgetman/unzip.c @@ -5,7 +5,6 @@ Copyright (C) 1998-2005 Gilles Vollant */ - #include #include #include @@ -26,6 +25,9 @@ #endif +//hack: prevent mozilla to redifine z functions +#define MOZZCONF_H + #include "unzip.h" #include diff --git a/modules/x11_out/Makefile b/modules/x11_out/Makefile index cf47d9d..ab00d89 100644 --- a/modules/x11_out/Makefile +++ b/modules/x11_out/Makefile @@ -2,7 +2,7 @@ include ../../config.mak vpath %.c $(SRC_PATH)/modules/x11_out -CFLAGS= $(OPTFLAGS) +CFLAGS= $(OPTFLAGS) -Wno-deprecated-declarations ifeq ($(DEBUGBUILD), yes) CFLAGS+=-g diff --git a/modules/x11_out/x11_out.c b/modules/x11_out/x11_out.c index b9ef396..e299352 100644 --- a/modules/x11_out/x11_out.c +++ b/modules/x11_out/x11_out.c @@ -1440,6 +1440,7 @@ DeleteX11VideoOutput (GF_VideoOutput * vout) /* * interface query */ +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -1453,8 +1454,8 @@ const u32 *QueryInterfaces() /* * interface create */ -GF_BaseInterface * -LoadInterface (u32 InterfaceType) +GF_EXPORT +GF_BaseInterface *LoadInterface (u32 InterfaceType) { if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return (GF_BaseInterface *) NewX11VideoOutput (); @@ -1465,8 +1466,8 @@ LoadInterface (u32 InterfaceType) /* * interface destroy */ -void -ShutdownInterface (GF_BaseInterface *ifce) +GF_EXPORT +void ShutdownInterface (GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/modules/xvid_dec/xvid_dec.c b/modules/xvid_dec/xvid_dec.c index d470670..76c44e3 100644 --- a/modules/xvid_dec/xvid_dec.c +++ b/modules/xvid_dec/xvid_dec.c @@ -465,6 +465,8 @@ void DeleteXVIDDec(GF_BaseDecoder *ifcg) #endif /*GPAC_DISABLE_AV_PARSERS*/ + +GF_EXPORT const u32 *QueryInterfaces() { static u32 si [] = { @@ -476,6 +478,7 @@ const u32 *QueryInterfaces() return si; } +GF_EXPORT GF_BaseInterface *LoadInterface(u32 InterfaceType) { #ifndef GPAC_DISABLE_AV_PARSERS @@ -484,6 +487,7 @@ GF_BaseInterface *LoadInterface(u32 InterfaceType) return NULL; } +GF_EXPORT void ShutdownInterface(GF_BaseInterface *ifce) { switch (ifce->InterfaceType) { diff --git a/regression_tests/bifs/bifs-3D-positioning-layer3D.bt b/regression_tests/bifs/bifs-3D-positioning-layer3D.bt index dbf640e..61018d6 100644 --- a/regression_tests/bifs/bifs-3D-positioning-layer3D.bt +++ b/regression_tests/bifs/bifs-3D-positioning-layer3D.bt @@ -100,7 +100,7 @@ OrderedGroup { Shape { appearance Appearance { # material Material { emissiveColor 0 1 0} - texture ImageTexture { url './../auxiliary_files/logo.jpg"} + texture ImageTexture { url "./../auxiliary_files/logo.jpg"} } geometry Box { size 20 20 20} } diff --git a/src/compositor/audio_render.c b/src/compositor/audio_render.c index cc9704b..6fdb997 100644 --- a/src/compositor/audio_render.c +++ b/src/compositor/audio_render.c @@ -282,13 +282,11 @@ static GF_Err gf_ar_setup_output_format(GF_AudioRenderer *ar) while ((l = gf_list_enum(ar->audio_listeners, &k))) { l->on_audio_reconfig(l->udta, in_freq, in_bps, in_ch, in_cfg); } - } - + } return GF_OK; } - static u32 gf_ar_fill_output(void *ptr, char *buffer, u32 buffer_size) { u32 written; @@ -635,6 +633,8 @@ u32 gf_sc_ar_get_clock(GF_AudioRenderer *ar) if (ar->Frozen) return ar->FreezeTime - ar->startTime; return gf_sys_clock() - ar->startTime; } + +GF_EXPORT void gf_sc_reload_audio_filters(GF_Compositor *compositor) { GF_AudioRenderer *ar = compositor->audio_renderer; @@ -656,13 +656,22 @@ void gf_sc_reload_audio_filters(GF_Compositor *compositor) GF_Err gf_sc_add_audio_listener(GF_Compositor *compositor, GF_AudioListener *al) { + GF_AudioMixer *mixer; + u32 sr, ch, bps, ch_cfg; if (!compositor || !al || !al->on_audio_frame || !al->on_audio_reconfig) return GF_BAD_PARAM; if (!compositor->audio_renderer) return GF_NOT_SUPPORTED; - gf_mixer_lock(compositor->audio_renderer->mixer, 1); + mixer = compositor->audio_renderer->mixer; + gf_mixer_lock(mixer, 1); + if (!compositor->audio_renderer->audio_listeners) compositor->audio_renderer->audio_listeners = gf_list_new(); gf_list_add(compositor->audio_renderer->audio_listeners, al); - gf_mixer_lock(compositor->audio_renderer->mixer, 0); + + gf_mixer_get_config(mixer, &sr, &ch, &bps, &ch_cfg); + + al->on_audio_reconfig(al->udta, sr, bps, ch, ch_cfg); + + gf_mixer_lock(mixer, 0); return GF_OK; } diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index 8672579..bdb227c 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -969,6 +969,7 @@ void gf_sc_lock(GF_Compositor *compositor, Bool doLock) } } +GF_EXPORT GF_Err gf_sc_set_size(GF_Compositor *compositor, u32 NewWidth, u32 NewHeight) { Bool lock_ok; @@ -1279,6 +1280,7 @@ void gf_sc_reload_config(GF_Compositor *compositor) gf_sc_lock(compositor, 0); } +GF_EXPORT GF_Err gf_sc_set_option(GF_Compositor *compositor, u32 type, u32 value) { GF_Err e; @@ -1622,6 +1624,7 @@ void gf_sc_map_point(GF_Compositor *compositor, s32 X, s32 Y, Fixed *bifsX, Fixe } +GF_EXPORT GF_Err gf_sc_get_screen_buffer(GF_Compositor *compositor, GF_VideoSurface *framebuffer, u32 depth_dump_mode) { GF_Err e; @@ -1656,6 +1659,7 @@ GF_Err gf_sc_get_offscreen_buffer(GF_Compositor *compositor, GF_VideoSurface *fr } +GF_EXPORT GF_Err gf_sc_release_screen_buffer(GF_Compositor *compositor, GF_VideoSurface *framebuffer) { GF_Err e; @@ -1671,6 +1675,7 @@ GF_Err gf_sc_release_screen_buffer(GF_Compositor *compositor, GF_VideoSurface *f return e; } +GF_EXPORT Double gf_sc_get_fps(GF_Compositor *compositor, Bool absoluteFPS) { Double fps; @@ -2703,6 +2708,7 @@ Bool gf_sc_user_event(GF_Compositor *compositor, GF_Event *event) } } +GF_EXPORT void gf_sc_register_extra_graph(GF_Compositor *compositor, GF_SceneGraph *extra_scene, Bool do_remove) { gf_sc_lock(compositor, 1); diff --git a/src/compositor/events.c b/src/compositor/events.c index 5059bfd..482c2dc 100644 --- a/src/compositor/events.c +++ b/src/compositor/events.c @@ -1750,6 +1750,7 @@ static GF_Node *browse_parent_for_focus(GF_Compositor *compositor, GF_Node *elt, return browse_parent_for_focus(compositor, (GF_Node*)par, prev_focus); } +GF_EXPORT u32 gf_sc_focus_switch_ring(GF_Compositor *compositor, Bool move_prev, GF_Node *focus, u32 force_focus) { Bool current_focus = 1; diff --git a/src/compositor/mpeg4_grouping_3d.c b/src/compositor/mpeg4_grouping_3d.c index db8b1c0..68a5b14 100644 --- a/src/compositor/mpeg4_grouping_3d.c +++ b/src/compositor/mpeg4_grouping_3d.c @@ -251,6 +251,7 @@ static void TraverseBillboard(GF_Node *n, void *rs, Bool is_destroy) DestroyTransform(n); return; } + if (! tr_state->camera) return; /*can't cache the matrix here*/ gf_mx_init(st->mx); @@ -348,8 +349,6 @@ static void TraverseLOD(GF_Node *node, void *rs, Bool is_destroy) return; } - - /*WARNING: X3D/MPEG4 NOT COMPATIBLE*/ if (gf_node_get_tag(node) == TAG_MPEG4_LOD) { children = ((M_LOD *) node)->level; @@ -366,27 +365,32 @@ static void TraverseLOD(GF_Node *node, void *rs, Bool is_destroy) if (!children) return; nb_children = gf_node_list_get_count(children); - /*can't cache the matric here*/ - usr = tr_state->camera->position; - pos = center; - gf_mx_copy(mx, tr_state->model_matrix); - gf_mx_inverse(&mx); - gf_mx_apply_vec(&mx, &usr); - gf_vec_diff(pos, pos, usr); - dist = gf_vec_len(pos); - for (which_child=0; which_childcount; which_child++) { - if (distvals[which_child]) break; - } - if (which_child>=nb_children) which_child = nb_children-1; - - /*check if we're traversing the same child or not for audio rendering*/ - do_all = 0; - if (gf_node_dirty_get(node)) { - gf_node_dirty_clear(node, 0); - do_all = 1; - } else if ((s32) which_child != *prev_child) { - *prev_child = which_child; + if (!tr_state->camera) { do_all = 1; + which_child = 0; + } else { + /*can't cache the matrix here*/ + usr = tr_state->camera->position; + pos = center; + gf_mx_copy(mx, tr_state->model_matrix); + gf_mx_inverse(&mx); + gf_mx_apply_vec(&mx, &usr); + gf_vec_diff(pos, pos, usr); + dist = gf_vec_len(pos); + for (which_child=0; which_childcount; which_child++) { + if (distvals[which_child]) break; + } + if (which_child>=nb_children) which_child = nb_children-1; + + /*check if we're traversing the same child or not for audio rendering*/ + do_all = 0; + if (gf_node_dirty_get(node)) { + gf_node_dirty_clear(node, 0); + do_all = 1; + } else if ((s32) which_child != *prev_child) { + *prev_child = which_child; + do_all = 1; + } } if (do_all) { diff --git a/src/compositor/svg_grouping.c b/src/compositor/svg_grouping.c index 5d0e1b7..bf457d6 100644 --- a/src/compositor/svg_grouping.c +++ b/src/compositor/svg_grouping.c @@ -1397,6 +1397,7 @@ GF_Node *compositor_svg_get_xlink_resource_node(GF_Node *node, XMLRI *xlink) return NULL; } +GF_EXPORT GF_SceneGraph *gf_sc_animation_get_scenegraph(GF_Node *node) { SVGlinkStack *stack; diff --git a/src/ietf/rtp_streamer.c b/src/ietf/rtp_streamer.c index 850af4b..335d460 100644 --- a/src/ietf/rtp_streamer.c +++ b/src/ietf/rtp_streamer.c @@ -127,6 +127,7 @@ static GF_Err rtp_stream_init_channel(GF_RTPStreamer *rtp, u32 path_mtu, const c return GF_OK; } +GF_EXPORT GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeScale, const char *ip_dest, u16 port, u32 MTU, u8 TTL, const char *ifce_addr, u32 flags, char *dsi, u32 dsi_len, @@ -456,6 +457,7 @@ GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeSc } +GF_EXPORT GF_RTPStreamer *gf_rtp_streamer_new(u32 streamType, u32 oti, u32 timeScale, const char *ip_dest, u16 port, u32 MTU, u8 TTL, const char *ifce_addr, u32 flags, char *dsi, u32 dsi_len) @@ -466,6 +468,7 @@ GF_RTPStreamer *gf_rtp_streamer_new(u32 streamType, u32 oti, u32 timeScale, } +GF_EXPORT void gf_rtp_streamer_del(GF_RTPStreamer *streamer) { if (streamer) { @@ -521,6 +524,7 @@ void gf_media_format_ttxt_sdp(GP_RTPPacketizer *builder, char *payload_name, cha #endif /*!defined(GPAC_DISABLE_ISOM) && !defined(GPAC_DISABLE_STREAMING)*/ +GF_EXPORT GF_Err gf_rtp_streamer_append_sdp_extended(GF_RTPStreamer *rtp, u16 ESID, char *dsi, u32 dsi_len, GF_ISOFile *isofile, u32 isotrack, char *KMS_URI, u32 width, u32 height, char **out_sdp_buffer) { u32 size; @@ -666,6 +670,7 @@ GF_Err gf_rtp_streamer_append_sdp_extended(GF_RTPStreamer *rtp, u16 ESID, char * return GF_OK; } +GF_EXPORT char *gf_rtp_streamer_format_sdp_header(char *app_name, char *ip_dest, char *session_name, char *iod64) { u64 size; @@ -692,6 +697,7 @@ char *gf_rtp_streamer_format_sdp_header(char *app_name, char *ip_dest, char *ses return sdp; } +GF_EXPORT GF_Err gf_rtp_streamer_append_sdp(GF_RTPStreamer *rtp, u16 ESID, char *dsi, u32 dsi_len, char *KMS_URI, char **out_sdp_buffer) { return gf_rtp_streamer_append_sdp_extended(rtp, ESID, dsi, dsi_len, NULL, 0, KMS_URI, 0, 0, out_sdp_buffer); @@ -716,17 +722,20 @@ GF_Err gf_rtp_streamer_send_au(GF_RTPStreamer *rtp, char *data, u32 size, u64 ct return gf_rtp_streamer_send_data(rtp, data, size, size, cts, dts, is_rap, 1, 1, 0, 0, 0); } +GF_EXPORT GF_Err gf_rtp_streamer_send_au_with_sn(GF_RTPStreamer *rtp, char *data, u32 size, u64 cts, u64 dts, Bool is_rap, u32 inc_au_sn) { if (inc_au_sn) rtp->packetizer->sl_header.AU_sequenceNumber += inc_au_sn; return gf_rtp_streamer_send_data(rtp, data, size, size, cts, dts, is_rap, 1, 1, rtp->packetizer->sl_header.AU_sequenceNumber, 0, 0); } +GF_EXPORT void gf_rtp_streamer_disable_auto_rtcp(GF_RTPStreamer *streamer) { streamer->channel->no_auto_rtcp = 1; } +GF_EXPORT GF_Err gf_rtp_streamer_send_rtcp(GF_RTPStreamer *streamer, Bool force_ts, u32 rtp_ts) { if (force_ts) streamer->channel->last_pck_ts = rtp_ts; diff --git a/src/isomedia/avc_ext.c b/src/isomedia/avc_ext.c index 6119265..b75f512 100644 --- a/src/isomedia/avc_ext.c +++ b/src/isomedia/avc_ext.c @@ -256,6 +256,7 @@ static GF_Err gf_isom_avc_config_update_ex(GF_ISOFile *the_file, u32 trackNumber return GF_OK; } +GF_EXPORT GF_Err gf_isom_avc_config_update(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_AVCConfig *cfg) { return gf_isom_avc_config_update_ex(the_file, trackNumber, DescriptionIndex, cfg, 0); @@ -266,6 +267,7 @@ GF_Err gf_isom_svc_config_update(GF_ISOFile *the_file, u32 trackNumber, u32 Desc return gf_isom_avc_config_update_ex(the_file, trackNumber, DescriptionIndex, cfg, is_add ? 1 : 2); } +GF_EXPORT GF_Err gf_isom_set_ipod_compatible(GF_ISOFile *the_file, u32 trackNumber) { static const u8 ipod_ext[][16] = { { 0x6B, 0x68, 0x40, 0xF2, 0x5F, 0x24, 0x4F, 0xC5, 0xBA, 0x39, 0xA5, 0x1B, 0xCF, 0x03, 0x23, 0xF3} }; diff --git a/src/isomedia/box_dump.c b/src/isomedia/box_dump.c index bad1efc..168cd0b 100644 --- a/src/isomedia/box_dump.c +++ b/src/isomedia/box_dump.c @@ -3107,6 +3107,7 @@ static void dump_data(FILE *trace, char *name, char *data, u32 data_size) fprintf(trace, "\" "); } +GF_EXPORT GF_Err gf_isom_dump_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, FILE * trace) { u32 i, count; @@ -3139,6 +3140,7 @@ GF_Err gf_isom_dump_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, F return GF_OK; } +GF_EXPORT GF_Err gf_isom_dump_ismacryp_sample(GF_ISOFile *the_file, u32 trackNumber, u32 SampleNum, FILE * trace) { GF_ISOSample *samp; @@ -3235,7 +3237,7 @@ static GF_Err apple_tag_dump(GF_Box *a, FILE * trace) break; default: if (strcmp(name, "Unknown")) { - if (itune->data->data[0]) { + if (itune->data && itune->data->data[0]) { fprintf(trace, " value=\"%s\" ", itune->data->data); } else { fprintf(trace, " value=\""); @@ -3247,7 +3249,8 @@ static GF_Err apple_tag_dump(GF_Box *a, FILE * trace) } } fprintf(trace, ">\n"); - gf_full_box_dump((GF_Box *)itune->data, trace); + if (itune->data) + gf_full_box_dump((GF_Box *)itune->data, trace); DumpBox(a, trace); fprintf(trace, "\n", name); return GF_OK; diff --git a/src/isomedia/box_funcs.c b/src/isomedia/box_funcs.c index c870f45..bccc707 100644 --- a/src/isomedia/box_funcs.c +++ b/src/isomedia/box_funcs.c @@ -256,6 +256,7 @@ GF_Err gf_isom_full_box_get_size(GF_Box *ptr) } +GF_EXPORT GF_Err gf_isom_box_write_header(GF_Box *ptr, GF_BitStream *bs) { if (! bs || !ptr) return GF_BAD_PARAM; @@ -324,6 +325,7 @@ GF_Err gf_isom_box_array_size(GF_Box *parent, GF_List *list) #endif /*GPAC_DISABLE_ISOM_WRITE*/ +GF_EXPORT GF_Box *gf_isom_box_new(u32 boxType) { GF_Box *a; @@ -580,6 +582,7 @@ GF_Box *gf_isom_box_new(u32 boxType) } +GF_EXPORT void gf_isom_box_del(GF_Box *a) { if (!a) return; @@ -1063,6 +1066,7 @@ GF_Err gf_isom_box_read(GF_Box *a, GF_BitStream *bs) #ifndef GPAC_DISABLE_ISOM_WRITE +GF_EXPORT GF_Err gf_isom_box_write(GF_Box *a, GF_BitStream *bs) { switch (a->type) { @@ -1296,6 +1300,7 @@ GF_Err gf_isom_box_write(GF_Box *a, GF_BitStream *bs) } +GF_EXPORT GF_Err gf_isom_box_size(GF_Box *a) { switch (a->type) { diff --git a/src/isomedia/hint_track.c b/src/isomedia/hint_track.c index 3ce477d..3eeba72 100644 --- a/src/isomedia/hint_track.c +++ b/src/isomedia/hint_track.c @@ -710,6 +710,7 @@ static void ReorderSDP(char *sdp_text, Bool is_movie_sdp) } //add an SDP line to the SDP container at the track level (media-specific SDP info) +GF_EXPORT GF_Err gf_isom_sdp_add_track_line(GF_ISOFile *the_file, u32 trackNumber, const char *text) { GF_TrackBox *trak; @@ -784,6 +785,7 @@ GF_Err gf_isom_sdp_clean_track(GF_ISOFile *the_file, u32 trackNumber) //add an SDP line to the SDP container at the movie level (presentation SDP info) //NOTE: the \r\n end of line for SDP is automatically inserted +GF_EXPORT GF_Err gf_isom_sdp_add_line(GF_ISOFile *movie, const char *text) { GF_UserDataMap *map; @@ -845,6 +847,7 @@ GF_Err gf_isom_sdp_add_line(GF_ISOFile *movie, const char *text) //remove all SDP info at the movie level +GF_EXPORT GF_Err gf_isom_sdp_clean(GF_ISOFile *movie) { GF_UserDataMap *map; diff --git a/src/isomedia/isma_sample.c b/src/isomedia/isma_sample.c index af64dd5..485f1ba 100644 --- a/src/isomedia/isma_sample.c +++ b/src/isomedia/isma_sample.c @@ -333,6 +333,7 @@ GF_Err gf_isom_remove_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, return GF_OK; } +GF_EXPORT GF_Err gf_isom_change_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, char *scheme_uri, char *kms_uri) { GF_TrackBox *trak; diff --git a/src/isomedia/isom_read.c b/src/isomedia/isom_read.c index 66821b9..737304b 100644 --- a/src/isomedia/isom_read.c +++ b/src/isomedia/isom_read.c @@ -1992,6 +1992,7 @@ GF_Err gf_isom_release_segment(GF_ISOFile *movie, Bool reset_tables) return GF_OK; } +GF_EXPORT GF_Err gf_isom_open_segment(GF_ISOFile *movie, const char *fileName, u64 start_range, u64 end_range) { #ifdef GPAC_DISABLE_ISOM_FRAGMENTS @@ -2295,6 +2296,7 @@ GF_Err gf_isom_get_track_layout_info(GF_ISOFile *movie, u32 trackNumber, u32 *wi /*returns total amount of media bytes in track*/ +GF_EXPORT u64 gf_isom_get_media_data_size(GF_ISOFile *movie, u32 trackNumber) { u32 i, size; @@ -2614,6 +2616,7 @@ GF_Err gf_isom_get_timed_meta_data_info(GF_ISOFile *file, u32 track, u32 sampleD return GF_OK; } +GF_EXPORT u32 gf_isom_get_next_alternate_group_id(GF_ISOFile *movie) { u32 id = 0; @@ -2650,6 +2653,7 @@ GF_Err gf_isom_sample_get_subsample(GF_ISOFile *movie, u32 track, u32 sampleNumb return GF_OK; } +GF_EXPORT GF_Err gf_isom_get_rvc_config(GF_ISOFile *movie, u32 track, u32 sampleDescriptionIndex, u16 *rvc_predefined, char **data, u32 *size, const char **mime) { GF_MPEGVisualSampleEntryBox *entry; @@ -2696,6 +2700,7 @@ Bool gf_isom_moov_first(GF_ISOFile *movie) return 0; } +GF_EXPORT void gf_isom_reset_fragment_info(GF_ISOFile *movie) { u32 i; diff --git a/src/isomedia/isom_write.c b/src/isomedia/isom_write.c index 33b7160..0ab755a 100644 --- a/src/isomedia/isom_write.c +++ b/src/isomedia/isom_write.c @@ -137,6 +137,7 @@ GF_Err gf_isom_add_track_to_root_od(GF_ISOFile *movie, u32 trackNumber) } //remove the root OD +GF_EXPORT GF_Err gf_isom_remove_root_od(GF_ISOFile *movie) { GF_Err e; @@ -150,6 +151,7 @@ GF_Err gf_isom_remove_root_od(GF_ISOFile *movie) } //remove a track to the root OD +GF_EXPORT GF_Err gf_isom_remove_track_from_root_od(GF_ISOFile *movie, u32 trackNumber) { GF_List *esds; @@ -232,6 +234,7 @@ GF_Err gf_isom_set_track_enabled(GF_ISOFile *movie, u32 trackNumber, u8 enableTr return GF_OK; } +GF_EXPORT GF_Err gf_isom_set_media_language(GF_ISOFile *movie, u32 trackNumber, char *three_char_code) { GF_Err e; @@ -313,6 +316,7 @@ GF_Err gf_isom_add_desc_to_root_od(GF_ISOFile *movie, GF_Descriptor *theDesc) } +GF_EXPORT GF_Err gf_isom_set_timescale(GF_ISOFile *movie, u32 timeScale) { GF_Err e; @@ -325,6 +329,8 @@ GF_Err gf_isom_set_timescale(GF_ISOFile *movie, u32 timeScale) return GF_OK; } + +GF_EXPORT GF_Err gf_isom_set_pl_indication(GF_ISOFile *movie, u8 PL_Code, u8 ProfileLevel) { GF_IsomInitialObjectDescriptor *iod; @@ -776,6 +782,7 @@ GF_Err gf_isom_append_sample_data(GF_ISOFile *movie, u32 trackNumber, char *data //you must have created a StreamDescription with URL or URN specifying your referenced file //the data offset specifies the begining of the chunk //Use streamDescriptionIndex to specify the desired stream (if several) +GF_EXPORT GF_Err gf_isom_add_sample_reference(GF_ISOFile *movie, u32 trackNumber, u32 StreamDescriptionIndex, GF_ISOSample *sample, u64 dataOffset) { GF_TrackBox *trak; @@ -830,6 +837,7 @@ GF_Err gf_isom_add_sample_reference(GF_ISOFile *movie, u32 trackNumber, u32 Stre //set the duration of the last media sample. If not set, the duration of the last sample is the //duration of the previous one if any, or 1000 (default value). +GF_EXPORT GF_Err gf_isom_set_last_sample_duration(GF_ISOFile *movie, u32 trackNumber, u32 duration) { GF_TrackBox *trak; @@ -851,26 +859,24 @@ GF_Err gf_isom_set_last_sample_duration(GF_ISOFile *movie, u32 trackNumber, u32 ent = (GF_SttsEntry*) &stts->entries[stts->nb_entries-1]; mdur -= ent->sampleDelta; - if (duration) { - mdur += duration; - //we only have one sample - if (ent->sampleCount == 1) { - ent->sampleDelta = duration; - } else { - if (ent->sampleDelta == duration) return GF_OK; - ent->sampleCount -= 1; + mdur += duration; + //we only have one sample + if (ent->sampleCount == 1) { + ent->sampleDelta = duration; + } else { + if (ent->sampleDelta == duration) return GF_OK; + ent->sampleCount -= 1; - if (stts->nb_entries==stts->alloc_size) { - stts->alloc_size++; - stts->entries = gf_realloc(stts->entries, sizeof(GF_SttsEntry)*stts->alloc_size); - if (!stts->entries) return GF_OUT_OF_MEM; - } - stts->entries[stts->nb_entries].sampleCount = 1; - stts->entries[stts->nb_entries].sampleDelta = duration; - stts->nb_entries++; - //and update the write cache - stts->w_currentSampleNum = trak->Media->information->sampleTable->SampleSize->sampleCount; + if (stts->nb_entries==stts->alloc_size) { + stts->alloc_size++; + stts->entries = gf_realloc(stts->entries, sizeof(GF_SttsEntry)*stts->alloc_size); + if (!stts->entries) return GF_OUT_OF_MEM; } + stts->entries[stts->nb_entries].sampleCount = 1; + stts->entries[stts->nb_entries].sampleDelta = duration; + stts->nb_entries++; + //and update the write cache + stts->w_currentSampleNum = trak->Media->information->sampleTable->SampleSize->sampleCount; } trak->Media->mediaHeader->modificationTime = gf_isom_get_mp4time(); trak->Media->mediaHeader->duration = mdur; @@ -944,6 +950,7 @@ GF_Err gf_isom_update_sample_reference(GF_ISOFile *movie, u32 trackNumber, u32 s //Remove a given sample +GF_EXPORT GF_Err gf_isom_remove_sample(GF_ISOFile *movie, u32 trackNumber, u32 sampleNumber) { GF_Err e; @@ -999,6 +1006,7 @@ GF_Err gf_isom_remove_sample(GF_ISOFile *movie, u32 trackNumber, u32 sampleNumbe } +GF_EXPORT GF_Err gf_isom_set_final_name(GF_ISOFile *movie, char *filename) { GF_Err e; @@ -1100,6 +1108,7 @@ insertIPI: //use carefully. Very usefull when you made a lot of changes (IPMP, IPI, OCI, ...) //THIS WILL REPLACE THE WHOLE DESCRIPTOR ... +GF_EXPORT GF_Err gf_isom_change_mpeg4_description(GF_ISOFile *movie, u32 trackNumber, u32 StreamDescriptionIndex, GF_ESD *newESD) { GF_Err e; @@ -1266,6 +1275,7 @@ GF_Err gf_isom_set_audio_info(GF_ISOFile *movie, u32 trackNumber, u32 StreamDesc } //set the storage mode of a file (FLAT, STREAMABLE, INTERLEAVED) +GF_EXPORT GF_Err gf_isom_set_storage_mode(GF_ISOFile *movie, u8 storageMode) { GF_Err e; @@ -1289,6 +1299,7 @@ GF_Err gf_isom_set_storage_mode(GF_ISOFile *movie, u8 storageMode) //update or insert a new edit segment in the track time line. Edits are used to modify //the media normal timing. EditTime and EditDuration are expressed in Movie TimeScale //If a segment with EditTime already exists, IT IS ERASED +GF_EXPORT GF_Err gf_isom_set_edit_segment(GF_ISOFile *movie, u32 trackNumber, u64 EditTime, u64 EditDuration, u64 MediaTime, u8 EditMode) { GF_TrackBox *trak; @@ -1379,6 +1390,7 @@ found: } //remove the edit segments for the whole track +GF_EXPORT GF_Err gf_isom_remove_edit_segments(GF_ISOFile *movie, u32 trackNumber) { GF_Err e; @@ -1429,6 +1441,7 @@ GF_Err gf_isom_remove_edit_segment(GF_ISOFile *movie, u32 trackNumber, u32 seg_i } +GF_EXPORT GF_Err gf_isom_append_edit_segment(GF_ISOFile *movie, u32 trackNumber, u64 EditDuration, u64 MediaTime, u8 EditMode) { GF_Err e; @@ -1471,6 +1484,7 @@ GF_Err gf_isom_append_edit_segment(GF_ISOFile *movie, u32 trackNumber, u64 EditD return SetTrackDuration(trak); } +GF_EXPORT GF_Err gf_isom_modify_edit_segment(GF_ISOFile *movie, u32 trackNumber, u32 seg_index, u64 EditDuration, u64 MediaTime, u8 EditMode) { GF_Err e; @@ -1504,6 +1518,7 @@ GF_Err gf_isom_modify_edit_segment(GF_ISOFile *movie, u32 trackNumber, u32 seg_i } //removes the desired track +GF_EXPORT GF_Err gf_isom_remove_track(GF_ISOFile *movie, u32 trackNumber) { GF_Err e; @@ -1622,6 +1637,7 @@ GF_Err gf_isom_remove_track(GF_ISOFile *movie, u32 trackNumber) } +GF_EXPORT GF_Err gf_isom_set_copyright(GF_ISOFile *movie, const char *threeCharCode, char *notice) { GF_Err e; @@ -1664,6 +1680,7 @@ GF_Err gf_isom_set_copyright(GF_ISOFile *movie, const char *threeCharCode, char return udta_AddBox(movie->moov->udta, (GF_Box *) ptr); } +GF_EXPORT GF_Err gf_isom_add_chapter(GF_ISOFile *movie, u32 trackNumber, u64 timestamp, char *name) { GF_Err e; @@ -1949,7 +1966,7 @@ GF_Err gf_isom_use_compact_size(GF_ISOFile *movie, u32 trackNumber, u8 Compactio } - +GF_EXPORT GF_Err gf_isom_set_brand_info(GF_ISOFile *movie, u32 MajorBrand, u32 MinorVersion) { u32 i, *p; @@ -1995,6 +2012,8 @@ GF_Err gf_isom_set_brand_info(GF_ISOFile *movie, u32 MajorBrand, u32 MinorVersio return GF_OK; } + +GF_EXPORT GF_Err gf_isom_modify_alternate_brand(GF_ISOFile *movie, u32 Brand, u8 AddIt) { u32 i, k, *p; @@ -2258,6 +2277,7 @@ GF_Err gf_isom_add_sample_fragment(GF_ISOFile *movie, u32 trackNumber, u32 sampl } +GF_EXPORT GF_Err gf_isom_remove_sample_fragment(GF_ISOFile *movie, u32 trackNumber, u32 sampleNumber) { GF_TrackBox *trak; @@ -2289,6 +2309,7 @@ GF_Err gf_isom_remove_sample_fragments(GF_ISOFile *movie, u32 trackNumber) return GF_OK; } +GF_EXPORT GF_Err gf_isom_clone_pl_indications(GF_ISOFile *orig, GF_ISOFile *dest) { GF_IsomInitialObjectDescriptor *iod_d; @@ -2394,7 +2415,7 @@ GF_Err gf_isom_clone_movie(GF_ISOFile *orig_file, GF_ISOFile *dest_file, Bool cl } - +GF_EXPORT GF_Err gf_isom_clone_track(GF_ISOFile *orig_file, u32 orig_track, GF_ISOFile *dest_file, Bool keep_data_ref, u32 *dest_track) { GF_TrackBox *trak, *new_tk; @@ -2517,6 +2538,8 @@ GF_Err gf_isom_clone_sample_descriptions(GF_ISOFile *the_file, u32 trackNumber, return e; } + +GF_EXPORT GF_Err gf_isom_clone_sample_description(GF_ISOFile *the_file, u32 trackNumber, GF_ISOFile *orig_file, u32 orig_track, u32 orig_desc_index, char *URLname, char *URNname, u32 *outDescriptionIndex) { GF_TrackBox *trak; @@ -2802,6 +2825,7 @@ GF_Err gf_isom_remove_sample_description(GF_ISOFile *movie, u32 trackNumber, u32 //sets a track reference +GF_EXPORT GF_Err gf_isom_set_track_reference(GF_ISOFile *the_file, u32 trackNumber, u32 referenceType, u32 ReferencedTrackID) { GF_Err e; @@ -2832,6 +2856,7 @@ GF_Err gf_isom_set_track_reference(GF_ISOFile *the_file, u32 trackNumber, u32 re } //removes a track reference +GF_EXPORT GF_Err gf_isom_remove_track_reference(GF_ISOFile *the_file, u32 trackNumber, u32 referenceType, u32 ReferenceIndex) { GF_Err e; @@ -2943,6 +2968,7 @@ GF_Err gf_isom_remove_cts_info(GF_ISOFile *the_file, u32 trackNumber) return GF_OK; } +GF_EXPORT GF_Err gf_isom_set_cts_packing(GF_ISOFile *the_file, u32 trackNumber, Bool unpack) { GF_Err e; @@ -2971,6 +2997,7 @@ GF_Err gf_isom_set_track_matrix(GF_ISOFile *the_file, u32 trackNumber, u32 matri return GF_OK; } +GF_EXPORT GF_Err gf_isom_set_track_layout_info(GF_ISOFile *the_file, u32 trackNumber, u32 width, u32 height, s32 translation_x, s32 translation_y, s16 layer) { GF_TrackBox *trak = gf_isom_get_track_from_file(the_file, trackNumber); @@ -3129,7 +3156,7 @@ GF_Err gf_isom_set_media_timescale(GF_ISOFile *the_file, u32 trackNumber, u32 ne } - +GF_EXPORT Bool gf_isom_is_same_sample_description(GF_ISOFile *f1, u32 tk1, u32 sdesc_index1, GF_ISOFile *f2, u32 tk2, u32 sdesc_index2) { u32 i, count; @@ -3259,6 +3286,7 @@ Bool gf_isom_is_same_sample_description(GF_ISOFile *f1, u32 tk1, u32 sdesc_index return ret; } +GF_EXPORT u64 gf_isom_estimate_size(GF_ISOFile *movie) { GF_Err e; @@ -3377,6 +3405,7 @@ GF_Err gf_isom_set_max_samples_per_chunk(GF_ISOFile *movie, u32 trackNumber, u32 } +GF_EXPORT GF_Err gf_isom_set_extraction_slc(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, GF_SLConfig *slConfig) { GF_TrackBox *trak; @@ -3475,6 +3504,7 @@ u32 gf_isom_get_track_priority_in_group(GF_ISOFile *the_file, u32 trackNumber) } +GF_EXPORT GF_Err gf_isom_make_interleave(GF_ISOFile *file, Double TimeInSec) { GF_Err e; @@ -3485,6 +3515,7 @@ GF_Err gf_isom_make_interleave(GF_ISOFile *file, Double TimeInSec) } +GF_EXPORT GF_Err gf_isom_set_handler_name(GF_ISOFile *the_file, u32 trackNumber, const char *nameUTF8) { GF_TrackBox *trak; @@ -3687,6 +3718,7 @@ GF_Err gf_isom_add_uuid(GF_ISOFile *movie, u32 trackNumber, bin128 UUID, char *d /*Apple extensions*/ +GF_EXPORT GF_Err gf_isom_apple_set_tag(GF_ISOFile *mov, u32 tag, const char *data, u32 data_len) { GF_BitStream *bs; @@ -3999,6 +4031,7 @@ GF_Err gf_isom_add_subsample(GF_ISOFile *movie, u32 track, u32 sampleNumber, u32 } +GF_EXPORT GF_Err gf_isom_set_rvc_config(GF_ISOFile *movie, u32 track, u32 sampleDescriptionIndex, u16 rvc_predefined, char *mime, char *data, u32 size) { GF_MPEGVisualSampleEntryBox *entry; diff --git a/src/isomedia/media.c b/src/isomedia/media.c index e8ab639..c84bfa9 100644 --- a/src/isomedia/media.c +++ b/src/isomedia/media.c @@ -425,6 +425,10 @@ Bool Media_IsSelfContained(GF_MediaBox *mdia, u32 StreamDescIndex) Media_GetSampleDesc(mdia, StreamDescIndex, &se, &drefIndex); if (!drefIndex) return 0; a = (GF_FullBox*)gf_list_get(mdia->information->dataInformation->dref->boxList, drefIndex - 1); + if (!a) { + GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] broken file: Data reference index set to %d but no data reference entry found\n", drefIndex)); + return 0; + } if (a->flags & 1) return 1; /*QT specific*/ if (a->type == GF_4CC('a', 'l', 'i', 's')) return 1; diff --git a/src/isomedia/meta.c b/src/isomedia/meta.c index 6fb0a9d..5f17c15 100644 --- a/src/isomedia/meta.c +++ b/src/isomedia/meta.c @@ -64,6 +64,7 @@ u32 gf_isom_has_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num) return 0; } +GF_EXPORT GF_Err gf_isom_extract_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num, char *outName, Bool *is_binary) { u32 i, count; @@ -189,6 +190,7 @@ u32 gf_isom_get_meta_item_by_id(GF_ISOFile *file, Bool root_meta, u32 track_num, return 0; } +GF_EXPORT GF_Err gf_isom_extract_meta_item_extended(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_id, const char *dump_file_name, char **out_data, u32 *out_size, const char **out_mime ) { GF_BitStream *item_bs; @@ -285,6 +287,7 @@ GF_Err gf_isom_extract_meta_item_extended(GF_ISOFile *file, Bool root_meta, u32 return GF_OK; } +GF_EXPORT GF_Err gf_isom_extract_meta_item(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_id, const char *dump_file_name) { return gf_isom_extract_meta_item_extended(file, root_meta, track_num, item_id, dump_file_name, NULL, NULL, NULL); @@ -295,6 +298,7 @@ GF_Err gf_isom_extract_meta_item_mem(GF_ISOFile *file, Bool root_meta, u32 track return gf_isom_extract_meta_item_extended(file, root_meta, track_num, item_id, NULL, out_data, out_size, out_mime); } +GF_EXPORT u32 gf_isom_get_meta_primary_item_id(GF_ISOFile *file, Bool root_meta, u32 track_num) { GF_MetaBox *meta = gf_isom_get_meta(file, root_meta, track_num); @@ -306,6 +310,7 @@ u32 gf_isom_get_meta_primary_item_id(GF_ISOFile *file, Bool root_meta, u32 track #ifndef GPAC_DISABLE_ISOM_WRITE +GF_EXPORT GF_Err gf_isom_set_meta_type(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 metaType) { char szName[20]; @@ -363,6 +368,7 @@ GF_Err gf_isom_set_meta_type(GF_ISOFile *file, Bool root_meta, u32 track_num, u3 return GF_OK; } +GF_EXPORT GF_Err gf_isom_remove_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num) { u32 i; @@ -382,6 +388,7 @@ GF_Err gf_isom_remove_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num) return GF_OK; } +GF_EXPORT GF_Err gf_isom_set_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num, char *XMLFileName, Bool IsBinaryXML) { GF_Err e; @@ -614,6 +621,7 @@ GF_Err gf_isom_add_meta_item_extended(GF_ISOFile *file, Bool root_meta, u32 trac return GF_OK; } +GF_EXPORT GF_Err gf_isom_add_meta_item(GF_ISOFile *file, Bool root_meta, u32 track_num, Bool self_reference, char *resource_path, const char *item_name, const char *mime_type, const char *content_encoding, const char *URL, const char *URN) { return gf_isom_add_meta_item_extended(file, root_meta, track_num, self_reference, resource_path, item_name, mime_type, content_encoding, URL, URN, NULL, 0); @@ -624,6 +632,7 @@ GF_Err gf_isom_add_meta_item_memory(GF_ISOFile *file, Bool root_meta, u32 track_ return gf_isom_add_meta_item_extended(file, root_meta, track_num, 0, NULL, item_name, mime_type, content_encoding, NULL, NULL, data, data_len); } +GF_EXPORT GF_Err gf_isom_remove_meta_item(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_id) { GF_ItemInfoEntryBox *iinf; @@ -653,6 +662,7 @@ GF_Err gf_isom_remove_meta_item(GF_ISOFile *file, Bool root_meta, u32 track_num, return GF_OK; } +GF_EXPORT GF_Err gf_isom_set_meta_primary_item(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_id) { GF_MetaBox *meta = gf_isom_get_meta(file, root_meta, track_num); diff --git a/src/isomedia/movie_fragments.c b/src/isomedia/movie_fragments.c index 187ff4e..964ffef 100644 --- a/src/isomedia/movie_fragments.c +++ b/src/isomedia/movie_fragments.c @@ -875,7 +875,7 @@ GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegments_per_sidx, u32 re Bool first_frag_in_subseg; Bool no_sidx = 0; u32 count, idx, cur_dur, sidx_dur, sidx_idx, idx_offset, frag_count; - u64 last_top_box_pos, root_prev_offset, local_sidx_start, local_sidx_end, prev_earliest_cts, prev_earliest_dts; + u64 last_top_box_pos, root_prev_offset, local_sidx_start, local_sidx_end, prev_earliest_cts; GF_TrackBox *trak = NULL; GF_Err e; /*number of subsegment in this segment (eg nb references in the first SIDX found)*/ @@ -945,7 +945,6 @@ GF_Err gf_isom_close_segment(GF_ISOFile *movie, s32 subsegments_per_sidx, u32 re frags_per_subsidx = 0; prev_earliest_cts = 0; - prev_earliest_dts = ref_track_decode_time; if (daisy_chain_sidx) daisy_sidx = gf_list_new(); @@ -1507,6 +1506,9 @@ GF_Err gf_isom_fragment_add_sample(GF_ISOFile *movie, u32 TrackID, GF_ISOSample ent->Duration = Duration; ent->size = sample->dataLength; ent->flags = GF_ISOM_FORMAT_FRAG_FLAGS(PaddingBits, sample->IsRAP, DegradationPriority); + if (sample->IsRAP) { + ent->flags |= GF_ISOM_GET_FRAG_DEPEND_FLAGS(0, 2, 0, 0); + } gf_list_add(trun->entries, ent); trun->sample_count += 1; @@ -1601,6 +1603,8 @@ GF_Err gf_isom_fragment_copy_subsample(GF_ISOFile *dest, u32 TrackID, GF_ISOFile GF_Err e; GF_TrackBox *trak; GF_TrackFragmentBox *traf; + GF_TrunEntry *ent; + GF_TrackFragmentRunBox *trun; if (!dest->moof || !(dest->FragmentsFlags & GF_ISOM_FRAG_WRITE_READY) ) return GF_BAD_PARAM; traf = GetTraf(dest, TrackID); @@ -1609,6 +1613,25 @@ GF_Err gf_isom_fragment_copy_subsample(GF_ISOFile *dest, u32 TrackID, GF_ISOFile trak = gf_isom_get_track_from_file(orig, track); if (!trak) return GF_BAD_PARAM; + /*modify depends flags*/ + if (trak->Media->information->sampleTable->SampleDep) { + u32 dependsOn, dependedOn, redundant; + + dependsOn = dependedOn = redundant = 0; + count = gf_list_count(traf->TrackRuns); + if (!count) return GF_BAD_PARAM; + trun = (GF_TrackFragmentRunBox *)gf_list_get(traf->TrackRuns, count-1); + count = gf_list_count(trun->entries); + if (!count) return GF_BAD_PARAM; + + ent = (GF_TrunEntry *)gf_list_get(trun->entries, count-1); + e = stbl_GetSampleDepType(trak->Media->information->sampleTable->SampleDep, sampleNumber, &dependsOn, &dependedOn, &redundant); + if (e) return e; + + GF_ISOM_RESET_FRAG_DEPEND_FLAGS(ent->flags); + ent->flags |= GF_ISOM_GET_FRAG_DEPEND_FLAGS(0, dependsOn, dependedOn, redundant); + } + /*copy subsample info if any*/ if ( gf_isom_sample_get_subsample_entry(orig, track, sampleNumber, &sub_sample)) { if (!traf || !traf->tfhd->sample_desc_index) return GF_BAD_PARAM; diff --git a/src/isomedia/sample_descs.c b/src/isomedia/sample_descs.c index 5d1c21e..616cb0b 100644 --- a/src/isomedia/sample_descs.c +++ b/src/isomedia/sample_descs.c @@ -373,7 +373,7 @@ GF_Err gf_isom_ac3_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_AC3Confi - +GF_EXPORT GF_Err gf_isom_get_dims_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex, GF_DIMSDescription *desc) { GF_DIMSSampleEntryBox *dims; diff --git a/src/mcrypt/sha1.c b/src/mcrypt/sha1.c index 5c8100f..3ce8c61 100644 --- a/src/mcrypt/sha1.c +++ b/src/mcrypt/sha1.c @@ -306,6 +306,7 @@ void gf_sha1_finish(GF_SHA1Context *ctx, u8 output[20] ) /* * Output = SHA-1( file contents ) */ +GF_EXPORT s32 gf_sha1_file( const char *path, u8 output[20] ) { FILE *f; diff --git a/src/media_tools/ait.c b/src/media_tools/ait.c index 8adb546..112ab70 100644 --- a/src/media_tools/ait.c +++ b/src/media_tools/ait.c @@ -393,18 +393,14 @@ static GF_Err gf_m2ts_decode_ait(GF_M2TS_AIT *ait, char *data, u32 data_size, u static void gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT* ait){ - u32 nb_app_desc,k,desc_id; - - u32 nb_of_app,j,i; + u32 nb_app_desc, k, desc_id, nb_of_app, j; GF_M2TS_CHANNEL_APPLICATION_INFO* ChanAppInfo; - char* url_base; - char* url_appli_path; + char *url_base, *url_appli_path; nb_of_app = gf_list_count(ait->application_decoded); url_base = NULL; url_appli_path = NULL; - j=0; - i=0; + j=0; /* Link the AIT and the channel */ ChanAppInfo = gf_m2ts_get_channel_application_info(ts->ChannelAppList,ait->service_id); diff --git a/src/media_tools/av_parsers.c b/src/media_tools/av_parsers.c index fa6f6c7..3f6fc62 100644 --- a/src/media_tools/av_parsers.c +++ b/src/media_tools/av_parsers.c @@ -2777,6 +2777,7 @@ static const u32 ac3_mod_to_chans[] = { 2, 1, 2, 3, 3, 4, 4, 5 }; +GF_EXPORT u32 gf_ac3_get_channels(u32 acmod) { u32 nb_ch; @@ -2784,6 +2785,7 @@ u32 gf_ac3_get_channels(u32 acmod) return nb_ch; } +GF_EXPORT u32 gf_ac3_get_bitrate(u32 brcode) { return ac3_sizecod_to_bitrate[brcode]; @@ -2842,6 +2844,7 @@ Bool gf_ac3_parser(u8 *buf, u32 buflen, u32 *pos, GF_AC3Header *hdr, Bool full_p } +GF_EXPORT Bool gf_ac3_parser_bs(GF_BitStream *bs, GF_AC3Header *hdr, Bool full_parse) { u32 fscod, frmsizecod, bsid, ac3_mod, freq, framesize, bsmod; diff --git a/src/media_tools/dsmcc.c b/src/media_tools/dsmcc.c index 6b3e02c..ed764fb 100644 --- a/src/media_tools/dsmcc.c +++ b/src/media_tools/dsmcc.c @@ -278,7 +278,7 @@ static GF_Err gf_m2ts_dsmcc_download_data(GF_M2TS_DSMCC_OVERLORD *dsmcc_overlord } case DOWNLOAD_DATA_BLOCK: { - u32 data_shift,modules_count,i; + u32 modules_count, i; GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK* DownloadDataBlock; GF_SAFEALLOC(DownloadDataBlock,GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK); DataMessage->dataMessagePayload = DownloadDataBlock; @@ -312,7 +312,7 @@ static GF_Err gf_m2ts_dsmcc_download_data(GF_M2TS_DSMCC_OVERLORD *dsmcc_overlord return GF_CORRUPTED_DATA; } DownloadDataBlock->blockDataByte = (char*)gf_calloc(DownloadDataBlock->dataBlocksize,sizeof(char)); - data_shift = (u32)(gf_bs_get_position(bs)); + *data_shift = (u32)(gf_bs_get_position(bs)); gf_bs_read_data(bs,DownloadDataBlock->blockDataByte,DownloadDataBlock->dataBlocksize); memcpy(dsmcc_module->buffer+dsmcc_module->byte_sift,DownloadDataBlock->blockDataByte,DownloadDataBlock->dataBlocksize*sizeof(char)); dsmcc_module->byte_sift += DownloadDataBlock->dataBlocksize; @@ -357,14 +357,11 @@ static GF_Err gf_m2ts_dsmcc_download_data(GF_M2TS_DSMCC_OVERLORD *dsmcc_overlord } case DOWNLOAD_SERVER_INITIATE: - { - u32 localbyteshift; GF_Err e; GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT* DownloadServerInit; GF_SAFEALLOC(DownloadServerInit,GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT); DataMessage->dataMessagePayload = DownloadServerInit; - localbyteshift = (u32)(gf_bs_get_position(bs)); gf_bs_read_data(bs,DownloadServerInit->serverId,20); gf_m2ts_dsmcc_process_compatibility_descriptor(&DownloadServerInit->CompatibilityDescr,data,bs,data_shift); DownloadServerInit->privateDataLength = gf_bs_read_int(bs,16); @@ -942,7 +939,6 @@ static GF_Err dsmcc_process_biop_file(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER GF_M2TS_DSMCC_SERVICE_GATEWAY* ServiceGateway; GF_M2TS_DSMCC_FILE* File; FILE* pFile; - char* FileType; u8* descr_tag; GF_SAFEALLOC(BIOP_File,GF_M2TS_DSMCC_BIOP_FILE); @@ -970,8 +966,7 @@ static GF_Err dsmcc_process_biop_file(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER switch(*descr_tag){ case CONTENT_TYPE_DESCRIPTOR: { - GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(BIOP_File->descriptor,0); - FileType = strdup(ContentTypeDescr->content_type_data_byte); + //GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(BIOP_File->descriptor,0); } default: { @@ -1020,8 +1015,6 @@ static GF_Err dsmcc_process_biop_directory(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_H GF_M2TS_DSMCC_BIOP_DIRECTORY* BIOP_Directory; GF_M2TS_DSMCC_DIR* Dir; - char* ParentName; - char* FileType; u32 i; GF_M2TS_DSMCC_SERVICE_GATEWAY* ServiceGateway; @@ -1043,7 +1036,6 @@ static GF_Err dsmcc_process_biop_directory(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_H ServiceGateway->objectKey_data = BIOP_Directory->Header->objectKey_data; ServiceGateway->parent = NULL; ServiceGateway->name = (char*)gf_strdup(dsmcc_overlord->root_dir); - ParentName = ServiceGateway->name; }else{ /* get the dir related to the payload */ Dir = dsmcc_get_directory(ServiceGateway->Dir,BIOP_Directory->Header->objectKey_data); @@ -1112,8 +1104,7 @@ static GF_Err dsmcc_process_biop_directory(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_H switch(*descr_tag){ case CONTENT_TYPE_DESCRIPTOR: { - GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(BIOP_Directory->Name[i].descriptor ,j); - FileType = strdup(ContentTypeDescr->content_type_data_byte); + //GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(BIOP_Directory->Name[i].descriptor ,j); } default: { @@ -1168,7 +1159,7 @@ static GF_Err dsmcc_process_biop_stream_event(GF_BitStream* bs,GF_M2TS_DSMCC_BIO u32 i; GF_M2TS_DSMCC_BIOP_STREAM_EVENT* BIOP_StreamEvent; //GF_M2TS_DSMCC_FILE* File; - u32 eventdata,Info_length; + u32 eventdata; GF_SAFEALLOC(BIOP_StreamEvent,GF_M2TS_DSMCC_BIOP_STREAM_EVENT); @@ -1201,10 +1192,8 @@ static GF_Err dsmcc_process_biop_stream_event(GF_BitStream* bs,GF_M2TS_DSMCC_BIO } } - Info_length = BIOP_StreamEvent->Header->objectInfo_length - (BIOP_StreamEvent->Info.aDescription_length + 14 + BIOP_StreamEvent->eventNames_count + eventdata); - BIOP_StreamEvent->serviceContextList_count = gf_bs_read_int(bs,8); - if(BIOP_StreamEvent->serviceContextList_count){ + if (BIOP_StreamEvent->serviceContextList_count) { BIOP_StreamEvent->ServiceContext = (GF_M2TS_DSMCC_SERVICE_CONTEXT*)gf_calloc(BIOP_StreamEvent->serviceContextList_count,sizeof(GF_M2TS_DSMCC_SERVICE_CONTEXT)); dsmcc_biop_get_context(bs,BIOP_StreamEvent->ServiceContext,BIOP_StreamEvent->serviceContextList_count); } @@ -1212,7 +1201,7 @@ static GF_Err dsmcc_process_biop_stream_event(GF_BitStream* bs,GF_M2TS_DSMCC_BIO BIOP_StreamEvent->messageBody_length = gf_bs_read_int(bs,32); BIOP_StreamEvent->taps_count = gf_bs_read_int(bs,8); BIOP_StreamEvent->Taps = (GF_M2TS_DSMCC_BIOP_TAPS*)gf_calloc(BIOP_StreamEvent->taps_count,sizeof(GF_M2TS_DSMCC_BIOP_TAPS)); - for(i=0;itaps_count;i++){ + for (i=0;itaps_count;i++) { BIOP_StreamEvent->Taps[i].id = gf_bs_read_int(bs,16); BIOP_StreamEvent->Taps[i].use = gf_bs_read_int(bs,16); BIOP_StreamEvent->Taps[i].assocTag = gf_bs_read_int(bs,16); @@ -1241,13 +1230,10 @@ static GF_Err dsmcc_process_biop_stream_event(GF_BitStream* bs,GF_M2TS_DSMCC_BIO static GF_Err dsmcc_process_biop_stream_message(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header,GF_M2TS_DSMCC_SERVICE_GATEWAY* ServiceGateway){ u32 i; - GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE* BIOP_StreamMessage; - u32 eventdata,Info_length; + GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE* BIOP_StreamMessage; GF_SAFEALLOC(BIOP_StreamMessage,GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE); - eventdata = 0; - BIOP_StreamMessage->Header = BIOP_Header; /* Get Info */ BIOP_StreamMessage->Info.aDescription_length = gf_bs_read_int(bs,8); @@ -1261,9 +1247,6 @@ static GF_Err dsmcc_process_biop_stream_message(GF_BitStream* bs,GF_M2TS_DSMCC_B BIOP_StreamMessage->Info.video = gf_bs_read_int(bs,8); BIOP_StreamMessage->Info.data = gf_bs_read_int(bs,8); - - Info_length = BIOP_StreamMessage->Header->objectInfo_length - (BIOP_StreamMessage->Info.aDescription_length + 10); - BIOP_StreamMessage->serviceContextList_count = gf_bs_read_int(bs,8); if(BIOP_StreamMessage->serviceContextList_count){ BIOP_StreamMessage->ServiceContext = (GF_M2TS_DSMCC_SERVICE_CONTEXT*)gf_calloc(BIOP_StreamMessage->serviceContextList_count,sizeof(GF_M2TS_DSMCC_SERVICE_CONTEXT)); @@ -1857,18 +1840,15 @@ static void dsmcc_free_biop_ior(GF_M2TS_DSMCC_IOR* IOR) gf_list_del(IOR->taggedProfile); } -static void dsmcc_free_biop_descriptor(GF_List* list){ +static void dsmcc_free_biop_descriptor(GF_List* list) +{ u8* descr_tag; - u32 descr_count; - - descr_count = gf_list_count(list); - - while(gf_list_count(list)){ + while(gf_list_count(list)) { descr_tag = (u8*)gf_list_get(list,0); - switch(*descr_tag){ + switch(*descr_tag) { case CACHING_PRIORITY_DESCRIPTOR: { diff --git a/src/media_tools/dvb_mpe.c b/src/media_tools/dvb_mpe.c index 0349a32..1882d24 100644 --- a/src/media_tools/dvb_mpe.c +++ b/src/media_tools/dvb_mpe.c @@ -425,15 +425,16 @@ void gf_m2ts_mpe_send_datagram(GF_M2TS_Demuxer *ts, u32 mpe_pid, unsigned char * Bool gf_m2ts_compare_ip(u8 rx_ip_adress[4], u8 ip_adress_bootstrap[4]) { - Bool Boostrap_ip; u8 i; - for (i=0; isock, ip_packet->data, ip_packet->u32_udp_data_size - 8); diff --git a/src/media_tools/filestreamer.c b/src/media_tools/filestreamer.c index 0bc694f..4a15a7b 100644 --- a/src/media_tools/filestreamer.c +++ b/src/media_tools/filestreamer.c @@ -167,6 +167,7 @@ static GF_Err gf_isom_streamer_setup_sdp(GF_ISOMRTPStreamer *streamer, char*sdpf return GF_OK; } +GF_EXPORT GF_Err gf_isom_streamer_write_sdp(GF_ISOMRTPStreamer *streamer, char*sdpfilename) { return gf_isom_streamer_setup_sdp(streamer, sdpfilename, NULL); @@ -198,6 +199,7 @@ void gf_isom_streamer_reset(GF_ISOMRTPStreamer *streamer, Bool is_loop) if (is_loop) streamer->timelineOrigin = 0; } +GF_EXPORT GF_Err gf_isom_streamer_send_next_packet(GF_ISOMRTPStreamer *streamer, s32 send_ahead_delay, s32 max_sleep_time) { GF_Err e = GF_OK; @@ -330,6 +332,7 @@ static u16 check_next_port(GF_ISOMRTPStreamer *streamer, u16 first_port) return first_port; } +GF_EXPORT GF_ISOMRTPStreamer *gf_isom_streamer_new(const char *file_name, const char *ip_dest, u16 port, Bool loop, Bool force_mpeg4, u32 path_mtu, u32 ttl, char *ifce_addr) { GF_ISOMRTPStreamer *streamer; @@ -503,6 +506,7 @@ exit: return NULL; } +GF_EXPORT void gf_isom_streamer_del(GF_ISOMRTPStreamer *streamer) { GF_RTPTrack *track = streamer->stream; diff --git a/src/media_tools/img.c b/src/media_tools/img.c index ade42ed..fdf04ee 100644 --- a/src/media_tools/img.c +++ b/src/media_tools/img.c @@ -519,6 +519,7 @@ void gf_png_flush(png_structp png) } /* write a png file */ +GF_EXPORT GF_Err gf_img_png_enc(char *data, u32 width, u32 height, s32 stride, u32 pixel_format, char *dst, u32 *dst_size) { GFpng udta; diff --git a/src/media_tools/isom_tools.c b/src/media_tools/isom_tools.c index 3f336a1..9f37d01 100644 --- a/src/media_tools/isom_tools.c +++ b/src/media_tools/isom_tools.c @@ -609,6 +609,7 @@ remove_track: return GF_OK; } +GF_EXPORT GF_Err gf_media_make_psp(GF_ISOFile *mp4) { u32 i, count; @@ -714,7 +715,7 @@ GF_Err gf_media_fragment_file(GF_ISOFile *input, const char *output_file, const GF_Err e; char sOpt[100], sKey[100]; char szCodecs[200], szCodec[100]; - u32 cur_seg, fragment_index, nb_fragments, max_sap_type; + u32 cur_seg, fragment_index, max_sap_type; GF_ISOFile *output; GF_ISOSample *sample, *next; GF_List *fragmenters; @@ -1069,7 +1070,6 @@ restart_fragmentation_pass: max_segment_duration = 0; - nb_fragments=0; while ( (count = gf_list_count(fragmenters)) ) { @@ -1416,8 +1416,6 @@ restart_fragmentation_pass: if (dash_mode) { char buffer[1000]; - u32 h, m; - Double s; /*flush last segment*/ if (!switch_segment) { @@ -1449,9 +1447,8 @@ restart_fragmentation_pass: } period_duration += file_duration; - h = (u32) (period_duration/3600); - m = (u32) (period_duration-h*60)/60; - s = period_duration - h*3600 - m*60; + //u32 h = (u32) (period_duration/3600); + //u32 m = (u32) (period_duration-h*60)/60; bandwidth = (u32) (file_size * 8 / file_duration); fprintf(mpd, " output_udta; @@ -1706,7 +1708,7 @@ GF_Err gf_m2ts_program_stream_update_ts_scale(GF_ESInterface *_self, u32 time_sc return GF_OK; } - +GF_EXPORT GF_M2TS_Mux_Program *gf_m2ts_mux_program_add(GF_M2TS_Mux *muxer, u32 program_number, u32 pmt_pid, u32 pmt_refresh_rate, u32 pcr_offset, Bool mpeg4_signaling) { GF_M2TS_Mux_Program *program; @@ -1732,6 +1734,7 @@ GF_M2TS_Mux_Program *gf_m2ts_mux_program_add(GF_M2TS_Mux *muxer, u32 program_num return program; } +GF_EXPORT GF_M2TS_Mux *gf_m2ts_mux_new(u32 mux_rate, u32 pat_refresh_rate, Bool real_time) { GF_BitStream *bs; @@ -1804,6 +1807,7 @@ void gf_m2ts_mux_program_del(GF_M2TS_Mux_Program *prog) gf_free(prog); } +GF_EXPORT void gf_m2ts_mux_del(GF_M2TS_Mux *mux) { while (mux->programs) { @@ -1838,6 +1842,7 @@ void gf_m2ts_mux_update_bitrate(GF_M2TS_Mux *mux) } } +GF_EXPORT void gf_m2ts_mux_update_config(GF_M2TS_Mux *mux, Bool reset_time) { GF_M2TS_Mux_Program *prog; @@ -1875,11 +1880,13 @@ void gf_m2ts_mux_update_config(GF_M2TS_Mux *mux, Bool reset_time) } } +GF_EXPORT u32 gf_m2ts_get_sys_clock(GF_M2TS_Mux *muxer) { return gf_sys_clock() - muxer->init_sys_time; } +GF_EXPORT u32 gf_m2ts_get_ts_clock(GF_M2TS_Mux *muxer) { u32 now, init; @@ -1888,6 +1895,7 @@ u32 gf_m2ts_get_ts_clock(GF_M2TS_Mux *muxer) return now-init; } +GF_EXPORT GF_Err gf_m2ts_mux_use_single_au_pes_mode(GF_M2TS_Mux *muxer, Bool strict_au_pes_mode) { if (!muxer) return GF_BAD_PARAM; @@ -1895,6 +1903,7 @@ GF_Err gf_m2ts_mux_use_single_au_pes_mode(GF_M2TS_Mux *muxer, Bool strict_au_pes return GF_OK; } +GF_EXPORT GF_Err gf_m2ts_mux_set_initial_pcr(GF_M2TS_Mux *muxer, u64 init_pcr_value) { if (!muxer) return GF_BAD_PARAM; @@ -1902,6 +1911,7 @@ GF_Err gf_m2ts_mux_set_initial_pcr(GF_M2TS_Mux *muxer, u64 init_pcr_value) return GF_OK; } +GF_EXPORT const char *gf_m2ts_mux_process(GF_M2TS_Mux *muxer, u32 *status) { GF_M2TS_Mux_Program *program; diff --git a/src/media_tools/media_import.c b/src/media_tools/media_import.c index 5b632f5..25deb74 100644 --- a/src/media_tools/media_import.c +++ b/src/media_tools/media_import.c @@ -3700,6 +3700,7 @@ exit: return e; } +GF_EXPORT GF_Err gf_media_avc_rewrite_samples(GF_ISOFile *file, u32 track, u32 prev_size, u32 new_size) { u32 i, count, di, remain, msize; @@ -5483,7 +5484,6 @@ void m2ts_rewrite_avc_sample(GF_MediaImporter *import, GF_TSImport *tsimp) { GF_Err e; u32 sc_pos, start; - char *data; GF_BitStream *bs; GF_ISOSample *samp; u32 count = gf_isom_get_sample_count(import->dest, tsimp->track); @@ -5493,7 +5493,6 @@ void m2ts_rewrite_avc_sample(GF_MediaImporter *import, GF_TSImport *tsimp) sc_pos = 1; start = 0; bs = gf_bs_new(samp->data, samp->dataLength, GF_BITSTREAM_WRITE); - data = samp->data; while (1) { if (!samp->data[start+sc_pos] && !samp->data[start+sc_pos+1] && !samp->data[start+sc_pos+2] && (samp->data[start+sc_pos+3]==1)) { gf_bs_seek(bs, start); diff --git a/src/media_tools/mpd.c b/src/media_tools/mpd.c index feeed1c..bf2578a 100644 --- a/src/media_tools/mpd.c +++ b/src/media_tools/mpd.c @@ -159,6 +159,7 @@ GF_Err gf_mpd_parse_base_url(GF_List *container, GF_XMLNode *node) GF_SAFEALLOC(url, GF_MPD_BaseURL); if (! url) return GF_OUT_OF_MEM; e = gf_list_add(container, url); + if (e) return GF_OUT_OF_MEM; i = 0; while ( (att = gf_list_enum(node->attributes, &i))) { @@ -653,7 +654,7 @@ static GF_Err gf_mpd_parse_period(GF_MPD *mpd, GF_XMLNode *root) return GF_OK; } - +GF_EXPORT GF_MPD *gf_mpd_new() { GF_MPD *mpd; @@ -826,6 +827,7 @@ void gf_mpd_period_free(void *_item) gf_free(ptr); } +GF_EXPORT void gf_mpd_del(GF_MPD *mpd) { gf_mpd_del_list(mpd->program_infos, gf_mpd_prog_info_free, 0); @@ -838,6 +840,7 @@ void gf_mpd_del(GF_MPD *mpd) gf_free(mpd); } +GF_EXPORT GF_Err gf_mpd_init_from_dom(GF_XMLNode *root, GF_MPD *mpd, const char *default_base_url) { GF_Err e; @@ -891,6 +894,8 @@ GF_Err gf_mpd_init_from_dom(GF_XMLNode *root, GF_MPD *mpd, const char *default_b mpd->max_subsegment_duration = gf_mpd_parse_duration(att->value); } } + if (mpd->type == GF_MPD_TYPE_STATIC) + mpd->minimum_update_period = 0; child_index = 0; while (1) { @@ -920,6 +925,7 @@ GF_Err gf_mpd_init_from_dom(GF_XMLNode *root, GF_MPD *mpd, const char *default_b return GF_OK; } +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) diff --git a/src/media_tools/mpegts.c b/src/media_tools/mpegts.c index 22b243c..6c214e3 100644 --- a/src/media_tools/mpegts.c +++ b/src/media_tools/mpegts.c @@ -46,6 +46,8 @@ #define DEBUG_TS_PACKET 0 + +GF_EXPORT const char *gf_m2ts_get_stream_name(u32 streamType) { switch (streamType) { @@ -2232,6 +2234,7 @@ static void gf_m2ts_process_packet(GF_M2TS_Demuxer *ts, unsigned char *data) return; } +GF_EXPORT GF_Err gf_m2ts_process_data(GF_M2TS_Demuxer *ts, char *data, u32 data_size) { u32 pos; @@ -2329,6 +2332,7 @@ void gf_m2ts_set_segment_switch(GF_M2TS_Demuxer *ts) } } +GF_EXPORT void gf_m2ts_reset_parsers(GF_M2TS_Demuxer *ts) { u32 i; @@ -2391,6 +2395,7 @@ static void gf_m2ts_process_section_discard(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION { } +GF_EXPORT GF_Err gf_m2ts_set_pes_framing(GF_M2TS_PES *pes, u32 mode) { GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] Setting pes framing mode of PID %d to %d\n", pes->pid, mode) ); @@ -2452,6 +2457,7 @@ GF_Err gf_m2ts_set_pes_framing(GF_M2TS_PES *pes, u32 mode) return GF_OK; } +GF_EXPORT GF_M2TS_Demuxer *gf_m2ts_demux_new() { GF_M2TS_Demuxer *ts; @@ -2480,6 +2486,7 @@ GF_M2TS_Demuxer *gf_m2ts_demux_new() return ts; } +GF_EXPORT void gf_m2ts_demux_dmscc_init(GF_M2TS_Demuxer *ts){ char* temp_dir; @@ -2504,6 +2511,7 @@ void gf_m2ts_demux_dmscc_init(GF_M2TS_Demuxer *ts){ } +GF_EXPORT void gf_m2ts_demux_del(GF_M2TS_Demuxer *ts) { u32 i; @@ -2908,6 +2916,7 @@ static GF_Err gf_dvb_tune(GF_Tuner *tuner, const char *url, const char *chan_pat return GF_OK; } +GF_EXPORT u32 gf_dvb_get_freq_from_url(const char *channels_config_path, const char *url) { FILE *channels_config_file; @@ -3003,6 +3012,7 @@ static GF_Err TSDemux_SetupFile(GF_M2TS_Demuxer *ts, char *url) } +GF_EXPORT GF_Err TSDemux_Demux_Setup(GF_M2TS_Demuxer *ts, const char *url, Bool loop) { char szURL[2048]; @@ -3041,6 +3051,7 @@ GF_Err TSDemux_Demux_Setup(GF_M2TS_Demuxer *ts, const char *url, Bool loop) return GF_NOT_SUPPORTED; } +GF_EXPORT GF_Err TSDemux_CloseDemux(GF_M2TS_Demuxer *ts) { GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[TSDemux] Destroying demuxer\n")); @@ -3059,7 +3070,7 @@ GF_Err TSDemux_CloseDemux(GF_M2TS_Demuxer *ts) return GF_OK; } - +GF_EXPORT GF_Err TSDemux_DemuxPlay(GF_M2TS_Demuxer *ts){ /*set the state variable outside the TS thread. If inside, we may get called for shutdown before the TS thread has started diff --git a/src/scene_manager/encode_isom.c b/src/scene_manager/encode_isom.c index 5a04550..021b4e5 100644 --- a/src/scene_manager/encode_isom.c +++ b/src/scene_manager/encode_isom.c @@ -414,6 +414,7 @@ static GF_Err gf_sm_encode_scene(GF_SceneManager *ctx, GF_ISOFile *mp4, GF_SMEnc GF_ISOSample *samp; GF_StreamContext *sc; GF_ESD *esd; + GF_MuxInfo *mux; #ifndef GPAC_DISABLE_BIFS_ENC GF_BifsEncoder *bifs_enc; #endif @@ -896,6 +897,14 @@ force_scene_rap: gf_sm_finalize_mux(mp4, esd, (u32) init_offset); gf_isom_set_last_sample_duration(mp4, track, 0); + mux = gf_sm_get_mux_info(esd); + if (mux && mux->duration) { + u64 tot_dur = mux->duration * esd->slConfig->timestampResolution / 1000; + u64 dur = gf_isom_get_media_duration(mp4, track); + if (dur <= tot_dur) + gf_isom_set_last_sample_duration(mp4, track, (u32) (tot_dur - dur)); + } + if (delete_desc) { gf_odf_desc_del((GF_Descriptor *) esd); esd = NULL; diff --git a/src/scene_manager/loader_bt.c b/src/scene_manager/loader_bt.c index de85f89..78b908c 100644 --- a/src/scene_manager/loader_bt.c +++ b/src/scene_manager/loader_bt.c @@ -3755,7 +3755,7 @@ GF_Err gf_sm_load_init_bt(GF_SceneLoader *load) } - +GF_EXPORT GF_List *gf_sm_load_bt_from_string(GF_SceneGraph *in_scene, char *node_str, Bool force_wrl) { GF_SceneLoader ctx; diff --git a/src/scenegraph/base_scenegraph.c b/src/scenegraph/base_scenegraph.c index a2d1806..c1e2ad6 100644 --- a/src/scenegraph/base_scenegraph.c +++ b/src/scenegraph/base_scenegraph.c @@ -42,6 +42,7 @@ static void node_modif_stub(GF_SceneGraph *sg, GF_Node *node, GF_FieldInfo *info { } +GF_EXPORT GF_SceneGraph *gf_sg_new() { GF_SceneGraph *tmp; @@ -522,6 +523,7 @@ void gf_sg_set_private(GF_SceneGraph *sg, void *ptr) if (sg) sg->userpriv = ptr; } +GF_EXPORT void *gf_sg_get_private(GF_SceneGraph *sg) { return sg ? sg->userpriv : NULL; @@ -1977,6 +1979,7 @@ static GF_Err gf_node_get_field_by_name_enum(GF_Node *node, char *name, GF_Field return GF_BAD_PARAM; } +GF_EXPORT GF_Err gf_node_get_field_by_name(GF_Node *node, char *name, GF_FieldInfo *field) { s32 res = -1; @@ -2135,6 +2138,7 @@ u32 gf_xml_get_namespace_id(char *name) return GF_XMLNS_UNDEFINED; } +GF_EXPORT GF_Err gf_sg_add_namespace(GF_SceneGraph *sg, char *name, char *qname) { u32 id; @@ -2241,6 +2245,7 @@ const char *gf_sg_get_namespace(GF_SceneGraph *sg, u32 xmlns_id) } +GF_EXPORT char *gf_node_dump_attribute(GF_Node *n, GF_FieldInfo *info) { #ifndef GPAC_DISABLE_SVG diff --git a/src/scenegraph/commands.c b/src/scenegraph/commands.c index d244c57..6d06516 100644 --- a/src/scenegraph/commands.c +++ b/src/scenegraph/commands.c @@ -29,6 +29,8 @@ #include + +GF_EXPORT GF_Command *gf_sg_command_new(GF_SceneGraph *graph, u32 tag) { GF_Command *ptr; @@ -872,6 +874,7 @@ GF_Err gf_sg_command_apply(GF_SceneGraph *graph, GF_Command *com, Double time_of return GF_OK; } +GF_EXPORT GF_CommandField *gf_sg_command_field_new(GF_Command *com) { GF_CommandField *ptr; diff --git a/src/scenegraph/dom_events.c b/src/scenegraph/dom_events.c index a435a53..4739de2 100644 --- a/src/scenegraph/dom_events.c +++ b/src/scenegraph/dom_events.c @@ -125,6 +125,7 @@ GF_Err gf_sg_listener_add(GF_Node *listener, GF_DOMEventTarget *evt_target) return gf_list_add(evt_target->evt_list, listener); } +GF_EXPORT GF_Err gf_node_dom_listener_add(GF_Node *node, GF_Node *listener) { if (!node || !listener) return GF_BAD_PARAM; @@ -143,6 +144,7 @@ GF_Err gf_node_dom_listener_add(GF_Node *node, GF_Node *listener) return gf_sg_listener_add(listener, node->sgprivate->interact->dom_evt); } +GF_EXPORT GF_Err gf_dom_listener_del(GF_Node *listener, GF_DOMEventTarget *target) { GF_FieldInfo info; @@ -713,6 +715,7 @@ void gf_smil_setup_events(GF_Node *node) gf_smil_setup_event_list(node, * (GF_List **)info.far_ptr, 0); } +GF_EXPORT void gf_dom_set_textContent(GF_Node *n, char *text) { GF_ParentNode *par = (GF_ParentNode *)n; @@ -721,6 +724,7 @@ void gf_dom_set_textContent(GF_Node *n, char *text) if (text) gf_dom_add_text_node(n, gf_strdup( text) ); } +GF_EXPORT GF_DOMText *gf_dom_add_text_node(GF_Node *parent, char *text_data) { GF_DOMText *text; @@ -742,6 +746,7 @@ GF_DOMText *gf_dom_new_text_node(GF_SceneGraph *sg) return text; } +GF_EXPORT char *gf_dom_flatten_textContent(GF_Node *n) { u32 len = 0; diff --git a/src/scenegraph/dom_smjs.c b/src/scenegraph/dom_smjs.c index 8b4ec65..02a9bbd 100644 --- a/src/scenegraph/dom_smjs.c +++ b/src/scenegraph/dom_smjs.c @@ -3274,7 +3274,7 @@ static JSBool dcci_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, js GF_DOMFullNode *n; GF_DOM_Event evt; char *str; - jsval readonly; + jsval readonly=0; if (!JS_InstanceOf(c, obj, &dom_rt->DCCIClass, NULL) ) return JS_TRUE; n = (GF_DOMFullNode*) dom_get_node(c, obj); if (!n) return JS_TRUE; diff --git a/src/scenegraph/mpeg4_nodes.c b/src/scenegraph/mpeg4_nodes.c index df72149..07d1a36 100644 --- a/src/scenegraph/mpeg4_nodes.c +++ b/src/scenegraph/mpeg4_nodes.c @@ -37996,6 +37996,7 @@ u32 gf_sg_mpeg4_node_get_child_ndt(GF_Node *node) } +GF_EXPORT u32 gf_node_mpeg4_type_by_class_name(const char *node_name) { if(!node_name) return 0; diff --git a/src/scenegraph/svg_attributes.c b/src/scenegraph/svg_attributes.c index a6a7802..e09a072 100644 --- a/src/scenegraph/svg_attributes.c +++ b/src/scenegraph/svg_attributes.c @@ -166,6 +166,7 @@ static const struct dom_event_def {u32 event; const char *name; u32 category; } { GF_EVENT_VP_RESIZE, "gpac_vp_changed", GF_DOM_EVENT_DOM }, }; +GF_EXPORT u32 gf_dom_event_type_by_name(const char *name) { u32 i, count; @@ -408,6 +409,9 @@ static const struct predef_keyid {u32 key_code; const char *name; } predefined_ { GF_KEY_RECORD, "Record" }, { GF_KEY_BEGINPAGE, "BeginPage" } }; + + +GF_EXPORT const char *gf_dom_get_key_name(u32 key_identifier) { u32 count = sizeof(predefined_key_identifiers) / sizeof(struct predef_keyid); @@ -3071,6 +3075,7 @@ GF_Err gf_svg_parse_element_id(GF_Node *n, const char *nodename, Bool warning_if } /* Parse an SVG attribute */ +GF_EXPORT GF_Err gf_svg_parse_attribute(GF_Node *n, GF_FieldInfo *info, char *attribute_content, u8 anim_value_type) { /* for all attributes, except strings, apply some sort of white space normalization*/ diff --git a/src/scenegraph/svg_smjs.c b/src/scenegraph/svg_smjs.c index 7a1bd54..d322061 100644 --- a/src/scenegraph/svg_smjs.c +++ b/src/scenegraph/svg_smjs.c @@ -2422,17 +2422,17 @@ static void svg_script_predestroy(GF_Node *n, void *eff, Bool is_destroy) static GF_Err JSScript_CreateSVGContext(GF_SceneGraph *sg) { GF_SVGJS *svg_js; - Bool do_lock = gf_sg_javascript_initialized(); GF_SAFEALLOC(svg_js, GF_SVGJS); - if (do_lock) gf_sg_lock_javascript(NULL, 1); /*create new ecmascript context*/ svg_js->js_ctx = gf_sg_ecmascript_new(sg); if (!svg_js->js_ctx) { gf_free(svg_js); - if (do_lock) gf_sg_lock_javascript(NULL, 0); return GF_SCRIPT_ERROR; } + + gf_sg_lock_javascript(svg_js->js_ctx, 1); + if (!svg_rt) { GF_SAFEALLOC(svg_rt, GF_SVGuDOM); JS_SETUP_CLASS(svg_rt->svgElement, "SVGElement", JSCLASS_HAS_PRIVATE, svg_element_getProperty, svg_element_setProperty, dom_element_finalize); @@ -2449,10 +2449,12 @@ static GF_Err JSScript_CreateSVGContext(GF_SceneGraph *sg) sg->svg_js = svg_js; /*load SVG & DOM APIs*/ svg_init_js_api(sg); - if (do_lock) gf_sg_lock_javascript(NULL, 0); svg_js->script_execute = svg_script_execute; svg_js->handler_execute = svg_script_execute_handler; + + gf_sg_lock_javascript(svg_js->js_ctx, 0); + return GF_OK; } diff --git a/src/scenegraph/vrml_route.c b/src/scenegraph/vrml_route.c index 13a48ee..17b4a5f 100644 --- a/src/scenegraph/vrml_route.c +++ b/src/scenegraph/vrml_route.c @@ -351,6 +351,7 @@ Bool gf_sg_route_activate(GF_Route *r) } +GF_EXPORT void gf_node_event_out(GF_Node *node, u32 FieldIndex) { u32 i; diff --git a/src/scenegraph/vrml_script.c b/src/scenegraph/vrml_script.c index 7de3386..d51f74f 100644 --- a/src/scenegraph/vrml_script.c +++ b/src/scenegraph/vrml_script.c @@ -288,6 +288,7 @@ GF_Err gf_sg_script_field_get_info(GF_ScriptField *field, GF_FieldInfo *info) return GF_OK; } +GF_EXPORT void gf_sg_script_event_in(GF_Node *node, GF_FieldInfo *in_field) { GF_ScriptPriv *priv = (GF_ScriptPriv *)node->sgprivate->UserPrivate; diff --git a/src/scenegraph/vrml_smjs.c b/src/scenegraph/vrml_smjs.c index e7961c3..8ef6f5e 100644 --- a/src/scenegraph/vrml_smjs.c +++ b/src/scenegraph/vrml_smjs.c @@ -37,6 +37,7 @@ /*fixes for JS > 1.8.0rc1 where GC routines have changed*/ +GF_EXPORT Bool gf_js_add_root(JSContext *cx, void *rp, u32 type) { #if (JS_VERSION>=185) @@ -83,6 +84,8 @@ Bool gf_js_add_named_root(JSContext *cx, void *rp, u32 type, const char *name) return (JS_AddNamedRoot(cx, rp, name)==JS_TRUE) ? 1 : 0; #endif } + +GF_EXPORT Bool gf_js_remove_root(JSContext *cx, void *rp, u32 type) { #if (JS_VERSION>=185) @@ -319,15 +322,25 @@ JSContext *gf_sg_ecmascript_new(GF_SceneGraph *sg) gf_sg_load_script_modules(sg); } js_rt->nb_inst++; + + gf_mx_p(js_rt->mx); +#if defined(JS_THREADSAFE) && (JS_VERSION>=185) + if (gf_mx_get_num_locks(js_rt->mx)==1) { + JS_SetRuntimeThread(js_rt->js_runtime); + } +#endif + ctx = JS_NewContext(js_rt->js_runtime, STACK_CHUNK_BYTES); JS_SetOptions(ctx, JS_GetOptions(ctx) | JSOPTION_WERROR); -#ifdef JS_THREADSAFE -#if (JS_VERSION>=185) +#if defined(JS_THREADSAFE) && (JS_VERSION>=185) JS_ClearContextThread(ctx); - JS_ClearRuntimeThread(js_rt->js_runtime); -#endif + if (gf_mx_get_num_locks(js_rt->mx)==1) { + JS_ClearRuntimeThread(js_rt->js_runtime); + } #endif + gf_mx_v(js_rt->mx); + return ctx; } @@ -355,6 +368,8 @@ void gf_sg_ecmascript_del(JSContext *ctx) } } + +GF_EXPORT #if (JS_VERSION>=185) JSBool gf_sg_js_has_instance(JSContext *c, JSObject *obj,const jsval *val, JSBool *vp) #else @@ -4421,12 +4436,12 @@ Bool JSScriptFromFile(GF_Node *node, const char *opt_file, Bool no_complain) return 0; } + static void JSScript_LoadVRML(GF_Node *node) { char *str; JSBool ret; u32 i; - Bool do_lock = gf_sg_javascript_initialized(); Bool local_script; jsval rval, fval; M_Script *script = (M_Script *)node; @@ -4453,15 +4468,14 @@ static void JSScript_LoadVRML(GF_Node *node) } local_script = str ? 1 : 0; - if (do_lock) gf_sg_lock_javascript(priv->js_ctx, 1); + /*lock runtime and set current thread before creating the context*/ priv->js_ctx = gf_sg_ecmascript_new(node->sgprivate->scenegraph); if (!priv->js_ctx) { - if (do_lock) gf_sg_lock_javascript(priv->js_ctx, 0); GF_LOG(GF_LOG_ERROR, GF_LOG_SCRIPT, ("[VRML JS] Cannot allocate ECMAScript context for node\n")); return; } - if (!do_lock) gf_sg_lock_javascript(priv->js_ctx, 1); + gf_sg_lock_javascript(priv->js_ctx, 1); JS_SetContextPrivate(priv->js_ctx, node); gf_sg_script_init_sm_api(priv, node); @@ -4744,6 +4758,7 @@ void gf_sg_set_script_action(GF_SceneGraph *scene, gf_sg_script_action script_ac #ifdef GPAC_HAS_SPIDERMONKEY +GF_EXPORT GF_Node *gf_sg_js_get_node(JSContext *c, JSObject *obj) { #ifndef GPAC_DISABLE_VRML @@ -4776,13 +4791,6 @@ Bool gf_sg_has_scripting() #endif } -Bool gf_sg_javascript_initialized() -{ -#ifdef GPAC_HAS_SPIDERMONKEY - if (js_rt) return 1; -#endif - return 0; -} #ifdef GPAC_HAS_SPIDERMONKEY @@ -4794,13 +4802,15 @@ Bool gf_sg_javascript_initialized() * (mozilla doc is wrong here) * * */ +GF_EXPORT void gf_sg_lock_javascript(struct JSContext *cx, Bool LockIt) { if (!js_rt) return; - assert(cx); + if (LockIt) { gf_mx_p(js_rt->mx); #ifdef JS_THREADSAFE + assert(cx); if (gf_mx_get_num_locks(js_rt->mx)==1) { #if (JS_VERSION>=185) JS_SetRuntimeThread(js_rt->js_runtime); @@ -4811,6 +4821,7 @@ void gf_sg_lock_javascript(struct JSContext *cx, Bool LockIt) #endif } else { #ifdef JS_THREADSAFE + assert(cx); if (gf_mx_get_num_locks(js_rt->mx)==1) { JS_EndRequest(cx); #if (JS_VERSION>=185) @@ -4823,6 +4834,7 @@ void gf_sg_lock_javascript(struct JSContext *cx, Bool LockIt) } } +GF_EXPORT Bool gf_sg_try_lock_javascript(struct JSContext *cx) { assert(cx); diff --git a/src/scenegraph/vrml_tools.c b/src/scenegraph/vrml_tools.c index 5c73e63..7459f26 100644 --- a/src/scenegraph/vrml_tools.c +++ b/src/scenegraph/vrml_tools.c @@ -33,6 +33,7 @@ #include +GF_EXPORT Bool gf_node_in_table_by_tag(u32 tag, u32 NDTType) { if (!tag) return 0; @@ -652,6 +653,7 @@ void gf_sg_vrml_field_pointer_del(void *field, u32 FieldType) /********************************************************************* MF Fields manipulation (alloc, gf_realloc, GetAt) *********************************************************************/ +GF_EXPORT const char *gf_sg_vrml_get_event_type_name(u32 EventType, Bool forX3D) { switch (EventType) { @@ -663,6 +665,7 @@ const char *gf_sg_vrml_get_event_type_name(u32 EventType, Bool forX3D) } } +GF_EXPORT const char *gf_sg_vrml_get_field_type_by_name(u32 FieldType) { @@ -753,6 +756,7 @@ u32 gf_sg_field_type_by_name(char *fieldType) void gf_sg_sfurl_del(SFURL url) { if (url.url) gf_free(url.url); } +GF_EXPORT Bool gf_sg_vrml_is_sf_field(u32 FieldType) { return (FieldTypeodm = odm; tmp->flags = codec->flags | GF_ESM_CODEC_IS_USE; tmp->decio = codec->decio; + tmp->process = codec->process; return tmp; } diff --git a/src/terminal/network_service.c b/src/terminal/network_service.c index 85015f1..10bc92c 100644 --- a/src/terminal/network_service.c +++ b/src/terminal/network_service.c @@ -889,6 +889,7 @@ GF_ClientService *gf_term_service_new(GF_Terminal *term, struct _od_manager *own return serv; } +GF_EXPORT Bool gf_term_is_supported_url(GF_Terminal *term, const char *fileName, Bool use_parent_url, Bool no_mime_check) { GF_InputService *ifce; diff --git a/src/terminal/object_browser.c b/src/terminal/object_browser.c index ed6fed0..a034b2c 100644 --- a/src/terminal/object_browser.c +++ b/src/terminal/object_browser.c @@ -60,6 +60,7 @@ static Bool gf_term_check_odm(GF_Terminal *term, GF_ObjectManager *odm) /*returns top-level OD of the presentation*/ +GF_EXPORT GF_ObjectManager *gf_term_get_root_object(GF_Terminal *term) { if (!term) return NULL; @@ -68,6 +69,7 @@ GF_ObjectManager *gf_term_get_root_object(GF_Terminal *term) } /*returns number of sub-ODs in the current root. scene_od must be an inline OD*/ +GF_EXPORT u32 gf_term_get_object_count(GF_Terminal *term, GF_ObjectManager *scene_od) { if (!term || !scene_od) return 0; @@ -77,6 +79,7 @@ u32 gf_term_get_object_count(GF_Terminal *term, GF_ObjectManager *scene_od) } /*returns indexed (0-based) OD manager in the scene*/ +GF_EXPORT GF_ObjectManager *gf_term_get_object(GF_Terminal *term, GF_ObjectManager *scene_od, u32 index) { if (!term || !scene_od) return NULL; @@ -85,6 +88,7 @@ GF_ObjectManager *gf_term_get_object(GF_Terminal *term, GF_ObjectManager *scene_ return (GF_ObjectManager *) gf_list_get(scene_od->subscene->resources, index); } +GF_EXPORT u32 gf_term_object_subscene_type(GF_Terminal *term, GF_ObjectManager *odm) { if (!term || !odm) return 0; @@ -106,6 +110,7 @@ void gf_term_select_object(GF_Terminal *term, GF_ObjectManager *odm) gf_scene_select_object(term->root_scene, odm); } +GF_EXPORT u32 gf_term_get_current_service_id(GF_Terminal *term) { SFURL *the_url; @@ -131,6 +136,7 @@ static void get_codec_stats(GF_Codec *dec, GF_MediaInfo *info) info->total_dec_time = dec->total_dec_time; } +GF_EXPORT GF_Err gf_term_get_object_info(GF_Terminal *term, GF_ObjectManager *odm, GF_MediaInfo *info) { GF_Channel *ch; @@ -268,7 +274,7 @@ GF_Err gf_term_get_object_info(GF_Terminal *term, GF_ObjectManager *odm, GF_Medi return GF_OK; } - +GF_EXPORT Bool gf_term_get_download_info(GF_Terminal *term, GF_ObjectManager *odm, u32 *d_enum, const char **server, const char **path, u32 *bytes_done, u32 *total_bytes, u32 *bytes_per_sec) { GF_DownloadSession * sess; @@ -283,6 +289,7 @@ Bool gf_term_get_download_info(GF_Terminal *term, GF_ObjectManager *odm, u32 *d_ return 1; } +GF_EXPORT Bool gf_term_get_channel_net_info(GF_Terminal *term, GF_ObjectManager *odm, u32 *d_enum, u32 *chid, NetStatCommand *netcom, GF_Err *ret_code) { GF_Channel *ch; @@ -305,6 +312,7 @@ Bool gf_term_get_channel_net_info(GF_Terminal *term, GF_ObjectManager *odm, u32 return 1; } +GF_EXPORT GF_Err gf_term_get_service_info(GF_Terminal *term, GF_ObjectManager *odm, NetInfoCommand *netinfo) { GF_Err e; @@ -317,7 +325,7 @@ GF_Err gf_term_get_service_info(GF_Terminal *term, GF_ObjectManager *odm, NetInf return e; } - +GF_EXPORT const char *gf_term_get_world_info(GF_Terminal *term, GF_ObjectManager *scene_od, GF_List *descriptions) { GF_Node *info; @@ -351,7 +359,7 @@ const char *gf_term_get_world_info(GF_Terminal *term, GF_ObjectManager *scene_od return "GPAC"; } - +GF_EXPORT GF_Err gf_term_dump_scene(GF_Terminal *term, char *rad_name, char **filename, Bool xml_dump, Bool skip_protos, GF_ObjectManager *scene_od) { #ifndef GPAC_DISABLE_SCENE_DUMP diff --git a/src/terminal/object_manager.c b/src/terminal/object_manager.c index d1621a8..938811b 100644 --- a/src/terminal/object_manager.c +++ b/src/terminal/object_manager.c @@ -284,7 +284,6 @@ void gf_odm_setup_entry_point(GF_ObjectManager *odm, const char *service_sub_url u32 od_type; char *ext; char *sub_url = (char *) service_sub_url; - GF_Terminal *term; GF_Descriptor *desc; if (odm->flags & GF_ODM_DESTROYED) { @@ -293,8 +292,6 @@ void gf_odm_setup_entry_point(GF_ObjectManager *odm, const char *service_sub_url } // assert(odm->OD==NULL); - term = odm->term; - GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[ODM] Setting up root object for %s\n", odm->net_service->url)); if (odm->subscene) od_type = GF_MEDIA_OBJECT_SCENE; @@ -585,10 +582,12 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv) return; } odm->net_service = serv; + assert(odm->OD); if (!odm->OD->URLString) odm->net_service->nb_odm_users++; } /*if this is a remote OD, we need a new manager and a new service...*/ + assert(odm->OD); if (odm->OD->URLString) { GF_ClientService *parent = odm->net_service; char *url = odm->OD->URLString; @@ -1881,6 +1880,7 @@ GF_Segment *gf_odm_find_segment(GF_ObjectManager *odm, char *descName) { GF_Segment *desc; u32 i = 0; + if (!odm->OD) return NULL; while ( (desc = (GF_Segment *)gf_list_enum(odm->OD->OCIDescriptors, &i)) ){ if (desc->tag != GF_ODF_SEGMENT_TAG) continue; if (!stricmp(desc->SegmentName, descName)) return desc; diff --git a/src/terminal/scene.c b/src/terminal/scene.c index fb4fcfa..f28c221 100644 --- a/src/terminal/scene.c +++ b/src/terminal/scene.c @@ -82,7 +82,7 @@ static void inline_on_media_event(GF_Scene *scene, u32 type) gf_term_service_media_event(scene->scene_codec->odm, type); } - +GF_EXPORT GF_Scene *gf_scene_new(GF_Scene *parentScene) { GF_Scene *tmp; diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c index bd44c1d..44ab289 100644 --- a/src/terminal/terminal.c +++ b/src/terminal/terminal.c @@ -782,6 +782,7 @@ void gf_term_message(GF_Terminal *term, const char *service, const char *message gf_term_send_event(term, &evt); } +GF_EXPORT GF_Err gf_term_step_clocks(GF_Terminal * term, u32 ms_diff) { u32 i, j; @@ -1223,6 +1224,7 @@ void gf_term_lock_compositor(GF_Terminal *term, Bool LockIt) } /*locks media quaue*/ +GF_EXPORT void gf_term_lock_media_queue(GF_Terminal *term, Bool LockIt) { if (LockIt) { @@ -1270,7 +1272,7 @@ static void media_event_collect_info(GF_ClientService *net, GF_ObjectManager *od void gf_term_service_media_event_with_download(GF_ObjectManager *odm, u32 event_type, u64 loaded_size, u64 total_size, u32 bytes_per_sec) { #ifndef GPAC_DISABLE_SVG - u32 i, count, min_buffer, min_time, transport; + u32 i, count, min_buffer, min_time; Bool locked; GF_DOMMediaEvent media_event; GF_DOM_Event evt; @@ -1289,7 +1291,6 @@ void gf_term_service_media_event_with_download(GF_ObjectManager *odm, u32 event_ memset(&media_event, 0, sizeof(GF_DOMMediaEvent)); - transport = 0; media_event.bufferValid = 0; media_event.session_name = odm->net_service->url; @@ -1337,6 +1338,7 @@ void gf_term_service_media_event(GF_ObjectManager *odm, u32 event_type) } /* Browses all registered relocators (ZIP-based, ISOFF-based or file-system-based to relocate a URI based on the locale */ +GF_EXPORT Bool gf_term_relocate_url(GF_Terminal *term, const char *service_url, const char *parent_url, char *out_relocated_url, char *out_localized_url) { u32 i, count; @@ -1810,18 +1812,21 @@ GF_Err gf_term_scene_update(GF_Terminal *term, char *type, char *com) return e; } +GF_EXPORT GF_Err gf_term_get_screen_buffer(GF_Terminal *term, GF_VideoSurface *framebuffer) { if (!term) return GF_BAD_PARAM; return gf_sc_get_screen_buffer(term->compositor, framebuffer, 0); } +GF_EXPORT GF_Err gf_term_get_offscreen_buffer(GF_Terminal *term, GF_VideoSurface *framebuffer, u32 view_idx, u32 depth_buffer_type) { if (!term) return GF_BAD_PARAM; return gf_sc_get_offscreen_buffer(term->compositor, framebuffer, view_idx, depth_buffer_type); } +GF_EXPORT GF_Err gf_term_release_screen_buffer(GF_Terminal *term, GF_VideoSurface *framebuffer) { if (!term) return GF_BAD_PARAM; @@ -1899,6 +1904,7 @@ Bool gf_term_forward_event(GF_Terminal *term, GF_Event *evt, Bool consumed, Bool return 0; } +GF_EXPORT GF_Err gf_term_add_event_filter(GF_Terminal *terminal, GF_TermEventFilter *ef) { GF_Err e; @@ -1911,6 +1917,7 @@ GF_Err gf_term_add_event_filter(GF_Terminal *terminal, GF_TermEventFilter *ef) return e; } +GF_EXPORT GF_Err gf_term_remove_event_filter(GF_Terminal *terminal, GF_TermEventFilter *ef) { if (!terminal || !ef || !terminal->event_filters) return GF_BAD_PARAM; @@ -1975,6 +1982,7 @@ static void set_clocks_speed(GF_Terminal *term, Fixed ratio) } } +GF_EXPORT void gf_term_set_speed(GF_Terminal *term, Fixed speed) { Double fps; @@ -2006,6 +2014,7 @@ void gf_term_set_speed(GF_Terminal *term, Fixed speed) gf_sc_set_fps(term->compositor, fps); } +GF_EXPORT void gf_term_process_shortcut(GF_Terminal *term, GF_Event *ev) { GF_Event evt; @@ -2243,6 +2252,7 @@ void gf_scene_switch_quality(GF_Scene *scene, Bool up) } } +GF_EXPORT void gf_term_switch_quality(GF_Terminal *term, Bool up) { gf_scene_switch_quality(term->root_scene, up); diff --git a/src/utils/alloc.c b/src/utils/alloc.c index 7ef1876..83bf5cf 100644 --- a/src/utils/alloc.c +++ b/src/utils/alloc.c @@ -96,6 +96,12 @@ CDECL void scalable_free(void* ptr); #define CDECL #endif +#ifndef SYMBOL_EXPORT +#if defined(__GNUC__) && __GNUC__ >= 4 +#define SYMBOL_EXPORT __attribute__((visibility("default"))) +#endif +#endif + #if (USE_MALLOC==DL_MALLOC) CDECL void * dlmalloc(size_t size); @@ -169,7 +175,6 @@ char *gf_strdup(const char *str) #else -CDECL size_t gpac_allocated_memory = 0; size_t gpac_nb_alloc_blocs = 0; @@ -294,27 +299,31 @@ static void *(*gf_mem_realloc_proto)(void *ptr, size_t size, char *filename, int static void (*gf_mem_free_proto)(void *ptr, char *filename, int line) = gf_mem_free_basic; static char *(*gf_mem_strdup_proto)(const char *str, char *filename, int line) = gf_mem_strdup_basic; -CDECL +SYMBOL_EXPORT CDECL void *gf_mem_malloc(size_t size, char *filename, int line) { return gf_mem_malloc_proto(size, filename, line); } -CDECL + +SYMBOL_EXPORT CDECL void *gf_mem_calloc(size_t num, size_t size_of, char *filename, int line) { return gf_mem_calloc_proto(num, size_of, filename, line); } -CDECL + +SYMBOL_EXPORT CDECL void *gf_mem_realloc(void *ptr, size_t size, char *filename, int line) { return gf_mem_realloc_proto(ptr, size, filename, line); } -CDECL + +SYMBOL_EXPORT CDECL void gf_mem_free(void *ptr, char *filename, int line) { gf_mem_free_proto(ptr, filename, line); } -CDECL + +SYMBOL_EXPORT CDECL char *gf_mem_strdup(const char *str, char *filename, int line) { return gf_mem_strdup_proto(str, filename, line); diff --git a/src/utils/base_encoding.c b/src/utils/base_encoding.c index 5f38080..3f8907c 100644 --- a/src/utils/base_encoding.c +++ b/src/utils/base_encoding.c @@ -182,6 +182,7 @@ u32 gf_base16_decode(char *in, u32 inSize, char *out, u32 outSize) #define ZLIB_COMPRESS_SAFE 4 +GF_EXPORT GF_Err gf_gz_compress_payload(char **data, u32 data_len, u32 *max_size) { z_stream stream; @@ -224,6 +225,7 @@ GF_Err gf_gz_compress_payload(char **data, u32 data_len, u32 *max_size) return GF_OK; } +GF_EXPORT GF_Err gf_gz_decompress_payload(char *data, u32 data_len, char **uncompressed_data, u32 *out_size) { z_stream d_stream; diff --git a/src/utils/color.c b/src/utils/color.c index 4487c76..78cba2b 100644 --- a/src/utils/color.c +++ b/src/utils/color.c @@ -846,6 +846,8 @@ static void load_line_YUV420SP(u8 *src_bits, u32 x_offset, u32 y_offset, u32 y_p static void gf_cmx_apply_argb(GF_ColorMatrix *_this, u8 *a_, u8 *r_, u8 *g_, u8 *b_); +//#define COLORKEY_MPEG4_STRICT + GF_EXPORT GF_Err gf_stretch_bits(GF_VideoSurface *dst, GF_VideoSurface *src, GF_Window *dst_wnd, GF_Window *src_wnd, u8 alpha, Bool flip, GF_ColorKey *key, GF_ColorMatrix *cmat) { @@ -1045,6 +1047,30 @@ GF_Err gf_stretch_bits(GF_VideoSurface *dst, GF_VideoSurface *src, GF_Window *ds load_line_yuva(src->video_buffer, x_off, the_row, src->pitch_y, src_w, src->height, tmp); } the_row = src_row - 1; + + if (cmat) { + for (i=0; i<2*src_w; i++) { + u32 idx = 4*i; + gf_cmx_apply_argb(cmat, &tmp[idx+3], &tmp[idx], &tmp[idx+1], &tmp[idx+2]); + } + } + if (key) { + for (i=0; i<2*src_w; i++) { + u32 idx = 4*i; + s32 thres, v; + v = tmp[idx]-kr; thres = ABS(v); + v = tmp[idx+1]-kg; thres += ABS(v); + v = tmp[idx+2]-kb; thres += ABS(v); + thres/=3; +#ifdef COLORKEY_MPEG4_STRICT + if (thres < kl) tmp[idx+3] = 0; + else if (thres <= kh) tmp[idx+3] = (thres-kl)*ka / (kh-kl); +#else + if (thres < kh) tmp[idx+3] = 0; +#endif + else tmp[idx+3] = ka; + } + } } rows = flip ? tmp : tmp + src_w * 4; } else { @@ -1071,7 +1097,7 @@ GF_Err gf_stretch_bits(GF_VideoSurface *dst, GF_VideoSurface *src, GF_Window *ds v = tmp[idx+1]-kg; thres += ABS(v); v = tmp[idx+2]-kb; thres += ABS(v); thres/=3; -#if 0 +#ifdef COLORKEY_MPEG4_STRICT if (thres < kl) tmp[idx+3] = 0; else if (thres <= kh) tmp[idx+3] = (thres-kl)*ka / (kh-kl); #else @@ -1099,7 +1125,7 @@ GF_Err gf_stretch_bits(GF_VideoSurface *dst, GF_VideoSurface *src, GF_Window *ds v = tmp[idx+1]-kg; thres += ABS(v); v = tmp[idx+2]-kb; thres += ABS(v); thres/=3; -#if 0 +#ifdef COLORKEY_MPEG4_STRICT if (thres < kl) tmp[idx+3] = 0; else if (thres <= kh) tmp[idx+3] = (thres-kl)*ka / (kh-kl); #else diff --git a/src/utils/downloader.c b/src/utils/downloader.c index 8a7763e..e12f3b4 100644 --- a/src/utils/downloader.c +++ b/src/utils/downloader.c @@ -586,6 +586,7 @@ void gf_dm_delete_cached_file_entry(const GF_DownloadManager * dm, const char * GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[CACHE] Cannot find URL %s, cache file won't be deleted.\n", url)); } +GF_EXPORT void gf_dm_delete_cached_file_entry_session(const GF_DownloadSession * sess, const char * url) { if (sess && sess->dm && url) { GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[CACHE] Requesting deletion for %s\n", url)); @@ -624,6 +625,7 @@ static void gf_dm_disconnect(GF_DownloadSession *sess, Bool force_close) gf_mx_v(sess->mx); } +GF_EXPORT void gf_dm_sess_del(GF_DownloadSession *sess) { GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[Downloader] gf_dm_sess_del(%p)\n", sess )); @@ -707,6 +709,7 @@ Bool gf_dm_is_thread_dead(GF_DownloadSession *sess) return (sess->flags & GF_DOWNLOAD_SESSION_THREAD_DEAD) ? 1 : 0; } +GF_EXPORT GF_Err gf_dm_sess_last_error(GF_DownloadSession *sess) { if (!sess) return GF_BAD_PARAM; @@ -878,6 +881,7 @@ GF_Err gf_dm_get_url_info(const char * url, GF_URL_Info * info, const char * bas return GF_OK; } +GF_EXPORT GF_Err gf_dm_sess_setup_from_url(GF_DownloadSession *sess, const char *url) { Bool socket_changed = 0; @@ -986,6 +990,7 @@ static u32 gf_dm_session_thread(void *par) } +GF_EXPORT GF_DownloadSession *gf_dm_sess_new_simple(GF_DownloadManager * dm, const char *url, u32 dl_flags, gf_dm_user_io user_io, void *usr_cbk, @@ -1018,6 +1023,7 @@ GF_DownloadSession *gf_dm_sess_new_simple(GF_DownloadManager * dm, const char *u return sess; } +GF_EXPORT GF_DownloadSession *gf_dm_sess_new(GF_DownloadManager *dm, const char *url, u32 dl_flags, gf_dm_user_io user_io, void *usr_cbk, @@ -1282,7 +1288,7 @@ DownloadedCacheEntry gf_dm_refresh_cache_entry(GF_DownloadSession *sess) { return sess->cache_entry; } - +GF_EXPORT const char *gf_dm_sess_mime_type(GF_DownloadSession *sess) { DownloadedCacheEntry entry; @@ -1298,6 +1304,7 @@ const char *gf_dm_sess_mime_type(GF_DownloadSession *sess) return gf_cache_get_mime_type( sess->cache_entry ); } +GF_EXPORT GF_Err gf_dm_sess_set_range(GF_DownloadSession *sess, u64 start_range, u64 end_range) { if (!sess) return GF_BAD_PARAM; @@ -1309,6 +1316,7 @@ GF_Err gf_dm_sess_set_range(GF_DownloadSession *sess, u64 start_range, u64 end_r return GF_OK; } +GF_EXPORT GF_Err gf_dm_sess_process(GF_DownloadSession *sess) { Bool go; @@ -1404,6 +1412,8 @@ static void gf_cache_cleanup_cache(GF_DownloadManager * dm) { } #endif + +GF_EXPORT GF_DownloadManager *gf_dm_new(GF_Config *cfg) { const char *opt; @@ -1474,6 +1484,7 @@ void gf_dm_set_auth_callback(GF_DownloadManager *dm, } } +GF_EXPORT void gf_dm_del(GF_DownloadManager *dm) { if (!dm) @@ -1734,6 +1745,7 @@ Bool gf_dm_sess_can_be_cached_on_disk(const GF_DownloadSession *sess) return gf_cache_get_content_length(sess->cache_entry) != 0; } +GF_EXPORT void gf_dm_sess_abort(GF_DownloadSession * sess) { assert(sess); @@ -2613,7 +2625,9 @@ static void wget_NetIO(void *cbk, GF_NETIO_Parameter *param) } -GF_Err gf_dm_wget(const char *url, const char *filename){ +GF_EXPORT +GF_Err gf_dm_wget(const char *url, const char *filename) +{ GF_Err e; GF_DownloadManager * dm = NULL; dm = gf_dm_new(NULL); @@ -2652,6 +2666,7 @@ GF_Err gf_dm_wget_with_cache(GF_DownloadManager * dm, return e; } +GF_EXPORT GF_Err gf_dm_get_file_memory(const char *url, char **out_data, u32 *out_size, char **out_mime) { GF_Err e; @@ -2709,6 +2724,7 @@ GF_Err gf_dm_get_file_memory(const char *url, char **out_data, u32 *out_size, ch return e; } +GF_EXPORT const char *gf_dm_sess_get_resource_name(GF_DownloadSession *dnload) { return dnload ? dnload->orig_url : NULL; @@ -2906,6 +2922,7 @@ void gf_dm_set_data_rate(GF_DownloadManager *dm, u32 rate_in_byte_per_sec) } } +GF_EXPORT u32 gf_dm_get_data_rate(GF_DownloadManager *dm) { return dm->limit_data_rate; diff --git a/src/utils/os_config_init.c b/src/utils/os_config_init.c index 6a0a23d..8de4c42 100644 --- a/src/utils/os_config_init.c +++ b/src/utils/os_config_init.c @@ -480,6 +480,7 @@ static void check_modules_dir(GF_Config *cfg) } } +GF_EXPORT GF_Config *gf_cfg_init(const char *file, Bool *new_cfg) { GF_Config *cfg; diff --git a/src/utils/os_divers.c b/src/utils/os_divers.c index f69a7a8..f80e2b8 100644 --- a/src/utils/os_divers.c +++ b/src/utils/os_divers.c @@ -75,6 +75,8 @@ static u32 sys_start_time = 0; #ifndef WIN32 + +GF_EXPORT u32 gf_sys_clock() { struct timeval now; @@ -84,6 +86,7 @@ u32 gf_sys_clock() #endif +GF_EXPORT void gf_sleep(u32 ms) { #ifdef WIN32 @@ -277,6 +280,7 @@ void CE_CharToWide(char *str, unsigned short *w_str) #endif +GF_EXPORT GF_Err gf_delete_file(const char *fileName) { #if defined(_WIN32_WCE) @@ -329,6 +333,7 @@ u32 gf_rand() #include #endif +GF_EXPORT u64 gf_file_modification_time(const char *filename) { #if defined(_WIN32_WCE) @@ -362,6 +367,7 @@ u64 gf_file_modification_time(const char *filename) return 0; } +GF_EXPORT FILE *gf_temp_file_new() { #if defined(_WIN32_WCE) @@ -389,7 +395,7 @@ FILE *gf_temp_file_new() #endif } - +GF_EXPORT void gf_utc_time_since_1970(u32 *sec, u32 *msec) { #if defined (WIN32) && !defined(_WIN32_WCE) @@ -430,6 +436,7 @@ void gf_get_user_name(char *buf, u32 buf_size) /*enumerate directories*/ +GF_EXPORT GF_Err gf_enum_directory(const char *dir, Bool enum_directory, gf_enum_dir_item enum_dir_fct, void *cbck, const char *filter) { char item_path[GF_MAX_PATH]; @@ -637,6 +644,7 @@ next: #ifndef WIN32 +GF_EXPORT char * my_str_upr(char *str) { u32 i; @@ -645,6 +653,8 @@ char * my_str_upr(char *str) } return str; } + +GF_EXPORT char * my_str_lwr(char *str) { u32 i; @@ -655,6 +665,7 @@ char * my_str_lwr(char *str) } #endif +GF_EXPORT u64 gf_f64_tell(FILE *fp) { #if defined(_WIN32_WCE) @@ -672,6 +683,7 @@ u64 gf_f64_tell(FILE *fp) #endif } +GF_EXPORT u64 gf_f64_seek(FILE *fp, s64 offset, s32 whence) { #if defined(_WIN32_WCE) @@ -689,6 +701,7 @@ u64 gf_f64_seek(FILE *fp, s64 offset, s32 whence) #endif } +GF_EXPORT FILE *gf_f64_open(const char *file_name, const char *mode) { #if defined(WIN32) @@ -705,6 +718,8 @@ FILE *gf_f64_open(const char *file_name, const char *mode) #if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! defined(_GNU_SOURCE) #define HAVE_STRERROR_R 1 #endif + +GF_EXPORT size_t gf_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) { @@ -759,10 +774,12 @@ Bool gf_prompt_has_input() { return kbhit(); } + char gf_prompt_get_char() { return getchar(); } + void gf_prompt_set_echo_off(Bool echo_off) { DWORD flags; @@ -809,6 +826,7 @@ void gf_prompt_set_echo_off(Bool echo_off) close_keyboard(0); } +GF_EXPORT Bool gf_prompt_has_input() { u8 ch; @@ -829,6 +847,7 @@ Bool gf_prompt_has_input() return 0; } +GF_EXPORT char gf_prompt_get_char() { char ch; @@ -998,6 +1017,7 @@ void gf_mem_enable_tracker(); static u64 memory_at_gpac_startup = 0; +GF_EXPORT void gf_sys_init(Bool enable_memory_tracker) { if (!sys_init) { @@ -1093,6 +1113,7 @@ void gf_sys_init(Bool enable_memory_tracker) } } +GF_EXPORT void gf_sys_close() { if (sys_init > 0) { @@ -1392,9 +1413,9 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) #include #endif #include - + static u64 total_physical_memory = 0; - + Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) { size_t length; @@ -1675,7 +1696,7 @@ Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) #endif - +GF_EXPORT Bool gf_sys_get_rti(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) { Bool res = gf_sys_get_rti_os(refresh_time_ms, rti, flags); @@ -1701,8 +1722,7 @@ char * gf_get_default_cache_directory(){ } - - +GF_EXPORT Bool gf_sys_get_battery_state(Bool *onBattery, u32 *onCharge, u32*level, u32 *batteryLifeTime, u32 *batteryFullLifeTime) { #if defined(_WIN32_WCE) @@ -1829,7 +1849,7 @@ struct _GF_GlobalLock_opaque { }; #endif - +GF_EXPORT GF_GlobalLock * gf_global_resource_lock(const char * resourceName){ #ifdef WIN32 #ifdef _WIN32_WCE @@ -1876,6 +1896,7 @@ GF_GlobalLock * gf_global_resource_lock(const char * resourceName){ * \param lock The resource to unlock * \return GF_OK if evertything went fine */ +GF_EXPORT GF_Err gf_global_resource_unlock(GF_GlobalLock * lock){ if (!lock) return GF_BAD_PARAM; diff --git a/src/utils/os_module.c b/src/utils/os_module.c index 36bd874..7a81459 100644 --- a/src/utils/os_module.c +++ b/src/utils/os_module.c @@ -334,6 +334,7 @@ u32 gf_modules_refresh(GF_ModuleManager *pm) inst->interfaces = gf_list_new(); inst->plugman = pm; inst->name = gf_strdup("gm_gpac_js.dylib"); + gf_list_add(pm->plug_list, inst); } { ModuleInstance *inst; @@ -403,7 +404,7 @@ u32 gf_modules_refresh(GF_ModuleManager *pm) gf_enum_directory(pm->dir, 0, enum_modules, pm, ".dylib"); #endif #else - GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("Refreshing list of modules in directory %s...\n", pm->dir)); + GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("Refreshing list of modules in directory %s...\n", pm->dir)); gf_enum_directory(pm->dir, 0, enum_modules, pm, ".so"); #endif diff --git a/src/utils/os_net.c b/src/utils/os_net.c index 412a803..d17ef2f 100644 --- a/src/utils/os_net.c +++ b/src/utils/os_net.c @@ -307,6 +307,7 @@ static Bool gf_sk_ipv6_set_remote_address(GF_Socket *sock, const char *address, #endif +GF_EXPORT GF_Err gf_sk_get_host_name(char *buffer) { s32 ret = gethostname(buffer, GF_MAX_IP_NAME_LEN); @@ -346,6 +347,7 @@ GF_Err gf_sk_get_local_ip(GF_Socket *sock, char *buffer) } +GF_EXPORT GF_Socket *gf_sk_new(u32 SocketType) { GF_Socket *tmp; @@ -374,6 +376,7 @@ GF_Socket *gf_sk_new(u32 SocketType) return tmp; } +GF_EXPORT GF_Err gf_sk_set_buffer_size(GF_Socket *sock, Bool SendBuffer, u32 NewSize) { if (!sock || !sock->socket) return GF_BAD_PARAM; @@ -386,6 +389,7 @@ GF_Err gf_sk_set_buffer_size(GF_Socket *sock, Bool SendBuffer, u32 NewSize) return GF_OK; } +GF_EXPORT GF_Err gf_sk_set_block_mode(GF_Socket *sock, u32 NonBlockingOn) { s32 res; @@ -447,6 +451,7 @@ static void gf_sk_free(GF_Socket *sock) } +GF_EXPORT void gf_sk_del(GF_Socket *sock) { assert( sock ); @@ -602,6 +607,7 @@ GF_Err gf_sk_connect(GF_Socket *sock, const char *PeerName, u16 PortNumber, cons //binds the given socket to the specified port. If ReUse is true //this will enable reuse of ports on a single machine +GF_EXPORT GF_Err gf_sk_bind(GF_Socket *sock, const char *local_ip, u16 port, const char *peer_name, u16 peer_port, u32 options) { #ifdef GPAC_HAS_IPV6 @@ -804,6 +810,7 @@ GF_Err gf_sk_bind(GF_Socket *sock, const char *local_ip, u16 port, const char *p } //send length bytes of a buffer +GF_EXPORT GF_Err gf_sk_send(GF_Socket *sock, const char *buffer, u32 length) { u32 count; @@ -866,6 +873,7 @@ GF_Err gf_sk_send(GF_Socket *sock, const char *buffer, u32 length) } +GF_EXPORT u32 gf_sk_is_multicast_address(const char *multi_IPAdd) { #ifdef GPAC_HAS_IPV6 @@ -894,6 +902,7 @@ u32 gf_sk_is_multicast_address(const char *multi_IPAdd) #endif } +GF_EXPORT GF_Err gf_sk_setup_multicast(GF_Socket *sock, const char *multi_IPAdd, u16 MultiPortNumber, u32 TTL, Bool NoBind, char *local_interface_ip) { s32 ret; @@ -1079,6 +1088,7 @@ GF_Err gf_sk_setup_multicast(GF_Socket *sock, const char *multi_IPAdd, u16 Multi //fetch nb bytes on a socket and fill the buffer from startFrom //length is the allocated size of the receiving buffer //BytesRead is the number of bytes read from the network +GF_EXPORT GF_Err gf_sk_receive(GF_Socket *sock, char *buffer, u32 length, u32 startFrom, u32 *BytesRead) { s32 res; diff --git a/src/utils/os_thread.c b/src/utils/os_thread.c index f74cc08..ec82ad2 100644 --- a/src/utils/os_thread.c +++ b/src/utils/os_thread.c @@ -103,6 +103,7 @@ static const char *log_th_name(u32 id) #endif +GF_EXPORT GF_Thread *gf_th_new(const char *name) { GF_Thread *tmp = gf_malloc(sizeof(GF_Thread)); @@ -213,6 +214,7 @@ exit: #endif } +GF_EXPORT GF_Err gf_th_run(GF_Thread *t, u32 (*Run)(void *param), void *param) { #ifdef WIN32 @@ -286,6 +288,7 @@ void gf_th_stop(GF_Thread *t) Thread_Stop(t, 0); } +GF_EXPORT void gf_th_del(GF_Thread *t) { Thread_Stop(t, 0); @@ -372,6 +375,7 @@ u32 gf_th_status(GF_Thread *t) } +GF_EXPORT u32 gf_th_id() { #ifdef WIN32 @@ -401,6 +405,7 @@ struct __tag_mutex }; +GF_EXPORT GF_Mutex *gf_mx_new(const char *name) { #ifndef WIN32 @@ -436,6 +441,7 @@ GF_Mutex *gf_mx_new(const char *name) return tmp; } +GF_EXPORT void gf_mx_del(GF_Mutex *mx) { #ifdef WIN32 @@ -456,6 +462,7 @@ void gf_mx_del(GF_Mutex *mx) gf_free(mx); } +GF_EXPORT void gf_mx_v(GF_Mutex *mx) { u32 caller; @@ -488,6 +495,7 @@ void gf_mx_v(GF_Mutex *mx) } } +GF_EXPORT u32 gf_mx_p(GF_Mutex *mx) { #ifndef WIN32 @@ -546,6 +554,7 @@ s32 gf_mx_get_num_locks(GF_Mutex *mx) return -1; } +GF_EXPORT Bool gf_mx_try_lock(GF_Mutex *mx) { u32 caller; @@ -601,7 +610,7 @@ struct __tag_semaphore #endif }; - +GF_EXPORT GF_Semaphore *gf_sema_new(u32 MaxCount, u32 InitCount) { GF_Semaphore *tmp = gf_malloc(sizeof(GF_Semaphore)); @@ -644,6 +653,7 @@ GF_Semaphore *gf_sema_new(u32 MaxCount, u32 InitCount) return tmp; } +GF_EXPORT void gf_sema_del(GF_Semaphore *sm) { #if defined(WIN32) @@ -660,6 +670,7 @@ void gf_sema_del(GF_Semaphore *sm) gf_free(sm); } +GF_EXPORT u32 gf_sema_notify(GF_Semaphore *sm, u32 NbRelease) { u32 prevCount; @@ -702,6 +713,7 @@ void gf_sema_wait(GF_Semaphore *sm) #endif } +GF_EXPORT Bool gf_sema_wait_for(GF_Semaphore *sm, u32 TimeOut) { #ifdef WIN32 diff --git a/src/utils/ringbuffer.c b/src/utils/ringbuffer.c index b9789f7..0e5c754 100644 --- a/src/utils/ringbuffer.c +++ b/src/utils/ringbuffer.c @@ -23,6 +23,7 @@ */ #include +GF_EXPORT GF_Ringbuffer * gf_ringbuffer_new(u32 sz) { GF_Ringbuffer *rb; @@ -40,6 +41,7 @@ GF_Ringbuffer * gf_ringbuffer_new(u32 sz) return rb; } +GF_EXPORT void gf_ringbuffer_del(GF_Ringbuffer * ringbuffer){ if (!ringbuffer) return; @@ -71,6 +73,7 @@ static u32 gf_ringbuffer_available_for_write (GF_Ringbuffer * rb) } } +GF_EXPORT u32 gf_ringbuffer_available_for_read (GF_Ringbuffer * rb) { size_t w, r; @@ -85,6 +88,7 @@ u32 gf_ringbuffer_available_for_read (GF_Ringbuffer * rb) } } +GF_EXPORT u32 gf_ringbuffer_read(GF_Ringbuffer *rb, u8 *dest, u32 szDest) { u32 free_sz, sz2, to_read, n1, n2; @@ -118,6 +122,7 @@ u32 gf_ringbuffer_read(GF_Ringbuffer *rb, u8 *dest, u32 szDest) return to_read; } +GF_EXPORT u32 gf_ringbuffer_write (GF_Ringbuffer * rb, const u8 *src, u32 sz) { u32 free_sz, sz2, to_write, n1, n2; diff --git a/src/utils/unicode.c b/src/utils/unicode.c index dc7fbc7..a416526 100644 --- a/src/utils/unicode.c +++ b/src/utils/unicode.c @@ -35,8 +35,8 @@ Acknowledgement Internet Society. */ -u32 -utf8_to_ucs4(u32 * ucs4_buf, u32 utf8_len, unsigned char *utf8_buf) +GF_EXPORT +u32 utf8_to_ucs4(u32 * ucs4_buf, u32 utf8_len, unsigned char *utf8_buf) { const unsigned char *utf8_endbuf = utf8_buf + utf8_len; u32 ucs_len = 0; diff --git a/src/utils/url.c b/src/utils/url.c index b5053c4..4f50a04 100644 --- a/src/utils/url.c +++ b/src/utils/url.c @@ -88,7 +88,7 @@ char *gf_url_get_absolute_path(const char *pathName, const char *parentPath) return gf_strdup(pathName); } - +GF_EXPORT char *gf_url_concatenate(const char *parentName, const char *pathName) { u32 pathSepCount, i, prot_type;