From 1f70b6d5efecc2797620bc00b62ff6f84c3400d7 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Fri, 20 Apr 2012 12:26:10 +0200 Subject: [PATCH] Imported Upstream version 0.4.5+svn4019~dfsg0 --- applications/mp4box/filedump.c | 58 +++++++++++---- applications/mp4box/fileimport.c | 5 +- applications/mp4box/main.c | 4 +- configure | 2 +- include/gpac/internal/isomedia_dev.h | 15 ++++ modules/dx_hw/dx_video.c | 4 +- modules/platinum/GPACPlatinum.cpp | 2 +- modules/platinum/GenericDevice.cpp | 34 +++++---- modules/platinum/GenericDevice.h | 6 +- modules/platinum/Makefile | 2 +- modules/sdl_out/video.c | 11 ++- regression_tests/bifs/bifs-misc-srt-import.bt | 1 + src/compositor/compositor.c | 4 +- src/compositor/texturing_gl.c | 9 +++ src/isomedia/box_code_base.c | 74 +++++++++++++++++++ src/isomedia/box_dump.c | 18 ++++- src/isomedia/box_funcs.c | 5 ++ src/isomedia/isom_read.c | 1 + src/scenegraph/dom_smjs.c | 6 +- src/scenegraph/vrml_smjs.c | 2 +- 20 files changed, 217 insertions(+), 46 deletions(-) diff --git a/applications/mp4box/filedump.c b/applications/mp4box/filedump.c index de2b4a0..9f14702 100644 --- a/applications/mp4box/filedump.c +++ b/applications/mp4box/filedump.c @@ -1844,6 +1844,10 @@ typedef struct u64 last_SAP_PTS; u32 last_SAP_offset; + /*Interpolated PCR value for the pcrb*/ + u64 interpolated_pcr_value; + u64 last_pcr_value; + /* information about the first PAT found in the subsegment */ u32 last_pat_position; u32 first_pat_position; @@ -1873,6 +1877,9 @@ typedef struct //GF_List *sidxs; GF_SegmentIndexBox *sidx; + + //GF_List *pcrbs; + GF_PcrInfoBox *pcrb; } GF_M2TS_IndexingInfo; typedef struct @@ -1929,6 +1936,14 @@ static void m2ts_sidx_add_entry(GF_SegmentIndexBox *sidx, Bool ref_type, ref->SAP_delta_time = (sap_type ? RAP_delta_time: 0); } +static void m2ts_pcrb_add_entry(GF_PcrInfoBox *pcrb, u64 interpolatedPCR) +{ + pcrb->subsegment_count++; + pcrb->pcr_values = gf_realloc(pcrb->pcr_values, pcrb->subsegment_count*sizeof(u64)); + + pcrb->pcr_values[pcrb->subsegment_count-1] = interpolatedPCR; +} + static void m2ts_sidx_update_prev_entry_duration(GF_SegmentIndexBox *sidx, u32 duration) { GF_SIDXReference *ref; @@ -1960,6 +1975,10 @@ static void m2ts_sidx_flush_entry(GF_M2TS_IndexingInfo *index_info) GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("Segment: Reference PID: %d, EPTime: "LLU", Start Offset: %d bytes\n", index_info->reference_pid, index_info->base_PTS, index_info->base_offset)); index_info->sidx = m2ts_sidx_new(index_info->reference_pid, index_info->base_PTS, index_info->base_offset); } + + if (!index_info->pcrb) { + index_info->pcrb = (GF_PcrInfoBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_PCRB); + } /* determine the end of the current index */ if (index_info->segment_at_rap) { @@ -1976,6 +1995,7 @@ static void m2ts_sidx_flush_entry(GF_M2TS_IndexingInfo *index_info) SAP_delta_time= (u32)(index_info->first_SAP_PTS - index_info->base_PTS); SAP_offset = (u32)(index_info->first_SAP_offset - index_info->base_offset); m2ts_sidx_add_entry(index_info->sidx, 0, size, duration, index_info->first_pes_sap, index_info->SAP_type, SAP_delta_time); + m2ts_pcrb_add_entry(index_info->pcrb, index_info->interpolated_pcr_value); /* adjust the previous index duration */ if (index_info->sidx->nb_refs > 0 && (index_info->base_PTS < index_info->prev_last_PTS) ) { @@ -2260,19 +2280,23 @@ static void on_m2ts_dump_event(GF_M2TS_Demuxer *ts, u32 evt_type, void *par) if (gf_list_count(ts->programs)>1 && pck->stream->program->number != dumper->prog_number) break; if (dumper->has_seen_pat) { - if (dumper->timestamps_info_file) { - GF_M2TS_PES *pes = pck->stream; - /*FIXME : not used GF_M2TS_Program *prog = pes->program; */ - /* Interpolated PCR value for the TS packet containing the PES header start */ - u64 interpolated_pcr_value = 0; - if (pes->last_pcr_value && pes->before_last_pcr_value && pes->last_pcr_value > pes->before_last_pcr_value) { - u32 delta_pcr_pck_num = pes->last_pcr_value_pck_number - pes->before_last_pcr_value_pck_number; - u32 delta_pts_pcr_pck_num = pes->pes_start_packet_number - pes->last_pcr_value_pck_number; - u64 delta_pcr_value = pes->last_pcr_value - pes->before_last_pcr_value; - /* we can compute the interpolated pcr value for the packet containing the PES header */ - interpolated_pcr_value = pes->last_pcr_value + (u64)((delta_pcr_value*delta_pts_pcr_pck_num*1.0)/delta_pcr_pck_num); - } + /*We need the interpolated PCR for the pcrb, hence moved this calculus out, and saving the calculated value in index_info to put it in the pcrb*/ + GF_M2TS_PES *pes = pck->stream; + /*FIXME : not used GF_M2TS_Program *prog = pes->program; */ + /* Interpolated PCR value for the TS packet containing the PES header start */ + u64 interpolated_pcr_value = 0; + if (pes->last_pcr_value && pes->before_last_pcr_value && pes->last_pcr_value > pes->before_last_pcr_value) { + u32 delta_pcr_pck_num = pes->last_pcr_value_pck_number - pes->before_last_pcr_value_pck_number; + u32 delta_pts_pcr_pck_num = pes->pes_start_packet_number - pes->last_pcr_value_pck_number; + u64 delta_pcr_value = pes->last_pcr_value - pes->before_last_pcr_value; + /* we can compute the interpolated pcr value for the packet containing the PES header */ + interpolated_pcr_value = pes->last_pcr_value + (u64)((delta_pcr_value*delta_pts_pcr_pck_num*1.0)/delta_pcr_pck_num); + index_info->interpolated_pcr_value = interpolated_pcr_value; + index_info->last_pcr_value = pes->last_pcr_value; + } + + if (dumper->timestamps_info_file) { fprintf(dumper->timestamps_info_file, "%u\t%d\t", pck->stream->pes_start_packet_number, pck->stream->pid); if (interpolated_pcr_value) fprintf(dumper->timestamps_info_file, "%f", interpolated_pcr_value/(300.0 * 90000)); fprintf(dumper->timestamps_info_file, "\t"); @@ -2629,7 +2653,7 @@ void dump_mpeg2_ts(char *mpeg2ts_file, char *out_name, Bool prog_num, dumper.index_info.index_bs = gf_bs_from_file(dumper.index_info.index_file, GF_BITSTREAM_WRITE); { GF_SegmentTypeBox *styp = (GF_SegmentTypeBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_STYP); - styp->majorBrand = GF_4CC('s','i','s','x'); + styp->majorBrand = GF_4CC('r','i','s','x'); styp->minorVersion = 0; styp->altBrand = (u32*)gf_malloc(sizeof(u32)); styp->altBrand[0] = styp->majorBrand; @@ -2747,6 +2771,14 @@ void dump_mpeg2_ts(char *mpeg2ts_file, char *out_name, Bool prog_num, gf_isom_box_size((GF_Box *)dumper.index_info.sidx); if (dumper.index_info.index_bs) gf_isom_box_write((GF_Box *)dumper.index_info.sidx, dumper.index_info.index_bs); gf_isom_box_del((GF_Box *)dumper.index_info.sidx); + } + + // ToDo: Should be configurable by some switch + if (dumper.index_info.pcrb) { + gf_isom_box_size((GF_Box *)dumper.index_info.pcrb); + if (dumper.index_info.index_bs) gf_isom_box_write((GF_Box *)dumper.index_info.pcrb, dumper.index_info.index_bs); + gf_isom_box_del((GF_Box *)dumper.index_info.pcrb); + } if (dumper.index_info.mpd_file) fclose(dumper.index_info.mpd_file); if (dumper.index_info.index_file) fclose(dumper.index_info.index_file); diff --git a/applications/mp4box/fileimport.c b/applications/mp4box/fileimport.c index 4d2b77b..0745ed8 100644 --- a/applications/mp4box/fileimport.c +++ b/applications/mp4box/fileimport.c @@ -558,7 +558,7 @@ typedef struct u32 stop_state; } TKInfo; -GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, char *inName, Double InterleavingTime, Double chunk_start_time, Bool adjust_split_end, const char *tmpdir) +GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, char *inName, Double InterleavingTime, Double chunk_start_time, Bool adjust_split_end, char *outName, const char *tmpdir) { u32 i, count, nb_tk, needs_rap_sync, cur_file, conv_type, nb_tk_done, nb_samp, nb_done, di; Double max_dur, cur_file_time; @@ -764,6 +764,7 @@ GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, if (chunk_extraction) { sprintf(szFile, "%s_%d_%d%s", szName, (u32) chunk_start, (u32) (chunk_start+split_dur), ext); + if (outName) strcpy(szFile, outName); } else { sprintf(szFile, "%s_%03d%s", szName, cur_file+1, ext); } @@ -1038,7 +1039,7 @@ GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, } if (chunk_extraction) { - fprintf(stdout, "Extracting chunk %s - duration %02.2f seconds\n", szFile, file_split_dur); + fprintf(stdout, "Extracting chunk %s - duration %02.2fs (%02.2fs->%02.2fs)\n", szFile, file_split_dur, chunk_start, (chunk_start+split_dur)); } else { fprintf(stdout, "Storing split-file %s - duration %02.2f seconds\n", szFile, file_split_dur); } diff --git a/applications/mp4box/main.c b/applications/mp4box/main.c index 270fbc2..fc806c5 100644 --- a/applications/mp4box/main.c +++ b/applications/mp4box/main.c @@ -48,7 +48,7 @@ #ifndef GPAC_DISABLE_ISOM_WRITE GF_Err import_file(GF_ISOFile *dest, char *inName, u32 import_flags, Double force_fps, u32 frames_per_sample); -GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, char *inName, Double InterleavingTime, Double chunk_start, Bool adjust_split_end, const char *tmpdir); +GF_Err split_isomedia_file(GF_ISOFile *mp4, Double split_dur, u32 split_size_kb, char *inName, Double InterleavingTime, Double chunk_start, Bool adjust_split_end, char *outName, const char *tmpdir); GF_Err cat_isomedia_file(GF_ISOFile *mp4, char *fileName, u32 import_flags, Double force_fps, u32 frames_per_sample, char *tmp_dir, Bool force_cat); #if !defined(GPAC_DISABLE_MEDIA_IMPORT) && !defined(GPAC_DISABLE_SCENE_ENCODER) @@ -2654,7 +2654,7 @@ int mp4boxMain(int argc, char **argv) #if !(definedGPAC_DISABLE_ISOM_WRITE) && !defined(GPAC_DISABLE_MEDIA_IMPORT) if (split_duration || split_size) { - split_isomedia_file(file, split_duration, split_size, inName, InterleavingTime, split_start, adjust_split_end, tmpdir); + split_isomedia_file(file, split_duration, split_size, inName, InterleavingTime, split_start, adjust_split_end, outName, tmpdir); /*never save file when splitting is desired*/ open_edit = 0; needSave = 0; diff --git a/configure b/configure index 22c9fa6..ac610b7 100755 --- a/configure +++ b/configure @@ -2261,7 +2261,7 @@ if test "$linux" = "yes" ; then echo "DVB Support: $has_dvb4linux" fi -echo "XMLPRC Support: $has_xmlrpc" +echo "XMLRPC Support: $has_xmlrpc" if test "$wx_too_old" = "yes" ; then has_wx="no" diff --git a/include/gpac/internal/isomedia_dev.h b/include/gpac/internal/isomedia_dev.h index 4050327..4950165 100644 --- a/include/gpac/internal/isomedia_dev.h +++ b/include/gpac/internal/isomedia_dev.h @@ -189,6 +189,7 @@ enum GF_ISOM_BOX_TYPE_STYP = GF_4CC( 's', 't', 'y', 'p' ), GF_ISOM_BOX_TYPE_TFDT = GF_4CC( 't', 'f', 'd', 't' ), GF_ISOM_BOX_TYPE_SIDX = GF_4CC( 's', 'i', 'd', 'x' ), + GF_ISOM_BOX_TYPE_PCRB = GF_4CC( 'p', 'c', 'r', 'b' ), /*3GPP text / MPEG-4 StreamingText*/ GF_ISOM_BOX_TYPE_FTAB = GF_4CC( 'f', 't', 'a', 'b' ), @@ -1888,6 +1889,13 @@ typedef struct __sidx_box GF_SIDXReference *refs; } GF_SegmentIndexBox; +typedef struct __pcrInfo_box +{ + GF_ISOM_BOX + u32 subsegment_count; + u64 *pcr_values; +} GF_PcrInfoBox; + /*********************************************************** @@ -3415,6 +3423,13 @@ GF_Err sidx_Write(GF_Box *s, GF_BitStream *bs); GF_Err sidx_Size(GF_Box *s); GF_Err sidx_dump(GF_Box *a, FILE * trace); +GF_Box *pcrb_New(); +void pcrb_del(GF_Box *s); +GF_Err pcrb_Read(GF_Box *s, GF_BitStream *bs); +GF_Err pcrb_Write(GF_Box *s, GF_BitStream *bs); +GF_Err pcrb_Size(GF_Box *s); +GF_Err pcrb_dump(GF_Box *a, FILE * trace); + GF_Box *subs_New(); void subs_del(GF_Box *); GF_Err subs_Write(GF_Box *s, GF_BitStream *bs); diff --git a/modules/dx_hw/dx_video.c b/modules/dx_hw/dx_video.c index ee119d6..7f9b190 100644 --- a/modules/dx_hw/dx_video.c +++ b/modules/dx_hw/dx_video.c @@ -540,9 +540,9 @@ static GF_Err DD_SetFullScreen(GF_VideoOutput *dr, Bool bOn, u32 *outWidth, u32 { if (!dd->fullscreen && (dd->os_hwnd==dd->fs_hwnd)) { - SetWindowPos(dd->os_hwnd, NULL, 0, 0, dd->width+dd->off_w, dd->height+dd->off_h, SWP_NOZORDER | SWP_NOMOVE | SWP_ASYNCWINDOWPOS); + SetWindowPos(dd->os_hwnd, NULL, 0, 0, dd->store_width+dd->off_w, dd->store_height+dd->off_h, SWP_NOZORDER | SWP_NOMOVE | SWP_ASYNCWINDOWPOS); } - e = InitDirectDraw(dr, dd->width, dd->height); + e = InitDirectDraw(dr, dd->store_width, dd->store_height); } if (bOn) { diff --git a/modules/platinum/GPACPlatinum.cpp b/modules/platinum/GPACPlatinum.cpp index 667d00e..0ad6076 100644 --- a/modules/platinum/GPACPlatinum.cpp +++ b/modules/platinum/GPACPlatinum.cpp @@ -1585,7 +1585,7 @@ static Bool upnp_process(GF_TermExt *termext, u32 action, void *param) count = gf_list_count(upnp->m_Devices); for (i=0; im_Devices, i); - if (device->run_proc) { + if (!JSVAL_IS_NULL(device->run_proc)) { if (!arg_set) { argv[0] = DOUBLE_TO_JSVAL( JS_NewDouble(upnp->m_pJSCtx, (Double)now / 1000.0) ); arg_set = 1; diff --git a/modules/platinum/GenericDevice.cpp b/modules/platinum/GenericDevice.cpp index bb32dcc..514c27d 100644 --- a/modules/platinum/GenericDevice.cpp +++ b/modules/platinum/GenericDevice.cpp @@ -39,7 +39,7 @@ GPAC_ServiceItem::GPAC_ServiceItem(GPAC_DeviceItem *device, PLT_Service *service { #ifdef GPAC_HAS_SPIDERMONKEY obj = NULL; - on_event = 0; + on_event = JSVAL_NULL; m_StateListeners = gf_list_new(); m_ArgListeners = gf_list_new(); subscribed = 0; @@ -64,9 +64,9 @@ void GPAC_ServiceItem::DetachJS() JS_SetPrivate(js_ctx, obj, NULL); obj = NULL; } - if (on_event) { + if (!JSVAL_IS_NULL(on_event)) { gf_js_remove_root(js_ctx, &on_event, GF_JSGC_VAL); - on_event = NULL; + on_event = JSVAL_NULL; } while (gf_list_count(m_StateListeners)) { GPAC_StateVariableListener *svl = (GPAC_StateVariableListener *)gf_list_get(m_StateListeners, 0); @@ -129,8 +129,9 @@ static JSBool SMJS_FUNCTION(upnp_service_set_listener) if (!service || !argc || !JSVAL_IS_OBJECT(argv[0])) return JS_FALSE; if (argc<1) { - if (service->on_event) gf_js_remove_root(c, &service->on_event, GF_JSGC_VAL); - service->on_event = NULL; + if (!JSVAL_IS_NULL(service->on_event)) + gf_js_remove_root(c, &service->on_event, GF_JSGC_VAL); + service->on_event = JSVAL_NULL; if (!JSVAL_IS_NULL(argv[0])) { service->on_event = argv[0]; gf_js_add_root(c, &service->on_event, GF_JSGC_VAL); @@ -156,7 +157,8 @@ static JSBool SMJS_FUNCTION(upnp_service_set_listener) svl->var = service->m_service->FindStateVariable(name); gf_list_add(service->m_StateListeners, svl); } - if (svl->on_event) gf_js_remove_root(c, &svl->on_event, GF_JSGC_VAL); + if (!JSVAL_IS_NULL(svl->on_event)) + gf_js_remove_root(c, &svl->on_event, GF_JSGC_VAL); if (JSVAL_IS_NULL(argv[0])) { gf_list_del_item(service->m_StateListeners, svl); delete svl; @@ -220,7 +222,8 @@ static JSBool SMJS_FUNCTION(upnp_service_set_action_listener) gf_list_add(service->m_ArgListeners, argl); } argl->action = action; - if (argl->on_event) gf_js_remove_root(c, &argl->on_event, GF_JSGC_VAL); + if (!JSVAL_IS_NULL(argl->on_event)) + gf_js_remove_root(c, &argl->on_event, GF_JSGC_VAL); if (JSVAL_IS_NULL(argv[1])) { gf_list_del_item(service->m_ArgListeners, argl); delete argl; @@ -683,7 +686,7 @@ NPT_Result GPAC_GenericController::OnEventNotify(PLT_Service* service, NPT_List< } if (!serv) return NPT_SUCCESS; - if (serv->on_event) { + if (!JSVAL_IS_NULL(serv->on_event)) { jsval rval; m_pUPnP->LockJavascript(1); serv->vars = vars; @@ -794,12 +797,15 @@ GPAC_GenericDevice::~GPAC_GenericDevice() void GPAC_GenericDevice::DetachJS(JSContext *c) { u32 i, count; - if (obj) gf_js_remove_root(c, &obj, GF_JSGC_OBJECT); + if (obj) + gf_js_remove_root(c, &obj, GF_JSGC_OBJECT); obj = NULL; - if (run_proc) gf_js_remove_root(c, &run_proc, GF_JSGC_VAL); - run_proc = NULL; - if (act_proc) gf_js_remove_root(c, &act_proc, GF_JSGC_VAL); - act_proc = NULL; + if (!JSVAL_IS_NULL(run_proc)) + gf_js_remove_root(c, &run_proc, GF_JSGC_VAL); + run_proc = JSVAL_NULL; + if (!JSVAL_IS_NULL(act_proc)) + gf_js_remove_root(c, &act_proc, GF_JSGC_VAL); + act_proc = JSVAL_NULL; count = gf_list_count(m_pServices); for (i=0; ios_handle) SDLVid_SetCaption(); GF_LOG(GF_LOG_INFO, GF_LOG_MMIO, ("[SDL] Video output initialized - screen resolution %d %d\n", dr->max_screen_width, dr->max_screen_height)); return 1; @@ -1030,7 +1029,15 @@ static GF_Err SDLVid_ProcessEvent(GF_VideoOutput *dr, GF_Event *evt) which we don't want to do since the setup MUST occur in the rendering thread for some configs (openGL)*/ return GF_NOT_SUPPORTED; case GF_EVENT_SIZE: - SDLVid_ResizeWindow(dr, evt->size.width, evt->size.height); + { + SDLVID(); + if (ctx->fullscreen) { + ctx->store_width = evt->size.width; + ctx->store_height = evt->size.height; + } else { + SDLVid_ResizeWindow(dr, evt->size.width, evt->size.height); + } + } break; case GF_EVENT_MOVE: break; diff --git a/regression_tests/bifs/bifs-misc-srt-import.bt b/regression_tests/bifs/bifs-misc-srt-import.bt index b1d92ad..adecd67 100644 --- a/regression_tests/bifs/bifs-misc-srt-import.bt +++ b/regression_tests/bifs/bifs-misc-srt-import.bt @@ -62,6 +62,7 @@ AT 0 { ES_Descriptor { ES_ID 4 OCR_ES_ID 1 + dependsOn_ES_ID 1 muxInfo MuxInfo { fileName "../auxiliary_files/subtitle.srt" textNode "TXT" diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index bdb227c..19ca532 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -655,7 +655,8 @@ GF_Err gf_sc_set_scene_size(GF_Compositor *compositor, u32 Width, u32 Height, Bo compositor->scene_height = Height; compositor->scene_width = Width; } - if (force_size) compositor->has_size_info = 1; + if (force_size) + compositor->has_size_info = 1; return GF_OK; } @@ -990,7 +991,6 @@ GF_Err gf_sc_set_size(GF_Compositor *compositor, u32 NewWidth, u32 NewHeight) if ((compositor->display_width == NewWidth) && (compositor->display_height == NewHeight) ) { compositor->msg_type |= GF_SR_CFG_WINDOWSIZE_NOTIF; } - if (lock_ok) gf_sc_lock(compositor, 0); return GF_OK; diff --git a/src/compositor/texturing_gl.c b/src/compositor/texturing_gl.c index 49b036e..273df27 100644 --- a/src/compositor/texturing_gl.c +++ b/src/compositor/texturing_gl.c @@ -939,10 +939,19 @@ static Bool gf_sc_texture_enable_matte_texture(GF_Node *n) return 1; #else +/*To remove: gcc 4.6 introduces this warning*/ +#if __GNUC__ == 4 && __GNUC_MINOR__ == 6 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress" +#endif if (glActiveTexture==NULL) { tx_bind(b_surf); return 1; } +/*To remove: gcc 4.6 introduces this warning*/ +#if __GNUC__ == 4 && __GNUC_MINOR__ == 6 +#pragma GCC diagnostic pop +#endif matte_hdl = gf_node_get_private(n); if (!matte_hdl->tx_io) { gf_sc_texture_allocate(matte_hdl); diff --git a/src/isomedia/box_code_base.c b/src/isomedia/box_code_base.c index ab39b6d..33420b6 100644 --- a/src/isomedia/box_code_base.c +++ b/src/isomedia/box_code_base.c @@ -7859,6 +7859,80 @@ GF_Err sidx_Size(GF_Box *s) #endif /*GPAC_DISABLE_ISOM_WRITE*/ +GF_Box *pcrb_New() +{ + GF_PcrInfoBox *tmp; + + GF_SAFEALLOC(tmp, GF_PcrInfoBox); + if (tmp == NULL) return NULL; + tmp->type = GF_ISOM_BOX_TYPE_PCRB; + return (GF_Box *)tmp; +} + +void pcrb_del(GF_Box *s) +{ + GF_PcrInfoBox *ptr = (GF_PcrInfoBox *) s; + if (ptr == NULL) return; + if (ptr->pcr_values) gf_free(ptr->pcr_values); + gf_free(ptr); +} + +GF_Err pcrb_Read(GF_Box *s,GF_BitStream *bs) +{ + u32 i; + GF_PcrInfoBox *ptr = (GF_PcrInfoBox*) s; + + ptr->subsegment_count = gf_bs_read_u32(bs); + ptr->size -= 4; + + ptr->pcr_values = gf_malloc(sizeof(u64)*ptr->subsegment_count); + for (i=0; isubsegment_count; i++) { + u64 data1 = gf_bs_read_u32(bs); + u64 data2 = gf_bs_read_u32(bs); + ptr->size -= 8; + ptr->pcr_values[i] = (data1 << 10) | (data2 >> 22); + + } + return GF_OK; +} + +#ifndef GPAC_DISABLE_ISOM_WRITE + +GF_Err pcrb_Write(GF_Box *s, GF_BitStream *bs) +{ + GF_Err e; + u32 i; + GF_PcrInfoBox *ptr = (GF_PcrInfoBox*) s; + + e = gf_isom_box_write_header(s, bs); + if (e) return e; + + gf_bs_write_u32(bs, ptr->subsegment_count); + + for (i=0; isubsegment_count; i++ ) { + u32 data1 = (u32) (ptr->pcr_values[i] >> 10); + u32 data2 = (u32) ((ptr->pcr_values[i]& 0x3FF) << 22); + + gf_bs_write_u32(bs, data1); + gf_bs_write_u32(bs, data2); + } + return GF_OK; +} + +GF_Err pcrb_Size(GF_Box *s) +{ + GF_Err e; + GF_PcrInfoBox *ptr = (GF_PcrInfoBox*) s; + e = gf_isom_box_get_size(s); + if (e) return e; + + ptr->size += 4; + ptr->size += ptr->subsegment_count * 8; + + return GF_OK; +} + +#endif /*GPAC_DISABLE_ISOM_WRITE*/ GF_Box *subs_New() diff --git a/src/isomedia/box_dump.c b/src/isomedia/box_dump.c index 168cd0b..c59c602 100644 --- a/src/isomedia/box_dump.c +++ b/src/isomedia/box_dump.c @@ -431,6 +431,8 @@ GF_Err gf_box_dump(void *ptr, FILE * trace) return lsrc_dump(a, trace); case GF_ISOM_BOX_TYPE_SIDX: return sidx_dump(a, trace); + case GF_ISOM_BOX_TYPE_PCRB: + return pcrb_dump(a, trace); default: return defa_dump(a, trace); } @@ -455,7 +457,6 @@ GF_EXPORT GF_Err gf_isom_dump(GF_ISOFile *mov, FILE * trace) { GF_Err gf_box_dump(void *ptr, FILE * trace); - void BadTopBoxErr(GF_Box *a, FILE * trace); u32 i; GF_Box *box; if (!mov || !trace) return GF_BAD_PARAM; @@ -478,6 +479,7 @@ GF_Err gf_isom_dump(GF_ISOFile *mov, FILE * trace) case GF_ISOM_BOX_TYPE_MOOF: case GF_ISOM_BOX_TYPE_STYP: case GF_ISOM_BOX_TYPE_SIDX: + case GF_ISOM_BOX_TYPE_PCRB: #endif break; @@ -3519,6 +3521,20 @@ GF_Err sidx_dump(GF_Box *a, FILE * trace) return GF_OK; } +GF_Err pcrb_dump(GF_Box *a, FILE * trace) +{ + u32 i; + GF_PcrInfoBox *p = (GF_PcrInfoBox *)a; + fprintf(trace, "\n", p->subsegment_count); + DumpBox(a, trace); + + for (i=0; isubsegment_count; i++) { + fprintf(trace, "\n", p->pcr_values[i]); + } + fprintf(trace, "\n"); + return GF_OK; +} + GF_Err subs_dump(GF_Box *a, FILE * trace) { u32 entry_count, i, j; diff --git a/src/isomedia/box_funcs.c b/src/isomedia/box_funcs.c index bccc707..5af31e2 100644 --- a/src/isomedia/box_funcs.c +++ b/src/isomedia/box_funcs.c @@ -571,6 +571,7 @@ GF_Box *gf_isom_box_new(u32 boxType) case GF_ISOM_BOX_TYPE_SIDX: return sidx_New(); case GF_ISOM_BOX_TYPE_SUBS: return subs_New(); case GF_ISOM_BOX_TYPE_TFDT: return tfdt_New(); + case GF_ISOM_BOX_TYPE_PCRB: return pcrb_New(); #endif case GF_ISOM_BOX_TYPE_RVCC: return rvcc_New(); @@ -825,6 +826,7 @@ void gf_isom_box_del(GF_Box *a) case GF_ISOM_BOX_TYPE_LSR1: lsr1_del(a); return; case GF_ISOM_BOX_TYPE_SIDX: sidx_del(a); return; + case GF_ISOM_BOX_TYPE_PCRB: pcrb_del(a); return; case GF_ISOM_BOX_TYPE_SUBS: subs_del(a); return; case GF_ISOM_BOX_TYPE_RVCC: rvcc_del(a); return; @@ -1058,6 +1060,7 @@ GF_Err gf_isom_box_read(GF_Box *a, GF_BitStream *bs) case GF_ISOM_BOX_TYPE_SIDX: return sidx_Read(a, bs); case GF_ISOM_BOX_TYPE_SUBS: return subs_Read(a, bs); case GF_ISOM_BOX_TYPE_RVCC: return rvcc_Read(a, bs); + case GF_ISOM_BOX_TYPE_PCRB: return pcrb_Read(a, bs); default: return defa_Read(a, bs); @@ -1291,6 +1294,7 @@ GF_Err gf_isom_box_write(GF_Box *a, GF_BitStream *bs) case GF_ISOM_BOX_TYPE_LSR1: return lsr1_Write(a, bs); case GF_ISOM_BOX_TYPE_SIDX: return sidx_Write(a, bs); + case GF_ISOM_BOX_TYPE_PCRB: return pcrb_Write(a, bs); case GF_ISOM_BOX_TYPE_SUBS: return subs_Write(a, bs); case GF_ISOM_BOX_TYPE_RVCC: return rvcc_Write(a, bs); @@ -1524,6 +1528,7 @@ GF_Err gf_isom_box_size(GF_Box *a) case GF_ISOM_BOX_TYPE_LSR1: return lsr1_Size(a); case GF_ISOM_BOX_TYPE_SIDX: return sidx_Size(a); + case GF_ISOM_BOX_TYPE_PCRB: return pcrb_Size(a); case GF_ISOM_BOX_TYPE_SUBS: return subs_Size(a); case GF_ISOM_BOX_TYPE_RVCC: return rvcc_Size(a); diff --git a/src/isomedia/isom_read.c b/src/isomedia/isom_read.c index 737304b..94bc82d 100644 --- a/src/isomedia/isom_read.c +++ b/src/isomedia/isom_read.c @@ -107,6 +107,7 @@ Bool gf_isom_probe_file(const char *fileName) case GF_ISOM_BOX_TYPE_MDAT: case GF_ISOM_BOX_TYPE_FTYP: #ifndef GPAC_DISABLE_ISOM_FRAGMENTS + case GF_ISOM_BOX_TYPE_MOOF: case GF_ISOM_BOX_TYPE_STYP: #endif case GF_ISOM_BOX_TYPE_FREE: diff --git a/src/scenegraph/dom_smjs.c b/src/scenegraph/dom_smjs.c index 02a9bbd..5ff9594 100644 --- a/src/scenegraph/dom_smjs.c +++ b/src/scenegraph/dom_smjs.c @@ -3274,7 +3274,7 @@ static JSBool dcci_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, js GF_DOMFullNode *n; GF_DOM_Event evt; char *str; - jsval readonly=0; + jsval readonly=JSVAL_NULL; if (!JS_InstanceOf(c, obj, &dom_rt->DCCIClass, NULL) ) return JS_TRUE; n = (GF_DOMFullNode*) dom_get_node(c, obj); if (!n) return JS_TRUE; @@ -3545,6 +3545,10 @@ void dom_js_load(GF_SceneGraph *scene, JSContext *c, JSObject *global) {0, 0, 0, 0, 0} }; dom_rt->dom_node_proto = JS_InitClass(c, global, 0, &dom_rt->domNodeClass, 0, 0, nodeProps, nodeFuncs, 0, 0); + if (!dom_rt->dom_node_proto) { + GF_LOG(GF_LOG_ERROR, GF_LOG_SCRIPT, ("[DOMCore] Not enough memory to initialize JS node class\n")); + return; + } GF_LOG(GF_LOG_DEBUG, GF_LOG_SCRIPT, ("[DOMCore] node class initialized\n")); JS_DefineProperty(c, dom_rt->dom_node_proto, "ELEMENT_NODE", INT_TO_JSVAL(1), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT); diff --git a/src/scenegraph/vrml_smjs.c b/src/scenegraph/vrml_smjs.c index 8ef6f5e..f7d481c 100644 --- a/src/scenegraph/vrml_smjs.c +++ b/src/scenegraph/vrml_smjs.c @@ -302,7 +302,7 @@ void JS_ClearRuntimeThread(JSRuntime *jsr) #ifdef __SYMBIAN32__ const long MAX_HEAP_BYTES = 256 * 1024L; #else -const long MAX_HEAP_BYTES = 4*1024 * 1024L; +const long MAX_HEAP_BYTES = 32*1024*1024L; #endif const long STACK_CHUNK_BYTES = 8*1024L; -- 2.30.2