Beispiel #1
0
Bool ISOR_CanHandleURL(GF_InputService *plug, const char *url)
{
    char *ext;
    if (!strnicmp(url, "rtsp://", 7)) return 0;
    ext = strrchr(url, '.');
    {
        u32 i;
        /* We don't start at 0 since first one is specific */
        for (i = 3 ; ISOR_MIME_TYPES[i]; i+=3)
            if (gf_term_check_extension(plug, ISOR_MIME_TYPES[i], ISOR_MIME_TYPES[i+1], ISOR_MIME_TYPES[i+2], ext))
                return 1;
    }

    if (ext && gf_isom_probe_file(url)) {
        gf_term_check_extension(plug, ISOR_MIME_TYPES[0], ext+1, ISOR_MIME_TYPES[2], ext);
        return 1;
    }
    return 0;
}
Beispiel #2
0
void gf_mse_source_buffer_append_arraybuffer(GF_HTML_SourceBuffer *sb, GF_HTML_ArrayBuffer *buffer)
{
	assert(sb->parser);
	gf_mse_source_buffer_set_update(sb, GF_TRUE);

	buffer->url = (char *)gf_malloc(256);
	sprintf(buffer->url, "gmem://%d@%p", buffer->length, buffer->data);
	buffer->reference_count++;
#ifndef GPAC_DISABLE_ISOM
	buffer->is_init = (gf_isom_probe_file(buffer->url) == 2 ? GF_TRUE : GF_FALSE);
#endif
	GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE] Appending segment %s to SourceBuffer %p\n", buffer->url, sb));

	gf_list_add(sb->input_buffer, buffer);
	/* Call the parser (asynchronously) and return */
	/* the updating attribute will be positioned back to 0 when the parser is done */
	{
		GF_Thread *t = gf_th_new(NULL);
		gf_list_add(sb->threads, t);
		gf_th_run(t, gf_mse_parse_segment, sb);
	}
}
Beispiel #3
0
int stream_file_rtp(int argc, char **argv) 
{
	GF_ISOMRTPStreamer *file_streamer;
	char *sdp_file = "session.sdp";
	char *ip_dest = "127.0.0.1";
	char *ifce_addr = NULL;
	char *inName = NULL;
	char *logs=NULL; 
	FILE *logfile=NULL;
	u16 port = 7000;
	u32 ttl = 1;
	Bool loop = 1;
	Bool mem_track = 0;
	Bool force_mpeg4 = 0;
	u32 path_mtu = 1450;
	u32 i;

	for (i = 1; i < (u32) argc ; i++) {
		char *arg = argv[i];

		if (arg[0] != '-') {
			if (inName) { fprintf(stderr, "Error - 2 input names specified, please check usage\n"); return 1; }
			inName = arg;
		}
		else if (!stricmp(arg, "-noloop")) loop = 0;
		else if (!stricmp(arg, "-mpeg4")) force_mpeg4 = 1;
		else if (!strnicmp(arg, "-port=", 6)) port = atoi(arg+6);
		else if (!strnicmp(arg, "-mtu=", 5)) path_mtu = atoi(arg+5);
		else if (!strnicmp(arg, "-dst=", 5)) ip_dest = arg+5;
		else if (!strnicmp(arg, "-ttl=", 5)) ttl = atoi(arg+5);
		else if (!strnicmp(arg, "-ifce=", 6)) ifce_addr = arg+6;
		else if (!strnicmp(arg, "-sdp=", 5)) sdp_file = arg+5;
		else if (!stricmp(arg, "-mem-track")) mem_track = 1;
		else if (!strnicmp(arg, "-logs=", 6)) logs = arg+6;
		else if (!strnicmp(arg, "-lf=", 4)) logfile = gf_f64_open(arg+4, "wt");
	}

	gf_sys_init(mem_track);
	if (logs) 
		gf_log_set_tools_levels(logs);
	else 
		gf_log_set_tool_level(GF_LOG_RTP, GF_LOG_INFO); //set to debug to have packet list
	if (logfile) {
		gf_log_set_callback(logfile, on_logs);
	}

	if (!gf_isom_probe_file(inName)) {
		fprintf(stderr, "File %s is not a valid ISO Media file and cannot be streamed\n", inName);
		if (logfile) fclose(logfile);
		gf_sys_close();
		return 1;
	}

	file_streamer = gf_isom_streamer_new(inName, ip_dest, port, loop, force_mpeg4, path_mtu, ttl, ifce_addr);
	if (!file_streamer) {
		fprintf(stderr, "Cannot create file streamer\n");
	} else {
		u32 check = 50;
		fprintf(stderr, "Starting streaming %s to %s:%d\n", inName, ip_dest, port);
		gf_isom_streamer_write_sdp(file_streamer, sdp_file);

		while (1) {
			gf_isom_streamer_send_next_packet(file_streamer, 0, 0);
			check--;
			if (!check) {
				if (gf_prompt_has_input()) {
					char c = (char) gf_prompt_get_char(); 
					if (c=='q') break;
				}
				check = 50;
			}
		}
		gf_isom_streamer_del(file_streamer);
	}
	if (logfile) fclose(logfile);
	gf_sys_close();
	return 0;
}