Beispiel #1
0
static GF_Err VTT_ProcessData(GF_SceneDecoder *plug, const char *inBuffer, u32 inBufferLength,
                              u16 ES_ID, u32 stream_time, u32 mmlevel)
{
	GF_Err e = GF_OK;
	VTTDec *vttdec = (VTTDec *)plug->privateStack;
	if (!vttdec->has_rendering_script) return GF_BAD_PARAM;

	if (stream_time==(u32)-1) {
		/* TODO */
		return GF_OK;
	}

	switch (vttdec->oti) {
	case GPAC_OTI_PRIVATE_SCENE_VTT:
		/*full parsing*/
		if (vttdec->file_size) {
			/*init step*/
			if (!vttdec->use_progressive) {
				/*not done yet*/
				if (!vtt_check_download(vttdec)) return GF_OK;
				/* TODO: parse */
			} else {
				/* TODO: parse what you can */
			}
		}
		break;

	case GPAC_OTI_SCENE_VTT:
		/* TODO: try to parse a cue from the given string */
		break;

	case GPAC_OTI_SCENE_VTT_MP4:
	{
#ifndef GPAC_DISABLE_MEDIA_IMPORT
		char start[100], end[100];
		GF_List *cues;
		cues = gf_webvtt_parse_cues_from_data(inBuffer, inBufferLength, 0);
		gf_webvtt_js_removeCues(vttdec->sg->RootNode);
		if (gf_list_count(cues)) {
			while (gf_list_count(cues)) {
				GF_WebVTTCue *cue = (GF_WebVTTCue *)gf_list_get(cues, 0);
				gf_list_rem(cues, 0);
				sprintf(start, "%02d:%02d:%02d.%03d", cue->start.hour, cue->start.min, cue->start.sec, cue->start.ms);
				sprintf(end, "%02d:%02d:%02d.%03d", cue->end.hour, cue->end.min, cue->end.sec, cue->end.ms);
				gf_webvtt_js_addCue(vttdec->sg->RootNode, cue->id, start, end, cue->settings, cue->text);

				gf_webvtt_cue_del(cue);
			}
		}
		gf_list_del(cues);
#endif
	}
	break;

	default:
		return GF_BAD_PARAM;
	}

	return e;
}
Beispiel #2
0
GF_EXPORT
GF_List *gf_webvtt_parse_iso_cues(GF_ISOSample *iso_sample, u64 start)
{
	return gf_webvtt_parse_cues_from_data(iso_sample->data, iso_sample->dataLength, start);
}