Codebase list gpac / 52fbf58
Imported Upstream version 0.4.5+svn4002~dfsg0 Alessio Treglia 12 years ago
111 changed file(s) with 2310 addition(s) and 1844 deletion(s). Raw diff Collapse all Expand all
44 ifeq ($(DISABLE_ISOFF), no)
55 APPDIRS+=mp4box
66 ifeq ($(DISABLE_M2TS), no)
7 ifeq ($(DISABLE_SENG), no)
78 APPDIRS+=mp42ts
9 endif
810 endif
911 endif
1012
3333
3434 #error "Cannot compile MP42TS if GPAC is not built with ISO File Format support"
3535
36 #else
36 #endif
37
38 #ifdef GPAC_DISABLE_MPEG2TS_MUX
39
40 #error "Cannot compile MP42TS if GPAC is not built with MPEG2-TS Muxing support"
41
42 #endif
3743
3844
3945 #define DEFAULT_PCR_OFFSET 18000
439445 return GF_OK;
440446 }
441447
448 #ifndef GPAC_DISABLE_STREAMING
442449 typedef struct
443450 {
444451 /*RTP channel*/
496503 }
497504 return GF_OK;
498505 }
506 #endif
499507
500508 static GF_Err void_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param)
501509 {
731739 {
732740 GF_Err e;
733741 u64 last_src_modif, mod_time;
734 Bool has_carousel=0;
735742 M2TSProgram *prog = (M2TSProgram *)param;
736743 GF_SceneEngine *seng = prog->seng;
737744 GF_SimpleDataDescriptor *audio_desc;
740747 u32 period, ts_delta;
741748 u16 es_id, aggregate_on_stream;
742749 e = GF_OK;
743 if (prog->rate){
744 has_carousel = 1;
745 }
746750 gf_sleep(2000); /*TODO: events instead? What are we waiting for?*/
747751 gf_seng_encode_context(seng, SampleCallBack);
748752
910914 return e ? 1 : 0;
911915 }
912916
913
917 #ifndef GPAC_DISABLE_STREAMING
914918 static void rtp_sl_packet_cbk(void *udta, char *payload, u32 size, GF_SLHeader *hdr, GF_Err e)
915919 {
916920 GF_ESIRTP *rtp = (GF_ESIRTP*)udta;
10261030 }
10271031 fprintf(stderr, "RTP interface initialized\n");
10281032 }
1033 #endif /*GPAC_DISABLE_STREAMING*/
10291034
10301035 void fill_seng_es_ifce(GF_ESInterface *ifce, u32 i, GF_SceneEngine *seng, u32 period)
10311036 {
10591064
10601065 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)
10611066 {
1067 #ifndef GPAC_DISABLE_STREAMING
10621068 GF_SDPInfo *sdp;
1069 #endif
10631070 u32 i;
10641071 GF_Err e;
10651072
12111218 return 1;
12121219 }
12131220
1221 #ifndef GPAC_DISABLE_STREAMING
12141222 /*open SDP file*/
12151223 if (strstr(src, ".sdp")) {
12161224 GF_X_Attribute *att;
12791287 gf_sdp_info_del(sdp);
12801288
12811289 return 2;
1282 }
1283 else if (strstr(src, ".bt")) //open .bt file
1290 } else
1291 #endif /*GPAC_DISABLE_STREAMING*/
1292 if (strstr(src, ".bt")) //open .bt file
12841293 {
12851294 u32 load_type=0;
12861295 prog->seng = gf_seng_init(prog, src, load_type, NULL, (load_type == GF_SM_LOAD_DIMS) ? 1 : 0);
17881797 char *ts_out = NULL, *udp_out = NULL, *rtp_out = NULL, *audio_input_ip = NULL;
17891798 FILE *ts_output_file = NULL;
17901799 GF_Socket *ts_output_udp_sk = NULL, *audio_input_udp_sk = NULL;
1800 #ifndef GPAC_DISABLE_STREAMING
17911801 GF_RTPChannel *ts_output_rtp = NULL;
17921802 GF_RTSPTransport tr;
17931803 GF_RTPHeader hdr;
1804 #endif
17941805 char *video_buffer;
17951806 u32 video_buffer_size;
17961807 u16 output_port = 0, audio_input_port = 0;
18221833 last_video_time = 0;
18231834 audio_input_type = 0;
18241835 ts_output_udp_sk = NULL;
1836 udp_out = NULL;
1837 #ifndef GPAC_DISABLE_STREAMING
18251838 ts_output_rtp = NULL;
1839 rtp_out = NULL;
1840 #endif
1841 ts_out = NULL;
18261842 src_name = NULL;
1827 ts_out = NULL;
1828 udp_out = NULL;
1829 rtp_out = NULL;
18301843 nb_progs = 0;
18311844 mux_rate = 0;
18321845 run_time = 0;
19121925 goto exit;
19131926 }
19141927 }
1928 #ifndef GPAC_DISABLE_STREAMING
19151929 if (rtp_out != NULL) {
19161930 ts_output_rtp = gf_rtp_new();
19171931 gf_rtp_set_ports(ts_output_rtp, output_port);
19471961 hdr.SSRC = tr.SSRC;
19481962 hdr.Marker = 0;
19491963 }
1964 #endif /*GPAC_DISABLE_STREAMING*/
19501965
19511966 /************************************/
19521967 /* create streaming audio input */
21072122 fprintf(stderr, "Error %s sending UDP packet\n", gf_error_to_string(e));
21082123 }
21092124 }
2125 #ifndef GPAC_DISABLE_STREAMING
21102126 if (ts_output_rtp != NULL) {
21112127 hdr.SequenceNumber++;
21122128 /*muxer clock at 90k*/
21192135 fprintf(stderr, "Error %s sending RTP packet\n", gf_error_to_string(e));
21202136 }
21212137 }
2138 #endif
21222139 if (status>=GF_M2TS_STATE_PADDING) {
21232140 break;
21242141 }
21722189 }
21732190 if (ts_output_file) fclose(ts_output_file);
21742191 if (ts_output_udp_sk) gf_sk_del(ts_output_udp_sk);
2192 #ifndef GPAC_DISABLE_STREAMING
21752193 if (ts_output_rtp) gf_rtp_del(ts_output_rtp);
2194 #endif
21762195 if (ts_out) gf_free(ts_out);
21772196 if (audio_input_udp_sk) gf_sk_del(audio_input_udp_sk);
21782197 if (audio_input_buffer) gf_free (audio_input_buffer);
21792198 if (video_buffer) gf_free(video_buffer);
21802199 if (udp_out) gf_free(udp_out);
2200 #ifndef GPAC_DISABLE_STREAMING
21812201 if (rtp_out) gf_free(rtp_out);
2202 #endif
21822203 if (aac_reader) AAC_Reader_del(aac_reader);
21832204 if (muxer) gf_m2ts_mux_del(muxer);
21842205
22072228 return 1;
22082229 }
22092230
2210 #endif /*GPAC_DISABLE_ISOM*/
931931 /*track done*/
932932 if ((tki->stop_state==2) || (!is_last && (tki->sample_count == tki->last_sample)) ) {
933933 if (tki->has_non_raps) last_rap_sample_time = 0;
934 time = (Double) (s64) ( gf_isom_get_sample_dts(mp4, tki->tk, tki->last_sample+1) - tki->firstDTS);
935 time /= tki->time_scale;
936 if (file_split_dur==(Double)GF_MAX_FLOAT || file_split_dur<time) file_split_dur = time;
934937 continue;
935938 }
936939
3636
3737 #else
3838
39 #ifndef GPAC_DISABLE_STREAMING
39 #if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG)
4040
4141 void PrintStreamerUsage()
4242 {
804804 }
805805
806806
807 #endif /*GPAC_DISABLE_STREAMING*/
807 #endif /*!defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG)*/
808808
809809 #endif /*defined(GPAC_DISABLE_ISOM) || defined(GPAC_DISABLE_ISOM_WRITE)*/
106106 #endif
107107
108108
109 #ifndef GPAC_DISABLE_STREAMING
109 #if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG)
110110 void PrintStreamerUsage();
111111 int stream_file_rtp(int argc, char **argv);
112112 int live_session(int argc, char **argv);
822822
823823 #endif /*GPAC_DISABLE_ISOM_HINTING*/
824824
825 #ifndef GPAC_DISABLE_ISOM_WRITE
825 #if !defined(GPAC_DISABLE_ISOM_WRITE) && !defined(GPAC_DISABLE_AV_PARSERS)
826826
827827 static void check_media_profile(GF_ISOFile *file, u32 track)
828828 {
912912 gf_isom_set_pl_indication(file, GF_ISOM_PL_INLINE, 0);
913913 }
914914
915 #endif
915 #endif /*!defined(GPAC_DISABLE_ISOM_WRITE) && !defined(GPAC_DISABLE_AV_PARSERS)*/
916916
917917 /*return value:
918918 0: not supported
12031203 #ifndef GPAC_DISABLE_SCENE_ENCODER
12041204 GF_SMEncodeOptions opts;
12051205 #endif
1206 #ifndef GPAC_DISABLE_STREAMING
1206 #if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG)
12071207 SDPLine sdp_lines[MAX_CUMUL_OPS];
12081208 #endif
12091209 Double InterleavingTime, split_duration, split_start, import_fps, dash_duration;
13851385 i++;
13861386 }
13871387 #endif /*GPAC_DISABLE_MEDIA_EXPORT*/
1388
1389 #ifndef GPAC_DISABLE_STREAMING
1388 #if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG)
13901389 else if (!stricmp(arg, "-rtp")) {
13911390 stream_rtp = 1;
13921391 }
1393 #endif
13941392 else if (!stricmp(arg, "-live")) {
13951393 live_scene = 1;
13961394 }
1395 #endif
13971396 else if (!stricmp(arg, "-diod")) {
13981397 dump_iod = 1;
13991398 }
15891588 else if (!stricmp(arg, "-mtu")) { CHECK_NEXT_ARG MTUSize = atoi(argv[i+1]); i++; }
15901589 else if (!stricmp(arg, "-cardur")) { CHECK_NEXT_ARG car_dur = atoi(argv[i+1]); i++; }
15911590 else if (!stricmp(arg, "-rate")) { CHECK_NEXT_ARG rtp_rate = atoi(argv[i+1]); i++; }
1591 #ifndef GPAC_DISABLE_SENG
15921592 else if (!stricmp(arg, "-add-sdp") || !stricmp(arg, "-sdp_ex")) {
15931593 char *id;
15941594 CHECK_NEXT_ARG
16151615 nb_sdp_ex++;
16161616 i++;
16171617 }
1618 #endif /*GPAC_DISABLE_SENG*/
16181619 #endif /*GPAC_DISABLE_ISOM_HINTING*/
16191620
16201621 else if (!stricmp(arg, "-single")) {
20992100 else if (!strcmp(argv[i+1], "crypt")) PrintEncryptUsage();
21002101 else if (!strcmp(argv[i+1], "meta")) PrintMetaUsage();
21012102 else if (!strcmp(argv[i+1], "swf")) PrintSWFUsage();
2102 #ifndef GPAC_DISABLE_STREAMING
2103 #if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG)
21032104 else if (!strcmp(argv[i+1], "rtp")) PrintStreamerUsage();
21042105 else if (!strcmp(argv[i+1], "live")) PrintLiveUsage ();
21052106 #endif
21142115 PrintEncryptUsage();
21152116 PrintMetaUsage();
21162117 PrintSWFUsage();
2117 #ifndef GPAC_DISABLE_STREAMING
2118 #if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG)
21182119 PrintStreamerUsage();
21192120 PrintLiveUsage ();
21202121 #endif
21392140 return 1;
21402141 }
21412142
2142 #ifndef GPAC_DISABLE_STREAMING
2143 #if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG)
21432144 if (live_scene) {
21442145 return live_session(argc, argv);
21452146 }
21462147 if (stream_rtp) {
21472148 return stream_file_rtp(argc, argv);
21482149 }
2149 #endif /*GPAC_DISABLE_STREAMING*/
2150 #endif
21502151
21512152 if (raw_cat) {
21522153 char chunk[4096];
27852786 }
27862787
27872788 if (remove_sys_tracks) {
2789 #ifndef GPAC_DISABLE_AV_PARSERS
27882790 remove_systems_tracks(file);
2791 #endif
27892792 needSave = 1;
27902793 if (conv_type < GF_ISOM_CONV_TYPE_ISMA_EX) conv_type = 0;
27912794 }
32143217 u32 k, l, sps_id1, sps_id2;
32153218 GF_AVCConfig *avccfg1 = gf_isom_avc_config_get(in, j+1, 1);
32163219 GF_AVCConfig *avccfg2 = gf_isom_avc_config_get(init_seg, track, 1);
3220 #ifndef GPAC_DISABLE_AV_PARSERS
32173221 for (k=0; k<gf_list_count(avccfg2->sequenceParameterSets); k++) {
32183222 GF_AVCConfigSlot *slc = gf_list_get(avccfg2->sequenceParameterSets, k);
32193223 gf_avc_get_sps_info(slc->data, slc->size, &sps_id1, NULL, NULL, NULL, NULL);
32263230 }
32273231 }
32283232 }
3233 #endif
32293234 /*no conflicts in SPS ids, merge all SPS in a single sample desc*/
32303235 if (do_merge) {
32313236 while (gf_list_count(avccfg1->sequenceParameterSets)) {
33623367 }
33633368 if (e) goto err_exit;
33643369
3365 #ifndef GPAC_DISABLE_ISOM_HINTING
3370 #if !defined(GPAC_DISABLE_ISOM_HINTING) && !defined(GPAC_DISABLE_SENG)
33663371 for (i=0; i<nb_sdp_ex; i++) {
33673372 if (sdp_lines[i].trackID) {
33683373 u32 track = gf_isom_get_track_by_id(file, sdp_lines[i].trackID);
33913396 needSave = 1;
33923397 }
33933398 }
3394 #endif /*GPAC_DISABLE_ISOM_HINTING*/
3399 #endif /*!defined(GPAC_DISABLE_ISOM_HINTING) && !defined(GPAC_DISABLE_SENG)*/
33953400
33963401 if (cprt) {
33973402 e = gf_isom_set_copyright(file, "und", cprt);
156156 BITMAPINFOHEADER fi;
157157 FILE *fout;
158158 u32 j, i;
159 char *ptr, *prev;
160
161 prev = strrchr(rad_name, '.');
162 //if (prev) prev[0] = '\0';
159 char *ptr;
163160
164161 if (fb->pixel_format==GF_PIXEL_GREYSCALE) sprintf(str, "%s_%d_depth.bmp", rad_name, img_num);
165162 else sprintf(str, "%s_%d.bmp", rad_name, img_num);
258255 {
259256 FILE *fout;
260257 u32 i, j;
261 char val;
262258 unsigned char *depth;
263259
264260 depth = (unsigned char *) fb->video_buffer;
269265 for (i=0;i<fb->width; i++) {
270266
271267 #ifdef GPAC_USE_TINYGL
272 val = fputc(depth[2*i+j*fb->width*sizeof(unsigned short)], fout);
273 val = fputc(depth[2*i+j*fb->width*sizeof(unsigned short) + 1], fout);
268 fputc(depth[2*i+j*fb->width*sizeof(unsigned short)], fout);
269 fputc(depth[2*i+j*fb->width*sizeof(unsigned short) + 1], fout);
274270 #else
275 val = fputc(depth[i+j*fb->width], fout);
271 fputc(depth[i+j*fb->width], fout);
276272 #endif
277273 }
278274 }
284280
285281 FILE *fout;
286282 u32 i, j;
287 char val;
288283 unsigned char *buf;
289284
290285 buf = (unsigned char *) fb->video_buffer;
296291 if (!fout) return;
297292 for (j=0; j<fb->height; j++) {
298293 for (i=0;i<fb->width*4; i++) {
299 val = fputc(buf[i+j*fb->pitch_y], fout);
294 fputc(buf[i+j*fb->pitch_y], fout);
300295 }
301296 }
302297 fclose(fout);
11851185 if (!strcmp(str, "Raw Video Output")) fprintf(stdout, "WARNING: using raw output video (memory only) - no display used\n");
11861186 /*check audio output*/
11871187 str = gf_cfg_get_key(cfg_file, "Audio", "DriverName");
1188 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");
1188 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");
11891189
11901190 str = gf_cfg_get_key(cfg_file, "General", "NoMIMETypeFetch");
11911191 no_mime_check = (str && !stricmp(str, "yes")) ? 1 : 0;
664664 #spidermonkey test for new API
665665 if test "$has_js" = "no" ; then
666666
667 cat > $TMPCPP << EOF
667 cat > $TMPCPP << EOF
668668 #include <jsapi.h>
669669 int main( void ) { JSContext *cx; jsval *rp; return JS_AddValueRoot(cx, rp); }
670670 EOF
691691 if test "$has_js" = "no" ; then
692692 js_inc="/usr/include/$i"
693693 js_flags="-DXP_UNIX -I$js_inc"
694 js_lib="-L/usr/lib/$i/ -lxul -lmozsqlite3 -lmozalloc -lnss3"
694 js_lib="-L/usr/lib/$i/ -lxul -lmozsqlite3 -lmozalloc -lnssutil3 -lnss3"
695695 if $cpp -o $TMPO $TMPCPP $js_flags $js_lib 2> /dev/null ; then
696696 has_js="$i"
697 elif $cpp -o $TMPO $TMPCPP $js_flags -lnssutil3 $js_lib -lssl3 2> /dev/null ; then
698 #firefox 11 compatibility
699 has_js="$i"
700 js_lib="-lnssutil3 $js_lib -lssl3"
697701 fi
698702 fi
699703 done
815819 #if the lib has been compiled with or without the macro. We currently just decide that if the macro is present
816820 #in the header, it was enabled in the build
817821 if test "$new_js_api" = "no" ; then
818 if grep MOZILLA_1_8_BRANCH $js_inc/jsapi.h > /dev/null 2>&1 ; then
819 js_flags="-DMOZILLA_1_8_BRANCH $js_flags"
820 echo "WARNING: Turning on MOZILLA_1_8_BRANCH SpiderMonkey macro"
821 echo "If you have troubles with scripts in GPAC, disable this macro and recompile"
822 fi
822 if grep MOZILLA_1_8_BRANCH $js_inc/jsapi.h > /dev/null 2>&1 ; then
823 js_flags="-DMOZILLA_1_8_BRANCH $js_flags"
824 echo "WARNING: Turning on MOZILLA_1_8_BRANCH SpiderMonkey macro"
825 echo "If you have troubles with scripts in GPAC, disable this macro and recompile"
826 fi
823827 else
824 #check presence of ***RuntimeThread
825 if grep RuntimeThread $js_inc/jsapi.h > /dev/null 2>&1 ; then
826 js_flags="$js_flags"
827 else
828 js_flags="-DNO_JS_RUNTIMETHREAD $js_flags"
829 fi
828 cat > $TMPC << EOF
829 #include <jsapi.h>
830 int main( void ) { JSContext *cx; JS_SetRuntimeThread(cx); }
831 EOF
832 if $cc -o $TMPO $TMPC $js_flags $LDFLAGS $js_lib 2> /dev/null ; then
833 js_flags="$js_flags"
834 else
835 js_flags="-DNO_JS_RUNTIMETHREAD $js_flags"
836 fi
830837 fi
831838 fi
832839 fi
14211428 }
14221429 EOF
14231430
1424 if $cc -o $TMPE $TMPC $LDFLAGS > /dev/null 2>&1 ; then
1431 if $cc -o $TMPE $TMPC $LDFLAGS $extralibs > /dev/null 2>&1 ; then
14251432 has_ipv6="yes"
14261433 fi
14271434
18871894 if $cc -o $TMPO $TMPCPP -I$xulsdk_path $LDFLAGS 2> /dev/null ; then
18881895 has_xul="system"
18891896 xul_flags="-I$xulsdk_path $xul_flags"
1890 else
1897 fi
1898
1899 if test "$has_xul" = "no" ; then
1900 if $pkg_config --exists libxul 2> /dev/null ; then
1901 if $cpp -o $TMPO $TMPCPP `$pkg_config --cflags libxul` `$pkg_config --libs libxul` ; then
1902 has_xul="system"
1903 xul_flags="`$pkg_config --cflags libxul` `$pkg_config --libs libxul`"
1904 fi
1905 fi
1906 fi
1907
1908 if test "$has_xul" = "no" ; then
18911909 if $cc -o $TMPO $TMPCPP $xul_flags -I$local_inc/gecko-sdk/include $LDFLAGS 2> /dev/null ; then
18921910 has_xul="local"
18931911 xul_flags="-I$local_inc/gecko-sdk/include $xul_flags"
18941912 else
1895 #xulrunner directories are sometimes included through js packages
1896 if test "$has_js" = "system" ;then
1897 if $cpp -o $TMPO $TMPCPP $js_flags $js_lib_pkg $LDFLAGS 2> /dev/null ; then
1913 #xulrunner directories are sometimes included through js/xul/ff packages
1914 if test ! "$has_js" = "no" -a ! "$has_js" = "local" ; then
1915 if $cc -o $TMPO $TMPCPP $js_flags $js_lib_pkg $LDFLAGS 2> /dev/null ; then
18981916 xul_flags=`$pkg_config --cflags mozilla-js`
1899 has_xul="system"
1917 has_xul="$has_js"
19001918 fi
19011919 fi
19021920 fi
23342352 fi
23352353
23362354 ldir=`pwd`
2337 CFLAGS="$CFLAGS -DGPAC_HAVE_CONFIG_H -I\"$ldir\""
2338 CPPFLAGS="$CPPFLAGS -DGPAC_HAVE_CONFIG_H -I\"$ldir\""
2355 CFLAGS="$CFLAGS -fvisibility=\"hidden\" -DGPAC_HAVE_CONFIG_H -I\"$ldir\""
2356 CPPFLAGS="$CPPFLAGS"
23392357
23402358
23412359 echo "Creating config.mak"
25012519 echo "XML2_CFLAGS=$libxml2_cflags" >> config.mak
25022520 echo "XML2_LIBS=$libxml2_lib_flags" >> config.mak
25032521 fi
2522 if test "$disable_parsers" = "yes" ; then
2523 disable_m2ts_mux="yes"
2524 fi
25042525 if test "$disable_m2ts_mux" = "yes" -o "$disable_m2ts" = "yes" ; then
25052526 echo "DISABLE_M2TS=yes" >> config.mak
25062527 else
25072528 echo "DISABLE_M2TS=no" >> config.mak
2529 fi
2530 if test "$disable_beng" = "no"; then
2531 echo "DISABLE_SENG=no" >> config.mak
25082532 fi
25092533
25102534 echo "GPAC_USE_TINYGL=$has_tinygl" >> config.mak
00 // 01122011 AMD1 startWidget listWidgets getWidget implemented
1
2 var iphone_wm_gui = (function () {
3
4 // to make sure the initialization is done only once
5 var init = true;
6
7 // constant
8 var xlinkns = 'http://www.w3.org/1999/xlink';
9 //var evns = 'http://www.w3.org/2001/xml-events';
10
11 // state of the widget manager: displays homepage (value=home) or executes widget (value="exec")
12 var state = 'home';
13
14 // convenience variables for SVG elements
15 var homepage = null, arrows = null, icons = null, widgetContainer = null, homebar = null, execbar = null;
16
17 // where is the index into pages of icons on the home page
18 var where = 0,maxwhere = 0,whereW = 0;
19
20 // array of activated widgets
21 var activatedWidgets = new Array();
22 var numActivatedWidgets = 0;
23
24 // variables for flexible layout
25 // variables for flexible layout
26 var totalWidth = 0,totalHeight = 0,iconNbHoriz = 0,iconNbVert = 0,iconsPerPage = 0;
27
28 //previous size
29 var previousWidth = 0,previousHeight = 0;
30
31 // to differentiate between install icon and scan dir for icons
32 var isThisAScan = null;
33
34 // preferred icon type
35 var preferredIconType = '.svg';
36
37 // adapt layout to the size of the screen
38 function adaptLayoutToSize() {
39 if (l_deb < log_level) {
40 alert("[UI] adaptLayoutToSize");
41 }
42 var tmpObject, tmpObj2;
43 // get size to adapt to
44 totalWidth = document.documentElement.viewport.width;
45 totalHeight = document.documentElement.viewport.height;
46 if (totalWidth == 0) {
47 totalWidth = 160;
48 }
49 if (totalHeight == 0) {
50 totalHeight = 280;
51 }
52 while (totalWidth < 160 || totalHeight < 280) {
53 totalWidth *= 4;
54 totalHeight *= 4;
55 }
56 // min size is 160 by 280
57 if (totalWidth < 160) {
58 totalWidth = 160;
59 }
60 if (totalHeight < 280) {
61 totalHeight = 280;
62 }
63 // round to lower multiple of 80
64 totalWidth -= totalWidth % 80;
65 var iconHeight = totalHeight - 120;
66 iconHeight -= iconHeight % 80;
67 // how many lines and columns of icons
68 iconNbHoriz = totalWidth / 80;
69 iconNbVert = iconHeight / 80;
70 totalHeight = iconHeight + 120;
71 // 120 is upper bar (60) + lower bar (60)
72 iconsPerPage = iconNbHoriz * iconNbVert;
73 // fix svg viewbox
74 document.getElementById("svg").setAttribute("viewBox", "0 0 " + totalWidth + " " + totalHeight);
75 // fix odd line
76 tmpObj2 = document.getElementById("odd");
77 var i, already = tmpObj2.getElementsByTagName("use").length;
78 //alert("odd line "+already+" "+iconNbHoriz);
79 for (i = already; i < iconNbHoriz; i++) {
80 tmpObject = document.createElement("use");
81 tmpObject.setAttribute("x", i * 80);
82 tmpObject.setAttributeNS(xlinkns, "href", (((i % 2) == 0) ? "#lightRect" : "#darkRect" ));
83 tmpObj2.appendChild(tmpObject);
84 }
85 // fix even line
86 tmpObj2 = document.getElementById("even");
87 already = tmpObj2.getElementsByTagName("use").length;
88 //alert("even line "+already+" "+iconNbHoriz);
89 for (i = already; i < iconNbHoriz; i++) {
90 tmpObject = document.createElement("use");
91 tmpObject.setAttribute("x", i * 80);
92 tmpObject.setAttributeNS(xlinkns, "href", (((i % 2) == 0) ? "#darkRect" : "#lightRect" ));
93 tmpObj2.appendChild(tmpObject);
94 }
95 // fix frame (black with rounded corners)
96 tmpObject = document.getElementById("frame");
97 tmpObject.setAttribute("width", totalWidth);
98 tmpObject.setAttribute("height", totalHeight);
99 tmpObject = document.getElementById("frame2");
100 tmpObject.setAttribute("width", totalWidth);
101 tmpObject.setAttribute("height", totalHeight);
102 // fix screen (white)
103 tmpObject = document.getElementById("screen");
104 tmpObject.setAttribute("width", totalWidth);
105 tmpObject.setAttribute("height", totalHeight - 120);
106 // fix grid back (gray)
107 tmpObject = document.getElementById("gridback");
108 tmpObject.setAttribute("width", totalWidth);
109 tmpObject.setAttribute("height", totalHeight - 120);
110 // fix icon background grid
111 tmpObject = document.getElementById("grid");
112 already = tmpObject.getElementsByTagName("use").length;
113 for (i = already; i < iconNbVert; i++) {
114 tmpObj2 = document.createElement("use");
115 tmpObj2.setAttribute("y", i * 80);
116 tmpObj2.setAttributeNS(xlinkns, "href", (((i % 2) == 0) ? "#odd" : "#even" ));
117 tmpObject.appendChild(tmpObj2);
118 }
119 // if there are already too many lines, remove the extra ones otherwise they are rendered on top of the lower
120 // part of the decoration
121 if (already > iconNbVert) {
122 while (already-- > iconNbVert) {
123 tmpObject.removeChild(tmpObject.lastChild);
124 }
125 }
126 // fix commands (lower bar)
127 document.getElementById("commands").setAttribute("transform", "translate(0, " + (totalHeight - 60) + ")");
128 document.getElementById("homeButton").setAttribute("transform", "translate(" + (totalWidth / 2) + ", 30)");
129 document.getElementById("right").setAttribute("transform", "translate(" + (totalWidth - 50) + ", 10)");
130 document.getElementById("rightW").setAttribute("transform", "translate(" + (totalWidth - 50) + ", 10)");
131 // fix the cuts (white rects left and right because we have no clipping)
132 tmpObject = document.getElementById("leftCut");
133 tmpObject.setAttribute("width", totalWidth);
134 tmpObject.setAttribute("height", totalHeight);
135 tmpObject.setAttribute("x", -1 - totalWidth);
136 tmpObject = document.getElementById("rightCut");
137 tmpObject.setAttribute("width", totalWidth);
138 tmpObject.setAttribute("height", totalHeight);
139 tmpObject.setAttribute("x", 1 + totalWidth);
140 // respace executing widgets if any
141 tmpObject = widgetContainer.getElementsByTagName("g");
142 for (i = 0; i < tmpObject.length; i++) {
143 var gg = tmpObject.item(i);
144 gg.setAttribute("transform", "translate(" + (totalWidth * (i - 1)) + ", 0)");
145 if (gg.firstElementChild != null) {
146 gg.firstElementChild.setAttribute("width", totalWidth);
147 gg.firstElementChild.setAttribute("height", totalHeight - 120);
148 }
149 }
150 }
151
152 //
153 // widget close on click at "Kill" button
154 //
155 function on_kill_widget() {
156 if (state == 'exec') {
157 widget_close(activatedWidgets[whereW]);
158 }
159 }
160
161 //
162 // widget get on click at "GetW" button
163 //
164 function on_get_widget() {
165 alert("on_get_widget "+WidgetManager.MPEGUStandardServiceProviders.length);
166 if (WidgetManager.MPEGUStandardServiceProviders.length != 0) {
167 upnp_renders = selector_window1();
168 upnp_renders.on_select = function(item) {
169 upnp_renders.unregister(root);
170 upnp_renders = null;
171 if (item == -1) {
172 return;
173 }
174 alert("upnp_renders.on_select(" + item + ")");
175 var device = WidgetManager.MPEGUStandardServiceProviders[item];
176 device.standardService.SetActionListener("listWidgets", get_widget_callback(device), true);
177 device.standardService.CallAction("listWidgets", new Array());
178 }
179 upnp_renders.register(root);
180 }
181 }
182
183 function get_widget_callback(device) {
184 return function() {
185 //alert("get_widget_callback");
186 // msgHandler is the first argument, the next arguments are from the reply to listWidgets
187 var act = arguments[0];
188 var act1 = act.GetArgumentValue("widgetCodes");
189 var act2 = act.GetArgumentValue("widgetNames");
190 //alert(act1+" "+act2);
191 target_widgets = selector_window2(act1.split(" "), act2.split(" "));
192 target_widgets.on_select = function(item) {
193 alert("target_widgets.on_select");
194 target_widgets.unregister(root);
195 target_widgets = null;
196 if (item == -1) {
197 return;
198 }
199 alert("target_widgets.on_select(" + item + ")");
200 var args = new Array();
201 args[0] = "widgetCode";
202 args[1] = item;
203 device.standardService.CallAction("getWidget", args);
204 }
205 target_widgets.register(root);
206 }
207 }
208
209 //
210 // creates the menu of available targets for pushing a widget elsewhere
211 //
212 function selector_window1() {
213 var i, count, render;
214 var selector = document.createElement('g'), obj, child;
215 selector.setAttribute('transform', 'translate(10,10)');
216 count = WidgetManager.MPEGUStandardServiceProviders.length;
217 selector.appendChild(rect(0, 0, 300, 20 * (count + 1), 'white', 'black'));
218 for (i = 0; i < count; i++) {
219 render = WidgetManager.MPEGUStandardServiceProviders[i];
220 obj = createtext(render.Name, 'black', 5, 17 + (20 * i), 15, 'sans-serif');
221 obj.setAttribute('id', "select" + i);
222 selector.appendChild(obj);
223 obj.addEventListener('mouseover', sw1("select" + i), false);
224 obj.addEventListener('mouseout', sw2("select" + i), false);
225 obj.addEventListener('click', sw4(i), false);
226 }
227 obj = createtext('Cancel', 'rgb(0,0,120)', 55, 17 + (20 * i), 15, 'sans-serif');
228 obj.setAttribute('id', "canc");
229 selector.appendChild(obj);
230 obj.addEventListener('mouseover', function(evt) { document.getElementById("canc").setAttribute("fill", "red"); }, false);
231 obj.addEventListener('mouseout', function(evt) { document.getElementById("canc").setAttribute("fill", "black"); }, false);
232 obj.addEventListener('click', function(evt) { upnp_renders.on_select(-1); }, false);
233 selector.register = function(disp) {
234 disp.appendChild(this);
235 };
236 selector.unregister = function(disp) {
237 disp.removeChild(this);
238 };
239 return selector;
240 }
241
242 //
243 // creates the menu of available targets for pushing a widget elsewhere
244 //
245 function selector_window2(codes, names) {
246 alert("selector_window2");
247 var i, count, render;
248 var selector = document.createElement('g'), obj, child;
249 selector.setAttribute('transform', 'translate(10,10)');
250 count = codes.length;
251 selector.appendChild(rect(0, 0, 300, 20 * (count + 1), 'white', 'black'));
252 for (i = 0; i < count; i++) {
253 render = names[i];
254 obj = createtext(render, 'black', 5, 17 + (20 * i), 15, 'sans-serif');
255 obj.setAttribute('id', "selecto" + i);
256 selector.appendChild(obj);
257 obj.addEventListener('mouseover', sw1("selecto" + i), false);
258 obj.addEventListener('mouseout', sw2("selecto" + i), false);
259 obj.addEventListener('click', sw5(i), false);
260 }
261 obj = createtext('Cancel', 'rgb(0,0,120)', 55, 17 + (20 * i), 15, 'sans-serif');
262 obj.setAttribute('id', "cance");
263 selector.appendChild(obj);
264 obj.addEventListener('mouseover', function(evt) { document.getElementById("cance").setAttribute("fill", "red"); }, false);
265 obj.addEventListener('mouseout', function(evt) { document.getElementById("cance").setAttribute("fill", "black"); }, false);
266 obj.addEventListener('click', function(evt) { target_widgets.on_select(-1); }, false);
267 selector.register = function(disp) {
268 disp.appendChild(this);
269 };
270 selector.unregister = function(disp) {
271 disp.removeChild(this);
272 };
273 return selector;
274 }
275
276 function sw4(si) {
277 return function(evt) { upnp_renders.on_select(si); };
278 }
279
280 function sw5(si) {
281 return function(evt) { target_widgets.on_select(si); };
282 }
283
284 //
285 // when deleting an executing widgets, all executing widgets to its right are moved to the left
286 //
287 function recurseMoveAfterDelete(target) {
288 if (target != null && target.nextElementSibling != null) {
289 var v = target.nextElementSibling;
290 recurseMoveAfterDelete(v);
291 v.setAttribute("transform", target.getAttribute("transform"));
292 }
293 }
294
295 //
296 // click on home button to switch from icons to executing widgets
297 //
298 function home_button(evt) {
299 if (l_deb < log_level) {
300 alert("[UI] home_button");
301 }
302 if (state != 'home') {
303 state = 'home';
304 widgetContainer.setAttribute('display', 'none');
305 homepage.setAttribute('display', 'inline');
306 homebar.setAttribute('display', 'inline');
307 execbar.setAttribute('display', 'none');
308 arrows.setAttribute('display', 'inline');
309 arrowsW.setAttribute('display', 'none');
310 widgetAddList.setAttribute('display', 'none');
311 } else {
312 state = 'exec';
313 widgetContainer.setAttribute('display', 'inline');
314 homepage.setAttribute('display', 'none');
315 homebar.setAttribute('display', 'none');
316 execbar.setAttribute('display', 'inline');
317 arrows.setAttribute('display', 'none');
318 arrowsW.setAttribute('display', 'inline');
319 widgetAddList.setAttribute('display', 'none');
320 }
321 }
322
323 // constants
324 var adjustFrom = "0,0";
325 var animDue = true;
326
327 //
328 // after each change of icon page, this function adjusts the visibility of arrows in the lower bar
329 //
330 function adjustwhere(animDue) {
331 if (l_deb < log_level) {
332 alert("[UI] adjust " + where + " 0 " + maxwhere);
333 }
334 document.getElementById("left").setAttribute("display", ((where > 0) ? "inline" : "none"));
335 document.getElementById("right").setAttribute("display", ((where < maxwhere) ? "inline" : "none"));
336 if (!animDue) {
337 icons.setAttribute("transform", 'translate(' + (-80 * iconNbHoriz * where) + ',0)');
338 } else {
339 var aw = document.createElement("animateTransform");
340 aw.setAttribute("attributeName", "transform");
341 aw.setAttribute("type", "translate");
342 //alert('time '+document.documentElement.getCurrentTime());
343 aw.setAttribute("begin", document.documentElement.getCurrentTime());
344 aw.setAttribute("dur", "1s");
345 aw.setAttribute("fill", "freeze");
346 aw.setAttributeNS(xlinkns, "href", "#icons");
347 aw.setAttribute("from", adjustFrom);
348 aw.setAttribute("to", (-80 * iconNbHoriz * where) + ",0");
349 document.documentElement.appendChild(aw);
350 }
351 adjustFrom = (-80 * iconNbHoriz * where) + ",0";
352 }
353
354 //
355 // action of the left button on the lower bar
356 //
357 function left_button() {
358 if (l_deb < log_level) {
359 alert("[UI] left button " + where + " 0");
360 }
361 if (where > 0) {
362 where--;
363 adjustwhere(true);
364 }
365 }
366
367 //
368 // action of the right button of the lower bar
369 //
370 function right_button() {
371 if (l_deb < log_level) {
372 alert("[UI] right button " + where + " " + maxwhere);
373 }
374 if (where < maxwhere) {
375 where++;
376 adjustwhere(true);
377 }
378 }
379
380 var adjustFromW = "0,0";
381 var oldwhereW = -1;
382
383 //
384 // after each change of icon page, this function adjusts the visibility of arrows in the lower bar
385 //
386 function adjustWhereWidgets(animDue) {
387 if (oldwhereW != whereW) {
388 // hide oldwhereW
389 if (oldwhereW >= 0 && activatedWidgets[oldwhereW] != null) {
390 WidgetManager.corein_message(activatedWidgets[oldwhereW], "hide");
391 }
392 }
393 if (l_deb < log_level) {
394 alert("[UI] adjustW " + whereW + " 0 " + (numActivatedWidgets - 1));
395 }
396 document.getElementById("leftW").setAttribute("display", ((whereW > 0) ? "inline" : "none"));
397 document.getElementById("rightW").setAttribute("display", ((whereW < (numActivatedWidgets - 1)) ? "inline" : "none"));
398 if (!animDue) {
399 widgetContainer.setAttribute("transform", "translate(" + (-totalWidth * whereW) + ",0)");
400 } else {
401 var aw = document.createElement("animateTransform");
402 aw.setAttribute("attributeName", "transform");
403 aw.setAttribute("type", "translate");
404 aw.setAttribute("begin", document.documentElement.getCurrentTime());
405 aw.setAttribute("dur", "1s");
406 aw.setAttribute("fill", "freeze");
407 aw.setAttributeNS(xlinkns, "href", "#widget");
408 aw.setAttribute("from", adjustFromW);
409 aw.setAttribute("to", (-totalWidth * whereW) + ",0");
410 document.documentElement.appendChild(aw);
411 }
412 adjustFromW = (-totalWidth * whereW) + ",0";
413 document.getElementById("widgetName").textContent =
414 (whereW >= 0 && activatedWidgets[whereW] != null ? activatedWidgets[whereW].shortName : '-');
415 if (oldwhereW != whereW) {
416 // show whereW
417 if (whereW >= 0 && activatedWidgets[whereW] != null) {
418 WidgetManager.corein_message(activatedWidgets[whereW], "show");
419 }
420 oldwhereW = whereW;
421 }
422 }
423
424 //
425 // action of the left button on the lower bar
426 //
427 function left_buttonW() {
428 if (l_deb < log_level) {
429 alert("[UI] left button " + whereW);
430 }
431 if (whereW > 0) {
432 whereW--;
433 adjustWhereWidgets(animDue);
434 }
435 }
436
437 //
438 // action of the right button of the lower bar
439 //
440 function right_buttonW() {
441 if (l_deb < log_level) {
442 alert("[UI] right button " + whereW + " " + (numActivatedWidgets - 1));
443 }
444 if (whereW < (numActivatedWidgets - 1)) {
445 whereW++;
446 adjustWhereWidgets(animDue);
447 }
448 }
449
450 //
451 // action of each icon, starting the matching widget
452 //
453 function activating_widget(w) {
454 if (l_deb < log_level) {
455 alert("[UI] activating widget: " + w.name);
456 }
457 widget_add(w);
458 }
459
460 //
461 // main initialization function
462 // init variables, then init the widget manager C code, then inits UPnP
463 //
464 function initialize() {
465 if (l_deb < log_level) {
466 alert("[UI] initialize");
467 }
468 init = false;
469 var display_width = parseInt(gpac.getOption('Widgets', 'LastWMWidth'));
470 var display_height = parseInt(gpac.getOption('Widgets', 'LastWMHeight'));
471 if (display_width && display_height) {
472 gpac.set_size(display_width, display_height);
473 }
474 root = document.documentElement;
475 homepage = document.getElementById('homepage');
476 homebar = document.getElementById('homebar');
477 execbar = document.getElementById('execbar');
478 arrows = document.getElementById('arrows');
479 arrowsW = document.getElementById('arrowsW');
480 icons = document.getElementById('icons');
481 widgetContainer = document.getElementById('widget');
482 widgetAddList = document.getElementById('widgetAddList');
483 /* Setup the GPAC Widget Manager - this will also scan the available widgets */
484 log_level = l_inf;
485 widget_manager_init();
486 WidgetManager.on_widget_remove = widget_remove;
487 WidgetManager.on_widget_add = widget_add;
488 /* register the callback to be notified of incoming widgets */
489 has_upnp = (typeof UPnP != 'undefined');
490 if (has_upnp) {
491 /* setting the callback to allow other devices to push their widgets */
492 UPnP.onMediaConnect = onMediaConnect;
493 /* Tell GPAC that the calls to the main Renderer (like open, ...) must be forwared to this scene */
494 UPnP.BindRenderer();
495 }
496 WidgetManager.coreOutShow = coreOutShowImplementation;
497 WidgetManager.coreOutGetAttention = coreOutGetAttentionImplementation;
498 WidgetManager.coreOutHide = coreOutHideImplementation;
499 WidgetManager.coreOutRequestDeactivate = coreOutRequestDeactivateImplementation;
500 WidgetManager.coreOutInstallWidget = coreOutInstallWidgetImplementation;
501 WidgetManager.coreOutActivateTemporaryWidget = coreOutActivateTemporaryWidgetImplementation;
502 WidgetManager.coreOutMigrateComponent = coreOutMigrateComponentImplementation;
503 WidgetManager.coreOutRequestMigrationTargets = coreOutRequestMigrationTargetsImplementation;
504 }
505
506 //
507 // implementation of core:out install widget
508 //
509 function coreOutInstallWidgetImplementation(wid, args) {
510 var w = widgetInstall(args[0], true, false, wid);
511 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
512 if (ifce != null) {
513 wmjs_core_out_invoke_reply(coreOut.installWidgetMessage, ifce.get_message("installWidget"),
514 wid, (w != null ? 1 : 0)); // send return code 1 = success
515 }
516 }
517
518 //
519 // implementation of core:out activate temporary widget
520 //
521 function coreOutActivateTemporaryWidgetImplementation(wid, args) {
522 var w = widgetInstall(args[0], true, true, null);
523 if (w != null) {
524 activating_widget(w);
525 }
526 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
527 if (ifce != null) {
528 wmjs_core_out_invoke_reply(coreOut.activateTemporaryWidgetMessage, ifce.get_message("activateTemporaryWidget"),
529 wid, (w != null ? 1 : 0)); // send return code 1 = success
530 }
531 }
532
533 //
534 // implementation of core:out migrate component
535 //
536 function coreOutMigrateComponentImplementation(wid, args) {
537 //alert("coreOutMigrateComponent "+wid.name+" "+args.length);
538 var comp = wid.get_component(args[0], true);
539 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
540 if (comp == null) {
541 log(l_err, 'Component ' + args[0] + ' cannot be found in widget ' + wid.name);
542 if (ifce != null) {
543 wmjs_core_out_invoke_reply(coreOut.migrateComponentMessage, ifce.get_message("migrateComponent"), wid, 0);
544 }
545 return;
546 }
547 if (args.length > 1 && args[1] != null) {
548 //WidgetManager.migrate_widget(UPnP.GetMediaRenderer(parseInt(args[1])), comp);
549 WidgetManager.migrate_widget(WidgetManager.get_mpegu_service_providers(parseInt(args[1])), comp);
550 widget_close(comp);
551 } else {
552 upnp_renders = selector_window(comp);
553 upnp_renders.on_select = function(item, wid) {
554 upnp_renders.unregister(root);
555 upnp_renders = null;
556 if (item == -1) {
557 return;
558 }
559 if (comp != null) {
560 alert("upnp_renders.on_select(" + item + "," + comp.name + ")");
561 //WidgetManager.migrate_widget(UPnP.GetMediaRenderer(item), comp);
562 WidgetManager.migrate_widget(WidgetManager.get_mpegu_service_providers(item), comp);
563 widget_close(comp);
564 }
565 };
566 upnp_renders.register(root);
567 }
568 if (ifce != null) {
569 wmjs_core_out_invoke_reply(coreOut.migrateComponentMessage, ifce.get_message("migrateComponent"), wid, 1); // send return code 1 = success
570 }
571 }
572
573 //
574 // implementation of core:out request migration targets
575 //
576 function coreOutRequestMigrationTargetsImplementation(wid, args) {
577 var count = UPnP.MediaRenderersCount, codes = new Array(), names = new Array(), descriptions = new Array(), i;
578 for (i = 0; i < count; i++) {
579 var render = UPnP.GetMediaRenderer(i);
580 codes.push("" + i);
581 names.push(render.Name);
582 descriptions.push(render.HostName + " " + render.UUID);
583 }
584 i = null;
585 var ifce_count = wid.num_interfaces, j;
586 for (j = 0; j < ifce_count; j++) {
587 var ifce = wid.get_interface(j);
588 if (ifce.type == "urn:mpeg:mpegu:schema:widgets:core:out:2010") {
589 i = ifce;
590 break;
591 }
592 }
593 if (i != null) {
594 wmjs_core_out_invoke_reply(coreOut.requestMigrationTargetsMessage, i.get_message("requestMigrationTargets"),
595 wid, codes, names, descriptions);
596 }
597 }
598
599 //
600 // implementation of core:out Show message
601 // this is a request by the widget to be shown
602 //
603 function coreOutShowImplementation(wid, args) {
604 //alert("core:out show "+wid.name);
605 var target = widgetContainer.firstElementChild;
606 var i;
607 for (i = 0; i < numActivatedWidgets; i++) {
608 //alert("is it "+activatedWidgets[i].name);
609 if (activatedWidgets[i] == wid) {
610 break;
611 }
612 target = target.nextElementSibling;
613 }
614 // here, i is the index of the current widget
615 //alert(" "+i+" "+numActivatedWidgets);
616 if (i < numActivatedWidgets) {
617 whereW = i;
618 adjustWhereWidgets(false);
619 }
620 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
621 if (ifce != null) {
622 wmjs_core_out_invoke_reply(coreOut.showMessage, ifce.get_message("show"), wid, 1); // send return code 1 = success
623 }
624 }
625
626 //
627 // implementation of core:out GetAttention message
628 // this is a request by the widget to be shown and some special signal is given
629 //
630 function coreOutGetAttentionImplementation(wid, args) {
631 //alert("core:out getAttention "+wid.name);
632 var target = widgetContainer.firstElementChild;
633 var i;
634 for (i = 0; i < numActivatedWidgets; i++) {
635 //alert("is it "+activatedWidgets[i].name);
636 if (activatedWidgets[i] == wid) {
637 break;
638 }
639 target = target.nextElementSibling;
640 }
641 // here, i is the index of the current widget
642 //alert(" "+i+" "+numActivatedWidgets);
643 if (i < numActivatedWidgets) {
644 whereW = i;
645 adjustWhereWidgets(false);
646 }
647 document.getElementById("getAttention").beginElement();
648 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
649 if (ifce != null) {
650 wmjs_core_out_invoke_reply(coreOut.getAttentionMessage, ifce.get_message("getAttention"), wid, 1); // send return code 1 = success
651 }
652 }
653
654 //
655 // implementation of core:out hide message
656 // this is a request by the widget to be hidden (some other widget (if any) is shown)
657 //
658 function coreOutHideImplementation(wid, args) {
659 //alert("core:out hide "+wid.name);
660 var target = widgetContainer.firstElementChild;
661 var i;
662 for (i = 0; i < numActivatedWidgets; i++) {
663 //alert("is it "+activatedWidgets[i].name);
664 if (activatedWidgets[i] == wid) {
665 break;
666 }
667 target = target.nextElementSibling;
668 }
669 // here, i is the index of the current widget
670 //alert("hide "+i+" "+numActivatedWidgets);
671 if (i < numActivatedWidgets) {
672 if (whereW > 0) {
673 whereW--;
674 }
675 else if (whereW < numActivatedWidgets - 1) {
676 whereW++;
677 }
678 else {
1 /* wrapper as a module
2 var iphone_wm_gui = (function () {
3 */
4 // to make sure the initialization is done only once
5 var init = true;
6
7 // constant
8 var xlinkns = 'http://www.w3.org/1999/xlink';
9 //var evns = 'http://www.w3.org/2001/xml-events';
10
11 // state of the widget manager: displays homepage (value=home) or executes widget (value="exec")
12 var state = 'home';
13
14 // convenience variables for SVG elements
15 var homepage = null, arrows = null, icons = null, widgetContainer = null, homebar = null, execbar = null;
16
17 // where is the index into pages of icons on the home page
18 var where = 0,maxwhere = 0,whereW = 0;
19
20 // array of activated widgets
21 var activatedWidgets = new Array();
22 var numActivatedWidgets = 0;
23
24 // variables for flexible layout
25 // variables for flexible layout
26 var totalWidth = 0,totalHeight = 0,iconNbHoriz = 0,iconNbVert = 0,iconsPerPage = 0;
27
28 //previous size
29 var previousWidth = 0,previousHeight = 0;
30
31 // to differentiate between install icon and scan dir for icons
32 var isThisAScan = null;
33
34 // preferred icon type
35 var preferredIconType = '.svg';
36
37 // adapt layout to the size of the screen
38 function adaptLayoutToSize() {
39 if (l_deb < log_level) {
40 alert("[UI] adaptLayoutToSize");
41 }
42 display_width = parseInt( gpac.getOption('General', 'LastWidth') );
43 display_height = parseInt( gpac.getOption('General', 'LastHeight') );
44 alert("display "+display_width+" "+display_height);
45 if (!gpac.fullscreen && display_width && display_height) {
46 gpac.set_size(display_width, display_height);
47 }
48 var tmpObject, tmpObj2;
49 // get size to adapt to
50 totalWidth = document.documentElement.viewport.width;
51 totalHeight = document.documentElement.viewport.height;
52 if (totalWidth == 0) {
53 totalWidth = 160;
54 }
55 if (totalHeight == 0) {
56 totalHeight = 280;
57 }
58 while (totalWidth < 160 || totalHeight < 280) {
59 totalWidth *= 4;
60 totalHeight *= 4;
61 }
62 // min size is 160 by 280
63 if (totalWidth < 160) {
64 totalWidth = 160;
65 }
66 if (totalHeight < 280) {
67 totalHeight = 280;
68 }
69 // round to lower multiple of 80
70 totalWidth -= totalWidth % 80;
71 var iconHeight = totalHeight - 120;
72 iconHeight -= iconHeight % 80;
73 // how many lines and columns of icons
74 iconNbHoriz = totalWidth / 80;
75 iconNbVert = iconHeight / 80;
76 totalHeight = iconHeight + 120;
77 // 120 is upper bar (60) + lower bar (60)
78 iconsPerPage = iconNbHoriz * iconNbVert;
79 // fix svg viewbox
80 document.getElementById("svg").setAttribute("viewBox", "0 0 " + totalWidth + " " + totalHeight);
81 // fix odd line
82 tmpObj2 = document.getElementById("odd");
83 var i, already = tmpObj2.getElementsByTagName("use").length;
84 //alert("odd line "+already+" "+iconNbHoriz);
85 for (i = already; i < iconNbHoriz; i++) {
86 tmpObject = document.createElement("use");
87 tmpObject.setAttribute("x", i * 80);
88 tmpObject.setAttributeNS(xlinkns, "href", (((i % 2) == 0) ? "#lightRect" : "#darkRect" ));
89 tmpObj2.appendChild(tmpObject);
90 }
91 // fix even line
92 tmpObj2 = document.getElementById("even");
93 already = tmpObj2.getElementsByTagName("use").length;
94 //alert("even line "+already+" "+iconNbHoriz);
95 for (i = already; i < iconNbHoriz; i++) {
96 tmpObject = document.createElement("use");
97 tmpObject.setAttribute("x", i * 80);
98 tmpObject.setAttributeNS(xlinkns, "href", (((i % 2) == 0) ? "#darkRect" : "#lightRect" ));
99 tmpObj2.appendChild(tmpObject);
100 }
101 // fix frame (black with rounded corners)
102 tmpObject = document.getElementById("frame");
103 tmpObject.setAttribute("width", totalWidth);
104 tmpObject.setAttribute("height", totalHeight);
105 tmpObject = document.getElementById("frame2");
106 tmpObject.setAttribute("width", totalWidth);
107 tmpObject.setAttribute("height", totalHeight);
108 // fix screen (white)
109 tmpObject = document.getElementById("screen");
110 tmpObject.setAttribute("width", totalWidth);
111 tmpObject.setAttribute("height", totalHeight - 120);
112 // fix grid back (gray)
113 tmpObject = document.getElementById("gridback");
114 tmpObject.setAttribute("width", totalWidth);
115 tmpObject.setAttribute("height", totalHeight - 120);
116 // fix icon background grid
117 tmpObject = document.getElementById("grid");
118 already = tmpObject.getElementsByTagName("use").length;
119 for (i = already; i < iconNbVert; i++) {
120 tmpObj2 = document.createElement("use");
121 tmpObj2.setAttribute("y", i * 80);
122 tmpObj2.setAttributeNS(xlinkns, "href", (((i % 2) == 0) ? "#odd" : "#even" ));
123 tmpObject.appendChild(tmpObj2);
124 }
125 // if there are already too many lines, remove the extra ones otherwise they are rendered on top of the lower
126 // part of the decoration
127 if (already > iconNbVert) {
128 while (already-- > iconNbVert) {
129 tmpObject.removeChild(tmpObject.lastChild);
130 }
131 }
132 // fix commands (lower bar)
133 document.getElementById("commands").setAttribute("transform", "translate(0, " + (totalHeight - 60) + ")");
134 document.getElementById("homeButton").setAttribute("transform", "translate(" + (totalWidth / 2) + ", 30)");
135 document.getElementById("right").setAttribute("transform", "translate(" + (totalWidth - 50) + ", 10)");
136 document.getElementById("rightW").setAttribute("transform", "translate(" + (totalWidth - 50) + ", 10)");
137 // fix the cuts (white rects left and right because we have no clipping)
138 tmpObject = document.getElementById("leftCut");
139 tmpObject.setAttribute("width", totalWidth);
140 tmpObject.setAttribute("height", totalHeight);
141 tmpObject.setAttribute("x", -1 - totalWidth);
142 tmpObject = document.getElementById("rightCut");
143 tmpObject.setAttribute("width", totalWidth);
144 tmpObject.setAttribute("height", totalHeight);
145 tmpObject.setAttribute("x", 1 + totalWidth);
146 // respace executing widgets if any
147 tmpObject = widgetContainer.getElementsByTagName("g");
148 for (i = 0; i < tmpObject.length; i++) {
149 var gg = tmpObject.item(i);
150 gg.setAttribute("transform", "translate(" + (totalWidth * (i - 1)) + ", 0)");
151 if (gg.firstElementChild != null) {
152 gg.firstElementChild.setAttribute("width", totalWidth);
153 gg.firstElementChild.setAttribute("height", totalHeight - 120);
154 }
155 }
156 }
157
158 //
159 // widget close on click at "Kill" button
160 //
161 function on_kill_widget() {
162 if (state == 'exec') {
163 widget_close(activatedWidgets[whereW]);
164 }
165 }
166
167 //
168 // widget get on click at "GetW" button
169 //
170 function on_get_widget() {
171 alert("on_get_widget " + WidgetManager.MPEGUStandardServiceProviders.length);
172 if (WidgetManager.MPEGUStandardServiceProviders.length != 0) {
173 upnp_renders = selector_window1();
174 upnp_renders.on_select = function(item) {
175 upnp_renders.unregister(root);
176 upnp_renders = null;
177 if (item == -1) {
679178 return;
680179 }
681 adjustWhereWidgets(false);
682 }
683 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
684 if (ifce != null) {
685 wmjs_core_out_invoke_reply(coreOut.hideMessage, ifce.get_message("hide"), wid, 1); // send return code 1 = success
686 }
687 }
688
689 //
690 // implementation of core:out requestDeactivate message
691 // this is a request by the widget to be stopped
692 //
693 function coreOutRequestDeactivateImplementation(wid, args) {
694 //alert("core:out hide "+wid.name);
695 var target = widgetContainer.firstElementChild;
696 var i;
697 for (i = 0; i < numActivatedWidgets; i++) {
698 //alert("is it "+activatedWidgets[i].name);
699 if (activatedWidgets[i] == wid) {
700 break;
180 alert("upnp_renders.on_select(" + item + ")");
181 var device = WidgetManager.MPEGUStandardServiceProviders[item];
182 device.standardService.SetActionListener("listWidgets", get_widget_callback(device), true);
183 device.standardService.CallAction("listWidgets", new Array());
184 }
185 upnp_renders.register(root);
186 }
187 }
188
189 function get_widget_callback(device) {
190 return function() {
191 //alert("get_widget_callback");
192 // msgHandler is the first argument, the next arguments are from the reply to listWidgets
193 var act = arguments[0];
194 var act1 = act.GetArgumentValue("widgetCodes");
195 var act2 = act.GetArgumentValue("widgetNames");
196 //alert(act1+" "+act2);
197 target_widgets = selector_window2(act1.split(" "), act2.split(" "));
198 target_widgets.on_select = function(item) {
199 alert("target_widgets.on_select");
200 target_widgets.unregister(root);
201 target_widgets = null;
202 if (item == -1) {
203 return;
701204 }
702 target = target.nextElementSibling;
703 }
704 // here, i is the index of the current widget
705 //alert("hide "+i+" "+numActivatedWidgets);
706 if (i < numActivatedWidgets) {
707 widget_close(activatedWidgets[i]);
708 }
709 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
710 if (ifce != null) {
711 wmjs_core_out_invoke_reply(coreOut.requestDeactivateMessage, ifce.get_message("requestDeactivate"), wid, 1); // send return code 1 = success
712 }
713 }
714
715 //
716 // WM callback for when a component is activated by its parent
717 //
718 function widget_add(w) {
719 log(l_inf, "widget add " + w.name);
720 if (!w.activated) {
721 if (sameFileIgnoringSVGView(w.icon, w.main)) {
722 // same file in icon and main
723 } else {
724 widget_launch(w, document.createElement("animation"));
725 }
726 } else if (w.multipleInstances) {
727 var newwid = WidgetManager.open(w.manifest, null);
728 widget_launch(newwid, document.createElement("animation"));
729 } else return false;
205 alert("target_widgets.on_select(" + item + ")");
206 var args = new Array();
207 args[0] = "widgetCode";
208 args[1] = item;
209 device.standardService.SetActionListener("getWidget", get_widget_callback2, true);
210 device.standardService.CallAction("getWidget", args);
211 }
212 target_widgets.register(root);
213 }
214 }
215
216 function get_widget_callback2() {
217 // msgHandler is the first argument, the next arguments are from the reply to listWidgets
218 alert("callback2-1");
219 var act = arguments[0];
220 var act1 = act.GetArgumentValue("widgetUrl");
221 var act2 = act.GetArgumentValue("widgetContext");
222 alert("callback2-2 " + act1 + " " + act2);
223 var wid = WidgetManager.load(act1, null, act2);
224 WidgetManager.on_widget_add(wid);
225 }
226
227 //
228 // creates the menu of available targets for pushing a widget elsewhere
229 //
230 function selector_window1() {
231 var i, count, render;
232 var selector = document.createElement('g'), obj, child;
233 selector.setAttribute('transform', 'translate(10,10)');
234 count = WidgetManager.MPEGUStandardServiceProviders.length;
235 selector.appendChild(rect(0, 0, 300, 20 * (count + 1), 'white', 'black', null));
236 for (i = 0; i < count; i++) {
237 render = WidgetManager.MPEGUStandardServiceProviders[i];
238 obj = createtext(render.Name, 'black', 5, 17 + (20 * i), 15, 'sans-serif');
239 obj.setAttribute('id', "select" + i);
240 selector.appendChild(obj);
241 obj.addEventListener('mouseover', sw1("select" + i), false);
242 obj.addEventListener('mouseout', sw2("select" + i), false);
243 obj.addEventListener('click', sw4(i), false);
244 }
245 obj = createtext('Cancel', 'rgb(0,0,120)', 55, 17 + (20 * i), 15, 'sans-serif');
246 obj.setAttribute('id', "canc");
247 selector.appendChild(obj);
248 obj.addEventListener('mouseover', function() { document.getElementById("canc").setAttribute("fill", "red"); }, false);
249 obj.addEventListener('mouseout', function() { document.getElementById("canc").setAttribute("fill", "black"); }, false);
250 obj.addEventListener('click', function() { upnp_renders.on_select(-1); }, false);
251 selector.register = function(disp) {
252 disp.appendChild(this);
253 };
254 selector.unregister = function(disp) {
255 disp.removeChild(this);
256 };
257 return selector;
258 }
259
260 //
261 // creates the menu of available targets for pushing a widget elsewhere
262 //
263 function selector_window2(codes, names) {
264 alert("selector_window2");
265 var i, count, render;
266 var selector = document.createElement('g'), obj, child;
267 selector.setAttribute('transform', 'translate(10,10)');
268 count = codes.length;
269 selector.appendChild(rect(0, 0, 300, 20 * (count + 1), 'white', 'black', null));
270 for (i = 0; i < count; i++) {
271 render = names[i];
272 obj = createtext(render, 'black', 5, 17 + (20 * i), 15, 'sans-serif');
273 obj.setAttribute('id', "selecto" + i);
274 selector.appendChild(obj);
275 obj.addEventListener('mouseover', sw1("selecto" + i), false);
276 obj.addEventListener('mouseout', sw2("selecto" + i), false);
277 obj.addEventListener('click', sw5(i), false);
278 }
279 obj = createtext('Cancel', 'rgb(0,0,120)', 55, 17 + (20 * i), 15, 'sans-serif');
280 obj.setAttribute('id', "cance");
281 selector.appendChild(obj);
282 obj.addEventListener('mouseover', function() { document.getElementById("cance").setAttribute("fill", "red"); }, false);
283 obj.addEventListener('mouseout', function() { document.getElementById("cance").setAttribute("fill", "black"); }, false);
284 obj.addEventListener('click', function() { target_widgets.on_select(-1); }, false);
285 selector.register = function(disp) {
286 disp.appendChild(this);
287 };
288 selector.unregister = function(disp) {
289 disp.removeChild(this);
290 };
291 return selector;
292 }
293
294 function sw4(si) {
295 return function() { upnp_renders.on_select(si); };
296 }
297
298 function sw5(si) {
299 return function() { target_widgets.on_select(si); };
300 }
301
302 //
303 // when deleting an executing widgets, all executing widgets to its right are moved to the left
304 //
305 function recurseMoveAfterDelete(target) {
306 if (target != null && target.nextElementSibling != null) {
307 var v = target.nextElementSibling;
308 recurseMoveAfterDelete(v);
309 v.setAttribute("transform", target.getAttribute("transform"));
310 }
311 }
312
313 //
314 // click on home button to switch from icons to executing widgets
315 //
316 function home_button(evt) {
317 if (l_deb < log_level) {
318 alert("[UI] home_button");
319 }
320 if (state != 'home') {
321 state = 'home';
322 widgetContainer.setAttribute('display', 'none');
323 homepage.setAttribute('display', 'inline');
324 homebar.setAttribute('display', 'inline');
325 execbar.setAttribute('display', 'none');
326 arrows.setAttribute('display', 'inline');
327 arrowsW.setAttribute('display', 'none');
328 widgetAddList.setAttribute('display', 'none');
329 } else {
730330 state = 'exec';
731331 widgetContainer.setAttribute('display', 'inline');
732332 homepage.setAttribute('display', 'none');
735335 arrows.setAttribute('display', 'none');
736336 arrowsW.setAttribute('display', 'inline');
737337 widgetAddList.setAttribute('display', 'none');
738 return true;
739 }
740
741 function sameFileIgnoringSVGView(name1, name2) {
742 if (name1 == name2) {
743 return true;
744 }
745 if (name1 == null) {
746 return false;
747 }
748 var i1 = name1.indexOf("#");
749 var i2 = name2.indexOf("#");
750 if (i1 < 0) {
751 i1 = name1.length;
752 }
753 else {
754 i1--;
755 }
756 if (i2 < 0) {
757 i2 = name2.length;
758 }
759 else {
760 i2--;
761 }
762 return name1.substring(0, i1) == name2.substring(0, i2);
763 }
764
765 //
766 // recompute the number of widgets loaded currently
767 //
768 function getNbWidgets() {
769 var i, nbWidgets = 0;
770 for (i = 0; i < WidgetManager.num_widgets; i++) {
771 var w = WidgetManager.get(i);
772 if (w != null && w.loaded) {
773 nbWidgets++;
774 }
775 }
776 return nbWidgets;
777 }
778
779 //
780 // just resize the window and viewport, and initialize the first time this is called
781 //
782 function resize() {
783 if (init) {
784 initialize();
785 }
786 if (document.documentElement.viewport.width == previousWidth && document.documentElement.viewport.height == previousHeight) {
787 return;
788 }
789 if (l_deb < log_level) {
790 alert("[UI] start initialize() w:" + document.documentElement.viewport.width + " h:" + document.documentElement.viewport.height);
791 }
792 adaptLayoutToSize();
793 // start by filling the "home page" with known icons
794 where = 0;
795 var nbWidgets = getNbWidgets();
796 maxwhere = ((nbWidgets - 1) - ((nbWidgets - 1) % iconsPerPage)) / iconsPerPage;
797 var wid;
798 var iconIterator = document.getElementById("icons").firstElementChild;
799 var position = 0;
800 for (i = 1; i <= WidgetManager.num_widgets; i++) {
801 wid = WidgetManager.get(i - 1);
802 // alert("build:"+wid.main+" "+wid.loaded);
803 if (wid.loaded) {
804 insert_icon(wid, position, i - 1, iconIterator);
805 WidgetManager.corein_message(wid, 'setSize', 'width', totalWidth, 'height', totalHeight - 120, 'dpi', 96);
806 position++;
807 if (iconIterator != null) {
808 iconIterator = iconIterator.nextElementSibling;
809 }
810 }
811 }
812 adjustwhere(false);
813 adjustWhereWidgets(false);
814 previousWidth = document.documentElement.viewport.width;
815 previousHeight = document.documentElement.viewport.height;
816 gpac.setOption("Widgets", "LastWMWidth", '' + previousWidth);
817 gpac.setOption("Widgets", "LastWMHeight", '' + previousHeight);
818 }
819
820 //
821 // function inserting an icon on the home page
822 //
823 function insert_icon(widget, position, widgetIndex, previousIcon) {
824 if (l_deb < log_level) {
825 alert("[UI] insert_icon: " + widget.shortName + " " + position + " " + widgetIndex + " WMnw:" + WidgetManager.num_widgets);
826 }
827 widget.loaded = true;
828 if (l_deb < log_level) {
829 alert("[UI] widget name: " + widget.name);
830 }
831 var icon = null, original = null;
832 for (var i = 0; i < widget.icons.length; i++) {
833 // default to the first icon even if not of the preferred type
834 if (i == 0) {
835 icon = widget.icons[0].relocated_src;
836 //original = widget.icons[0].original;
837 // alert("choosing default icon " + icon);
838 }
839 // check for preferred type
840 if (widget.icons[i].relocated_src.indexOf(preferredIconType) > 0) {
841 icon = widget.icons[i].relocated_src;
842 //original = widget.icons[i].original;
843 break;
844 }
845 }
846 var shortName = widget.shortName;
847 if (typeof shortName == 'undefined') {
848 shortName = widget.name.substring(0, 9);
849 }
850 createIconSVGdecoration(previousIcon, widget, (((position % iconNbHoriz) * 80) + ((80 * (position - (position % iconsPerPage))) / iconNbVert)),
851 ((((position % iconsPerPage) - (position % iconNbHoriz)) / iconNbHoriz) * 80), "icons", icon,
852 shortName, widgetIndex);
853 }
854
855 /*function restoreFragmentOnURL(iconUrl, original) {
856 var l = original.indexOf('#');
857 if (l >= 0) {
858 return iconUrl + original.substring(l);
859 }
860 return iconUrl;
861 }*/
862
863 // constant
864 // const corein = "urn:mpeg:mpegu:schema:widgets:core:in:2010";
865
866 //
867 // commodity method to empty a list of children
868 //
869 function removeAllChildren(o) {
870 if (o != null && o.hasChildNodes()) {
871 while (o.childNodes.length >= 1) {
872 o.removeChild(o.firstChild);
873 }
874 }
875 }
876
877 //
878 // create the home page icon with all its behaviours
879 //
880 function createIconSVGdecoration(previousIcon, widget, x, y, fatherId, iconUrl, name, widIndex) {
881 var g, g2;
882 if (l_inf < log_level) {
883 alert("[UI] createIconSVGdecoration " + iconUrl + " " + x + " " + y);
884 }
885 if (previousIcon != null) {
886 g = previousIcon;
887 } else {
888 g = document.createElement("g");
889 document.getElementById(fatherId).appendChild(g);
890 }
891 g.setAttribute("transform", 'translate(' + x + ',' + y + ')');
892 if (previousIcon != null) {
893 g2 = g.firstElementChild;
894 } else {
895 g2 = document.createElement("g");
896 g2.setAttribute("transform", 'translate(15,10)');
897 g.appendChild(g2);
898 }
899 if (iconUrl == null || iconUrl == "") {
900 iconUrl = "icons/face-surprise.svg";
901 }
902 //
903 // process differently cases where widget.icon == widget.main
904 //
905 var container;
906 if (sameFileIgnoringSVGView(iconUrl, widget.main) && widget.main.indexOf('.svg') >= 0) {
907 // see if the animation already exists
908 container = document.getElementById(name);
909 if (container == null) {
910 // if the animation does not exist yet, create it
911 container = media('animation', iconUrl, 50, 50);
912 // store the animation in the main defs
913 document.getElementById("mainDefs").appendChild(container);
914 container.setAttribute('id', name);
915 }
916 if (previousIcon == null) {
917 // put the container in a use
918 var use = document.createElement("use");
919 use.setAttribute('id', 'iconContainer' + name);
920 use.setAttributeNS(xlinkns, 'href', '#' + name);
921 g2.appendChild(use);
922 }
923 } else {
924 if (previousIcon == null) {
925 container = appropriateElementForMedia(iconUrl, 50, 50);
926 container.setAttribute('id', name);
927 g2.appendChild(container);
928 }
929 }
930 if (previousIcon == null) {
931 g2 = document.createElement("g");
932 g2.setAttribute("transform", 'translate(40,70)');
933 g.appendChild(g2);
934 var anim = createtext(name, 'white', 0, 0, 14, 'Arial Unicode MS');
935 anim.setAttribute("text-anchor", "middle");
936 anim.setAttribute("display-align", "center");
937 g2.appendChild(anim);
938 var rect = invisible_rect(80, 80);
939 g.appendChild(rect);
940 rect.addEventListener("click", csi(widget), false);
941 }
942 }
943
944 function csi(widget) {
945 return function(evt) { activating_widget(widget);};
946 }
947
948 //
949 // widget closing action (WM callback)
950 //
951 function widget_close(wid) {
952 if (wid == null) {
953 return;
954 }
955 if (l_inf <= log_level) {
956 alert('[UI] widget_close:' + wid.name);
957 }
958 // maybe inform the widget that it is going to be deactivated
959 WidgetManager.corein_message(wid, "deactivate");
960 var target = widgetContainer.firstElementChild;
961 var i;
962 for (i = 0; i < numActivatedWidgets; i++) {
963 if (activatedWidgets[i] == wid) {
964 break;
965 }
966 target = target.nextElementSibling;
967 }
968 if (target != null) {
969 // move next widgets back one slot
970 recurseMoveAfterDelete(target);
971 // stop the subscene
972 if (target.firstElementChild != null) {
973 target.firstElementChild.setAttributeNS(xlinkns, "href", "");
974 }
975 // end trying
976 widgetContainer.removeChild(target);
977 }
978 wid.deactivate();
979 wid.activated = false;
980 activatedWidgets.splice(i, 1);
981 numActivatedWidgets--;
982 whereW = (whereW >= i ? (whereW > 0 ? whereW - 1 : 0) : whereW);
983 adjustWhereWidgets(false);
984 // if no more widgets, go back to the icons
985 if (numActivatedWidgets == 0) {
986 state = 'home';
987 widgetContainer.setAttribute('display', 'none');
988 homepage.setAttribute('display', 'inline');
989 homebar.setAttribute('display', 'inline');
990 execbar.setAttribute('display', 'none');
991 arrows.setAttribute('display', 'inline');
992 arrowsW.setAttribute('display', 'none');
993 widgetAddList.setAttribute('display', 'none');
994 }
995 if (!wid.permanent) {
996 WidgetManager.unload(wid, false);
997 }
998 }
999
1000 //
1001 // widget unloading action (WM callback)
1002 //
1003 function widget_remove(wid) {
1004 if (l_deb <= log_level) {
1005 alert('[UI] widget_remove:' + wid.name);
1006 }
1007 widget_close(wid);
1008 WidgetManager.unload(wid, false);
1009 }
1010
1011 //
1012 // widget launcher action
1013 //
1014 function widget_launch(wid, scene_container) {
1015 if (l_inf <= log_level) {
1016 alert('[UI] widget_launch:' + wid.name);
1017 }
1018 var tmp = document.createElement("g");
1019 tmp.setAttribute("transform", "translate(" + (totalWidth * numActivatedWidgets) + ", 0)");
1020 widgetContainer.appendChild(tmp);
1021 var icon = null;
1022 alert("wid: " + wid.name + "|" + wid.shortName);
1023 if (typeof wid.shortName != 'undefined') {
1024 var container = document.getElementById(wid.shortName);
1025 if (container != null) {
1026 icon = container.getAttributeNS(xlinkns, 'href');
1027 }
1028 }
1029 if (icon != null &&
1030 sameFileIgnoringSVGView(icon, wid.main) &&
1031 endsWith(wid.main, '.svg')) {
1032 // get the animation with id=shortName stored in mainDefs
1033 scene_container = document.getElementById(wid.shortName);
1034 // get the original use on it, used in the icon
1035 var iconContainer = document.getElementById('iconContainer' + wid.shortName);
1036 // create a new use
1037 var use = document.createElement('use');
1038 // point to the animation
1039 use.setAttributeNS(xlinkns, 'href', '#' + wid.shortName);
1040 // resize the animation
1041 scene_container.setAttribute("width", totalWidth);
1042 scene_container.setAttribute("height", totalHeight - 120);
1043 // resize the original use //TODO fix the aspect ratio conservation
1044 var m, t = Math.abs(totalHeight - 120 - totalWidth) / 2;
1045 if (totalWidth > totalHeight - 120) {
1046 m = 50 / (totalHeight - 120);
1047 iconContainer.setAttribute('transform', 'scale(' + m + ',' + m + ') translate(' + (-t) + ',0)');
1048 } else {
1049 m = 50 / totalWidth;
1050 iconContainer.setAttribute('transform', 'scale(' + m + ',' + m + ') translate(0,' + (-t) + ') ');
1051 }
1052 // add the new use as widget execution container
1053 tmp.appendChild(use);
1054 wid.activate(scene_container);
1055 } else {
1056 scene_container.setAttribute("width", totalWidth);
1057 scene_container.setAttribute("height", totalHeight - 120);
1058 tmp.appendChild(scene_container);
1059 scene_container.setAttributeNS(xlinkns, 'href', wid.main);
1060 wid.activate(scene_container);
1061 }
1062 wid.activated = true;
1063 activatedWidgets.splice(numActivatedWidgets, 0, wid);
1064 whereW = numActivatedWidgets;
1065 numActivatedWidgets++;
1066 adjustWhereWidgets(false);
1067 wid.load_component = widget_load_component;
1068 wid.permanent = true;
1069 wid.on_load = function () {
1070 WidgetManager.corein_message(this, 'setSize', 'width', totalWidth, 'height', totalHeight - 120, 'dpi', 96);
1071 };
1072 //
1073 if (log_level > l_inf) {
1074 var i = 0;
1075 alert(">>>>>>>>>>>>> " + wid.name + " interfaces:");
1076 for (; i < wid.num_interfaces; i++) {
1077 alert("" + wid.get_interface(i).type);
1078 }
1079 }
1080 //
1081 }
1082
1083 //
1084 // widget load component (WM callback)
1085 //
1086 function widget_load_component(comp, is_unload) {
1087 if (l_deb <= log_level) {
1088 alert('[UI] widget_load_component:' + comp.name);
1089 }
1090 if (is_unload) {
1091 widget_close(comp);
1092 comp.parent = null;
1093 } else {
1094 widget_add(comp);
1095 comp.permanent = false;
1096 comp.parent = this;
1097 }
1098 }
1099
1100 var upnp_renders = null, target_widgets = null;
1101
1102 //
1103 // widget remoting function
1104 //
1105 function on_widget_remote() {
1106 if (WidgetManager.MPEGUStandardServiceProviders.length != 0 && numActivatedWidgets > 0) {
1107 upnp_renders = selector_window(activatedWidgets[whereW]);
1108 upnp_renders.on_select = function(item, wid) {
1109 upnp_renders.unregister(root);
1110 upnp_renders = null;
1111 if (item == -1) {
1112 return;
1113 }
1114 if (wid != null) {
1115 alert("upnp_renders.on_select(" + item + "," + wid.name + ")");
1116 //WidgetManager.migrate_widget(UPnP.GetMediaRenderer(item), wid);
1117 WidgetManager.migrate_widget(WidgetManager.get_mpegu_service_providers(item), wid);
1118 widget_close(wid);
1119 }
1120 };
1121 upnp_renders.register(root);
1122 }
1123 }
1124
1125 //
1126 // creates the menu of available targets for pushing a widget elsewhere
1127 //
1128 function selector_window(widget) {
1129 var i, count, render;
1130 var selector = document.createElement('g'), obj, child;
1131 selector.setAttribute('transform', 'translate(10,10)');
1132 count = WidgetManager.MPEGUStandardServiceProviders.length;
1133 selector.appendChild(rect(0, 0, 300, 20 * (count + 1), 'white', 'black'));
1134 for (i = 0; i < count; i++) {
1135 render = WidgetManager.MPEGUStandardServiceProviders[i];
1136 obj = createtext(render.Name, 'black', 5, 17 + (20 * i), 15, 'sans-serif');
1137 obj.setAttribute('id', "selector" + i);
1138 selector.appendChild(obj);
1139 obj.addEventListener('mouseover', sw1("selector" + i), false);
1140 obj.addEventListener('mouseout', sw2("selector" + i), false);
1141 obj.addEventListener('click', sw3(i, widget), false);
1142 }
1143 obj = createtext('Cancel', 'rgb(0,0,120)', 55, 17 + (20 * i), 15, 'sans-serif');
1144 obj.setAttribute('id', "cancel");
1145 selector.appendChild(obj);
1146 obj.addEventListener('mouseover', function(evt) { document.getElementById("cancel").setAttribute("fill", "red"); }, false);
1147 obj.addEventListener('mouseout', function(evt) { document.getElementById("cancel").setAttribute("fill", "black"); }, false);
1148 obj.addEventListener('click', function(evt) { upnp_renders.on_select(-1, null); }, false);
1149 selector.register = function(disp) {
1150 disp.appendChild(this);
1151 };
1152 selector.unregister = function(disp) {
1153 disp.removeChild(this);
1154 };
1155 return selector;
1156 }
1157
1158 function sw1(s) {
1159 return function(evt) { document.getElementById(s).setAttribute("fill", "blue"); };
1160 }
1161
1162 function sw2(s) {
1163 return function(evt) { document.getElementById(s).setAttribute("fill", "black"); };
1164 }
1165
1166 function sw3(si, widget) {
1167 return function(evt) { upnp_renders.on_select(si, widget); };
1168 }
1169
1170 //
1171 // when a widget is pushed to here, install the widget and execute it
1172 //
1173 function onMediaConnect(url, src_ip) {
1174 if (l_inf <= log_level) {
1175 alert('[UI] onMediaConnect :\"' + url + '\"');
1176 }
1177 if (WidgetManager.probe(url)) {
1178 var w = WidgetManager.open(url, src_ip);
1179 if (w == null) {
338 }
339 }
340
341 // constants
342 var adjustFrom = "0,0";
343 var animDue = true;
344
345 //
346 // after each change of icon page, this function adjusts the visibility of arrows in the lower bar
347 //
348 function adjustwhere(animDue) {
349 if (l_deb < log_level) {
350 alert("[UI] adjust " + where + " 0 " + maxwhere);
351 }
352 document.getElementById("left").setAttribute("display", ((where > 0) ? "inline" : "none"));
353 document.getElementById("right").setAttribute("display", ((where < maxwhere) ? "inline" : "none"));
354 if (!animDue) {
355 icons.setAttribute("transform", 'translate(' + (-80 * iconNbHoriz * where) + ',0)');
356 } else {
357 var aw = document.createElement("animateTransform");
358 aw.setAttribute("attributeName", "transform");
359 aw.setAttribute("type", "translate");
360 //alert('time '+document.documentElement.getCurrentTime());
361 aw.setAttribute("begin", document.documentElement.getCurrentTime());
362 aw.setAttribute("dur", "1s");
363 aw.setAttribute("fill", "freeze");
364 aw.setAttributeNS(xlinkns, "href", "#icons");
365 aw.setAttribute("from", adjustFrom);
366 aw.setAttribute("to", (-80 * iconNbHoriz * where) + ",0");
367 document.documentElement.appendChild(aw);
368 }
369 adjustFrom = (-80 * iconNbHoriz * where) + ",0";
370 }
371
372 //
373 // action of the left button on the lower bar
374 //
375 function left_button() {
376 if (l_deb < log_level) {
377 alert("[UI] left button " + where + " 0");
378 }
379 if (where > 0) {
380 where--;
381 adjustwhere(true);
382 }
383 }
384
385 //
386 // action of the right button of the lower bar
387 //
388 function right_button() {
389 if (l_deb < log_level) {
390 alert("[UI] right button " + where + " " + maxwhere);
391 }
392 if (where < maxwhere) {
393 where++;
394 adjustwhere(true);
395 }
396 }
397
398 var adjustFromW = "0,0";
399 var oldwhereW = -1;
400
401 //
402 // after each change of icon page, this function adjusts the visibility of arrows in the lower bar
403 //
404 function adjustWhereWidgets(animDue) {
405 if (oldwhereW != whereW) {
406 // hide oldwhereW
407 if (oldwhereW >= 0 && activatedWidgets[oldwhereW] != null) {
408 WidgetManager.corein_message(activatedWidgets[oldwhereW], "hide");
409 }
410 }
411 if (l_deb < log_level) {
412 alert("[UI] adjustW " + whereW + " 0 " + (numActivatedWidgets - 1));
413 }
414 document.getElementById("leftW").setAttribute("display", ((whereW > 0) ? "inline" : "none"));
415 document.getElementById("rightW").setAttribute("display", ((whereW < (numActivatedWidgets - 1)) ? "inline" : "none"));
416 if (!animDue) {
417 widgetContainer.setAttribute("transform", "translate(" + (-totalWidth * whereW) + ",0)");
418 } else {
419 var aw = document.createElement("animateTransform");
420 aw.setAttribute("attributeName", "transform");
421 aw.setAttribute("type", "translate");
422 aw.setAttribute("begin", document.documentElement.getCurrentTime());
423 aw.setAttribute("dur", "1s");
424 aw.setAttribute("fill", "freeze");
425 aw.setAttributeNS(xlinkns, "href", "#widget");
426 aw.setAttribute("from", adjustFromW);
427 aw.setAttribute("to", (-totalWidth * whereW) + ",0");
428 document.documentElement.appendChild(aw);
429 }
430 adjustFromW = (-totalWidth * whereW) + ",0";
431 document.getElementById("widgetName").textContent =
432 (whereW >= 0 && activatedWidgets[whereW] != null ? activatedWidgets[whereW].shortName : '-');
433 if (oldwhereW != whereW) {
434 // show whereW
435 if (whereW >= 0 && activatedWidgets[whereW] != null) {
436 WidgetManager.corein_message(activatedWidgets[whereW], "show");
437 }
438 oldwhereW = whereW;
439 }
440 }
441
442 //
443 // action of the left button on the lower bar
444 //
445 function left_buttonW() {
446 if (l_deb < log_level) {
447 alert("[UI] left button " + whereW);
448 }
449 if (whereW > 0) {
450 whereW--;
451 adjustWhereWidgets(animDue);
452 }
453 }
454
455 //
456 // action of the right button of the lower bar
457 //
458 function right_buttonW() {
459 if (l_deb < log_level) {
460 alert("[UI] right button " + whereW + " " + (numActivatedWidgets - 1));
461 }
462 if (whereW < (numActivatedWidgets - 1)) {
463 whereW++;
464 adjustWhereWidgets(animDue);
465 }
466 }
467
468 //
469 // action of each icon, starting the matching widget
470 //
471 function activating_widget(w) {
472 if (l_deb < log_level) {
473 alert("[UI] activating widget: " + w.name);
474 }
475 widget_add(w);
476 }
477
478 //
479 // main initialization function
480 // init variables, then init the widget manager C code, then inits UPnP
481 //
482 function initialize() {
483 if (l_deb < log_level) {
484 alert("[UI] initialize");
485 }
486 init = false;
487 var display_width = parseInt(gpac.getOption('Widgets', 'LastWMWidth'));
488 var display_height = parseInt(gpac.getOption('Widgets', 'LastWMHeight'));
489 if (display_width && display_height) {
490 gpac.set_size(display_width, display_height);
491 }
492 root = document.documentElement;
493 homepage = document.getElementById('homepage');
494 homebar = document.getElementById('homebar');
495 execbar = document.getElementById('execbar');
496 arrows = document.getElementById('arrows');
497 arrowsW = document.getElementById('arrowsW');
498 icons = document.getElementById('icons');
499 widgetContainer = document.getElementById('widget');
500 widgetAddList = document.getElementById('widgetAddList');
501 /* Setup the GPAC Widget Manager - this will also scan the available widgets */
502 log_level = l_inf;
503 widget_manager_init();
504 WidgetManager.on_widget_remove = widget_remove;
505 WidgetManager.on_widget_add = widget_add;
506 /* register the callback to be notified of incoming widgets */
507 has_upnp = (typeof UPnP != 'undefined');
508 if (has_upnp) {
509 /* setting the callback to allow other devices to push their widgets */
510 UPnP.onMediaConnect = onMediaConnect;
511 /* Tell GPAC that the calls to the main Renderer (like open, ...) must be forwared to this scene */
512 UPnP.BindRenderer();
513 }
514 WidgetManager.coreOutShow = coreOutShowImplementation;
515 WidgetManager.coreOutGetAttention = coreOutGetAttentionImplementation;
516 WidgetManager.coreOutHide = coreOutHideImplementation;
517 WidgetManager.coreOutRequestDeactivate = coreOutRequestDeactivateImplementation;
518 WidgetManager.coreOutInstallWidget = coreOutInstallWidgetImplementation;
519 WidgetManager.coreOutActivateTemporaryWidget = coreOutActivateTemporaryWidgetImplementation;
520 WidgetManager.coreOutMigrateComponent = coreOutMigrateComponentImplementation;
521 WidgetManager.coreOutRequestMigrationTargets = coreOutRequestMigrationTargetsImplementation;
522 }
523
524 //
525 // implementation of core:out install widget
526 //
527 function coreOutInstallWidgetImplementation(wid, args) {
528 var w = widgetInstall(args[0], true, false, wid);
529 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
530 if (ifce != null) {
531 wmjs_core_out_invoke_reply(coreOut.installWidgetMessage, ifce.get_message("installWidget"),
532 wid, (w != null ? 1 : 0)); // send return code 1 = success
533 }
534 }
535
536 //
537 // implementation of core:out activate temporary widget
538 //
539 function coreOutActivateTemporaryWidgetImplementation(wid, args) {
540 var w = widgetInstall(args[0], true, true, null);
541 if (w != null) {
542 activating_widget(w);
543 }
544 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
545 if (ifce != null) {
546 wmjs_core_out_invoke_reply(coreOut.activateTemporaryWidgetMessage, ifce.get_message("activateTemporaryWidget"),
547 wid, (w != null ? 1 : 0)); // send return code 1 = success
548 }
549 }
550
551 //
552 // implementation of core:out migrate component
553 //
554 function coreOutMigrateComponentImplementation(wid, args) {
555 //alert("coreOutMigrateComponent "+wid.name+" "+args.length);
556 var comp = wid.get_component(args[0], true);
557 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
558 if (comp == null) {
559 log(l_err, 'Component ' + args[0] + ' cannot be found in widget ' + wid.name);
560 if (ifce != null) {
561 wmjs_core_out_invoke_reply(coreOut.migrateComponentMessage, ifce.get_message("migrateComponent"), wid, 0);
562 }
563 return;
564 }
565 if (args.length > 1 && args[1] != null) {
566 //WidgetManager.migrate_widget(UPnP.GetMediaRenderer(parseInt(args[1])), comp);
567 WidgetManager.migrate_widget(WidgetManager.get_mpegu_service_providers(parseInt(args[1])), comp);
568 widget_close(comp);
569 } else {
570 upnp_renders = selector_window(comp);
571 upnp_renders.on_select = function(item, wid) {
572 upnp_renders.unregister(root);
573 upnp_renders = null;
574 if (item == -1) {
1180575 return;
1181576 }
1182 widget_add(w);
1183 adjustWhereWidgets(false);
1184 w.permanent = false;
1185 }
1186 }
1187
577 if (comp != null) {
578 alert("upnp_renders.on_select(" + item + "," + comp.name + ")");
579 //WidgetManager.migrate_widget(UPnP.GetMediaRenderer(item), comp);
580 WidgetManager.migrate_widget(WidgetManager.get_mpegu_service_providers(item), comp);
581 widget_close(comp);
582 }
583 };
584 upnp_renders.register(root);
585 }
586 if (ifce != null) {
587 wmjs_core_out_invoke_reply(coreOut.migrateComponentMessage, ifce.get_message("migrateComponent"), wid, 1); // send return code 1 = success
588 }
589 }
590
591 //
592 // implementation of core:out request migration targets
593 //
594 function coreOutRequestMigrationTargetsImplementation(wid, args) {
595 var count = UPnP.MediaRenderersCount, codes = new Array(), names = new Array(), descriptions = new Array(), i;
596 for (i = 0; i < count; i++) {
597 var render = UPnP.GetMediaRenderer(i);
598 codes.push("" + i);
599 names.push(render.Name);
600 descriptions.push(render.HostName + " " + render.UUID);
601 }
602 i = null;
603 var ifce_count = wid.num_interfaces, j;
604 for (j = 0; j < ifce_count; j++) {
605 var ifce = wid.get_interface(j);
606 if (ifce.type == "urn:mpeg:mpegu:schema:widgets:core:out:2010") {
607 i = ifce;
608 break;
609 }
610 }
611 if (i != null) {
612 wmjs_core_out_invoke_reply(coreOut.requestMigrationTargetsMessage, i.get_message("requestMigrationTargets"),
613 wid, codes, names, descriptions);
614 }
615 }
616
617 //
618 // implementation of core:out Show message
619 // this is a request by the widget to be shown
620 //
621 function coreOutShowImplementation(wid, args) {
622 //alert("core:out show "+wid.name);
623 var target = widgetContainer.firstElementChild;
624 var i;
625 for (i = 0; i < numActivatedWidgets; i++) {
626 //alert("is it "+activatedWidgets[i].name);
627 if (activatedWidgets[i] == wid) {
628 break;
629 }
630 target = target.nextElementSibling;
631 }
632 // here, i is the index of the current widget
633 //alert(" "+i+" "+numActivatedWidgets);
634 if (i < numActivatedWidgets) {
635 whereW = i;
636 adjustWhereWidgets(false);
637 }
638 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
639 if (ifce != null) {
640 wmjs_core_out_invoke_reply(coreOut.showMessage, ifce.get_message("show"), wid, 1); // send return code 1 = success
641 }
642 }
643
644 //
645 // implementation of core:out GetAttention message
646 // this is a request by the widget to be shown and some special signal is given
647 //
648 function coreOutGetAttentionImplementation(wid, args) {
649 //alert("core:out getAttention "+wid.name);
650 var target = widgetContainer.firstElementChild;
651 var i;
652 for (i = 0; i < numActivatedWidgets; i++) {
653 //alert("is it "+activatedWidgets[i].name);
654 if (activatedWidgets[i] == wid) {
655 break;
656 }
657 target = target.nextElementSibling;
658 }
659 // here, i is the index of the current widget
660 //alert(" "+i+" "+numActivatedWidgets);
661 if (i < numActivatedWidgets) {
662 whereW = i;
663 adjustWhereWidgets(false);
664 }
665 document.getElementById("getAttention").beginElement();
666 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
667 if (ifce != null) {
668 wmjs_core_out_invoke_reply(coreOut.getAttentionMessage, ifce.get_message("getAttention"), wid, 1); // send return code 1 = success
669 }
670 }
671
672 //
673 // implementation of core:out hide message
674 // this is a request by the widget to be hidden (some other widget (if any) is shown)
675 //
676 function coreOutHideImplementation(wid, args) {
677 //alert("core:out hide "+wid.name);
678 var target = widgetContainer.firstElementChild;
679 var i;
680 for (i = 0; i < numActivatedWidgets; i++) {
681 //alert("is it "+activatedWidgets[i].name);
682 if (activatedWidgets[i] == wid) {
683 break;
684 }
685 target = target.nextElementSibling;
686 }
687 // here, i is the index of the current widget
688 //alert("hide "+i+" "+numActivatedWidgets);
689 if (i < numActivatedWidgets) {
690 if (whereW > 0) {
691 whereW--;
692 }
693 else if (whereW < numActivatedWidgets - 1) {
694 whereW++;
695 }
696 else {
697 return;
698 }
699 adjustWhereWidgets(false);
700 }
701 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
702 if (ifce != null) {
703 wmjs_core_out_invoke_reply(coreOut.hideMessage, ifce.get_message("hide"), wid, 1); // send return code 1 = success
704 }
705 }
706
707 //
708 // implementation of core:out requestDeactivate message
709 // this is a request by the widget to be stopped
710 //
711 function coreOutRequestDeactivateImplementation(wid, args) {
712 //alert("core:out hide "+wid.name);
713 var target = widgetContainer.firstElementChild;
714 var i;
715 for (i = 0; i < numActivatedWidgets; i++) {
716 //alert("is it "+activatedWidgets[i].name);
717 if (activatedWidgets[i] == wid) {
718 break;
719 }
720 target = target.nextElementSibling;
721 }
722 // here, i is the index of the current widget
723 //alert("hide "+i+" "+numActivatedWidgets);
724 if (i < numActivatedWidgets) {
725 widget_close(activatedWidgets[i]);
726 }
727 var ifce = getInterfaceByType(wid, "urn:mpeg:mpegu:schema:widgets:core:out:2010");
728 if (ifce != null) {
729 wmjs_core_out_invoke_reply(coreOut.requestDeactivateMessage, ifce.get_message("requestDeactivate"), wid, 1); // send return code 1 = success
730 }
731 }
732
733 //
734 // WM callback for when a component is activated by its parent
735 //
736 function widget_add(w) {
737 log(l_inf, "widget add " + w.name);
738 if (!w.activated) {
739 if (sameFileIgnoringSVGView(w.icon, w.main)) {
740 // same file in icon and main
741 } else {
742 widget_launch(w, document.createElement("animation"));
743 }
744 } else if (w.multipleInstances) {
745 var newwid = WidgetManager.open(w.manifest, null);
746 widget_launch(newwid, document.createElement("animation"));
747 } else {
748 return false;
749 }
750 state = 'exec';
751 widgetContainer.setAttribute('display', 'inline');
752 homepage.setAttribute('display', 'none');
753 homebar.setAttribute('display', 'none');
754 execbar.setAttribute('display', 'inline');
755 arrows.setAttribute('display', 'none');
756 arrowsW.setAttribute('display', 'inline');
757 widgetAddList.setAttribute('display', 'none');
758 return true;
759 }
760
761 function sameFileIgnoringSVGView(name1, name2) {
762 if (name1 == name2) {
763 return true;
764 }
765 if (name1 == null) {
766 return false;
767 }
768 var i1 = name1.indexOf("#");
769 var i2 = name2.indexOf("#");
770 if (i1 < 0) {
771 i1 = name1.length;
772 }
773 else {
774 i1--;
775 }
776 if (i2 < 0) {
777 i2 = name2.length;
778 }
779 else {
780 i2--;
781 }
782 return name1.substring(0, i1) == name2.substring(0, i2);
783 }
784
785 //
786 // recompute the number of widgets loaded currently
787 //
788 function getNbWidgets() {
789 var i, nbWidgets = 0;
790 for (i = 0; i < WidgetManager.num_widgets; i++) {
791 var w = WidgetManager.get(i);
792 if (w != null && w.loaded) {
793 nbWidgets++;
794 }
795 }
796 return nbWidgets;
797 }
798
799 //
800 // just resize the window and viewport, and initialize the first time this is called
801 //
802 function resize() {
803 if (init) {
804 initialize();
805 }
806 if (document.documentElement.viewport.width == previousWidth && document.documentElement.viewport.height == previousHeight) {
807 return;
808 }
809 if (l_deb < log_level) {
810 alert("[UI] start initialize() w:" + document.documentElement.viewport.width + " h:" + document.documentElement.viewport.height);
811 }
812 adaptLayoutToSize();
813 // start by filling the "home page" with known icons
814 where = 0;
815 var nbWidgets = getNbWidgets();
816 maxwhere = ((nbWidgets - 1) - ((nbWidgets - 1) % iconsPerPage)) / iconsPerPage;
817 var wid;
818 var iconIterator = document.getElementById("icons").firstElementChild;
819 var position = 0;
820 for (i = 1; i <= WidgetManager.num_widgets; i++) {
821 wid = WidgetManager.get(i - 1);
822 // alert("build:"+wid.main+" "+wid.loaded);
823 if (wid.loaded) {
824 insert_icon(wid, position, i - 1, iconIterator);
825 WidgetManager.corein_message(wid, 'setSize', 'width', totalWidth, 'height', totalHeight - 120, 'dpi', 96);
826 position++;
827 if (iconIterator != null) {
828 iconIterator = iconIterator.nextElementSibling;
829 }
830 }
831 }
832 adjustwhere(false);
833 adjustWhereWidgets(false);
834 previousWidth = document.documentElement.viewport.width;
835 previousHeight = document.documentElement.viewport.height;
836 gpac.setOption("Widgets", "LastWMWidth", '' + previousWidth);
837 gpac.setOption("Widgets", "LastWMHeight", '' + previousHeight);
838 }
839
840 //
841 // function inserting an icon on the home page
842 //
843 function insert_icon(widget, position, widgetIndex, previousIcon) {
844 if (l_deb < log_level) {
845 alert("[UI] insert_icon: " + widget.shortName + " " + position + " " + widgetIndex + " WMnw:" + WidgetManager.num_widgets);
846 }
847 widget.loaded = true;
848 if (l_deb < log_level) {
849 alert("[UI] widget name: " + widget.name);
850 }
851 var icon = null, original = null;
852 for (var i = 0; i < widget.icons.length; i++) {
853 // default to the first icon even if not of the preferred type
854 if (i == 0) {
855 icon = widget.icons[0].relocated_src;
856 //original = widget.icons[0].original;
857 // alert("choosing default icon " + icon);
858 }
859 // check for preferred type
860 if (widget.icons[i].relocated_src.indexOf(preferredIconType) > 0) {
861 icon = widget.icons[i].relocated_src;
862 //original = widget.icons[i].original;
863 break;
864 }
865 }
866 var shortName = widget.shortName;
867 if (typeof shortName == 'undefined') {
868 shortName = widget.name.substring(0, 9);
869 }
870 createIconSVGdecoration(previousIcon, widget, (((position % iconNbHoriz) * 80) + ((80 * (position - (position % iconsPerPage))) / iconNbVert)),
871 ((((position % iconsPerPage) - (position % iconNbHoriz)) / iconNbHoriz) * 80), "icons", icon,
872 shortName, widgetIndex);
873 }
874
875 // constant
876 // const corein = "urn:mpeg:mpegu:schema:widgets:core:in:2010";
877
878 //
879 // commodity method to empty a list of children
880 //
881 function removeAllChildren(o) {
882 if (o != null && o.hasChildNodes()) {
883 while (o.childNodes.length >= 1) {
884 o.removeChild(o.firstChild);
885 }
886 }
887 }
888
889 //
890 // create the home page icon with all its behaviours
891 //
892 function createIconSVGdecoration(previousIcon, widget, x, y, fatherId, iconUrl, name, widIndex) {
893 var g, g2;
894 if (l_inf < log_level) {
895 alert("[UI] createIconSVGdecoration " + iconUrl + " " + x + " " + y);
896 }
897 if (previousIcon != null) {
898 g = previousIcon;
899 } else {
900 g = document.createElement("g");
901 document.getElementById(fatherId).appendChild(g);
902 }
903 g.setAttribute("transform", 'translate(' + x + ',' + y + ')');
904 if (previousIcon != null) {
905 g2 = g.firstElementChild;
906 } else {
907 g2 = document.createElement("g");
908 g2.setAttribute("transform", 'translate(15,10)');
909 g.appendChild(g2);
910 }
911 if (iconUrl == null || iconUrl == "") {
912 iconUrl = "icons/face-surprise.svg";
913 }
1188914 //
1189 // file list vars
915 // process differently cases where widget.icon == widget.main
1190916 //
1191 var flstart = 0,fllist = null,maxFileNames = 14;
1192
1193 //
1194 // create a file menu in the main screen, allowing to navigate directories and choose widget config files
1195 //
1196 function on_widget_add_menu() {
1197 state = 'list';
1198 widgetContainer.setAttribute('display', 'none');
1199 homepage.setAttribute('display', 'none');
1200 homebar.setAttribute('display', 'none');
1201 execbar.setAttribute('display', 'inline');
1202 arrows.setAttribute('display', 'none');
1203 arrowsW.setAttribute('display', 'none');
1204 widgetAddList.setAttribute('display', 'inline');
1205 maxFileNames = Math.round(((iconNbVert * 80) / 25) - 1.4);
1206 isThisAScan = false;
1207 refillWidgetAddList(false);
1208 }
1209
1210 //
1211 // create a file menu in the main screen, allowing to navigate directories and choose a directory to scan for widgets
1212 // and load all their icons
1213 //
1214 function on_dir_scan() {
1215 state = 'list';
1216 widgetContainer.setAttribute('display', 'none');
1217 homepage.setAttribute('display', 'none');
1218 homebar.setAttribute('display', 'none');
1219 execbar.setAttribute('display', 'inline');
1220 arrows.setAttribute('display', 'none');
1221 arrowsW.setAttribute('display', 'none');
1222 widgetAddList.setAttribute('display', 'inline');
1223 maxFileNames = Math.round(((iconNbVert * 80) / 25) - 1.4);
1224 isThisAScan = true;
1225 refillWidgetAddList(true);
1226 }
1227
1228 //
1229 // remove all installed icons
1230 //
1231 function on_clean_up() {
1232 var i;
1233 //if (l_inf <= log_level) alert('[UI] unloading ' + WidgetManager.num_widgets + ' widgets');
1234 for (i = WidgetManager.num_widgets - 1; i >= 0; i--) {
1235 var w = WidgetManager.get(i);
1236 if (w.loaded) {
1237 alert("unloading " + w.name);
1238 w.loaded = false;
1239 WidgetManager.unload(w, false);
1240 }
1241 }
1242 where = 0;
1243 maxwhere = 0;
1244 removeAllChildren(document.getElementById("icons"));
1245 adjustwhere(false);
1246 }
1247
1248 //
1249 // install, but do not launch, the widget whose config.xml has been chosen, and return to the home page
1250 //
1251 function widgetInstall(uri, manual, temporary, parent_wid) {
1252 var wid, j, count = WidgetManager.num_widgets, nbWidgets = getNbWidgets();
1253 for (j = 0; j < count; j++) {
1254 wid = WidgetManager.get(j);
1255 if (wid.url == uri) {
1256 if (wid.loaded) {
1257 break;
1258 }
1259 if (temporary) {
1260 wid.permanent = false;
1261 }
1262 else {
1263 insert_icon(wid, nbWidgets, nbWidgets);
1264 }
1265 }
1266 }
1267 if (j == count) {
1268 wid = WidgetManager.open(uri, null, parent_wid);
1269 if (wid != null) {
1270 if (temporary) {
1271 wid.permanent = false;
1272 }
1273 else {
1274 insert_icon(wid, nbWidgets, nbWidgets);
1275 }
1276 }
1277 }
1278 if (manual) {
1279 return wid;
1280 }
917 var container;
918 if (sameFileIgnoringSVGView(iconUrl, widget.main) && widget.main.indexOf('.svg') >= 0) {
919 // see if the animation already exists
920 container = document.getElementById(name);
921 if (container == null) {
922 // if the animation does not exist yet, create it
923 container = media('animation', iconUrl, 50, 50);
924 // store the animation in the main defs
925 document.getElementById("mainDefs").appendChild(container);
926 container.setAttribute('id', name);
927 }
928 if (previousIcon == null) {
929 // put the container in a use
930 var use = document.createElement("use");
931 use.setAttribute('id', 'iconContainer' + name);
932 use.setAttributeNS(xlinkns, 'href', '#' + name);
933 g2.appendChild(use);
934 }
935 } else {
936 if (previousIcon == null) {
937 container = appropriateElementForMedia(iconUrl, 50, 50);
938 container.setAttribute('id', name);
939 g2.appendChild(container);
940 }
941 }
942 if (previousIcon == null) {
943 g2 = document.createElement("g");
944 g2.setAttribute("transform", 'translate(40,70)');
945 g.appendChild(g2);
946 var anim = createtext(name, 'white', 0, 0, 14, 'Arial Unicode MS');
947 anim.setAttribute("text-anchor", "middle");
948 anim.setAttribute("display-align", "center");
949 g2.appendChild(anim);
950 var rect = invisible_rect(80, 80);
951 g.appendChild(rect);
952 rect.addEventListener("click", csi(widget), false);
953 }
954 }
955
956 function csi(widget) {
957 return function(evt) { activating_widget(widget);};
958 }
959
960 //
961 // widget closing action (WM callback)
962 //
963 function widget_close(wid) {
964 if (wid == null) {
965 return;
966 }
967 if (l_inf <= log_level) {
968 alert('[UI] widget_close:' + wid.name);
969 }
970 // maybe inform the widget that it is going to be deactivated
971 WidgetManager.corein_message(wid, "deactivate");
972 var target = widgetContainer.firstElementChild;
973 var i;
974 for (i = 0; i < numActivatedWidgets; i++) {
975 if (activatedWidgets[i] == wid) {
976 break;
977 }
978 target = target.nextElementSibling;
979 }
980 if (target != null) {
981 // move next widgets back one slot
982 recurseMoveAfterDelete(target);
983 // stop the subscene
984 if (target.firstElementChild != null) {
985 target.firstElementChild.setAttributeNS(xlinkns, "href", "");
986 }
987 // end trying
988 widgetContainer.removeChild(target);
989 }
990 wid.deactivate();
991 wid.activated = false;
992 activatedWidgets.splice(i, 1);
993 numActivatedWidgets--;
994 whereW = (whereW >= i ? (whereW > 0 ? whereW - 1 : 0) : whereW);
995 adjustWhereWidgets(false);
996 // if no more widgets, go back to the icons
997 if (numActivatedWidgets == 0) {
1281998 state = 'home';
1282999 widgetContainer.setAttribute('display', 'none');
12831000 homepage.setAttribute('display', 'inline');
12851002 execbar.setAttribute('display', 'none');
12861003 arrows.setAttribute('display', 'inline');
12871004 arrowsW.setAttribute('display', 'none');
1288 removeAllChildren(widgetAddList);
1289 maxwhere = ((nbWidgets - 1) - ((nbWidgets - 1) % iconsPerPage)) / iconsPerPage;
1290 where = maxwhere;
1291 adjustwhere(false);
1005 widgetAddList.setAttribute('display', 'none');
1006 }
1007 if (!wid.permanent) {
1008 WidgetManager.unload(wid, false);
1009 }
1010 }
1011
1012 //
1013 // widget unloading action (WM callback)
1014 //
1015 function widget_remove(wid) {
1016 if (l_deb <= log_level) {
1017 alert('[UI] widget_remove:' + wid.name);
1018 }
1019 widget_close(wid);
1020 WidgetManager.unload(wid, false);
1021 }
1022
1023 //
1024 // widget launcher action
1025 //
1026 function widget_launch(wid, scene_container) {
1027 if (l_inf <= log_level) {
1028 alert('[UI] widget_launch:' + wid.name);
1029 }
1030 var tmp = document.createElement("g");
1031 tmp.setAttribute("transform", "translate(" + (totalWidth * numActivatedWidgets) + ", 0)");
1032 widgetContainer.appendChild(tmp);
1033 var icon = null;
1034 alert("wid: " + wid.name + "|" + wid.shortName);
1035 if (typeof wid.shortName != 'undefined') {
1036 var container = document.getElementById(wid.shortName);
1037 if (container != null) {
1038 icon = container.getAttributeNS(xlinkns, 'href');
1039 }
1040 }
1041 if (icon != null &&
1042 sameFileIgnoringSVGView(icon, wid.main) &&
1043 endsWith(wid.main, '.svg')) {
1044 // get the animation with id=shortName stored in mainDefs
1045 scene_container = document.getElementById(wid.shortName);
1046 // get the original use on it, used in the icon
1047 var iconContainer = document.getElementById('iconContainer' + wid.shortName);
1048 // create a new use
1049 var use = document.createElement('use');
1050 // point to the animation
1051 use.setAttributeNS(xlinkns, 'href', '#' + wid.shortName);
1052 // resize the animation
1053 scene_container.setAttribute("width", totalWidth);
1054 scene_container.setAttribute("height", totalHeight - 120);
1055 // resize the original use
1056 //should do: fix the aspect ratio conservation
1057 var m, t = Math.abs(totalHeight - 120 - totalWidth) / 2;
1058 if (totalWidth > totalHeight - 120) {
1059 m = 50 / (totalHeight - 120);
1060 iconContainer.setAttribute('transform', 'scale(' + m + ',' + m + ') translate(' + (-t) + ',0)');
1061 } else {
1062 m = 50 / totalWidth;
1063 iconContainer.setAttribute('transform', 'scale(' + m + ',' + m + ') translate(0,' + (-t) + ') ');
1064 }
1065 // add the new use as widget execution container
1066 tmp.appendChild(use);
1067 wid.activate(scene_container);
1068 } else {
1069 scene_container.setAttribute("width", totalWidth);
1070 scene_container.setAttribute("height", totalHeight - 120);
1071 tmp.appendChild(scene_container);
1072 scene_container.setAttributeNS(xlinkns, 'href', wid.main);
1073 wid.activate(scene_container);
1074 }
1075 wid.activated = true;
1076 activatedWidgets.splice(numActivatedWidgets, 0, wid);
1077 whereW = numActivatedWidgets;
1078 numActivatedWidgets++;
1079 adjustWhereWidgets(false);
1080 wid.load_component = widget_load_component;
1081 wid.permanent = true;
1082 wid.on_load = function () {
1083 WidgetManager.corein_message(this, 'setSize', 'width', totalWidth, 'height', totalHeight - 120, 'dpi', 96);
1084 };
1085 //
1086 if (log_level > l_inf) {
1087 var i = 0;
1088 alert(">>>>>>>>>>>>> " + wid.name + " interfaces:");
1089 for (; i < wid.num_interfaces; i++) {
1090 alert("" + wid.get_interface(i).type);
1091 }
1092 }
1093 //
1094 }
1095
1096 //
1097 // widget load component (WM callback)
1098 //
1099 function widget_load_component(comp, is_unload) {
1100 if (l_deb <= log_level) {
1101 alert('[UI] widget_load_component:' + comp.name);
1102 }
1103 if (is_unload) {
1104 widget_close(comp);
1105 comp.parent = null;
1106 } else {
1107 widget_add(comp);
1108 comp.permanent = false;
1109 comp.parent = this;
1110 }
1111 }
1112
1113 var upnp_renders = null, target_widgets = null;
1114
1115 //
1116 // widget remoting function
1117 //
1118 function on_widget_remote() {
1119 if (WidgetManager.MPEGUStandardServiceProviders.length != 0 && numActivatedWidgets > 0) {
1120 upnp_renders = selector_window(activatedWidgets[whereW]);
1121 upnp_renders.on_select = function(item, wid) {
1122 upnp_renders.unregister(root);
1123 upnp_renders = null;
1124 if (item == -1) {
1125 return;
1126 }
1127 if (wid != null) {
1128 alert("upnp_renders.on_select(" + item + "," + wid.name + ")");
1129 //WidgetManager.migrate_widget(UPnP.GetMediaRenderer(item), wid);
1130 WidgetManager.migrate_widget(WidgetManager.get_mpegu_service_providers(item), wid);
1131 widget_close(wid);
1132 }
1133 };
1134 upnp_renders.register(root);
1135 }
1136 }
1137
1138 //
1139 // creates the menu of available targets for pushing a widget elsewhere
1140 //
1141 function selector_window(widget) {
1142 var i, count, render;
1143 var selector = document.createElement('g'), obj, child;
1144 selector.setAttribute('transform', 'translate(10,10)');
1145 count = WidgetManager.MPEGUStandardServiceProviders.length;
1146 selector.appendChild(rect(0, 0, 300, 20 * (count + 1), 'white', 'black'));
1147 for (i = 0; i < count; i++) {
1148 render = WidgetManager.MPEGUStandardServiceProviders[i];
1149 obj = createtext(render.Name, 'black', 5, 17 + (20 * i), 15, 'sans-serif');
1150 obj.setAttribute('id', "selector" + i);
1151 selector.appendChild(obj);
1152 obj.addEventListener('mouseover', sw1("selector" + i), false);
1153 obj.addEventListener('mouseout', sw2("selector" + i), false);
1154 obj.addEventListener('click', sw3(i, widget), false);
1155 }
1156 obj = createtext('Cancel', 'rgb(0,0,120)', 55, 17 + (20 * i), 15, 'sans-serif');
1157 obj.setAttribute('id', "cancel");
1158 selector.appendChild(obj);
1159 obj.addEventListener('mouseover', function(evt) { document.getElementById("cancel").setAttribute("fill", "red"); }, false);
1160 obj.addEventListener('mouseout', function(evt) { document.getElementById("cancel").setAttribute("fill", "black"); }, false);
1161 obj.addEventListener('click', function(evt) { upnp_renders.on_select(-1, null); }, false);
1162 selector.register = function(disp) {
1163 disp.appendChild(this);
1164 };
1165 selector.unregister = function(disp) {
1166 disp.removeChild(this);
1167 };
1168 return selector;
1169 }
1170
1171 function sw1(s) {
1172 return function(evt) { document.getElementById(s).setAttribute("fill", "blue"); };
1173 }
1174
1175 function sw2(s) {
1176 return function(evt) { document.getElementById(s).setAttribute("fill", "black"); };
1177 }
1178
1179 function sw3(si, widget) {
1180 return function(evt) { upnp_renders.on_select(si, widget); };
1181 }
1182
1183 //
1184 // when a widget is pushed to here, install the widget and execute it
1185 //
1186 function onMediaConnect(url, src_ip) {
1187 if (l_inf <= log_level) {
1188 alert('[UI] onMediaConnect :\"' + url + '\"');
1189 }
1190 if (WidgetManager.probe(url)) {
1191 var w = WidgetManager.open(url, src_ip);
1192 if (w == null) {
1193 return;
1194 }
1195 widget_add(w);
1196 adjustWhereWidgets(false);
1197 w.permanent = false;
1198 }
1199 }
1200
1201 //
1202 // file list vars
1203 //
1204 var flstart = 0,fllist = null,maxFileNames = 14;
1205
1206 //
1207 // create a file menu in the main screen, allowing to navigate directories and choose widget config files
1208 //
1209 function on_widget_add_menu() {
1210 state = 'list';
1211 widgetContainer.setAttribute('display', 'none');
1212 homepage.setAttribute('display', 'none');
1213 homebar.setAttribute('display', 'none');
1214 execbar.setAttribute('display', 'inline');
1215 arrows.setAttribute('display', 'none');
1216 arrowsW.setAttribute('display', 'none');
1217 widgetAddList.setAttribute('display', 'inline');
1218 maxFileNames = Math.round(((iconNbVert * 80) / 25) - 1.4);
1219 isThisAScan = false;
1220 refillWidgetAddList(false);
1221 }
1222
1223 //
1224 // create a file menu in the main screen, allowing to navigate directories and choose a directory to scan for widgets
1225 // and load all their icons
1226 //
1227 function on_dir_scan() {
1228 state = 'list';
1229 widgetContainer.setAttribute('display', 'none');
1230 homepage.setAttribute('display', 'none');
1231 homebar.setAttribute('display', 'none');
1232 execbar.setAttribute('display', 'inline');
1233 arrows.setAttribute('display', 'none');
1234 arrowsW.setAttribute('display', 'none');
1235 widgetAddList.setAttribute('display', 'inline');
1236 maxFileNames = Math.round(((iconNbVert * 80) / 25) - 1.4);
1237 isThisAScan = true;
1238 refillWidgetAddList(true);
1239 }
1240
1241 //
1242 // remove all installed icons
1243 //
1244 function on_clean_up() {
1245 var i;
1246 //if (l_inf <= log_level) alert('[UI] unloading ' + WidgetManager.num_widgets + ' widgets');
1247 for (i = WidgetManager.num_widgets - 1; i >= 0; i--) {
1248 var w = WidgetManager.get(i);
1249 if (w.loaded) {
1250 alert("unloading " + w.name);
1251 w.loaded = false;
1252 WidgetManager.unload(w, false);
1253 }
1254 }
1255 where = 0;
1256 maxwhere = 0;
1257 removeAllChildren(document.getElementById("icons"));
1258 adjustwhere(false);
1259 }
1260
1261 //
1262 // install, but do not launch, the widget whose config.xml has been chosen, and return to the home page
1263 //
1264 function widgetInstall(uri, manual, temporary, parent_wid) {
1265 var wid, j, count = WidgetManager.num_widgets, nbWidgets = getNbWidgets();
1266 for (j = 0; j < count; j++) {
1267 wid = WidgetManager.get(j);
1268 if (wid.url == uri) {
1269 if (wid.loaded) {
1270 break;
1271 }
1272 if (temporary) {
1273 wid.permanent = false;
1274 }
1275 else {
1276 insert_icon(wid, nbWidgets, nbWidgets);
1277 }
1278 }
1279 }
1280 if (j == count) {
1281 wid = WidgetManager.open(uri, null, parent_wid);
1282 if (wid != null) {
1283 if (temporary) {
1284 wid.permanent = false;
1285 }
1286 else {
1287 insert_icon(wid, nbWidgets, nbWidgets);
1288 }
1289 }
1290 }
1291 if (manual) {
12921292 return wid;
12931293 }
1294
1295 //
1296 // clean up file list space and refill it
1297 //
1298 function refillWidgetAddList(flag) {
1299 removeAllChildren(widgetAddList);
1300 fllist = null;
1301 flstart = 0;
1302 fllist = gpac.enum_directory(gpac.last_working_directory, "", false);
1303 fillWidgetAddList(flag);
1304 }
1305
1306 //
1307 // go to parent directory
1308 //
1309 function flUpDir(evt) {
1310 var s = gpac.last_working_directory;
1311 if (l_inf <= log_level) {
1312 alert("[UI] lwd:" + gpac.last_working_directory);
1313 }
1314 var index = s.lastIndexOf("\\");
1294 state = 'home';
1295 widgetContainer.setAttribute('display', 'none');
1296 homepage.setAttribute('display', 'inline');
1297 homebar.setAttribute('display', 'inline');
1298 execbar.setAttribute('display', 'none');
1299 arrows.setAttribute('display', 'inline');
1300 arrowsW.setAttribute('display', 'none');
1301 removeAllChildren(widgetAddList);
1302 maxwhere = ((nbWidgets - 1) - ((nbWidgets - 1) % iconsPerPage)) / iconsPerPage;
1303 where = maxwhere;
1304 adjustwhere(false);
1305 return wid;
1306 }
1307
1308 //
1309 // clean up file list space and refill it
1310 //
1311 function refillWidgetAddList(flag) {
1312 removeAllChildren(widgetAddList);
1313 fllist = null;
1314 flstart = 0;
1315 fllist = gpac.enum_directory(gpac.last_working_directory, "", false);
1316 fillWidgetAddList(flag);
1317 }
1318
1319 //
1320 // go to parent directory
1321 //
1322 function flUpDir(evt) {
1323 var s = gpac.last_working_directory;
1324 if (l_inf <= log_level) {
1325 alert("[UI] lwd:" + gpac.last_working_directory);
1326 }
1327 var index = s.lastIndexOf("\\");
1328 if (index != -1) {
1329 gpac.last_working_directory = s.substring(0, index);
1330 refillWidgetAddList(isThisAScan);
1331 } else {
1332 index = s.lastIndexOf("/");
13151333 if (index != -1) {
13161334 gpac.last_working_directory = s.substring(0, index);
13171335 refillWidgetAddList(isThisAScan);
13181336 } else {
1319 index = s.lastIndexOf("/");
1320 if (index != -1) {
1321 gpac.last_working_directory = s.substring(0, index);
1322 refillWidgetAddList(isThisAScan);
1323 } else {
1324 gpac.last_working_directory = "/";
1325 refillWidgetAddList(isThisAScan);
1326 }
1327 }
1328 }
1329
1330 //
1331 // go to a named directory
1332 //
1333 function flGoTo(newDir) {
1334 //alert("goto "+newDir);
1335 var s = gpac.last_working_directory;
1336 if (s == "/") {
1337 gpac.last_working_directory = newDir;
1338 } else {
1339 var c = s.charAt(s.length - 1);
1340 if (c != '\\' && c != '/') {
1341 s += "/";
1342 }
1343 gpac.last_working_directory = s + newDir;
1344 }
1345 //alert(gpac.last_working_directory);
1346 refillWidgetAddList(isThisAScan);
1347 }
1348
1349 //
1350 // if the directory contains more files that can be shown, show previous page of file names
1351 //
1352 function flPrevFiles(evt) {
1353 if (flstart == 0) {
1354 return;
1355 }
1356 flstart -= maxFileNames;
1357 if (flstart < 0) {
1358 flstart = 0;
1359 }
1337 gpac.last_working_directory = "/";
1338 refillWidgetAddList(isThisAScan);
1339 }
1340 }
1341 }
1342
1343 //
1344 // go to a named directory
1345 //
1346 function flGoTo(newDir) {
1347 //alert("goto "+newDir);
1348 var s = gpac.last_working_directory;
1349 if (s == "/") {
1350 gpac.last_working_directory = newDir;
1351 } else {
1352 var c = s.charAt(s.length - 1);
1353 if (c != '\\' && c != '/') {
1354 s += "/";
1355 }
1356 gpac.last_working_directory = s + newDir;
1357 }
1358 //alert(gpac.last_working_directory);
1359 refillWidgetAddList(isThisAScan);
1360 }
1361
1362 //
1363 // if the directory contains more files that can be shown, show previous page of file names
1364 //
1365 function flPrevFiles(evt) {
1366 if (flstart == 0) {
1367 return;
1368 }
1369 flstart -= maxFileNames;
1370 if (flstart < 0) {
1371 flstart = 0;
1372 }
1373 removeAllChildren(widgetAddList);
1374 fillWidgetAddList(isThisAScan);
1375 }
1376
1377 //
1378 // if the directory contains more files that can be shown, show next page of file names
1379 //
1380 function flNextFiles(evt) {
1381 if (flstart + maxFileNames < fllist.length) {
1382 flstart += maxFileNames;
13601383 removeAllChildren(widgetAddList);
13611384 fillWidgetAddList(isThisAScan);
13621385 }
1363
1364 //
1365 // if the directory contains more files that can be shown, show next page of file names
1366 //
1367 function flNextFiles(evt) {
1368 if (flstart + maxFileNames < fllist.length) {
1369 flstart += maxFileNames;
1370 removeAllChildren(widgetAddList);
1371 fillWidgetAddList(isThisAScan);
1372 }
1373 }
1374
1375 //
1376 // scan the current directory recursively for widgets, clean up and return to home page
1377 //
1378 function flScanDir(evt) {
1379 scan_directory(gpac.last_working_directory);
1380 state = 'home';
1381 var nbWidgets = getNbWidgets();
1382 widgetContainer.setAttribute('display', 'none');
1383 homepage.setAttribute('display', 'inline');
1384 homebar.setAttribute('display', 'inline');
1385 execbar.setAttribute('display', 'none');
1386 arrows.setAttribute('display', 'inline');
1387 arrowsW.setAttribute('display', 'none');
1388 removeAllChildren(widgetAddList);
1389 maxwhere = ((nbWidgets - 1) - ((nbWidgets - 1) % iconsPerPage)) / iconsPerPage;
1390 where = maxwhere;
1391 adjustwhere(false);
1392 }
1393
1394 //
1395 // scanning
1396 //
1397 function scan_directory(dir) {
1398 var ii, j, count, list, w, uri, loadedWidgets = 0;
1399 list = gpac.enum_directory(dir, '.xml;.wgt', 0);
1400 for (ii = 0; ii < list.length; ii++) {
1401 uri = list[ii].path + list[ii].name;
1402 if (list[ii].directory) {
1403 scan_directory(uri);
1404 } else {
1405 count = WidgetManager.num_widgets;
1406 for (j = 0; j < count; j++) {
1407 var wid = WidgetManager.get(j);
1386 }
1387
1388 //
1389 // scan the current directory recursively for widgets, clean up and return to home page
1390 //
1391 function flScanDir(evt) {
1392 scan_directory(gpac.last_working_directory);
1393 state = 'home';
1394 var nbWidgets = getNbWidgets();
1395 widgetContainer.setAttribute('display', 'none');
1396 homepage.setAttribute('display', 'inline');
1397 homebar.setAttribute('display', 'inline');
1398 execbar.setAttribute('display', 'none');
1399 arrows.setAttribute('display', 'inline');
1400 arrowsW.setAttribute('display', 'none');
1401 removeAllChildren(widgetAddList);
1402 maxwhere = ((nbWidgets - 1) - ((nbWidgets - 1) % iconsPerPage)) / iconsPerPage;
1403 where = maxwhere;
1404 adjustwhere(false);
1405 }
1406
1407 //
1408 // scanning
1409 //
1410 function scan_directory(dir) {
1411 var ii, j, count, list, w, uri, loadedWidgets = 0;
1412 list = gpac.enum_directory(dir, '.xml;.wgt', 0);
1413 for (ii = 0; ii < list.length; ii++) {
1414 uri = list[ii].path + list[ii].name;
1415 if (list[ii].directory) {
1416 scan_directory(uri);
1417 } else {
1418 count = WidgetManager.num_widgets;
1419 for (j = 0; j < count; j++) {
1420 var wid = WidgetManager.get(j);
1421 if (wid.loaded) {
1422 loadedWidgets++;
1423 }
1424 if (wid.url == uri) {
14081425 if (wid.loaded) {
1409 loadedWidgets++;
1410 }
1411 if (wid.url == uri) {
1412 if (wid.loaded) {
1413 break;
1414 }
1415 insert_icon(wid, getNbWidgets(), j);
14161426 break;
14171427 }
1418 }
1419 if (j == count) {
1420 w = WidgetManager.open(uri, null);
1421 if (w != null) {
1422 insert_icon(w, loadedWidgets, WidgetManager.num_widgets - 1);
1423 }
1428 insert_icon(wid, getNbWidgets(), j);
1429 break;
14241430 }
14251431 }
1426 }
1427 }
1428
1429 //
1430 // create the up, prev, next button, show current directory and as many file names as possible
1431 // the file names are active: clicking on a directory name goes to that directory
1432 // clicking on a file tries to load that file as a widget
1433 //
1434 function fillWidgetAddList(flag) {
1435 if (flag) {
1436 widgetAddList.appendChild(use("cartoucheflag"));
1437 document.getElementById("dirflag").textContent = gpac.last_working_directory;
1438 } else {
1439 widgetAddList.appendChild(use("cartouche"));
1440 document.getElementById("dir").textContent = gpac.last_working_directory;
1441 }
1442 // next lines are file names
1443 var obj;
1444 for (i = 0; i < (fllist.length - flstart) && i < maxFileNames; i++) {
1445 obj = use("fileMenuElement" + i);
1446 obj.setAttribute('transform', 'translate(0,' + (25 * (i + 1)) + ')');
1447 widgetAddList.appendChild(obj);
1448 document.getElementById("fileMenuElement" + i + "u").setAttributeNS(xlinkns, 'href', "#" + (fllist[i + flstart].directory ? 'folder' : 'new'));
1449 document.getElementById("fileMenuElement" + i + "t").textContent = fllist[i + flstart].name;
1450 if (obj.listener != null) {
1451 obj.removeEventListener("click", obj.listener);
1432 if (j == count) {
1433 w = WidgetManager.open(uri, null);
1434 if (w != null) {
1435 insert_icon(w, loadedWidgets, WidgetManager.num_widgets - 1);
1436 }
14521437 }
1453 if (fllist[i + flstart].directory) {
1454 obj.listener = createGoto(escaping(fllist[i + flstart].name));
1455 obj.addEventListener("click", obj.listener, false);
1456 } else if (isWidgetFileName(fllist[i + flstart].name)) {
1457 obj.listener = createWidgetInstall(escaping(gpac.last_working_directory + '/' + fllist[i + flstart].name));
1458 obj.addEventListener("click", obj.listener, false);
1459 }
1460 }
1461 }
1462
1463 function createGoto(s) {
1464 return function () {
1465 flGoTo(s);
1466 };
1467 }
1468
1469 function createWidgetInstall(s) {
1470 return function () {
1471 widgetInstall(s, false, false, null);
1472 };
1473 }
1474
1475 // // // // // // // // // // // // // // //
1476 // function library
1477 // // // // // // // // // // // // // // //
1478
1479 function isWidgetFileName(s) {
1480 if (endsWith(s, 'config.xml')) {
1481 return true;
1482 }
1483 if (endsWith(s, '.wgt')) {
1484 return true;
1485 }
1486 return false;
1487 }
1488
1489 //
1490 // replace globally \ with / in a string
1491 //
1492 function escaping(s) {
1493 s = s.replace(/\\/g, '/');
1494 return s;
1495 }
1496
1497 //
1498 // create rect
1499 //
1500 function rect(x, y, w, h, fill, stroke, id) {
1501 var child = document.createElement('rect');
1502 if (id != null) {
1503 child.setAttribute('id', id);
1504 }
1505 child.setAttribute('x', x);
1506 child.setAttribute('y', y);
1507 child.setAttribute('width', w);
1508 child.setAttribute('height', h);
1509 child.setAttribute('fill', fill);
1510 child.setAttribute('stroke', stroke);
1511 return child;
1512 }
1513
1514 //
1515 // create text
1516 //
1517 function createtext(content, fill, x, y, size, family) {
1518 var child = document.createElement('text');
1519 child.setAttribute('fill', fill);
1520 child.textContent = content;
1521 child.setAttribute('x', x);
1522 child.setAttribute('y', y);
1523 child.setAttribute('font-size', size);
1524 child.setAttribute('font-family', family);
1525 return child;
1526 }
1527
1528 //
1529 // create invisible rect getting all events
1530 //
1531 function invisible_rect(w, h) {
1532 var child = document.createElement('rect');
1533 child.setAttribute('width', w);
1534 child.setAttribute('height', h);
1535 child.setAttribute('fill', 'none');
1536 child.setAttribute('stroke', 'none');
1537 child.setAttribute('pointer-events', 'all');
1538 return child;
1539 }
1540
1541 //
1542 // create animation
1543 //
1544 function media(etype, uri, w, h) {
1545 var child = document.createElement(etype);
1546 child.setAttributeNS(xlinkns, 'href', uri);
1547 child.setAttribute('width', w);
1548 child.setAttribute('height', h);
1549 if (etype == 'animation') {
1550 child.setAttributeNS('http://gpac.sourceforge.net/svg-extensions', 'use-as-primary', 'false');
1551 }
1552 return child;
1553 }
1554
1555 //
1556 // create use
1557 //
1558 function use(uri) {
1559 var child = document.createElement('use');
1560 child.setAttributeNS(xlinkns, 'href', '#' + uri);
1561 return child;
1562 }
1563
1564 //
1565 // create appropriate element for media reference by the given uri
1566 //
1567 function appropriateElementForMedia(uri, w, h) {
1568 if (uri.indexOf('#') != -1) {
1569 return media('animation', uri, w, h);
1570 }
1571 if (endsWith(uri, '.svg')) {
1572 return media('animation', uri, w, h);
1573 }
1574 if (endsWith(uri, '.bt')) {
1575 return media('animation', uri, w, h);
1576 }
1577 if (endsWith(uri, '.png')) {
1578 return media('image', uri, w, h);
1579 }
1580 if (endsWith(uri, '.jpg')) {
1581 return media('image', uri, w, h);
1582 }
1583 if (endsWith(uri, '.gif')) {
1584 return media('image', uri, w, h);
1585 }
1586 if (l_war <= log_level) {
1587 alert("[UI] WARNING: bad suffix for an icon URI: " + uri);
1588 }
1438 }
1439 }
1440 }
1441
1442 //
1443 // create the up, prev, next button, show current directory and as many file names as possible
1444 // the file names are active: clicking on a directory name goes to that directory
1445 // clicking on a file tries to load that file as a widget
1446 //
1447 function fillWidgetAddList(flag) {
1448 if (flag) {
1449 widgetAddList.appendChild(use("cartoucheflag"));
1450 document.getElementById("dirflag").textContent = gpac.last_working_directory;
1451 } else {
1452 widgetAddList.appendChild(use("cartouche"));
1453 document.getElementById("dir").textContent = gpac.last_working_directory;
1454 }
1455 // next lines are file names
1456 var obj;
1457 for (i = 0; i < (fllist.length - flstart) && i < maxFileNames; i++) {
1458 obj = use("fileMenuElement" + i);
1459 obj.setAttribute('transform', 'translate(0,' + (25 * (i + 1)) + ')');
1460 widgetAddList.appendChild(obj);
1461 document.getElementById("fileMenuElement" + i + "u").setAttributeNS(xlinkns, 'href', "#" + (fllist[i + flstart].directory ? 'folder' : 'new'));
1462 document.getElementById("fileMenuElement" + i + "t").textContent = fllist[i + flstart].name;
1463 if (obj.listener != null) {
1464 obj.removeEventListener("click", obj.listener);
1465 }
1466 if (fllist[i + flstart].directory) {
1467 obj.listener = createGoto(escaping(fllist[i + flstart].name));
1468 obj.addEventListener("click", obj.listener, false);
1469 } else if (isWidgetFileName(fllist[i + flstart].name)) {
1470 obj.listener = createWidgetInstall(escaping(gpac.last_working_directory + '/' + fllist[i + flstart].name));
1471 obj.addEventListener("click", obj.listener, false);
1472 }
1473 }
1474 }
1475
1476 function createGoto(s) {
1477 return function () {
1478 flGoTo(s);
1479 };
1480 }
1481
1482 function createWidgetInstall(s) {
1483 return function () {
1484 widgetInstall(s, false, false, null);
1485 };
1486 }
1487
1488 // // // // // // // // // // // // // // //
1489 // function library
1490 // // // // // // // // // // // // // // //
1491
1492 function isWidgetFileName(s) {
1493 if (endsWith(s, 'config.xml')) {
1494 return true;
1495 }
1496 if (endsWith(s, '.wgt')) {
1497 return true;
1498 }
1499 return false;
1500 }
1501
1502 //
1503 // replace globally \ with / in a string
1504 //
1505 function escaping(s) {
1506 s = s.replace(/\\/g, '/');
1507 return s;
1508 }
1509
1510 //
1511 // create rect
1512 //
1513 function rect(x, y, w, h, fill, stroke, id) {
1514 var child = document.createElement('rect');
1515 if (id != null) {
1516 child.setAttribute('id', id);
1517 }
1518 child.setAttribute('x', x);
1519 child.setAttribute('y', y);
1520 child.setAttribute('width', w);
1521 child.setAttribute('height', h);
1522 child.setAttribute('fill', fill);
1523 child.setAttribute('stroke', stroke);
1524 return child;
1525 }
1526
1527 //
1528 // create text
1529 //
1530 function createtext(content, fill, x, y, size, family) {
1531 var child = document.createElement('text');
1532 child.setAttribute('fill', fill);
1533 child.textContent = content;
1534 child.setAttribute('x', x);
1535 child.setAttribute('y', y);
1536 child.setAttribute('font-size', size);
1537 child.setAttribute('font-family', family);
1538 return child;
1539 }
1540
1541 //
1542 // create invisible rect getting all events
1543 //
1544 function invisible_rect(w, h) {
1545 var child = document.createElement('rect');
1546 child.setAttribute('width', w);
1547 child.setAttribute('height', h);
1548 child.setAttribute('fill', 'none');
1549 child.setAttribute('stroke', 'none');
1550 child.setAttribute('pointer-events', 'all');
1551 return child;
1552 }
1553
1554 //
1555 // create animation
1556 //
1557 function media(etype, uri, w, h) {
1558 var child = document.createElement(etype);
1559 child.setAttributeNS(xlinkns, 'href', uri);
1560 child.setAttribute('width', w);
1561 child.setAttribute('height', h);
1562 if (etype == 'animation') {
1563 child.setAttributeNS('http://gpac.sourceforge.net/svg-extensions', 'use-as-primary', 'false');
1564 }
1565 return child;
1566 }
1567
1568 //
1569 // create use
1570 //
1571 function use(uri) {
1572 var child = document.createElement('use');
1573 child.setAttributeNS(xlinkns, 'href', '#' + uri);
1574 return child;
1575 }
1576
1577 //
1578 // create appropriate element for media reference by the given uri
1579 //
1580 function appropriateElementForMedia(uri, w, h) {
1581 if (uri.indexOf('#') != -1) {
1582 return media('animation', uri, w, h);
1583 }
1584 if (endsWith(uri, '.svg')) {
1585 return media('animation', uri, w, h);
1586 }
1587 if (endsWith(uri, '.bt')) {
1588 return media('animation', uri, w, h);
1589 }
1590 if (endsWith(uri, '.png')) {
15891591 return media('image', uri, w, h);
15901592 }
1591
1592 //
1593 // substitute for the useful predefined function endsWith
1594 //
1595 function endsWith(s1, s2) {
1596 return s1.toLowerCase().substring(s1.length - s2.length) == s2;
1597 }
1598
1599 // export the resize function as the resize member of iphone_wm_gui, as well as other functions
1600 return {
1601 resize: resize,
1602 left_button: left_button,
1603 right_button: right_button,
1604 left_buttonW: left_buttonW,
1605 right_buttonW: right_buttonW,
1606 home_button: home_button,
1607 on_dir_scan: on_dir_scan,
1608 on_clean_up: on_clean_up,
1609 on_widget_add_menu: on_widget_add_menu,
1610 on_kill_widget: on_kill_widget,
1611 on_get_widget: on_get_widget,
1612 on_widget_remote: on_widget_remote,
1613 flUpDir: flUpDir,
1614 flPrevFiles: flPrevFiles,
1615 flNextFiles: flNextFiles,
1616 flScanDir: flScanDir
1617 }
1618
1619 }());
1593 if (endsWith(uri, '.jpg')) {
1594 return media('image', uri, w, h);
1595 }
1596 if (endsWith(uri, '.gif')) {
1597 return media('image', uri, w, h);
1598 }
1599 if (l_war <= log_level) {
1600 alert("[UI] WARNING: bad suffix for an icon URI: " + uri);
1601 }
1602 return media('image', uri, w, h);
1603 }
1604
1605 //
1606 // substitute for the useful predefined function endsWith
1607 //
1608 function endsWith(s1, s2) {
1609 return s1.toLowerCase().substring(s1.length - s2.length) == s2;
1610 }
1611
1612 /* wrapper as a module
1613 // export the resize function as the resize member of iphone_wm_gui, as well as other functions
1614 return {
1615 resize: resize,
1616 left_button: left_button,
1617 right_button: right_button,
1618 left_buttonW: left_buttonW,
1619 right_buttonW: right_buttonW,
1620 home_button: home_button,
1621 on_dir_scan: on_dir_scan,
1622 on_clean_up: on_clean_up,
1623 on_widget_add_menu: on_widget_add_menu,
1624 on_kill_widget: on_kill_widget,
1625 on_get_widget: on_get_widget,
1626 on_widget_remote: on_widget_remote,
1627 flUpDir: flUpDir,
1628 flPrevFiles: flPrevFiles,
1629 flNextFiles: flNextFiles,
1630 flScanDir: flScanDir,
1631 get_widget_callback2: get_widget_callback2
1632 }
1633
1634 }());*/
16201635
16211636 function widget_activated_and_bound(wid) {
16221637 WidgetManager.corein_message(wid, "activate");
16231638 }
16241639
16251640 function printAllFieldsOf(obj, printableName) {
1626 var details = "fields of "+printableName+":\n";
1641 var details = "fields of " + printableName + ":\n";
16271642 for (var field in obj) {
1628 fieldContents = obj[field];
1629 if (typeof(fieldContents) == "function") {
1630 fieldContents = "(function)";
1631 }
1632 details += " " + field + ": " + fieldContents + "\n";
1643 fieldContents = obj[field];
1644 if (typeof(fieldContents) == "function") {
1645 fieldContents = "(function)";
1646 }
1647 details += " " + field + ": " + fieldContents + "\n";
16331648 }
16341649 alert(details);
16351650 }
481481 <text fill="black" font-family="Comic Sans MS" font-size="12" x="2" y="12">Scan</text>
482482 <handler ev:event="click">on_dir_scan();</handler>
483483 </g>
484 <g id="get" transform="translate(130, 22)">
485 <rect rx="8" ry="8" fill="rgb(140,140,50)" width="36" height="16"/>
486 <text fill="black" font-family="Comic Sans MS" font-size="12" x="2" y="12">GetW</text>
487 <handler ev:event="click">on_get_widget();</handler>
488 </g>
484489 </g>
485490 <rect id="screen" width="320" height="480" fill="white" stroke="black" x="0" y="60"/>
486491
13341334 void (*on_audio_reconfig)(void *udta, u32 samplerate, u32 bits_per_sample, u32 nb_channel, u32 channel_cfg);
13351335 } GF_AudioListener;
13361336
1337 /*adds a new audio listener - the on_audio_reconfig callback will be called before this function returns*/
13371338 GF_Err gf_sc_add_audio_listener(GF_Compositor *compositor, GF_AudioListener *al);
13381339 GF_Err gf_sc_remove_audio_listener(GF_Compositor *compositor, GF_AudioListener *al);
13391340
20372037 #define GF_ISOM_GET_FRAG_PAD(flag) ( (flag) >> 17) & 0x7
20382038 #define GF_ISOM_GET_FRAG_SYNC(flag) ( ! ( ( (flag) >> 16) & 0x1))
20392039 #define GF_ISOM_GET_FRAG_DEG(flag) (flag) & 0x7FFF
2040
2041 #define GF_ISOM_GET_FRAG_DEPEND_FLAGS(lead, depends, depended, redundant) ( (lead<<26) | (depends<<24) | (depended<<22) | (redundant<<20) )
2042 #define GF_ISOM_RESET_FRAG_DEPEND_FLAGS(flags) flags = flags & 0xFFFFF
20402043
20412044 GF_TrackExtendsBox *GetTrex(GF_MovieBox *moov, u32 TrackID);
20422045 #endif
410410
411411
412412 #ifndef GF_EXPORT
413 #if defined(__GNUC__) && __GNUC__ >= 4
414 #define GF_EXPORT __attribute__((visibility("default")))
415 #else
413416 /*use def files for windows or let compiler decide*/
414417 #define GF_EXPORT
418 #endif
415419 #endif
416420
417421
6161 * SONAME versions must be digits (not strings)
6262 */
6363 #define GPAC_VERSION "0.4.6-DEV"
64 #define GPAC_VERSION_MAJOR 1
65 #define GPAC_VERSION_MINOR 1
64 #define GPAC_VERSION_MAJOR 2
65 #define GPAC_VERSION_MINOR 0
6666 #define GPAC_VERSION_MICRO 0
6767
6868 #include <gpac/version.h>
928928 }
929929
930930 #endif
931 #endif
931932
932933 #ifndef DONT_USE_TERMINAL_MODULE_API
933934
981982 }
982983 }
983984 #endif
984 #endif
349349 * ********************************************************************
350350 * interface
351351 */
352 GF_EXPORT
352353 const u32 *QueryInterfaces()
353354 {
354355 static u32 si [] = {
358359 return si;
359360 }
360361
362 GF_EXPORT
361363 GF_BaseInterface *LoadInterface(u32 InterfaceType)
362364 {
363365 if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE)
365367 return NULL;
366368 }
367369
370 GF_EXPORT
368371 void ShutdownInterface(GF_BaseInterface *ifce)
369372 {
370373 if (ifce->InterfaceType==GF_AUDIO_OUTPUT_INTERFACE)
303303 GF_InputService *NewAESReader();
304304 void DeleteAESReader(void *ifce);
305305
306 GF_EXPORT
306307 GF_BaseInterface *LoadInterface(u32 InterfaceType)
307308 {
308309 switch (InterfaceType) {
312313 }
313314 }
314315
316 GF_EXPORT
315317 void ShutdownInterface(GF_BaseInterface *ifce)
316318 {
317319 switch (ifce->InterfaceType) {
322322 return si;
323323 }
324324
325 GF_EXPORT
325326 GF_BaseInterface *LoadInterface(u32 InterfaceType)
326327 {
327328 switch (InterfaceType) {
331332 }
332333 }
333334
335 GF_EXPORT
334336 void ShutdownInterface(GF_BaseInterface *ifce)
335337 {
336338 switch (ifce->InterfaceType) {
259259 * ********************************************************************
260260 * interface
261261 */
262 GF_EXPORT
262263 const u32 *QueryInterfaces()
263264 {
264265 static u32 si [] = {
268269 return si;
269270 }
270271
272 GF_EXPORT
271273 GF_BaseInterface *LoadInterface(u32 InterfaceType)
272274 {
273275 if (InterfaceType == GF_AUDIO_FILTER_INTERFACE)
275277 return NULL;
276278 }
277279
280 GF_EXPORT
278281 void ShutdownInterface(GF_BaseInterface *ifce)
279282 {
280283 if (ifce->InterfaceType==GF_AUDIO_FILTER_INTERFACE)
363363
364364
365365 /*interface query*/
366 GF_EXPORT
366367 const u32 *QueryInterfaces()
367368 {
368369 static u32 si [] = {
374375
375376
376377 /*interface create*/
378 GF_EXPORT
377379 GF_BaseInterface *LoadInterface(u32 InterfaceType)
378380 {
379381 if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return DirectFBNewVideo();
382384
383385
384386 /*interface destroy*/
387 GF_EXPORT
385388 void ShutdownInterface(GF_BaseInterface *ifce)
386389 {
387390 switch (ifce->InterfaceType) {
426426 gf_free(dr);
427427 }
428428 //----------------------------------------------------------------------
429 GF_EXPORT
429430 const u32 *QueryInterfaces()
430431 {
431432 static u32 si [] = {
435436 return si;
436437 }
437438
439 GF_EXPORT
438440 GF_BaseInterface *LoadInterface(u32 InterfaceType)
439441 {
440442 if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) return NewWAVRender();
441443 return NULL;
442444 }
443445
446 GF_EXPORT
444447 void ShutdownInterface(GF_BaseInterface *ifce)
445448 {
446449 switch (ifce->InterfaceType) {
368368 };
369369 return si;
370370 }
371
371372 /*interface create*/
373 GF_EXPORT
372374 GF_BaseInterface *LoadInterface(u32 InterfaceType)
373375 {
374376 if (InterfaceType == GF_INPUT_DEVICE_INTERFACE) return (GF_BaseInterface *) NewMPEGVSInputSesor();
375377 return NULL;
376378 }
379
377380 /*interface destroy*/
381 GF_EXPORT
378382 void ShutdownInterface(GF_BaseInterface *ifce)
379383 {
380384 switch (ifce->InterfaceType) {
199199 return si;
200200 }
201201 /*interface create*/
202 GF_EXPORT
202203 GF_BaseInterface *LoadInterface(u32 InterfaceType)
203204 {
204205 if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return (GF_BaseInterface *) NewRawVideoOutput();
205206 return NULL;
206207 }
207208 /*interface destroy*/
209 GF_EXPORT
208210 void ShutdownInterface(GF_BaseInterface *ifce)
209211 {
210212 switch (ifce->InterfaceType) {
647647 return si;
648648 }
649649 /*interface create*/
650 GF_EXPORT
650651 GF_BaseInterface *LoadInterface(u32 InterfaceType)
651652 {
652653 if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return (GF_BaseInterface *) NewRawVideoOutput();
653654 return NULL;
654655 }
655656 /*interface destroy*/
657 GF_EXPORT
656658 void ShutdownInterface(GF_BaseInterface *ifce)
657659 {
658660 switch (ifce->InterfaceType) {
720720 return si;
721721 }
722722 /*interface create*/
723 GF_EXPORT
723724 GF_BaseInterface *LoadInterface(u32 InterfaceType)
724725 {
725726 if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return NewDXVideoOutput();
727728 return NULL;
728729 }
729730 /*interface destroy*/
731 GF_EXPORT
730732 void ShutdownInterface(GF_BaseInterface *ifce)
731733 {
732734 switch (ifce->InterfaceType) {
494494 };
495495 return si;
496496 }
497
497498 /*interface create*/
498499 GF_EXPORT
499500 GF_BaseInterface *LoadInterface(u32 InterfaceType)
503504 if (InterfaceType == GF_MEDIA_DECODER_INTERFACE) return (GF_BaseInterface *) EPOC_codec_new();
504505 return NULL;
505506 }
507
506508 /*interface destroy*/
507509 GF_EXPORT
508510 void ShutdownInterface(GF_BaseInterface *ifce)
11
22 vpath %.c $(SRC_PATH)/modules/ffmpeg_in
33
4 CFLAGS=$(OPTFLAGS) -I"$(SRC_PATH)/include" $(ffmpeg_cflags)
4 CFLAGS=$(OPTFLAGS) -Wno-deprecated-declarations -I"$(SRC_PATH)/include" $(ffmpeg_cflags)
55
66 ifeq ($(DEBUGBUILD), yes)
77 CFLAGS+=-g
477477 }
478478 }
479479
480 #ifdef USE_PRE_0_7
480481 static int ff_url_read(void *h, unsigned char *buf, int size)
481482 {
482483 u32 retry = 10;
527528 #endif
528529 return full_size ? (int) full_size : -1;
529530 }
531 #endif /*USE_PRE_0_7*/
530532
531533
532534 static GF_Err FFD_ConnectService(GF_InputService *plug, GF_ClientService *serv, const char *url)
14811481
14821482
14831483 /*interface query*/
1484 GF_EXPORT
14841485 const u32 *QueryInterfaces()
14851486 {
14861487 static u32 si [] = {
14891490 };
14901491 return si;
14911492 }
1493
14921494 /*interface create*/
1495 GF_EXPORT
14931496 GF_BaseInterface *LoadInterface(u32 InterfaceType)
14941497 {
14951498 if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return (GF_BaseInterface *) NewGAPIVideoOutput();
14961499 return NULL;
14971500 }
1501
14981502 /*interface destroy*/
1503 GF_EXPORT
14991504 void ShutdownInterface(GF_BaseInterface *ifce)
15001505 {
15011506 GF_VideoOutput *dd = (GF_VideoOutput *)ifce;
363363 extern "C" {
364364 #endif
365365
366 GF_EXPORT
366367 const u32 *QueryInterfaces()
367368 {
368369 static u32 si [] = {
373374 return si;
374375 }
375376
377 GF_EXPORT
376378 GF_BaseInterface *LoadInterface(u32 InterfaceType)
377379 {
378380 if (InterfaceType==GF_FONT_READER_INTERFACE) return (GF_BaseInterface *)gdip_new_font_driver();
380382 return NULL;
381383 }
382384
385 GF_EXPORT
383386 void ShutdownInterface(GF_BaseInterface *ifce)
384387 {
385388 switch (ifce->InterfaceType) {
761761 SMJS_ARGS
762762 GF_GPACJSExt *gjs = (GF_GPACJSExt *)JS_GetPrivate(c, obj);
763763 if (!argc || !JSVAL_IS_OBJECT(argv[0])) return JS_FALSE;
764 if (JSVAL_IS_NULL(gjs->evt_fun) ) return JS_TRUE;
764
765 if (! JSVAL_IS_NULL(gjs->evt_fun) ) return JS_TRUE;
765766
766767 gjs->evt_fun = argv[0];
767768 gjs->evt_filter_obj = obj;
892893 /*nothing to do on unload*/
893894 if (unload) {
894895 gjs->nb_loaded--;
895 if (!gjs->nb_loaded && gjs->evt_filter.udta) {
896 /*if we destroy the script context holding the gpac event filter (only one for the time being), remove the filter*/
897 if ((gjs->c==c) && gjs->evt_filter.udta) {
896898 gf_term_remove_event_filter(gjs->term, &gjs->evt_filter);
899 gjs->evt_filter.udta = NULL;
897900 }
898901 return;
899902 }
956959
957960 JS_SETUP_CLASS(gjs->anyClass, "GPACOBJECT", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub_forSetter, JS_FinalizeStub);
958961 JS_InitClass(c, global, 0, &gjs->anyClass, 0, 0, 0, 0, 0, 0);
962
963 gjs->evt_fun = JSVAL_NULL;
959964 }
960965 }
961966
11
22 vpath %.c $(SRC_PATH)/modules/jack
33
4 CFLAGS= $(OPTFLAGS) -I"$(SRC_PATH)/include" $(OSS_CFLAGS)
4 CFLAGS= $(OPTFLAGS) -I"$(SRC_PATH)/include" $(OSS_CFLAGS) -Wno-deprecated-declarations
55
66 ifeq ($(DEBUGBUILD), yes)
77 CFLAGS+=-g
544544 * interface
545545 */
546546
547 GF_EXPORT
547548 const u32 *QueryInterfaces()
548549 {
549550 static u32 si [] = {
553554 return si;
554555 }
555556
556 GF_BaseInterface *
557 LoadInterface (u32 InterfaceType)
557 GF_EXPORT
558 GF_BaseInterface *LoadInterface (u32 InterfaceType)
558559 {
559560 if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE)
560561 {
563564 return NULL;
564565 }
565566
566 void
567 ShutdownInterface (GF_BaseInterface * ifce)
567 GF_EXPORT
568 void ShutdownInterface (GF_BaseInterface * ifce)
568569 {
569570 if (ifce->InterfaceType == GF_AUDIO_OUTPUT_INTERFACE)
570571 DeleteJackOutput ((GF_AudioOutput *) ifce);
11941194 return si;
11951195 }
11961196
1197 GF_EXPORT
11971198 GF_BaseInterface *LoadInterface(u32 InterfaceType)
11981199 {
11991200 switch (InterfaceType) {
12041205 }
12051206 }
12061207
1208 GF_EXPORT
12071209 void ShutdownInterface(GF_BaseInterface *ifce)
12081210 {
12091211 switch (ifce->InterfaceType) {
106106 }
107107
108108
109 GF_EXPORT
109110 const u32 *QueryInterfaces()
110111 {
111112 static u32 si [] = {
118119 return si;
119120 }
120121
122 GF_EXPORT
121123 GF_BaseInterface *LoadInterface(u32 InterfaceType)
122124 {
123125 #if !defined(GPAC_DISABLE_AV_PARSERS) && !defined(GPAC_DISABLE_OGG)
127129 return NULL;
128130 }
129131
132 GF_EXPORT
130133 void ShutdownInterface(GF_BaseInterface *ifce)
131134 {
132135 switch (ifce->InterfaceType) {
8080 count = gf_list_count(cfg->sequenceParameterSets);
8181 SetCommandLayer(Layer, 255, 0, &i, 0);//bufindex can be reset without pb
8282 for (i=0; i<count; i++) {
83 u32 w, h, par_n, par_d;
83 u32 w=0, h=0, par_n=0, par_d=0;
8484 GF_AVCConfigSlot *slc = gf_list_get(cfg->sequenceParameterSets, i);
8585
86 #ifndef GPAC_DISABLE_AV_PARSERS
8687 gf_avc_get_sps_info(slc->data, slc->size, &slc->id, &w, &h, &par_n, &par_d);
88 #endif
8789 /*by default use the base layer*/
8890 if (!i) {
8991 if ((ctx->width<w) || (ctx->height<h)) {
339341 gf_free(ifcg);
340342 }
341343
344 GF_EXPORT
342345 const u32 *QueryInterfaces()
343346 {
344347 static u32 si [] = {
350353 return si;
351354 }
352355
356 GF_EXPORT
353357 GF_BaseInterface *LoadInterface(u32 InterfaceType)
354358 {
355359 #ifndef GPAC_DISABLE_AV_PARSERS
358362 return NULL;
359363 }
360364
365 GF_EXPORT
361366 void ShutdownInterface(GF_BaseInterface *ifce)
362367 {
363368 switch (ifce->InterfaceType) {
256256 * ********************************************************************
257257 * interface
258258 */
259 GF_EXPORT
259260 const u32 *QueryInterfaces()
260261 {
261262 static u32 si [] = {
265266 return si;
266267 }
267268
269 GF_EXPORT
268270 GF_BaseInterface *LoadInterface(u32 InterfaceType)
269271 {
270272 if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE)
272274 return NULL;
273275 }
274276
277 GF_EXPORT
275278 void ShutdownInterface(GF_BaseInterface *ifce)
276279 {
277280 if (ifce->InterfaceType==GF_AUDIO_OUTPUT_INTERFACE)
119119 m_pAVService->SetStateVariable("AbsoluteCounterPosition", "2147483647"); // means NOT_IMPLEMENTED
120120
121121 // disable indirect eventing for certain state variables
122 PLT_StateVariable* var;
123 var = m_pAVService->FindStateVariable("RelativeTimePosition");
122 //PLT_StateVariable* var;
123 //var =
124 m_pAVService->FindStateVariable("RelativeTimePosition");
124125 //if (var) var->DisableIndirectEventing();
125 var = m_pAVService->FindStateVariable("AbsoluteTimePosition");
126 //var =
127 m_pAVService->FindStateVariable("AbsoluteTimePosition");
126128 //if (var) var->DisableIndirectEventing();
127 var = m_pAVService->FindStateVariable("RelativeCounterPosition");
129 //var =
130 m_pAVService->FindStateVariable("RelativeCounterPosition");
128131 //if (var) var->DisableIndirectEventing();
129 var = m_pAVService->FindStateVariable("AbsoluteCounterPosition");
132 //var =
133 m_pAVService->FindStateVariable("AbsoluteCounterPosition");
130134 //if (var) var->DisableIndirectEventing();
131135
132136 // GetTransportInfo
261261 case GF_EVENT_METADATA:
262262 if (m_pTerm->root_scene) {
263263 char szName[1024];
264 const char *artist;
265264 NetInfoCommand com;
266265 memset(&com, 0, sizeof(NetInfoCommand));
267266
271270 if (com.name) { strcat(szName, com.name); strcat(szName, " "); }
272271 if (com.album) { strcat(szName, "("); strcat(szName, com.album); strcat(szName, ")"); }
273272
274 artist = "Unknown";
273 /*const char *artist = "Unknown";
275274 if (com.artist) artist = com.artist;
276275 else if (com.writer) artist = com.writer;
277276 else if (com.composer) artist = com.composer;
278277
279 //MRSetMediaInfo(0, szName, com.artist ? com.artist : "Unknown");
278 MRSetMediaInfo(0, szName, com.artist ? com.artist : "Unknown");*/
280279 }
281280 }
282281 break;
319319 * ********************************************************************
320320 * interface
321321 */
322 GF_EXPORT
322323 const u32 *QueryInterfaces(u32 InterfaceType)
323324 {
324325 static u32 si [] = {
328329 return si;
329330 }
330331
331 GF_BaseInterface *
332 LoadInterface (u32 InterfaceType)
332 GF_EXPORT
333 GF_BaseInterface *LoadInterface (u32 InterfaceType)
333334 {
334335 if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE)
335336 return NewPulseAudioOutput ();
336337 return NULL;
337338 }
338339
339 void
340 ShutdownInterface (GF_BaseInterface * ifce)
340 GF_EXPORT
341 void ShutdownInterface (GF_BaseInterface * ifce)
341342 {
342343 if (ifce->InterfaceType == GF_AUDIO_OUTPUT_INTERFACE)
343344 DeletePulseAudioOutput ((GF_AudioOutput *) ifce);
151151 };
152152 return si;
153153 }
154
154155 /*interface create*/
156 GF_EXPORT
155157 GF_BaseInterface *LoadInterface(u32 InterfaceType)
156158 {
157159 if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return (GF_BaseInterface *) NewRawVideoOutput();
158160 return NULL;
159161 }
162
160163 /*interface destroy*/
164 GF_EXPORT
161165 void ShutdownInterface(GF_BaseInterface *ifce)
162166 {
163167 switch (ifce->InterfaceType) {
415415 gf_free(ifcg);
416416 }
417417
418 GF_EXPORT
418419 const u32 *QueryInterfaces()
419420 {
420421 static u32 si [] = {
426427 return si;
427428 }
428429
430 GF_EXPORT
429431 GF_BaseInterface *LoadInterface(u32 InterfaceType)
430432 {
431433 #ifndef GPAC_DISABLE_AV_PARSERS
434436 return NULL;
435437 }
436438
439 GF_EXPORT
437440 void ShutdownInterface(GF_BaseInterface *ifce)
438441 {
439442 switch (ifce->InterfaceType) {
4949
5050
5151 /*interface query*/
52 GF_EXPORT
5253 const u32 *QueryInterfaces()
5354 {
5455 static u32 si [] = {
5859 };
5960 return si;
6061 }
62
6163 /*interface create*/
64 GF_EXPORT
6265 GF_BaseInterface *LoadInterface(u32 InterfaceType)
6366 {
6467 if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE) return SDL_NewVideo();
6568 if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) return SDL_NewAudio();
6669 return NULL;
6770 }
71
6872 /*interface destroy*/
73 GF_EXPORT
6974 void ShutdownInterface(GF_BaseInterface *ifce)
7075 {
7176 switch (ifce->InterfaceType) {
463463 gf_free(dr);
464464 }
465465
466 GF_EXPORT
466467 const u32 *QueryInterfaces()
467468 {
468469 static u32 si [] = {
472473 return si;
473474 }
474475
476 GF_EXPORT
475477 GF_BaseInterface *LoadInterface(u32 InterfaceType)
476478 {
477479 if (InterfaceType == GF_AUDIO_OUTPUT_INTERFACE) return NewWAVRender();
478480 return NULL;
479481 }
480482
483 GF_EXPORT
481484 void ShutdownInterface(GF_BaseInterface *ifce)
482485 {
483486 switch (ifce->InterfaceType) {
33
44 Copyright (C) 1998-2005 Gilles Vollant
55 */
6
76
87 #include <stdio.h>
98 #include <stdlib.h>
2423 #endif
2524
2625 #endif
26
27 //hack: prevent mozilla to redifine z functions
28 #define MOZZCONF_H
2729
2830 #include "unzip.h"
2931 #include <gpac/tools.h>
11
22 vpath %.c $(SRC_PATH)/modules/x11_out
33
4 CFLAGS= $(OPTFLAGS)
4 CFLAGS= $(OPTFLAGS) -Wno-deprecated-declarations
55
66 ifeq ($(DEBUGBUILD), yes)
77 CFLAGS+=-g
14391439 /*
14401440 * interface query
14411441 */
1442 GF_EXPORT
14421443 const u32 *QueryInterfaces()
14431444 {
14441445 static u32 si [] = {
14521453 /*
14531454 * interface create
14541455 */
1455 GF_BaseInterface *
1456 LoadInterface (u32 InterfaceType)
1456 GF_EXPORT
1457 GF_BaseInterface *LoadInterface (u32 InterfaceType)
14571458 {
14581459 if (InterfaceType == GF_VIDEO_OUTPUT_INTERFACE)
14591460 return (GF_BaseInterface *) NewX11VideoOutput ();
14641465 /*
14651466 * interface destroy
14661467 */
1467 void
1468 ShutdownInterface (GF_BaseInterface *ifce)
1468 GF_EXPORT
1469 void ShutdownInterface (GF_BaseInterface *ifce)
14691470 {
14701471 switch (ifce->InterfaceType)
14711472 {
464464
465465 #endif /*GPAC_DISABLE_AV_PARSERS*/
466466
467
468 GF_EXPORT
467469 const u32 *QueryInterfaces()
468470 {
469471 static u32 si [] = {
475477 return si;
476478 }
477479
480 GF_EXPORT
478481 GF_BaseInterface *LoadInterface(u32 InterfaceType)
479482 {
480483 #ifndef GPAC_DISABLE_AV_PARSERS
483486 return NULL;
484487 }
485488
489 GF_EXPORT
486490 void ShutdownInterface(GF_BaseInterface *ifce)
487491 {
488492 switch (ifce->InterfaceType) {
9999 Shape {
100100 appearance Appearance {
101101 # material Material { emissiveColor 0 1 0}
102 texture ImageTexture { url './../auxiliary_files/logo.jpg"}
102 texture ImageTexture { url "./../auxiliary_files/logo.jpg"}
103103 }
104104 geometry Box { size 20 20 20}
105105 }
281281 while ((l = gf_list_enum(ar->audio_listeners, &k))) {
282282 l->on_audio_reconfig(l->udta, in_freq, in_bps, in_ch, in_cfg);
283283 }
284 }
285
284 }
286285 return GF_OK;
287286 }
288
289287
290288
291289 static u32 gf_ar_fill_output(void *ptr, char *buffer, u32 buffer_size)
634632 if (ar->Frozen) return ar->FreezeTime - ar->startTime;
635633 return gf_sys_clock() - ar->startTime;
636634 }
635
636 GF_EXPORT
637637 void gf_sc_reload_audio_filters(GF_Compositor *compositor)
638638 {
639639 GF_AudioRenderer *ar = compositor->audio_renderer;
655655
656656 GF_Err gf_sc_add_audio_listener(GF_Compositor *compositor, GF_AudioListener *al)
657657 {
658 GF_AudioMixer *mixer;
659 u32 sr, ch, bps, ch_cfg;
658660 if (!compositor || !al || !al->on_audio_frame || !al->on_audio_reconfig) return GF_BAD_PARAM;
659661 if (!compositor->audio_renderer) return GF_NOT_SUPPORTED;
660662
661 gf_mixer_lock(compositor->audio_renderer->mixer, 1);
663 mixer = compositor->audio_renderer->mixer;
664 gf_mixer_lock(mixer, 1);
665
662666 if (!compositor->audio_renderer->audio_listeners) compositor->audio_renderer->audio_listeners = gf_list_new();
663667 gf_list_add(compositor->audio_renderer->audio_listeners, al);
664 gf_mixer_lock(compositor->audio_renderer->mixer, 0);
668
669 gf_mixer_get_config(mixer, &sr, &ch, &bps, &ch_cfg);
670
671 al->on_audio_reconfig(al->udta, sr, bps, ch, ch_cfg);
672
673 gf_mixer_lock(mixer, 0);
665674 return GF_OK;
666675 }
667676
968968 }
969969 }
970970
971 GF_EXPORT
971972 GF_Err gf_sc_set_size(GF_Compositor *compositor, u32 NewWidth, u32 NewHeight)
972973 {
973974 Bool lock_ok;
12781279 gf_sc_lock(compositor, 0);
12791280 }
12801281
1282 GF_EXPORT
12811283 GF_Err gf_sc_set_option(GF_Compositor *compositor, u32 type, u32 value)
12821284 {
12831285 GF_Err e;
16211623 }
16221624
16231625
1626 GF_EXPORT
16241627 GF_Err gf_sc_get_screen_buffer(GF_Compositor *compositor, GF_VideoSurface *framebuffer, u32 depth_dump_mode)
16251628 {
16261629 GF_Err e;
16551658 }
16561659
16571660
1661 GF_EXPORT
16581662 GF_Err gf_sc_release_screen_buffer(GF_Compositor *compositor, GF_VideoSurface *framebuffer)
16591663 {
16601664 GF_Err e;
16701674 return e;
16711675 }
16721676
1677 GF_EXPORT
16731678 Double gf_sc_get_fps(GF_Compositor *compositor, Bool absoluteFPS)
16741679 {
16751680 Double fps;
27022707 }
27032708 }
27042709
2710 GF_EXPORT
27052711 void gf_sc_register_extra_graph(GF_Compositor *compositor, GF_SceneGraph *extra_scene, Bool do_remove)
27062712 {
27072713 gf_sc_lock(compositor, 1);
17491749 return browse_parent_for_focus(compositor, (GF_Node*)par, prev_focus);
17501750 }
17511751
1752 GF_EXPORT
17521753 u32 gf_sc_focus_switch_ring(GF_Compositor *compositor, Bool move_prev, GF_Node *focus, u32 force_focus)
17531754 {
17541755 Bool current_focus = 1;
250250 DestroyTransform(n);
251251 return;
252252 }
253 if (! tr_state->camera) return;
253254
254255 /*can't cache the matrix here*/
255256 gf_mx_init(st->mx);
347348 return;
348349 }
349350
350
351
352351 /*WARNING: X3D/MPEG4 NOT COMPATIBLE*/
353352 if (gf_node_get_tag(node) == TAG_MPEG4_LOD) {
354353 children = ((M_LOD *) node)->level;
365364 if (!children) return;
366365 nb_children = gf_node_list_get_count(children);
367366
368 /*can't cache the matric here*/
369 usr = tr_state->camera->position;
370 pos = center;
371 gf_mx_copy(mx, tr_state->model_matrix);
372 gf_mx_inverse(&mx);
373 gf_mx_apply_vec(&mx, &usr);
374 gf_vec_diff(pos, pos, usr);
375 dist = gf_vec_len(pos);
376 for (which_child=0; which_child<ranges->count; which_child++) {
377 if (dist<ranges->vals[which_child]) break;
378 }
379 if (which_child>=nb_children) which_child = nb_children-1;
380
381 /*check if we're traversing the same child or not for audio rendering*/
382 do_all = 0;
383 if (gf_node_dirty_get(node)) {
384 gf_node_dirty_clear(node, 0);
367 if (!tr_state->camera) {
385368 do_all = 1;
386 } else if ((s32) which_child != *prev_child) {
387 *prev_child = which_child;
388 do_all = 1;
369 which_child = 0;
370 } else {
371 /*can't cache the matrix here*/
372 usr = tr_state->camera->position;
373 pos = center;
374 gf_mx_copy(mx, tr_state->model_matrix);
375 gf_mx_inverse(&mx);
376 gf_mx_apply_vec(&mx, &usr);
377 gf_vec_diff(pos, pos, usr);
378 dist = gf_vec_len(pos);
379 for (which_child=0; which_child<ranges->count; which_child++) {
380 if (dist<ranges->vals[which_child]) break;
381 }
382 if (which_child>=nb_children) which_child = nb_children-1;
383
384 /*check if we're traversing the same child or not for audio rendering*/
385 do_all = 0;
386 if (gf_node_dirty_get(node)) {
387 gf_node_dirty_clear(node, 0);
388 do_all = 1;
389 } else if ((s32) which_child != *prev_child) {
390 *prev_child = which_child;
391 do_all = 1;
392 }
389393 }
390394
391395 if (do_all) {
13961396 return NULL;
13971397 }
13981398
1399 GF_EXPORT
13991400 GF_SceneGraph *gf_sc_animation_get_scenegraph(GF_Node *node)
14001401 {
14011402 SVGlinkStack *stack;
126126 return GF_OK;
127127 }
128128
129 GF_EXPORT
129130 GF_RTPStreamer *gf_rtp_streamer_new_extended(u32 streamType, u32 oti, u32 timeScale,
130131 const char *ip_dest, u16 port, u32 MTU, u8 TTL, const char *ifce_addr,
131132 u32 flags, char *dsi, u32 dsi_len,
455456 }
456457
457458
459 GF_EXPORT
458460 GF_RTPStreamer *gf_rtp_streamer_new(u32 streamType, u32 oti, u32 timeScale,
459461 const char *ip_dest, u16 port, u32 MTU, u8 TTL, const char *ifce_addr,
460462 u32 flags, char *dsi, u32 dsi_len)
465467
466468 }
467469
470 GF_EXPORT
468471 void gf_rtp_streamer_del(GF_RTPStreamer *streamer)
469472 {
470473 if (streamer) {
520523 #endif /*!defined(GPAC_DISABLE_ISOM) && !defined(GPAC_DISABLE_STREAMING)*/
521524
522525
526 GF_EXPORT
523527 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)
524528 {
525529 u32 size;
665669 return GF_OK;
666670 }
667671
672 GF_EXPORT
668673 char *gf_rtp_streamer_format_sdp_header(char *app_name, char *ip_dest, char *session_name, char *iod64)
669674 {
670675 u64 size;
691696 return sdp;
692697 }
693698
699 GF_EXPORT
694700 GF_Err gf_rtp_streamer_append_sdp(GF_RTPStreamer *rtp, u16 ESID, char *dsi, u32 dsi_len, char *KMS_URI, char **out_sdp_buffer)
695701 {
696702 return gf_rtp_streamer_append_sdp_extended(rtp, ESID, dsi, dsi_len, NULL, 0, KMS_URI, 0, 0, out_sdp_buffer);
715721 return gf_rtp_streamer_send_data(rtp, data, size, size, cts, dts, is_rap, 1, 1, 0, 0, 0);
716722 }
717723
724 GF_EXPORT
718725 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)
719726 {
720727 if (inc_au_sn) rtp->packetizer->sl_header.AU_sequenceNumber += inc_au_sn;
721728 return gf_rtp_streamer_send_data(rtp, data, size, size, cts, dts, is_rap, 1, 1, rtp->packetizer->sl_header.AU_sequenceNumber, 0, 0);
722729 }
723730
731 GF_EXPORT
724732 void gf_rtp_streamer_disable_auto_rtcp(GF_RTPStreamer *streamer)
725733 {
726734 streamer->channel->no_auto_rtcp = 1;
727735 }
728736
737 GF_EXPORT
729738 GF_Err gf_rtp_streamer_send_rtcp(GF_RTPStreamer *streamer, Bool force_ts, u32 rtp_ts)
730739 {
731740 if (force_ts) streamer->channel->last_pck_ts = rtp_ts;
255255 return GF_OK;
256256 }
257257
258 GF_EXPORT
258259 GF_Err gf_isom_avc_config_update(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex, GF_AVCConfig *cfg)
259260 {
260261 return gf_isom_avc_config_update_ex(the_file, trackNumber, DescriptionIndex, cfg, 0);
265266 return gf_isom_avc_config_update_ex(the_file, trackNumber, DescriptionIndex, cfg, is_add ? 1 : 2);
266267 }
267268
269 GF_EXPORT
268270 GF_Err gf_isom_set_ipod_compatible(GF_ISOFile *the_file, u32 trackNumber)
269271 {
270272 static const u8 ipod_ext[][16] = { { 0x6B, 0x68, 0x40, 0xF2, 0x5F, 0x24, 0x4F, 0xC5, 0xBA, 0x39, 0xA5, 0x1B, 0xCF, 0x03, 0x23, 0xF3} };
31063106 fprintf(trace, "\" ");
31073107 }
31083108
3109 GF_EXPORT
31093110 GF_Err gf_isom_dump_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, FILE * trace)
31103111 {
31113112 u32 i, count;
31383139 return GF_OK;
31393140 }
31403141
3142 GF_EXPORT
31413143 GF_Err gf_isom_dump_ismacryp_sample(GF_ISOFile *the_file, u32 trackNumber, u32 SampleNum, FILE * trace)
31423144 {
31433145 GF_ISOSample *samp;
32343236 break;
32353237 default:
32363238 if (strcmp(name, "Unknown")) {
3237 if (itune->data->data[0]) {
3239 if (itune->data && itune->data->data[0]) {
32383240 fprintf(trace, " value=\"%s\" ", itune->data->data);
32393241 } else {
32403242 fprintf(trace, " value=\"");
32463248 }
32473249 }
32483250 fprintf(trace, ">\n");
3249 gf_full_box_dump((GF_Box *)itune->data, trace);
3251 if (itune->data)
3252 gf_full_box_dump((GF_Box *)itune->data, trace);
32503253 DumpBox(a, trace);
32513254 fprintf(trace, "</%sBox>\n", name);
32523255 return GF_OK;
255255 }
256256
257257
258 GF_EXPORT
258259 GF_Err gf_isom_box_write_header(GF_Box *ptr, GF_BitStream *bs)
259260 {
260261 if (! bs || !ptr) return GF_BAD_PARAM;
323324
324325 #endif /*GPAC_DISABLE_ISOM_WRITE*/
325326
327 GF_EXPORT
326328 GF_Box *gf_isom_box_new(u32 boxType)
327329 {
328330 GF_Box *a;
579581 }
580582
581583
584 GF_EXPORT
582585 void gf_isom_box_del(GF_Box *a)
583586 {
584587 if (!a) return;
10621065
10631066 #ifndef GPAC_DISABLE_ISOM_WRITE
10641067
1068 GF_EXPORT
10651069 GF_Err gf_isom_box_write(GF_Box *a, GF_BitStream *bs)
10661070 {
10671071 switch (a->type) {
12951299 }
12961300
12971301
1302 GF_EXPORT
12981303 GF_Err gf_isom_box_size(GF_Box *a)
12991304 {
13001305 switch (a->type) {
709709 }
710710
711711 //add an SDP line to the SDP container at the track level (media-specific SDP info)
712 GF_EXPORT
712713 GF_Err gf_isom_sdp_add_track_line(GF_ISOFile *the_file, u32 trackNumber, const char *text)
713714 {
714715 GF_TrackBox *trak;
783784
784785 //add an SDP line to the SDP container at the movie level (presentation SDP info)
785786 //NOTE: the \r\n end of line for SDP is automatically inserted
787 GF_EXPORT
786788 GF_Err gf_isom_sdp_add_line(GF_ISOFile *movie, const char *text)
787789 {
788790 GF_UserDataMap *map;
844846
845847
846848 //remove all SDP info at the movie level
849 GF_EXPORT
847850 GF_Err gf_isom_sdp_clean(GF_ISOFile *movie)
848851 {
849852 GF_UserDataMap *map;
332332 return GF_OK;
333333 }
334334
335 GF_EXPORT
335336 GF_Err gf_isom_change_ismacryp_protection(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, char *scheme_uri, char *kms_uri)
336337 {
337338 GF_TrackBox *trak;
19911991 return GF_OK;
19921992 }
19931993
1994 GF_EXPORT
19941995 GF_Err gf_isom_open_segment(GF_ISOFile *movie, const char *fileName, u64 start_range, u64 end_range)
19951996 {
19961997 #ifdef GPAC_DISABLE_ISOM_FRAGMENTS
22942295
22952296
22962297 /*returns total amount of media bytes in track*/
2298 GF_EXPORT
22972299 u64 gf_isom_get_media_data_size(GF_ISOFile *movie, u32 trackNumber)
22982300 {
22992301 u32 i, size;
26132615 return GF_OK;
26142616 }
26152617
2618 GF_EXPORT
26162619 u32 gf_isom_get_next_alternate_group_id(GF_ISOFile *movie)
26172620 {
26182621 u32 id = 0;
26492652 return GF_OK;
26502653 }
26512654
2655 GF_EXPORT
26522656 GF_Err gf_isom_get_rvc_config(GF_ISOFile *movie, u32 track, u32 sampleDescriptionIndex, u16 *rvc_predefined, char **data, u32 *size, const char **mime)
26532657 {
26542658 GF_MPEGVisualSampleEntryBox *entry;
26952699 return 0;
26962700 }
26972701
2702 GF_EXPORT
26982703 void gf_isom_reset_fragment_info(GF_ISOFile *movie)
26992704 {
27002705 u32 i;
136136 }
137137
138138 //remove the root OD
139 GF_EXPORT
139140 GF_Err gf_isom_remove_root_od(GF_ISOFile *movie)
140141 {
141142 GF_Err e;
149150 }
150151
151152 //remove a track to the root OD
153 GF_EXPORT
152154 GF_Err gf_isom_remove_track_from_root_od(GF_ISOFile *movie, u32 trackNumber)
153155 {
154156 GF_List *esds;
231233 return GF_OK;
232234 }
233235
236 GF_EXPORT
234237 GF_Err gf_isom_set_media_language(GF_ISOFile *movie, u32 trackNumber, char *three_char_code)
235238 {
236239 GF_Err e;
312315 }
313316
314317
318 GF_EXPORT
315319 GF_Err gf_isom_set_timescale(GF_ISOFile *movie, u32 timeScale)
316320 {
317321 GF_Err e;
324328 return GF_OK;
325329 }
326330
331
332 GF_EXPORT
327333 GF_Err gf_isom_set_pl_indication(GF_ISOFile *movie, u8 PL_Code, u8 ProfileLevel)
328334 {
329335 GF_IsomInitialObjectDescriptor *iod;
775781 //you must have created a StreamDescription with URL or URN specifying your referenced file
776782 //the data offset specifies the begining of the chunk
777783 //Use streamDescriptionIndex to specify the desired stream (if several)
784 GF_EXPORT
778785 GF_Err gf_isom_add_sample_reference(GF_ISOFile *movie, u32 trackNumber, u32 StreamDescriptionIndex, GF_ISOSample *sample, u64 dataOffset)
779786 {
780787 GF_TrackBox *trak;
829836
830837 //set the duration of the last media sample. If not set, the duration of the last sample is the
831838 //duration of the previous one if any, or 1000 (default value).
839 GF_EXPORT
832840 GF_Err gf_isom_set_last_sample_duration(GF_ISOFile *movie, u32 trackNumber, u32 duration)
833841 {
834842 GF_TrackBox *trak;
850858 ent = (GF_SttsEntry*) &stts->entries[stts->nb_entries-1];
851859
852860 mdur -= ent->sampleDelta;
853 if (duration) {
854 mdur += duration;
855 //we only have one sample
856 if (ent->sampleCount == 1) {
857 ent->sampleDelta = duration;
858 } else {
859 if (ent->sampleDelta == duration) return GF_OK;
860 ent->sampleCount -= 1;
861
862 if (stts->nb_entries==stts->alloc_size) {
863 stts->alloc_size++;
864 stts->entries = gf_realloc(stts->entries, sizeof(GF_SttsEntry)*stts->alloc_size);
865 if (!stts->entries) return GF_OUT_OF_MEM;
866 }
867 stts->entries[stts->nb_entries].sampleCount = 1;
868 stts->entries[stts->nb_entries].sampleDelta = duration;
869 stts->nb_entries++;
870 //and update the write cache
871 stts->w_currentSampleNum = trak->Media->information->sampleTable->SampleSize->sampleCount;
872 }
861 mdur += duration;
862 //we only have one sample
863 if (ent->sampleCount == 1) {
864 ent->sampleDelta = duration;
865 } else {
866 if (ent->sampleDelta == duration) return GF_OK;
867 ent->sampleCount -= 1;
868
869 if (stts->nb_entries==stts->alloc_size) {
870 stts->alloc_size++;
871 stts->entries = gf_realloc(stts->entries, sizeof(GF_SttsEntry)*stts->alloc_size);
872 if (!stts->entries) return GF_OUT_OF_MEM;
873 }
874 stts->entries[stts->nb_entries].sampleCount = 1;
875 stts->entries[stts->nb_entries].sampleDelta = duration;
876 stts->nb_entries++;
877 //and update the write cache
878 stts->w_currentSampleNum = trak->Media->information->sampleTable->SampleSize->sampleCount;
873879 }
874880 trak->Media->mediaHeader->modificationTime = gf_isom_get_mp4time();
875881 trak->Media->mediaHeader->duration = mdur;
943949
944950
945951 //Remove a given sample
952 GF_EXPORT
946953 GF_Err gf_isom_remove_sample(GF_ISOFile *movie, u32 trackNumber, u32 sampleNumber)
947954 {
948955 GF_Err e;
9981005 }
9991006
10001007
1008 GF_EXPORT
10011009 GF_Err gf_isom_set_final_name(GF_ISOFile *movie, char *filename)
10021010 {
10031011 GF_Err e;
10991107
11001108 //use carefully. Very usefull when you made a lot of changes (IPMP, IPI, OCI, ...)
11011109 //THIS WILL REPLACE THE WHOLE DESCRIPTOR ...
1110 GF_EXPORT
11021111 GF_Err gf_isom_change_mpeg4_description(GF_ISOFile *movie, u32 trackNumber, u32 StreamDescriptionIndex, GF_ESD *newESD)
11031112 {
11041113 GF_Err e;
12651274 }
12661275
12671276 //set the storage mode of a file (FLAT, STREAMABLE, INTERLEAVED)
1277 GF_EXPORT
12681278 GF_Err gf_isom_set_storage_mode(GF_ISOFile *movie, u8 storageMode)
12691279 {
12701280 GF_Err e;
12881298 //update or insert a new edit segment in the track time line. Edits are used to modify
12891299 //the media normal timing. EditTime and EditDuration are expressed in Movie TimeScale
12901300 //If a segment with EditTime already exists, IT IS ERASED
1301 GF_EXPORT
12911302 GF_Err gf_isom_set_edit_segment(GF_ISOFile *movie, u32 trackNumber, u64 EditTime, u64 EditDuration, u64 MediaTime, u8 EditMode)
12921303 {
12931304 GF_TrackBox *trak;
13781389 }
13791390
13801391 //remove the edit segments for the whole track
1392 GF_EXPORT
13811393 GF_Err gf_isom_remove_edit_segments(GF_ISOFile *movie, u32 trackNumber)
13821394 {
13831395 GF_Err e;
14281440 }
14291441
14301442
1443 GF_EXPORT
14311444 GF_Err gf_isom_append_edit_segment(GF_ISOFile *movie, u32 trackNumber, u64 EditDuration, u64 MediaTime, u8 EditMode)
14321445 {
14331446 GF_Err e;
14701483 return SetTrackDuration(trak);
14711484 }
14721485
1486 GF_EXPORT
14731487 GF_Err gf_isom_modify_edit_segment(GF_ISOFile *movie, u32 trackNumber, u32 seg_index, u64 EditDuration, u64 MediaTime, u8 EditMode)
14741488 {
14751489 GF_Err e;
15031517 }
15041518
15051519 //removes the desired track
1520 GF_EXPORT
15061521 GF_Err gf_isom_remove_track(GF_ISOFile *movie, u32 trackNumber)
15071522 {
15081523 GF_Err e;
16211636 }
16221637
16231638
1639 GF_EXPORT
16241640 GF_Err gf_isom_set_copyright(GF_ISOFile *movie, const char *threeCharCode, char *notice)
16251641 {
16261642 GF_Err e;
16631679 return udta_AddBox(movie->moov->udta, (GF_Box *) ptr);
16641680 }
16651681
1682 GF_EXPORT
16661683 GF_Err gf_isom_add_chapter(GF_ISOFile *movie, u32 trackNumber, u64 timestamp, char *name)
16671684 {
16681685 GF_Err e;
19481965 }
19491966
19501967
1951
1968 GF_EXPORT
19521969 GF_Err gf_isom_set_brand_info(GF_ISOFile *movie, u32 MajorBrand, u32 MinorVersion)
19531970 {
19541971 u32 i, *p;
19942011 return GF_OK;
19952012 }
19962013
2014
2015 GF_EXPORT
19972016 GF_Err gf_isom_modify_alternate_brand(GF_ISOFile *movie, u32 Brand, u8 AddIt)
19982017 {
19992018 u32 i, k, *p;
22572276 }
22582277
22592278
2279 GF_EXPORT
22602280 GF_Err gf_isom_remove_sample_fragment(GF_ISOFile *movie, u32 trackNumber, u32 sampleNumber)
22612281 {
22622282 GF_TrackBox *trak;
22882308 return GF_OK;
22892309 }
22902310
2311 GF_EXPORT
22912312 GF_Err gf_isom_clone_pl_indications(GF_ISOFile *orig, GF_ISOFile *dest)
22922313 {
22932314 GF_IsomInitialObjectDescriptor *iod_d;
23932414 }
23942415
23952416
2396
2417 GF_EXPORT
23972418 GF_Err gf_isom_clone_track(GF_ISOFile *orig_file, u32 orig_track, GF_ISOFile *dest_file, Bool keep_data_ref, u32 *dest_track)
23982419 {
23992420 GF_TrackBox *trak, *new_tk;
25162537 return e;
25172538 }
25182539
2540
2541 GF_EXPORT
25192542 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)
25202543 {
25212544 GF_TrackBox *trak;
28012824
28022825
28032826 //sets a track reference
2827 GF_EXPORT
28042828 GF_Err gf_isom_set_track_reference(GF_ISOFile *the_file, u32 trackNumber, u32 referenceType, u32 ReferencedTrackID)
28052829 {
28062830 GF_Err e;
28312855 }
28322856
28332857 //removes a track reference
2858 GF_EXPORT
28342859 GF_Err gf_isom_remove_track_reference(GF_ISOFile *the_file, u32 trackNumber, u32 referenceType, u32 ReferenceIndex)
28352860 {
28362861 GF_Err e;
29422967 return GF_OK;
29432968 }
29442969
2970 GF_EXPORT
29452971 GF_Err gf_isom_set_cts_packing(GF_ISOFile *the_file, u32 trackNumber, Bool unpack)
29462972 {
29472973 GF_Err e;
29702996 return GF_OK;
29712997 }
29722998
2999 GF_EXPORT
29733000 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)
29743001 {
29753002 GF_TrackBox *trak = gf_isom_get_track_from_file(the_file, trackNumber);
31283155 }
31293156
31303157
3131
3158 GF_EXPORT
31323159 Bool gf_isom_is_same_sample_description(GF_ISOFile *f1, u32 tk1, u32 sdesc_index1, GF_ISOFile *f2, u32 tk2, u32 sdesc_index2)
31333160 {
31343161 u32 i, count;
32583285 return ret;
32593286 }
32603287
3288 GF_EXPORT
32613289 u64 gf_isom_estimate_size(GF_ISOFile *movie)
32623290 {
32633291 GF_Err e;
33763404 }
33773405
33783406
3407 GF_EXPORT
33793408 GF_Err gf_isom_set_extraction_slc(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, GF_SLConfig *slConfig)
33803409 {
33813410 GF_TrackBox *trak;
34743503 }
34753504
34763505
3506 GF_EXPORT
34773507 GF_Err gf_isom_make_interleave(GF_ISOFile *file, Double TimeInSec)
34783508 {
34793509 GF_Err e;
34843514 }
34853515
34863516
3517 GF_EXPORT
34873518 GF_Err gf_isom_set_handler_name(GF_ISOFile *the_file, u32 trackNumber, const char *nameUTF8)
34883519 {
34893520 GF_TrackBox *trak;
36863717
36873718 /*Apple extensions*/
36883719
3720 GF_EXPORT
36893721 GF_Err gf_isom_apple_set_tag(GF_ISOFile *mov, u32 tag, const char *data, u32 data_len)
36903722 {
36913723 GF_BitStream *bs;
39984030 }
39994031
40004032
4033 GF_EXPORT
40014034 GF_Err gf_isom_set_rvc_config(GF_ISOFile *movie, u32 track, u32 sampleDescriptionIndex, u16 rvc_predefined, char *mime, char *data, u32 size)
40024035 {
40034036 GF_MPEGVisualSampleEntryBox *entry;
424424 Media_GetSampleDesc(mdia, StreamDescIndex, &se, &drefIndex);
425425 if (!drefIndex) return 0;
426426 a = (GF_FullBox*)gf_list_get(mdia->information->dataInformation->dref->boxList, drefIndex - 1);
427 if (!a) {
428 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));
429 return 0;
430 }
427431 if (a->flags & 1) return 1;
428432 /*QT specific*/
429433 if (a->type == GF_4CC('a', 'l', 'i', 's')) return 1;
6363 return 0;
6464 }
6565
66 GF_EXPORT
6667 GF_Err gf_isom_extract_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num, char *outName, Bool *is_binary)
6768 {
6869 u32 i, count;
188189 return 0;
189190 }
190191
192 GF_EXPORT
191193 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 )
192194 {
193195 GF_BitStream *item_bs;
284286 return GF_OK;
285287 }
286288
289 GF_EXPORT
287290 GF_Err gf_isom_extract_meta_item(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_id, const char *dump_file_name)
288291 {
289292 return gf_isom_extract_meta_item_extended(file, root_meta, track_num, item_id, dump_file_name, NULL, NULL, NULL);
294297 return gf_isom_extract_meta_item_extended(file, root_meta, track_num, item_id, NULL, out_data, out_size, out_mime);
295298 }
296299
300 GF_EXPORT
297301 u32 gf_isom_get_meta_primary_item_id(GF_ISOFile *file, Bool root_meta, u32 track_num)
298302 {
299303 GF_MetaBox *meta = gf_isom_get_meta(file, root_meta, track_num);
305309 #ifndef GPAC_DISABLE_ISOM_WRITE
306310
307311
312 GF_EXPORT
308313 GF_Err gf_isom_set_meta_type(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 metaType)
309314 {
310315 char szName[20];
362367 return GF_OK;
363368 }
364369
370 GF_EXPORT
365371 GF_Err gf_isom_remove_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num)
366372 {
367373 u32 i;
381387 return GF_OK;
382388 }
383389
390 GF_EXPORT
384391 GF_Err gf_isom_set_meta_xml(GF_ISOFile *file, Bool root_meta, u32 track_num, char *XMLFileName, Bool IsBinaryXML)
385392 {
386393 GF_Err e;
613620 return GF_OK;
614621 }
615622
623 GF_EXPORT
616624 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)
617625 {
618626 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);
623631 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);
624632 }
625633
634 GF_EXPORT
626635 GF_Err gf_isom_remove_meta_item(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_id)
627636 {
628637 GF_ItemInfoEntryBox *iinf;
652661 return GF_OK;
653662 }
654663
664 GF_EXPORT
655665 GF_Err gf_isom_set_meta_primary_item(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_id)
656666 {
657667 GF_MetaBox *meta = gf_isom_get_meta(file, root_meta, track_num);
874874 Bool first_frag_in_subseg;
875875 Bool no_sidx = 0;
876876 u32 count, idx, cur_dur, sidx_dur, sidx_idx, idx_offset, frag_count;
877 u64 last_top_box_pos, root_prev_offset, local_sidx_start, local_sidx_end, prev_earliest_cts, prev_earliest_dts;
877 u64 last_top_box_pos, root_prev_offset, local_sidx_start, local_sidx_end, prev_earliest_cts;
878878 GF_TrackBox *trak = NULL;
879879 GF_Err e;
880880 /*number of subsegment in this segment (eg nb references in the first SIDX found)*/
944944 frags_per_subsidx = 0;
945945
946946 prev_earliest_cts = 0;
947 prev_earliest_dts = ref_track_decode_time;
948947
949948 if (daisy_chain_sidx)
950949 daisy_sidx = gf_list_new();
15061505 ent->Duration = Duration;
15071506 ent->size = sample->dataLength;
15081507 ent->flags = GF_ISOM_FORMAT_FRAG_FLAGS(PaddingBits, sample->IsRAP, DegradationPriority);
1508 if (sample->IsRAP) {
1509 ent->flags |= GF_ISOM_GET_FRAG_DEPEND_FLAGS(0, 2, 0, 0);
1510 }
15091511 gf_list_add(trun->entries, ent);
15101512
15111513 trun->sample_count += 1;
16001602 GF_Err e;
16011603 GF_TrackBox *trak;
16021604 GF_TrackFragmentBox *traf;
1605 GF_TrunEntry *ent;
1606 GF_TrackFragmentRunBox *trun;
16031607 if (!dest->moof || !(dest->FragmentsFlags & GF_ISOM_FRAG_WRITE_READY) ) return GF_BAD_PARAM;
16041608
16051609 traf = GetTraf(dest, TrackID);
16071611
16081612 trak = gf_isom_get_track_from_file(orig, track);
16091613 if (!trak) return GF_BAD_PARAM;
1614
1615 /*modify depends flags*/
1616 if (trak->Media->information->sampleTable->SampleDep) {
1617 u32 dependsOn, dependedOn, redundant;
1618
1619 dependsOn = dependedOn = redundant = 0;
1620 count = gf_list_count(traf->TrackRuns);
1621 if (!count) return GF_BAD_PARAM;
1622 trun = (GF_TrackFragmentRunBox *)gf_list_get(traf->TrackRuns, count-1);
1623 count = gf_list_count(trun->entries);
1624 if (!count) return GF_BAD_PARAM;
1625
1626 ent = (GF_TrunEntry *)gf_list_get(trun->entries, count-1);
1627 e = stbl_GetSampleDepType(trak->Media->information->sampleTable->SampleDep, sampleNumber, &dependsOn, &dependedOn, &redundant);
1628 if (e) return e;
1629
1630 GF_ISOM_RESET_FRAG_DEPEND_FLAGS(ent->flags);
1631 ent->flags |= GF_ISOM_GET_FRAG_DEPEND_FLAGS(0, dependsOn, dependedOn, redundant);
1632 }
16101633
16111634 /*copy subsample info if any*/
16121635 if ( gf_isom_sample_get_subsample_entry(orig, track, sampleNumber, &sub_sample)) {
372372
373373
374374
375
375 GF_EXPORT
376376 GF_Err gf_isom_get_dims_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex, GF_DIMSDescription *desc)
377377 {
378378 GF_DIMSSampleEntryBox *dims;
305305 /*
306306 * Output = SHA-1( file contents )
307307 */
308 GF_EXPORT
308309 s32 gf_sha1_file( const char *path, u8 output[20] )
309310 {
310311 FILE *f;
392392
393393 static void gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT* ait){
394394
395 u32 nb_app_desc,k,desc_id;
396
397 u32 nb_of_app,j,i;
395 u32 nb_app_desc, k, desc_id, nb_of_app, j;
398396 GF_M2TS_CHANNEL_APPLICATION_INFO* ChanAppInfo;
399 char* url_base;
400 char* url_appli_path;
397 char *url_base, *url_appli_path;
401398
402399 nb_of_app = gf_list_count(ait->application_decoded);
403400 url_base = NULL;
404401 url_appli_path = NULL;
405 j=0;
406 i=0;
402 j=0;
407403
408404 /* Link the AIT and the channel */
409405 ChanAppInfo = gf_m2ts_get_channel_application_info(ts->ChannelAppList,ait->service_id);
27762776 2, 1, 2, 3, 3, 4, 4, 5
27772777 };
27782778
2779 GF_EXPORT
27792780 u32 gf_ac3_get_channels(u32 acmod)
27802781 {
27812782 u32 nb_ch;
27832784 return nb_ch;
27842785 }
27852786
2787 GF_EXPORT
27862788 u32 gf_ac3_get_bitrate(u32 brcode)
27872789 {
27882790 return ac3_sizecod_to_bitrate[brcode];
28412843 }
28422844
28432845
2846 GF_EXPORT
28442847 Bool gf_ac3_parser_bs(GF_BitStream *bs, GF_AC3Header *hdr, Bool full_parse)
28452848 {
28462849 u32 fscod, frmsizecod, bsid, ac3_mod, freq, framesize, bsmod;
277277 }
278278 case DOWNLOAD_DATA_BLOCK:
279279 {
280 u32 data_shift,modules_count,i;
280 u32 modules_count, i;
281281 GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK* DownloadDataBlock;
282282 GF_SAFEALLOC(DownloadDataBlock,GF_M2TS_DSMCC_DOWNLOAD_DATA_BLOCK);
283283 DataMessage->dataMessagePayload = DownloadDataBlock;
311311 return GF_CORRUPTED_DATA;
312312 }
313313 DownloadDataBlock->blockDataByte = (char*)gf_calloc(DownloadDataBlock->dataBlocksize,sizeof(char));
314 data_shift = (u32)(gf_bs_get_position(bs));
314 *data_shift = (u32)(gf_bs_get_position(bs));
315315 gf_bs_read_data(bs,DownloadDataBlock->blockDataByte,DownloadDataBlock->dataBlocksize);
316316 memcpy(dsmcc_module->buffer+dsmcc_module->byte_sift,DownloadDataBlock->blockDataByte,DownloadDataBlock->dataBlocksize*sizeof(char));
317317 dsmcc_module->byte_sift += DownloadDataBlock->dataBlocksize;
356356
357357 }
358358 case DOWNLOAD_SERVER_INITIATE:
359
360359 {
361 u32 localbyteshift;
362360 GF_Err e;
363361 GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT* DownloadServerInit;
364362 GF_SAFEALLOC(DownloadServerInit,GF_M2TS_DSMCC_DOWNLOAD_SERVER_INIT);
365363 DataMessage->dataMessagePayload = DownloadServerInit;
366 localbyteshift = (u32)(gf_bs_get_position(bs));
367364 gf_bs_read_data(bs,DownloadServerInit->serverId,20);
368365 gf_m2ts_dsmcc_process_compatibility_descriptor(&DownloadServerInit->CompatibilityDescr,data,bs,data_shift);
369366 DownloadServerInit->privateDataLength = gf_bs_read_int(bs,16);
941938 GF_M2TS_DSMCC_SERVICE_GATEWAY* ServiceGateway;
942939 GF_M2TS_DSMCC_FILE* File;
943940 FILE* pFile;
944 char* FileType;
945941 u8* descr_tag;
946942
947943 GF_SAFEALLOC(BIOP_File,GF_M2TS_DSMCC_BIOP_FILE);
969965 switch(*descr_tag){
970966 case CONTENT_TYPE_DESCRIPTOR:
971967 {
972 GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(BIOP_File->descriptor,0);
973 FileType = strdup(ContentTypeDescr->content_type_data_byte);
968 //GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(BIOP_File->descriptor,0);
974969 }
975970 default:
976971 {
10191014
10201015 GF_M2TS_DSMCC_BIOP_DIRECTORY* BIOP_Directory;
10211016 GF_M2TS_DSMCC_DIR* Dir;
1022 char* ParentName;
1023 char* FileType;
10241017 u32 i;
10251018 GF_M2TS_DSMCC_SERVICE_GATEWAY* ServiceGateway;
10261019
10421035 ServiceGateway->objectKey_data = BIOP_Directory->Header->objectKey_data;
10431036 ServiceGateway->parent = NULL;
10441037 ServiceGateway->name = (char*)gf_strdup(dsmcc_overlord->root_dir);
1045 ParentName = ServiceGateway->name;
10461038 }else{
10471039 /* get the dir related to the payload */
10481040 Dir = dsmcc_get_directory(ServiceGateway->Dir,BIOP_Directory->Header->objectKey_data);
11111103 switch(*descr_tag){
11121104 case CONTENT_TYPE_DESCRIPTOR:
11131105 {
1114 GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(BIOP_Directory->Name[i].descriptor ,j);
1115 FileType = strdup(ContentTypeDescr->content_type_data_byte);
1106 //GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR* ContentTypeDescr = (GF_M2TS_DSMCC_BIOP_CONTENT_TYPE_DESRIPTOR*)gf_list_get(BIOP_Directory->Name[i].descriptor ,j);
11161107 }
11171108 default:
11181109 {
11671158 u32 i;
11681159 GF_M2TS_DSMCC_BIOP_STREAM_EVENT* BIOP_StreamEvent;
11691160 //GF_M2TS_DSMCC_FILE* File;
1170 u32 eventdata,Info_length;
1161 u32 eventdata;
11711162
11721163 GF_SAFEALLOC(BIOP_StreamEvent,GF_M2TS_DSMCC_BIOP_STREAM_EVENT);
11731164
12001191 }
12011192 }
12021193
1203 Info_length = BIOP_StreamEvent->Header->objectInfo_length - (BIOP_StreamEvent->Info.aDescription_length + 14 + BIOP_StreamEvent->eventNames_count + eventdata);
1204
12051194 BIOP_StreamEvent->serviceContextList_count = gf_bs_read_int(bs,8);
1206 if(BIOP_StreamEvent->serviceContextList_count){
1195 if (BIOP_StreamEvent->serviceContextList_count) {
12071196 BIOP_StreamEvent->ServiceContext = (GF_M2TS_DSMCC_SERVICE_CONTEXT*)gf_calloc(BIOP_StreamEvent->serviceContextList_count,sizeof(GF_M2TS_DSMCC_SERVICE_CONTEXT));
12081197 dsmcc_biop_get_context(bs,BIOP_StreamEvent->ServiceContext,BIOP_StreamEvent->serviceContextList_count);
12091198 }
12111200 BIOP_StreamEvent->messageBody_length = gf_bs_read_int(bs,32);
12121201 BIOP_StreamEvent->taps_count = gf_bs_read_int(bs,8);
12131202 BIOP_StreamEvent->Taps = (GF_M2TS_DSMCC_BIOP_TAPS*)gf_calloc(BIOP_StreamEvent->taps_count,sizeof(GF_M2TS_DSMCC_BIOP_TAPS));
1214 for(i=0;i<BIOP_StreamEvent->taps_count;i++){
1203 for (i=0;i<BIOP_StreamEvent->taps_count;i++) {
12151204 BIOP_StreamEvent->Taps[i].id = gf_bs_read_int(bs,16);
12161205 BIOP_StreamEvent->Taps[i].use = gf_bs_read_int(bs,16);
12171206 BIOP_StreamEvent->Taps[i].assocTag = gf_bs_read_int(bs,16);
12401229 static GF_Err dsmcc_process_biop_stream_message(GF_BitStream* bs,GF_M2TS_DSMCC_BIOP_HEADER* BIOP_Header,GF_M2TS_DSMCC_SERVICE_GATEWAY* ServiceGateway){
12411230
12421231 u32 i;
1243 GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE* BIOP_StreamMessage;
1244 u32 eventdata,Info_length;
1232 GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE* BIOP_StreamMessage;
12451233
12461234 GF_SAFEALLOC(BIOP_StreamMessage,GF_M2TS_DSMCC_BIOP_STREAM_MESSAGE);
1247
1248 eventdata = 0;
12491235
12501236 BIOP_StreamMessage->Header = BIOP_Header;
12511237 /* Get Info */
12601246 BIOP_StreamMessage->Info.video = gf_bs_read_int(bs,8);
12611247 BIOP_StreamMessage->Info.data = gf_bs_read_int(bs,8);
12621248
1263
1264 Info_length = BIOP_StreamMessage->Header->objectInfo_length - (BIOP_StreamMessage->Info.aDescription_length + 10);
1265
12661249 BIOP_StreamMessage->serviceContextList_count = gf_bs_read_int(bs,8);
12671250 if(BIOP_StreamMessage->serviceContextList_count){
12681251 BIOP_StreamMessage->ServiceContext = (GF_M2TS_DSMCC_SERVICE_CONTEXT*)gf_calloc(BIOP_StreamMessage->serviceContextList_count,sizeof(GF_M2TS_DSMCC_SERVICE_CONTEXT));
18561839 gf_list_del(IOR->taggedProfile);
18571840 }
18581841
1859 static void dsmcc_free_biop_descriptor(GF_List* list){
1842 static void dsmcc_free_biop_descriptor(GF_List* list)
1843 {
18601844 u8* descr_tag;
1861 u32 descr_count;
1862
1863 descr_count = gf_list_count(list);
1864
1865
1866 while(gf_list_count(list)){
1845
1846 while(gf_list_count(list)) {
18671847
18681848 descr_tag = (u8*)gf_list_get(list,0);
18691849
1870 switch(*descr_tag){
1850 switch(*descr_tag) {
18711851
18721852 case CACHING_PRIORITY_DESCRIPTOR:
18731853 {
424424
425425 Bool gf_m2ts_compare_ip(u8 rx_ip_adress[4], u8 ip_adress_bootstrap[4])
426426 {
427 Bool Boostrap_ip;
428427 u8 i;
429 for (i=0; i<sizeof(rx_ip_adress); i++)
428 for (i=0; i<4; i++)
430429 {
431430 if (rx_ip_adress[i] != ip_adress_bootstrap[i])
432 return Boostrap_ip = 0;
433 }
434 return Boostrap_ip = 1;
435 }
431 return 0;
432 }
433 return 1;
434 }
435
436
436437 u32 gf_m2ts_ipdatagram_reader(u8 *datagram,GF_M2TS_IP_Packet *ip_packet, u32 offset)
437438 {
438439
10931094 }
10941095
10951096 // ********************************************************
1096 // Envoi des données
1097 // Envoi des donn�es
10971098 // ********************************************************
10981099
10991100 e = gf_sk_send(Sock_Struct->sock, ip_packet->data, ip_packet->u32_udp_data_size - 8);
166166 return GF_OK;
167167 }
168168
169 GF_EXPORT
169170 GF_Err gf_isom_streamer_write_sdp(GF_ISOMRTPStreamer *streamer, char*sdpfilename)
170171 {
171172 return gf_isom_streamer_setup_sdp(streamer, sdpfilename, NULL);
197198 if (is_loop) streamer->timelineOrigin = 0;
198199 }
199200
201 GF_EXPORT
200202 GF_Err gf_isom_streamer_send_next_packet(GF_ISOMRTPStreamer *streamer, s32 send_ahead_delay, s32 max_sleep_time)
201203 {
202204 GF_Err e = GF_OK;
329331 return first_port;
330332 }
331333
334 GF_EXPORT
332335 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)
333336 {
334337 GF_ISOMRTPStreamer *streamer;
502505 return NULL;
503506 }
504507
508 GF_EXPORT
505509 void gf_isom_streamer_del(GF_ISOMRTPStreamer *streamer)
506510 {
507511 GF_RTPTrack *track = streamer->stream;
518518 }
519519
520520 /* write a png file */
521 GF_EXPORT
521522 GF_Err gf_img_png_enc(char *data, u32 width, u32 height, s32 stride, u32 pixel_format, char *dst, u32 *dst_size)
522523 {
523524 GFpng udta;
608608 return GF_OK;
609609 }
610610
611 GF_EXPORT
611612 GF_Err gf_media_make_psp(GF_ISOFile *mp4)
612613 {
613614 u32 i, count;
713714 GF_Err e;
714715 char sOpt[100], sKey[100];
715716 char szCodecs[200], szCodec[100];
716 u32 cur_seg, fragment_index, nb_fragments, max_sap_type;
717 u32 cur_seg, fragment_index, max_sap_type;
717718 GF_ISOFile *output;
718719 GF_ISOSample *sample, *next;
719720 GF_List *fragmenters;
10681069
10691070
10701071 max_segment_duration = 0;
1071 nb_fragments=0;
10721072
10731073 while ( (count = gf_list_count(fragmenters)) ) {
10741074
14151415
14161416 if (dash_mode) {
14171417 char buffer[1000];
1418 u32 h, m;
1419 Double s;
14201418
14211419 /*flush last segment*/
14221420 if (!switch_segment) {
14481446 }
14491447
14501448 period_duration += file_duration;
1451 h = (u32) (period_duration/3600);
1452 m = (u32) (period_duration-h*60)/60;
1453 s = period_duration - h*3600 - m*60;
1449 //u32 h = (u32) (period_duration/3600);
1450 //u32 m = (u32) (period_duration-h*60)/60;
14541451 bandwidth = (u32) (file_size * 8 / file_duration);
14551452
14561453 fprintf(mpd, " <Representation id=\"%d\" mimeType=\"%s/mp4\" codecs=\"%s\"", rep_idx ? rep_idx : 1, audio_only ? "audio" : "video", szCodecs);
15641561
15651562 #endif /*GPAC_DISABLE_ISOM_FRAGMENTS*/
15661563
1564 GF_EXPORT
15671565 GF_Err gf_media_mpd_start(char *mpd_name, char *title, Bool use_url_template, Bool single_segment, char *dash_ctx, GF_ISOFile *init_segment, Double period_duration)
15681566 {
15691567 u32 h, m;
16261624 return GF_OK;
16271625 }
16281626
1627 GF_EXPORT
16291628 GF_Err gf_media_mpd_end(char *mpd_name)
16301629 {
16311630 FILE *mpd = fopen(mpd_name, "a+t");
15681568 }
15691569 }
15701570
1571 GF_EXPORT
15711572 GF_M2TS_Mux_Stream *gf_m2ts_program_stream_add(GF_M2TS_Mux_Program *program, struct __elementary_stream_ifce *ifce, u32 pid, Bool is_pcr, Bool force_pes)
15721573 {
15731574 GF_M2TS_Mux_Stream *stream, *st;
16951696 return stream;
16961697 }
16971698
1699 GF_EXPORT
16981700 GF_Err gf_m2ts_program_stream_update_ts_scale(GF_ESInterface *_self, u32 time_scale)
16991701 {
17001702 GF_M2TS_Mux_Stream *stream = (GF_M2TS_Mux_Stream *)_self->output_udta;
17051707 return GF_OK;
17061708 }
17071709
1708
1710 GF_EXPORT
17091711 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)
17101712 {
17111713 GF_M2TS_Mux_Program *program;
17311733 return program;
17321734 }
17331735
1736 GF_EXPORT
17341737 GF_M2TS_Mux *gf_m2ts_mux_new(u32 mux_rate, u32 pat_refresh_rate, Bool real_time)
17351738 {
17361739 GF_BitStream *bs;
18031806 gf_free(prog);
18041807 }
18051808
1809 GF_EXPORT
18061810 void gf_m2ts_mux_del(GF_M2TS_Mux *mux)
18071811 {
18081812 while (mux->programs) {
18371841 }
18381842 }
18391843
1844 GF_EXPORT
18401845 void gf_m2ts_mux_update_config(GF_M2TS_Mux *mux, Bool reset_time)
18411846 {
18421847 GF_M2TS_Mux_Program *prog;
18741879 }
18751880 }
18761881
1882 GF_EXPORT
18771883 u32 gf_m2ts_get_sys_clock(GF_M2TS_Mux *muxer)
18781884 {
18791885 return gf_sys_clock() - muxer->init_sys_time;
18801886 }
18811887
1888 GF_EXPORT
18821889 u32 gf_m2ts_get_ts_clock(GF_M2TS_Mux *muxer)
18831890 {
18841891 u32 now, init;
18871894 return now-init;
18881895 }
18891896
1897 GF_EXPORT
18901898 GF_Err gf_m2ts_mux_use_single_au_pes_mode(GF_M2TS_Mux *muxer, Bool strict_au_pes_mode)
18911899 {
18921900 if (!muxer) return GF_BAD_PARAM;
18941902 return GF_OK;
18951903 }
18961904
1905 GF_EXPORT
18971906 GF_Err gf_m2ts_mux_set_initial_pcr(GF_M2TS_Mux *muxer, u64 init_pcr_value)
18981907 {
18991908 if (!muxer) return GF_BAD_PARAM;
19011910 return GF_OK;
19021911 }
19031912
1913 GF_EXPORT
19041914 const char *gf_m2ts_mux_process(GF_M2TS_Mux *muxer, u32 *status)
19051915 {
19061916 GF_M2TS_Mux_Program *program;
36993699 return e;
37003700 }
37013701
3702 GF_EXPORT
37023703 GF_Err gf_media_avc_rewrite_samples(GF_ISOFile *file, u32 track, u32 prev_size, u32 new_size)
37033704 {
37043705 u32 i, count, di, remain, msize;
54825483 {
54835484 GF_Err e;
54845485 u32 sc_pos, start;
5485 char *data;
54865486 GF_BitStream *bs;
54875487 GF_ISOSample *samp;
54885488 u32 count = gf_isom_get_sample_count(import->dest, tsimp->track);
54925492 sc_pos = 1;
54935493 start = 0;
54945494 bs = gf_bs_new(samp->data, samp->dataLength, GF_BITSTREAM_WRITE);
5495 data = samp->data;
54965495 while (1) {
54975496 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)) {
54985497 gf_bs_seek(bs, start);
158158 GF_SAFEALLOC(url, GF_MPD_BaseURL);
159159 if (! url) return GF_OUT_OF_MEM;
160160 e = gf_list_add(container, url);
161 if (e) return GF_OUT_OF_MEM;
161162
162163 i = 0;
163164 while ( (att = gf_list_enum(node->attributes, &i))) {
652653 return GF_OK;
653654 }
654655
655
656 GF_EXPORT
656657 GF_MPD *gf_mpd_new()
657658 {
658659 GF_MPD *mpd;
825826 gf_free(ptr);
826827 }
827828
829 GF_EXPORT
828830 void gf_mpd_del(GF_MPD *mpd)
829831 {
830832 gf_mpd_del_list(mpd->program_infos, gf_mpd_prog_info_free, 0);
837839 gf_free(mpd);
838840 }
839841
842 GF_EXPORT
840843 GF_Err gf_mpd_init_from_dom(GF_XMLNode *root, GF_MPD *mpd, const char *default_base_url)
841844 {
842845 GF_Err e;
890893 mpd->max_subsegment_duration = gf_mpd_parse_duration(att->value);
891894 }
892895 }
896 if (mpd->type == GF_MPD_TYPE_STATIC)
897 mpd->minimum_update_period = 0;
893898
894899 child_index = 0;
895900 while (1) {
919924 return GF_OK;
920925 }
921926
927 GF_EXPORT
922928 GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url,
923929 const char *mpd_file,
924930 u32 reload_count, char *mimeTypeForM3U8Segments, GF_ClientService *service, Bool do_import, Bool use_mpd_templates)
4545
4646 #define DEBUG_TS_PACKET 0
4747
48
49 GF_EXPORT
4850 const char *gf_m2ts_get_stream_name(u32 streamType)
4951 {
5052 switch (streamType) {
22312233 return;
22322234 }
22332235
2236 GF_EXPORT
22342237 GF_Err gf_m2ts_process_data(GF_M2TS_Demuxer *ts, char *data, u32 data_size)
22352238 {
22362239 u32 pos;
23282331 }
23292332 }
23302333
2334 GF_EXPORT
23312335 void gf_m2ts_reset_parsers(GF_M2TS_Demuxer *ts)
23322336 {
23332337 u32 i;
23902394 {
23912395 }
23922396
2397 GF_EXPORT
23932398 GF_Err gf_m2ts_set_pes_framing(GF_M2TS_PES *pes, u32 mode)
23942399 {
23952400 GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] Setting pes framing mode of PID %d to %d\n", pes->pid, mode) );
24512456 return GF_OK;
24522457 }
24532458
2459 GF_EXPORT
24542460 GF_M2TS_Demuxer *gf_m2ts_demux_new()
24552461 {
24562462 GF_M2TS_Demuxer *ts;
24792485 return ts;
24802486 }
24812487
2488 GF_EXPORT
24822489 void gf_m2ts_demux_dmscc_init(GF_M2TS_Demuxer *ts){
24832490
24842491 char* temp_dir;
25032510
25042511 }
25052512
2513 GF_EXPORT
25062514 void gf_m2ts_demux_del(GF_M2TS_Demuxer *ts)
25072515 {
25082516 u32 i;
29072915 return GF_OK;
29082916 }
29092917
2918 GF_EXPORT
29102919 u32 gf_dvb_get_freq_from_url(const char *channels_config_path, const char *url)
29112920 {
29122921 FILE *channels_config_file;
30023011
30033012 }
30043013
3014 GF_EXPORT
30053015 GF_Err TSDemux_Demux_Setup(GF_M2TS_Demuxer *ts, const char *url, Bool loop)
30063016 {
30073017 char szURL[2048];
30403050 return GF_NOT_SUPPORTED;
30413051 }
30423052
3053 GF_EXPORT
30433054 GF_Err TSDemux_CloseDemux(GF_M2TS_Demuxer *ts)
30443055 {
30453056 GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[TSDemux] Destroying demuxer\n"));
30583069 return GF_OK;
30593070 }
30603071
3061
3072 GF_EXPORT
30623073 GF_Err TSDemux_DemuxPlay(GF_M2TS_Demuxer *ts){
30633074
30643075 /*set the state variable outside the TS thread. If inside, we may get called for shutdown before the TS thread has started
413413 GF_ISOSample *samp;
414414 GF_StreamContext *sc;
415415 GF_ESD *esd;
416 GF_MuxInfo *mux;
416417 #ifndef GPAC_DISABLE_BIFS_ENC
417418 GF_BifsEncoder *bifs_enc;
418419 #endif
894895 /*if offset add edit list*/
895896 gf_sm_finalize_mux(mp4, esd, (u32) init_offset);
896897 gf_isom_set_last_sample_duration(mp4, track, 0);
898
899 mux = gf_sm_get_mux_info(esd);
900 if (mux && mux->duration) {
901 u64 tot_dur = mux->duration * esd->slConfig->timestampResolution / 1000;
902 u64 dur = gf_isom_get_media_duration(mp4, track);
903 if (dur <= tot_dur)
904 gf_isom_set_last_sample_duration(mp4, track, (u32) (tot_dur - dur));
905 }
897906
898907 if (delete_desc) {
899908 gf_odf_desc_del((GF_Descriptor *) esd);
37543754 }
37553755
37563756
3757
3757 GF_EXPORT
37583758 GF_List *gf_sm_load_bt_from_string(GF_SceneGraph *in_scene, char *node_str, Bool force_wrl)
37593759 {
37603760 GF_SceneLoader ctx;
4141 {
4242 }
4343
44 GF_EXPORT
4445 GF_SceneGraph *gf_sg_new()
4546 {
4647 GF_SceneGraph *tmp;
521522 if (sg) sg->userpriv = ptr;
522523 }
523524
525 GF_EXPORT
524526 void *gf_sg_get_private(GF_SceneGraph *sg)
525527 {
526528 return sg ? sg->userpriv : NULL;
19761978 return GF_BAD_PARAM;
19771979 }
19781980
1981 GF_EXPORT
19791982 GF_Err gf_node_get_field_by_name(GF_Node *node, char *name, GF_FieldInfo *field)
19801983 {
19811984 s32 res = -1;
21342137 return GF_XMLNS_UNDEFINED;
21352138 }
21362139
2140 GF_EXPORT
21372141 GF_Err gf_sg_add_namespace(GF_SceneGraph *sg, char *name, char *qname)
21382142 {
21392143 u32 id;
22402244 }
22412245
22422246
2247 GF_EXPORT
22432248 char *gf_node_dump_attribute(GF_Node *n, GF_FieldInfo *info)
22442249 {
22452250 #ifndef GPAC_DISABLE_SVG
2828
2929 #include <gpac/internal/laser_dev.h>
3030
31
32 GF_EXPORT
3133 GF_Command *gf_sg_command_new(GF_SceneGraph *graph, u32 tag)
3234 {
3335 GF_Command *ptr;
871873 return GF_OK;
872874 }
873875
876 GF_EXPORT
874877 GF_CommandField *gf_sg_command_field_new(GF_Command *com)
875878 {
876879 GF_CommandField *ptr;
124124 return gf_list_add(evt_target->evt_list, listener);
125125 }
126126
127 GF_EXPORT
127128 GF_Err gf_node_dom_listener_add(GF_Node *node, GF_Node *listener)
128129 {
129130 if (!node || !listener) return GF_BAD_PARAM;
142143 return gf_sg_listener_add(listener, node->sgprivate->interact->dom_evt);
143144 }
144145
146 GF_EXPORT
145147 GF_Err gf_dom_listener_del(GF_Node *listener, GF_DOMEventTarget *target)
146148 {
147149 GF_FieldInfo info;
712714 gf_smil_setup_event_list(node, * (GF_List **)info.far_ptr, 0);
713715 }
714716
717 GF_EXPORT
715718 void gf_dom_set_textContent(GF_Node *n, char *text)
716719 {
717720 GF_ParentNode *par = (GF_ParentNode *)n;
720723 if (text) gf_dom_add_text_node(n, gf_strdup( text) );
721724 }
722725
726 GF_EXPORT
723727 GF_DOMText *gf_dom_add_text_node(GF_Node *parent, char *text_data)
724728 {
725729 GF_DOMText *text;
741745 return text;
742746 }
743747
748 GF_EXPORT
744749 char *gf_dom_flatten_textContent(GF_Node *n)
745750 {
746751 u32 len = 0;
32733273 GF_DOMFullNode *n;
32743274 GF_DOM_Event evt;
32753275 char *str;
3276 jsval readonly;
3276 jsval readonly=0;
32773277 if (!JS_InstanceOf(c, obj, &dom_rt->DCCIClass, NULL) ) return JS_TRUE;
32783278 n = (GF_DOMFullNode*) dom_get_node(c, obj);
32793279 if (!n) return JS_TRUE;
3799537995 }
3799637996
3799737997
37998 GF_EXPORT
3799837999 u32 gf_node_mpeg4_type_by_class_name(const char *node_name)
3799938000 {
3800038001 if(!node_name) return 0;
165165 { GF_EVENT_VP_RESIZE, "gpac_vp_changed", GF_DOM_EVENT_DOM },
166166 };
167167
168 GF_EXPORT
168169 u32 gf_dom_event_type_by_name(const char *name)
169170 {
170171 u32 i, count;
407408 { GF_KEY_RECORD, "Record" },
408409 { GF_KEY_BEGINPAGE, "BeginPage" }
409410 };
411
412
413 GF_EXPORT
410414 const char *gf_dom_get_key_name(u32 key_identifier)
411415 {
412416 u32 count = sizeof(predefined_key_identifiers) / sizeof(struct predef_keyid);
30703074 }
30713075
30723076 /* Parse an SVG attribute */
3077 GF_EXPORT
30733078 GF_Err gf_svg_parse_attribute(GF_Node *n, GF_FieldInfo *info, char *attribute_content, u8 anim_value_type)
30743079 {
30753080 /* for all attributes, except strings, apply some sort of white space normalization*/
24212421 static GF_Err JSScript_CreateSVGContext(GF_SceneGraph *sg)
24222422 {
24232423 GF_SVGJS *svg_js;
2424 Bool do_lock = gf_sg_javascript_initialized();
24252424 GF_SAFEALLOC(svg_js, GF_SVGJS);
24262425
2427 if (do_lock) gf_sg_lock_javascript(NULL, 1);
24282426 /*create new ecmascript context*/
24292427 svg_js->js_ctx = gf_sg_ecmascript_new(sg);
24302428 if (!svg_js->js_ctx) {
24312429 gf_free(svg_js);
2432 if (do_lock) gf_sg_lock_javascript(NULL, 0);
24332430 return GF_SCRIPT_ERROR;
24342431 }
2432
2433 gf_sg_lock_javascript(svg_js->js_ctx, 1);
2434
24352435 if (!svg_rt) {
24362436 GF_SAFEALLOC(svg_rt, GF_SVGuDOM);
24372437 JS_SETUP_CLASS(svg_rt->svgElement, "SVGElement", JSCLASS_HAS_PRIVATE, svg_element_getProperty, svg_element_setProperty, dom_element_finalize);
24482448 sg->svg_js = svg_js;
24492449 /*load SVG & DOM APIs*/
24502450 svg_init_js_api(sg);
2451 if (do_lock) gf_sg_lock_javascript(NULL, 0);
24522451
24532452 svg_js->script_execute = svg_script_execute;
24542453 svg_js->handler_execute = svg_script_execute_handler;
2454
2455 gf_sg_lock_javascript(svg_js->js_ctx, 0);
2456
24552457 return GF_OK;
24562458 }
24572459
350350 }
351351
352352
353 GF_EXPORT
353354 void gf_node_event_out(GF_Node *node, u32 FieldIndex)
354355 {
355356 u32 i;
287287 return GF_OK;
288288 }
289289
290 GF_EXPORT
290291 void gf_sg_script_event_in(GF_Node *node, GF_FieldInfo *in_field)
291292 {
292293 GF_ScriptPriv *priv = (GF_ScriptPriv *)node->sgprivate->UserPrivate;
3636
3737
3838 /*fixes for JS > 1.8.0rc1 where GC routines have changed*/
39 GF_EXPORT
3940 Bool gf_js_add_root(JSContext *cx, void *rp, u32 type)
4041 {
4142 #if (JS_VERSION>=185)
8283 return (JS_AddNamedRoot(cx, rp, name)==JS_TRUE) ? 1 : 0;
8384 #endif
8485 }
86
87 GF_EXPORT
8588 Bool gf_js_remove_root(JSContext *cx, void *rp, u32 type)
8689 {
8790 #if (JS_VERSION>=185)
318321 gf_sg_load_script_modules(sg);
319322 }
320323 js_rt->nb_inst++;
324
325 gf_mx_p(js_rt->mx);
326 #if defined(JS_THREADSAFE) && (JS_VERSION>=185)
327 if (gf_mx_get_num_locks(js_rt->mx)==1) {
328 JS_SetRuntimeThread(js_rt->js_runtime);
329 }
330 #endif
331
321332 ctx = JS_NewContext(js_rt->js_runtime, STACK_CHUNK_BYTES);
322333 JS_SetOptions(ctx, JS_GetOptions(ctx) | JSOPTION_WERROR);
323334
324 #ifdef JS_THREADSAFE
325 #if (JS_VERSION>=185)
335 #if defined(JS_THREADSAFE) && (JS_VERSION>=185)
326336 JS_ClearContextThread(ctx);
327 JS_ClearRuntimeThread(js_rt->js_runtime);
328 #endif
329 #endif
337 if (gf_mx_get_num_locks(js_rt->mx)==1) {
338 JS_ClearRuntimeThread(js_rt->js_runtime);
339 }
340 #endif
341 gf_mx_v(js_rt->mx);
342
330343 return ctx;
331344 }
332345
354367 }
355368 }
356369
370
371 GF_EXPORT
357372 #if (JS_VERSION>=185)
358373 JSBool gf_sg_js_has_instance(JSContext *c, JSObject *obj,const jsval *val, JSBool *vp)
359374 #else
44204435 return 0;
44214436 }
44224437
4438
44234439 static void JSScript_LoadVRML(GF_Node *node)
44244440 {
44254441 char *str;
44264442 JSBool ret;
44274443 u32 i;
4428 Bool do_lock = gf_sg_javascript_initialized();
44294444 Bool local_script;
44304445 jsval rval, fval;
44314446 M_Script *script = (M_Script *)node;
44524467 }
44534468 local_script = str ? 1 : 0;
44544469
4455 if (do_lock) gf_sg_lock_javascript(priv->js_ctx, 1);
4470 /*lock runtime and set current thread before creating the context*/
44564471 priv->js_ctx = gf_sg_ecmascript_new(node->sgprivate->scenegraph);
44574472 if (!priv->js_ctx) {
4458 if (do_lock) gf_sg_lock_javascript(priv->js_ctx, 0);
44594473 GF_LOG(GF_LOG_ERROR, GF_LOG_SCRIPT, ("[VRML JS] Cannot allocate ECMAScript context for node\n"));
44604474 return;
44614475 }
44624476
4463 if (!do_lock) gf_sg_lock_javascript(priv->js_ctx, 1);
4477 gf_sg_lock_javascript(priv->js_ctx, 1);
44644478
44654479 JS_SetContextPrivate(priv->js_ctx, node);
44664480 gf_sg_script_init_sm_api(priv, node);
47434757
47444758 #ifdef GPAC_HAS_SPIDERMONKEY
47454759
4760 GF_EXPORT
47464761 GF_Node *gf_sg_js_get_node(JSContext *c, JSObject *obj)
47474762 {
47484763 #ifndef GPAC_DISABLE_VRML
47754790 #endif
47764791 }
47774792
4778 Bool gf_sg_javascript_initialized()
4779 {
4780 #ifdef GPAC_HAS_SPIDERMONKEY
4781 if (js_rt) return 1;
4782 #endif
4783 return 0;
4784 }
47854793
47864794 #ifdef GPAC_HAS_SPIDERMONKEY
47874795
47934801 * (mozilla doc is wrong here)
47944802 *
47954803 * */
4804 GF_EXPORT
47964805 void gf_sg_lock_javascript(struct JSContext *cx, Bool LockIt)
47974806 {
47984807 if (!js_rt) return;
4799 assert(cx);
4808
48004809 if (LockIt) {
48014810 gf_mx_p(js_rt->mx);
48024811 #ifdef JS_THREADSAFE
4812 assert(cx);
48034813 if (gf_mx_get_num_locks(js_rt->mx)==1) {
48044814 #if (JS_VERSION>=185)
48054815 JS_SetRuntimeThread(js_rt->js_runtime);
48104820 #endif
48114821 } else {
48124822 #ifdef JS_THREADSAFE
4823 assert(cx);
48134824 if (gf_mx_get_num_locks(js_rt->mx)==1) {
48144825 JS_EndRequest(cx);
48154826 #if (JS_VERSION>=185)
48224833 }
48234834 }
48244835
4836 GF_EXPORT
48254837 Bool gf_sg_try_lock_javascript(struct JSContext *cx)
48264838 {
48274839 assert(cx);
3232 #include <gpac/internal/bifs_dev.h>
3333
3434
35 GF_EXPORT
3536 Bool gf_node_in_table_by_tag(u32 tag, u32 NDTType)
3637 {
3738 if (!tag) return 0;
651652 /*********************************************************************
652653 MF Fields manipulation (alloc, gf_realloc, GetAt)
653654 *********************************************************************/
655 GF_EXPORT
654656 const char *gf_sg_vrml_get_event_type_name(u32 EventType, Bool forX3D)
655657 {
656658 switch (EventType) {
662664 }
663665 }
664666
667 GF_EXPORT
665668 const char *gf_sg_vrml_get_field_type_by_name(u32 FieldType)
666669 {
667670
752755
753756 void gf_sg_sfurl_del(SFURL url) { if (url.url) gf_free(url.url); }
754757
758 GF_EXPORT
755759 Bool gf_sg_vrml_is_sf_field(u32 FieldType)
756760 {
757761 return (FieldType<GF_SG_VRML_FIRST_MF);
858862 }
859863 }
860864
865 GF_EXPORT
861866 u32 gf_sg_vrml_get_sf_type(u32 FieldType)
862867 {
863868 switch (FieldType) {
10371042 return GF_OK;
10381043 }
10391044
1045 GF_EXPORT
10401046 GF_Err gf_sg_vrml_mf_get_item(void *mf, u32 FieldType, void **new_ptr, u32 ItemPos)
10411047 {
10421048 u32 FieldSize;
1534715347 }
1534815348
1534915349
15350 GF_EXPORT
1535015351 u32 gf_node_x3d_type_by_class_name(const char *node_name)
1535115352 {
1535215353 if(!node_name) return 0;
717717 return att;
718718 }
719719
720 GF_EXPORT
720721 GF_Err gf_node_get_attribute_by_name(GF_Node *node, char *name, u32 xmlns_code, Bool create_if_not_found, Bool set_default, GF_FieldInfo *field)
721722 {
722723 u32 attribute_tag = gf_xml_get_attribute_tag(node, name, xmlns_code);
7474 tmp->odm = odm;
7575 tmp->flags = codec->flags | GF_ESM_CODEC_IS_USE;
7676 tmp->decio = codec->decio;
77 tmp->process = codec->process;
7778 return tmp;
7879 }
7980
888888 return serv;
889889 }
890890
891 GF_EXPORT
891892 Bool gf_term_is_supported_url(GF_Terminal *term, const char *fileName, Bool use_parent_url, Bool no_mime_check)
892893 {
893894 GF_InputService *ifce;
5959
6060
6161 /*returns top-level OD of the presentation*/
62 GF_EXPORT
6263 GF_ObjectManager *gf_term_get_root_object(GF_Terminal *term)
6364 {
6465 if (!term) return NULL;
6768 }
6869
6970 /*returns number of sub-ODs in the current root. scene_od must be an inline OD*/
71 GF_EXPORT
7072 u32 gf_term_get_object_count(GF_Terminal *term, GF_ObjectManager *scene_od)
7173 {
7274 if (!term || !scene_od) return 0;
7678 }
7779
7880 /*returns indexed (0-based) OD manager in the scene*/
81 GF_EXPORT
7982 GF_ObjectManager *gf_term_get_object(GF_Terminal *term, GF_ObjectManager *scene_od, u32 index)
8083 {
8184 if (!term || !scene_od) return NULL;
8487 return (GF_ObjectManager *) gf_list_get(scene_od->subscene->resources, index);
8588 }
8689
90 GF_EXPORT
8791 u32 gf_term_object_subscene_type(GF_Terminal *term, GF_ObjectManager *odm)
8892 {
8993 if (!term || !odm) return 0;
105109 gf_scene_select_object(term->root_scene, odm);
106110 }
107111
112 GF_EXPORT
108113 u32 gf_term_get_current_service_id(GF_Terminal *term)
109114 {
110115 SFURL *the_url;
130135 info->total_dec_time = dec->total_dec_time;
131136 }
132137
138 GF_EXPORT
133139 GF_Err gf_term_get_object_info(GF_Terminal *term, GF_ObjectManager *odm, GF_MediaInfo *info)
134140 {
135141 GF_Channel *ch;
267273 return GF_OK;
268274 }
269275
270
276 GF_EXPORT
271277 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)
272278 {
273279 GF_DownloadSession * sess;
282288 return 1;
283289 }
284290
291 GF_EXPORT
285292 Bool gf_term_get_channel_net_info(GF_Terminal *term, GF_ObjectManager *odm, u32 *d_enum, u32 *chid, NetStatCommand *netcom, GF_Err *ret_code)
286293 {
287294 GF_Channel *ch;
304311 return 1;
305312 }
306313
314 GF_EXPORT
307315 GF_Err gf_term_get_service_info(GF_Terminal *term, GF_ObjectManager *odm, NetInfoCommand *netinfo)
308316 {
309317 GF_Err e;
316324 return e;
317325 }
318326
319
327 GF_EXPORT
320328 const char *gf_term_get_world_info(GF_Terminal *term, GF_ObjectManager *scene_od, GF_List *descriptions)
321329 {
322330 GF_Node *info;
350358 return "GPAC";
351359 }
352360
353
361 GF_EXPORT
354362 GF_Err gf_term_dump_scene(GF_Terminal *term, char *rad_name, char **filename, Bool xml_dump, Bool skip_protos, GF_ObjectManager *scene_od)
355363 {
356364 #ifndef GPAC_DISABLE_SCENE_DUMP
283283 u32 od_type;
284284 char *ext;
285285 char *sub_url = (char *) service_sub_url;
286 GF_Terminal *term;
287286 GF_Descriptor *desc;
288287
289288 if (odm->flags & GF_ODM_DESTROYED) {
291290 return;
292291 }
293292 // assert(odm->OD==NULL);
294
295 term = odm->term;
296293
297294 GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[ODM] Setting up root object for %s\n", odm->net_service->url));
298295
584581 return;
585582 }
586583 odm->net_service = serv;
584 assert(odm->OD);
587585 if (!odm->OD->URLString)
588586 odm->net_service->nb_odm_users++;
589587 }
590588 /*if this is a remote OD, we need a new manager and a new service...*/
589 assert(odm->OD);
591590 if (odm->OD->URLString) {
592591 GF_ClientService *parent = odm->net_service;
593592 char *url = odm->OD->URLString;
18801879 {
18811880 GF_Segment *desc;
18821881 u32 i = 0;
1882 if (!odm->OD) return NULL;
18831883 while ( (desc = (GF_Segment *)gf_list_enum(odm->OD->OCIDescriptors, &i)) ){
18841884 if (desc->tag != GF_ODF_SEGMENT_TAG) continue;
18851885 if (!stricmp(desc->SegmentName, descName)) return desc;
8181 gf_term_service_media_event(scene->scene_codec->odm, type);
8282 }
8383
84
84 GF_EXPORT
8585 GF_Scene *gf_scene_new(GF_Scene *parentScene)
8686 {
8787 GF_Scene *tmp;
781781 gf_term_send_event(term, &evt);
782782 }
783783
784 GF_EXPORT
784785 GF_Err gf_term_step_clocks(GF_Terminal * term, u32 ms_diff)
785786 {
786787 u32 i, j;
12221223 }
12231224
12241225 /*locks media quaue*/
1226 GF_EXPORT
12251227 void gf_term_lock_media_queue(GF_Terminal *term, Bool LockIt)
12261228 {
12271229 if (LockIt) {
12691271 void gf_term_service_media_event_with_download(GF_ObjectManager *odm, u32 event_type, u64 loaded_size, u64 total_size, u32 bytes_per_sec)
12701272 {
12711273 #ifndef GPAC_DISABLE_SVG
1272 u32 i, count, min_buffer, min_time, transport;
1274 u32 i, count, min_buffer, min_time;
12731275 Bool locked;
12741276 GF_DOMMediaEvent media_event;
12751277 GF_DOM_Event evt;
12881290
12891291
12901292 memset(&media_event, 0, sizeof(GF_DOMMediaEvent));
1291 transport = 0;
12921293 media_event.bufferValid = 0;
12931294 media_event.session_name = odm->net_service->url;
12941295
13361337 }
13371338
13381339 /* Browses all registered relocators (ZIP-based, ISOFF-based or file-system-based to relocate a URI based on the locale */
1340 GF_EXPORT
13391341 Bool gf_term_relocate_url(GF_Terminal *term, const char *service_url, const char *parent_url, char *out_relocated_url, char *out_localized_url)
13401342 {
13411343 u32 i, count;
18091811 return e;
18101812 }
18111813
1814 GF_EXPORT
18121815 GF_Err gf_term_get_screen_buffer(GF_Terminal *term, GF_VideoSurface *framebuffer)
18131816 {
18141817 if (!term) return GF_BAD_PARAM;
18151818 return gf_sc_get_screen_buffer(term->compositor, framebuffer, 0);
18161819 }
18171820
1821 GF_EXPORT
18181822 GF_Err gf_term_get_offscreen_buffer(GF_Terminal *term, GF_VideoSurface *framebuffer, u32 view_idx, u32 depth_buffer_type)
18191823 {
18201824 if (!term) return GF_BAD_PARAM;
18211825 return gf_sc_get_offscreen_buffer(term->compositor, framebuffer, view_idx, depth_buffer_type);
18221826 }
18231827
1828 GF_EXPORT
18241829 GF_Err gf_term_release_screen_buffer(GF_Terminal *term, GF_VideoSurface *framebuffer)
18251830 {
18261831 if (!term) return GF_BAD_PARAM;
18981903 return 0;
18991904 }
19001905
1906 GF_EXPORT
19011907 GF_Err gf_term_add_event_filter(GF_Terminal *terminal, GF_TermEventFilter *ef)
19021908 {
19031909 GF_Err e;
19101916 return e;
19111917 }
19121918
1919 GF_EXPORT
19131920 GF_Err gf_term_remove_event_filter(GF_Terminal *terminal, GF_TermEventFilter *ef)
19141921 {
19151922 if (!terminal || !ef || !terminal->event_filters) return GF_BAD_PARAM;
19741981 }
19751982 }
19761983
1984 GF_EXPORT
19771985 void gf_term_set_speed(GF_Terminal *term, Fixed speed)
19781986 {
19791987 Double fps;
20052013 gf_sc_set_fps(term->compositor, fps);
20062014 }
20072015
2016 GF_EXPORT
20082017 void gf_term_process_shortcut(GF_Terminal *term, GF_Event *ev)
20092018 {
20102019 GF_Event evt;
22422251 }
22432252 }
22442253
2254 GF_EXPORT
22452255 void gf_term_switch_quality(GF_Terminal *term, Bool up)
22462256 {
22472257 gf_scene_switch_quality(term->root_scene, up);
9595 #define CDECL
9696 #endif
9797
98 #ifndef SYMBOL_EXPORT
99 #if defined(__GNUC__) && __GNUC__ >= 4
100 #define SYMBOL_EXPORT __attribute__((visibility("default")))
101 #endif
102 #endif
103
98104 #if (USE_MALLOC==DL_MALLOC)
99105
100106 CDECL void * dlmalloc(size_t size);
168174 #else
169175
170176
171 CDECL
172177 size_t gpac_allocated_memory = 0;
173178 size_t gpac_nb_alloc_blocs = 0;
174179
293298 static void (*gf_mem_free_proto)(void *ptr, char *filename, int line) = gf_mem_free_basic;
294299 static char *(*gf_mem_strdup_proto)(const char *str, char *filename, int line) = gf_mem_strdup_basic;
295300
296 CDECL
301 SYMBOL_EXPORT CDECL
297302 void *gf_mem_malloc(size_t size, char *filename, int line)
298303 {
299304 return gf_mem_malloc_proto(size, filename, line);
300305 }
301 CDECL
306
307 SYMBOL_EXPORT CDECL
302308 void *gf_mem_calloc(size_t num, size_t size_of, char *filename, int line)
303309 {
304310 return gf_mem_calloc_proto(num, size_of, filename, line);
305311 }
306 CDECL
312
313 SYMBOL_EXPORT CDECL
307314 void *gf_mem_realloc(void *ptr, size_t size, char *filename, int line)
308315 {
309316 return gf_mem_realloc_proto(ptr, size, filename, line);
310317 }
311 CDECL
318
319 SYMBOL_EXPORT CDECL
312320 void gf_mem_free(void *ptr, char *filename, int line)
313321 {
314322 gf_mem_free_proto(ptr, filename, line);
315323 }
316 CDECL
324
325 SYMBOL_EXPORT CDECL
317326 char *gf_mem_strdup(const char *str, char *filename, int line)
318327 {
319328 return gf_mem_strdup_proto(str, filename, line);
181181
182182 #define ZLIB_COMPRESS_SAFE 4
183183
184 GF_EXPORT
184185 GF_Err gf_gz_compress_payload(char **data, u32 data_len, u32 *max_size)
185186 {
186187 z_stream stream;
223224 return GF_OK;
224225 }
225226
227 GF_EXPORT
226228 GF_Err gf_gz_decompress_payload(char *data, u32 data_len, char **uncompressed_data, u32 *out_size)
227229 {
228230 z_stream d_stream;
845845
846846 static void gf_cmx_apply_argb(GF_ColorMatrix *_this, u8 *a_, u8 *r_, u8 *g_, u8 *b_);
847847
848 //#define COLORKEY_MPEG4_STRICT
849
848850 GF_EXPORT
849851 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)
850852 {
10441046 load_line_yuva(src->video_buffer, x_off, the_row, src->pitch_y, src_w, src->height, tmp);
10451047 }
10461048 the_row = src_row - 1;
1049
1050 if (cmat) {
1051 for (i=0; i<2*src_w; i++) {
1052 u32 idx = 4*i;
1053 gf_cmx_apply_argb(cmat, &tmp[idx+3], &tmp[idx], &tmp[idx+1], &tmp[idx+2]);
1054 }
1055 }
1056 if (key) {
1057 for (i=0; i<2*src_w; i++) {
1058 u32 idx = 4*i;
1059 s32 thres, v;
1060 v = tmp[idx]-kr; thres = ABS(v);
1061 v = tmp[idx+1]-kg; thres += ABS(v);
1062 v = tmp[idx+2]-kb; thres += ABS(v);
1063 thres/=3;
1064 #ifdef COLORKEY_MPEG4_STRICT
1065 if (thres < kl) tmp[idx+3] = 0;
1066 else if (thres <= kh) tmp[idx+3] = (thres-kl)*ka / (kh-kl);
1067 #else
1068 if (thres < kh) tmp[idx+3] = 0;
1069 #endif
1070 else tmp[idx+3] = ka;
1071 }
1072 }
10471073 }
10481074 rows = flip ? tmp : tmp + src_w * 4;
10491075 } else {
10701096 v = tmp[idx+1]-kg; thres += ABS(v);
10711097 v = tmp[idx+2]-kb; thres += ABS(v);
10721098 thres/=3;
1073 #if 0
1099 #ifdef COLORKEY_MPEG4_STRICT
10741100 if (thres < kl) tmp[idx+3] = 0;
10751101 else if (thres <= kh) tmp[idx+3] = (thres-kl)*ka / (kh-kl);
10761102 #else
10981124 v = tmp[idx+1]-kg; thres += ABS(v);
10991125 v = tmp[idx+2]-kb; thres += ABS(v);
11001126 thres/=3;
1101 #if 0
1127 #ifdef COLORKEY_MPEG4_STRICT
11021128 if (thres < kl) tmp[idx+3] = 0;
11031129 else if (thres <= kh) tmp[idx+3] = (thres-kl)*ka / (kh-kl);
11041130 #else
585585 GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[CACHE] Cannot find URL %s, cache file won't be deleted.\n", url));
586586 }
587587
588 GF_EXPORT
588589 void gf_dm_delete_cached_file_entry_session(const GF_DownloadSession * sess, const char * url) {
589590 if (sess && sess->dm && url) {
590591 GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[CACHE] Requesting deletion for %s\n", url));
623624 gf_mx_v(sess->mx);
624625 }
625626
627 GF_EXPORT
626628 void gf_dm_sess_del(GF_DownloadSession *sess)
627629 {
628630 GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[Downloader] gf_dm_sess_del(%p)\n", sess ));
706708 return (sess->flags & GF_DOWNLOAD_SESSION_THREAD_DEAD) ? 1 : 0;
707709 }
708710
711 GF_EXPORT
709712 GF_Err gf_dm_sess_last_error(GF_DownloadSession *sess)
710713 {
711714 if (!sess) return GF_BAD_PARAM;
877880 return GF_OK;
878881 }
879882
883 GF_EXPORT
880884 GF_Err gf_dm_sess_setup_from_url(GF_DownloadSession *sess, const char *url)
881885 {
882886 Bool socket_changed = 0;
985989 }
986990
987991
992 GF_EXPORT
988993 GF_DownloadSession *gf_dm_sess_new_simple(GF_DownloadManager * dm, const char *url, u32 dl_flags,
989994 gf_dm_user_io user_io,
990995 void *usr_cbk,
10171022 return sess;
10181023 }
10191024
1025 GF_EXPORT
10201026 GF_DownloadSession *gf_dm_sess_new(GF_DownloadManager *dm, const char *url, u32 dl_flags,
10211027 gf_dm_user_io user_io,
10221028 void *usr_cbk,
12811287 return sess->cache_entry;
12821288 }
12831289
1284
1290 GF_EXPORT
12851291 const char *gf_dm_sess_mime_type(GF_DownloadSession *sess)
12861292 {
12871293 DownloadedCacheEntry entry;
12971303 return gf_cache_get_mime_type( sess->cache_entry );
12981304 }
12991305
1306 GF_EXPORT
13001307 GF_Err gf_dm_sess_set_range(GF_DownloadSession *sess, u64 start_range, u64 end_range)
13011308 {
13021309 if (!sess) return GF_BAD_PARAM;
13081315 return GF_OK;
13091316 }
13101317
1318 GF_EXPORT
13111319 GF_Err gf_dm_sess_process(GF_DownloadSession *sess)
13121320 {
13131321 Bool go;
14031411 }
14041412 #endif
14051413
1414
1415 GF_EXPORT
14061416 GF_DownloadManager *gf_dm_new(GF_Config *cfg)
14071417 {
14081418 const char *opt;
14731483 }
14741484 }
14751485
1486 GF_EXPORT
14761487 void gf_dm_del(GF_DownloadManager *dm)
14771488 {
14781489 if (!dm)
17331744 return gf_cache_get_content_length(sess->cache_entry) != 0;
17341745 }
17351746
1747 GF_EXPORT
17361748 void gf_dm_sess_abort(GF_DownloadSession * sess)
17371749 {
17381750 assert(sess);
26122624 }
26132625
26142626
2615 GF_Err gf_dm_wget(const char *url, const char *filename){
2627 GF_EXPORT
2628 GF_Err gf_dm_wget(const char *url, const char *filename)
2629 {
26162630 GF_Err e;
26172631 GF_DownloadManager * dm = NULL;
26182632 dm = gf_dm_new(NULL);
26512665 return e;
26522666 }
26532667
2668 GF_EXPORT
26542669 GF_Err gf_dm_get_file_memory(const char *url, char **out_data, u32 *out_size, char **out_mime)
26552670 {
26562671 GF_Err e;
27082723 return e;
27092724 }
27102725
2726 GF_EXPORT
27112727 const char *gf_dm_sess_get_resource_name(GF_DownloadSession *dnload)
27122728 {
27132729 return dnload ? dnload->orig_url : NULL;
29052921 }
29062922 }
29072923
2924 GF_EXPORT
29082925 u32 gf_dm_get_data_rate(GF_DownloadManager *dm)
29092926 {
29102927 return dm->limit_data_rate;
479479 }
480480 }
481481
482 GF_EXPORT
482483 GF_Config *gf_cfg_init(const char *file, Bool *new_cfg)
483484 {
484485 GF_Config *cfg;
7474
7575
7676 #ifndef WIN32
77
78 GF_EXPORT
7779 u32 gf_sys_clock()
7880 {
7981 struct timeval now;
8385 #endif
8486
8587
88 GF_EXPORT
8689 void gf_sleep(u32 ms)
8790 {
8891 #ifdef WIN32
276279
277280 #endif
278281
282 GF_EXPORT
279283 GF_Err gf_delete_file(const char *fileName)
280284 {
281285 #if defined(_WIN32_WCE)
328332 #include <sys/stat.h>
329333 #endif
330334
335 GF_EXPORT
331336 u64 gf_file_modification_time(const char *filename)
332337 {
333338 #if defined(_WIN32_WCE)
361366 return 0;
362367 }
363368
369 GF_EXPORT
364370 FILE *gf_temp_file_new()
365371 {
366372 #if defined(_WIN32_WCE)
388394 #endif
389395 }
390396
391
397 GF_EXPORT
392398 void gf_utc_time_since_1970(u32 *sec, u32 *msec)
393399 {
394400 #if defined (WIN32) && !defined(_WIN32_WCE)
429435
430436
431437 /*enumerate directories*/
438 GF_EXPORT
432439 GF_Err gf_enum_directory(const char *dir, Bool enum_directory, gf_enum_dir_item enum_dir_fct, void *cbck, const char *filter)
433440 {
434441 char item_path[GF_MAX_PATH];
636643
637644
638645 #ifndef WIN32
646 GF_EXPORT
639647 char * my_str_upr(char *str)
640648 {
641649 u32 i;
644652 }
645653 return str;
646654 }
655
656 GF_EXPORT
647657 char * my_str_lwr(char *str)
648658 {
649659 u32 i;
654664 }
655665 #endif
656666
667 GF_EXPORT
657668 u64 gf_f64_tell(FILE *fp)
658669 {
659670 #if defined(_WIN32_WCE)
671682 #endif
672683 }
673684
685 GF_EXPORT
674686 u64 gf_f64_seek(FILE *fp, s64 offset, s32 whence)
675687 {
676688 #if defined(_WIN32_WCE)
688700 #endif
689701 }
690702
703 GF_EXPORT
691704 FILE *gf_f64_open(const char *file_name, const char *mode)
692705 {
693706 #if defined(WIN32)
704717 #if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! defined(_GNU_SOURCE)
705718 #define HAVE_STRERROR_R 1
706719 #endif
720
721 GF_EXPORT
707722 size_t gf_fwrite(const void *ptr, size_t size, size_t nmemb,
708723 FILE *stream)
709724 {
758773 {
759774 return kbhit();
760775 }
776
761777 char gf_prompt_get_char()
762778 {
763779 return getchar();
764780 }
781
765782 void gf_prompt_set_echo_off(Bool echo_off)
766783 {
767784 DWORD flags;
808825 close_keyboard(0);
809826 }
810827
828 GF_EXPORT
811829 Bool gf_prompt_has_input()
812830 {
813831 u8 ch;
828846 return 0;
829847 }
830848
849 GF_EXPORT
831850 char gf_prompt_get_char()
832851 {
833852 char ch;
9971016
9981017 static u64 memory_at_gpac_startup = 0;
9991018
1019 GF_EXPORT
10001020 void gf_sys_init(Bool enable_memory_tracker)
10011021 {
10021022 if (!sys_init) {
10921112 }
10931113 }
10941114
1115 GF_EXPORT
10951116 void gf_sys_close()
10961117 {
10971118 if (sys_init > 0) {
13911412 #include <mach/shared_memory_server.h>
13921413 #endif
13931414 #include <mach/mach_error.h>
1394
1415
13951416 static u64 total_physical_memory = 0;
1396
1417
13971418 Bool gf_sys_get_rti_os(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags)
13981419 {
13991420 size_t length;
16741695
16751696 #endif
16761697
1677
1698 GF_EXPORT
16781699 Bool gf_sys_get_rti(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags)
16791700 {
16801701 Bool res = gf_sys_get_rti_os(refresh_time_ms, rti, flags);
17001721 }
17011722
17021723
1703
1704
1724 GF_EXPORT
17051725 Bool gf_sys_get_battery_state(Bool *onBattery, u32 *onCharge, u32*level, u32 *batteryLifeTime, u32 *batteryFullLifeTime)
17061726 {
17071727 #if defined(_WIN32_WCE)
18281848 };
18291849 #endif
18301850
1831
1851 GF_EXPORT
18321852 GF_GlobalLock * gf_global_resource_lock(const char * resourceName){
18331853 #ifdef WIN32
18341854 #ifdef _WIN32_WCE
18751895 * \param lock The resource to unlock
18761896 * \return GF_OK if evertything went fine
18771897 */
1898 GF_EXPORT
18781899 GF_Err gf_global_resource_unlock(GF_GlobalLock * lock){
18791900 if (!lock)
18801901 return GF_BAD_PARAM;
333333 inst->interfaces = gf_list_new();
334334 inst->plugman = pm;
335335 inst->name = gf_strdup("gm_gpac_js.dylib");
336 gf_list_add(pm->plug_list, inst);
336337 }
337338 {
338339 ModuleInstance *inst;
402403 gf_enum_directory(pm->dir, 0, enum_modules, pm, ".dylib");
403404 #endif
404405 #else
405 GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("Refreshing list of modules in directory %s...\n", pm->dir));
406 GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("Refreshing list of modules in directory %s...\n", pm->dir));
406407 gf_enum_directory(pm->dir, 0, enum_modules, pm, ".so");
407408 #endif
408409
306306 #endif
307307
308308
309 GF_EXPORT
309310 GF_Err gf_sk_get_host_name(char *buffer)
310311 {
311312 s32 ret = gethostname(buffer, GF_MAX_IP_NAME_LEN);
345346 }
346347
347348
349 GF_EXPORT
348350 GF_Socket *gf_sk_new(u32 SocketType)
349351 {
350352 GF_Socket *tmp;
373375 return tmp;
374376 }
375377
378 GF_EXPORT
376379 GF_Err gf_sk_set_buffer_size(GF_Socket *sock, Bool SendBuffer, u32 NewSize)
377380 {
378381 if (!sock || !sock->socket) return GF_BAD_PARAM;
385388 return GF_OK;
386389 }
387390
391 GF_EXPORT
388392 GF_Err gf_sk_set_block_mode(GF_Socket *sock, u32 NonBlockingOn)
389393 {
390394 s32 res;
446450 }
447451
448452
453 GF_EXPORT
449454 void gf_sk_del(GF_Socket *sock)
450455 {
451456 assert( sock );
601606
602607 //binds the given socket to the specified port. If ReUse is true
603608 //this will enable reuse of ports on a single machine
609 GF_EXPORT
604610 GF_Err gf_sk_bind(GF_Socket *sock, const char *local_ip, u16 port, const char *peer_name, u16 peer_port, u32 options)
605611 {
606612 #ifdef GPAC_HAS_IPV6
803809 }
804810
805811 //send length bytes of a buffer
812 GF_EXPORT
806813 GF_Err gf_sk_send(GF_Socket *sock, const char *buffer, u32 length)
807814 {
808815 u32 count;
865872 }
866873
867874
875 GF_EXPORT
868876 u32 gf_sk_is_multicast_address(const char *multi_IPAdd)
869877 {
870878 #ifdef GPAC_HAS_IPV6
893901 #endif
894902 }
895903
904 GF_EXPORT
896905 GF_Err gf_sk_setup_multicast(GF_Socket *sock, const char *multi_IPAdd, u16 MultiPortNumber, u32 TTL, Bool NoBind, char *local_interface_ip)
897906 {
898907 s32 ret;
10781087 //fetch nb bytes on a socket and fill the buffer from startFrom
10791088 //length is the allocated size of the receiving buffer
10801089 //BytesRead is the number of bytes read from the network
1090 GF_EXPORT
10811091 GF_Err gf_sk_receive(GF_Socket *sock, char *buffer, u32 length, u32 startFrom, u32 *BytesRead)
10821092 {
10831093 s32 res;
102102 #endif
103103
104104
105 GF_EXPORT
105106 GF_Thread *gf_th_new(const char *name)
106107 {
107108 GF_Thread *tmp = gf_malloc(sizeof(GF_Thread));
212213 #endif
213214 }
214215
216 GF_EXPORT
215217 GF_Err gf_th_run(GF_Thread *t, u32 (*Run)(void *param), void *param)
216218 {
217219 #ifdef WIN32
285287 Thread_Stop(t, 0);
286288 }
287289
290 GF_EXPORT
288291 void gf_th_del(GF_Thread *t)
289292 {
290293 Thread_Stop(t, 0);
371374 }
372375
373376
377 GF_EXPORT
374378 u32 gf_th_id()
375379 {
376380 #ifdef WIN32
400404 };
401405
402406
407 GF_EXPORT
403408 GF_Mutex *gf_mx_new(const char *name)
404409 {
405410 #ifndef WIN32
435440 return tmp;
436441 }
437442
443 GF_EXPORT
438444 void gf_mx_del(GF_Mutex *mx)
439445 {
440446 #ifdef WIN32
455461 gf_free(mx);
456462 }
457463
464 GF_EXPORT
458465 void gf_mx_v(GF_Mutex *mx)
459466 {
460467 u32 caller;
487494 }
488495 }
489496
497 GF_EXPORT
490498 u32 gf_mx_p(GF_Mutex *mx)
491499 {
492500 #ifndef WIN32
545553 return -1;
546554 }
547555
556 GF_EXPORT
548557 Bool gf_mx_try_lock(GF_Mutex *mx)
549558 {
550559 u32 caller;
600609 #endif
601610 };
602611
603
612 GF_EXPORT
604613 GF_Semaphore *gf_sema_new(u32 MaxCount, u32 InitCount)
605614 {
606615 GF_Semaphore *tmp = gf_malloc(sizeof(GF_Semaphore));
643652 return tmp;
644653 }
645654
655 GF_EXPORT
646656 void gf_sema_del(GF_Semaphore *sm)
647657 {
648658 #if defined(WIN32)
659669 gf_free(sm);
660670 }
661671
672 GF_EXPORT
662673 u32 gf_sema_notify(GF_Semaphore *sm, u32 NbRelease)
663674 {
664675 u32 prevCount;
701712 #endif
702713 }
703714
715 GF_EXPORT
704716 Bool gf_sema_wait_for(GF_Semaphore *sm, u32 TimeOut)
705717 {
706718 #ifdef WIN32
2222 */
2323 #include <gpac/ringbuffer.h>
2424
25 GF_EXPORT
2526 GF_Ringbuffer * gf_ringbuffer_new(u32 sz)
2627 {
2728 GF_Ringbuffer *rb;
3940 return rb;
4041 }
4142
43 GF_EXPORT
4244 void gf_ringbuffer_del(GF_Ringbuffer * ringbuffer){
4345 if (!ringbuffer)
4446 return;
7072 }
7173 }
7274
75 GF_EXPORT
7376 u32 gf_ringbuffer_available_for_read (GF_Ringbuffer * rb)
7477 {
7578 size_t w, r;
8487 }
8588 }
8689
90 GF_EXPORT
8791 u32 gf_ringbuffer_read(GF_Ringbuffer *rb, u8 *dest, u32 szDest)
8892 {
8993 u32 free_sz, sz2, to_read, n1, n2;
117121 return to_read;
118122 }
119123
124 GF_EXPORT
120125 u32 gf_ringbuffer_write (GF_Ringbuffer * rb, const u8 *src, u32 sz)
121126 {
122127 u32 free_sz, sz2, to_write, n1, n2;
3434 Internet Society.
3535 */
3636
37 u32
38 utf8_to_ucs4(u32 * ucs4_buf, u32 utf8_len, unsigned char *utf8_buf)
37 GF_EXPORT
38 u32 utf8_to_ucs4(u32 * ucs4_buf, u32 utf8_len, unsigned char *utf8_buf)
3939 {
4040 const unsigned char *utf8_endbuf = utf8_buf + utf8_len;
4141 u32 ucs_len = 0;
8787 return gf_strdup(pathName);
8888 }
8989
90
90 GF_EXPORT
9191 char *gf_url_concatenate(const char *parentName, const char *pathName)
9292 {
9393 u32 pathSepCount, i, prot_type;