int mpeg3_generate_toc_for_Squeak(mpeg3_t *file, int timecode_search, int print_streams, char *buffer, int bufferSize) {
	mpeg3_demuxer_t *demuxer;
	int i;
	char temp_buffer[256];
	if(file)
	{
		buffer[0] = 0x00;
		demuxer = mpeg3_new_demuxer(file, 0, 0, -1);
		mpeg3demux_create_title_for_Squeak(demuxer, timecode_search, buffer, bufferSize);
/* Just print the first title's streams */
		if(print_streams) mpeg3demux_print_streams_for_Squeak(demuxer, buffer,bufferSize);

		sprintf(temp_buffer, "SIZE: %ld\n", demuxer->titles[demuxer->current_title]->total_bytes);
		appendStringToBufferIfPossible(buffer,temp_buffer,bufferSize);		
		sprintf(temp_buffer, "PACKETSIZE: %ld\n", demuxer->packet_size);
		appendStringToBufferIfPossible(buffer,temp_buffer,bufferSize);		

		mpeg3demux_print_timecodes(demuxer->titles[demuxer->current_title], buffer);

		mpeg3_delete_demuxer(demuxer);
		return 0;
	}
	return 1;
}
Exemplo n.º 2
0
int mpeg3_generate_toc(FILE *output, char *path, int timecode_search, int print_streams)
{
	mpeg3_t *file = mpeg3_open(path);
	mpeg3_demuxer_t *demuxer;
	int i;

	if(file)
	{
		demuxer = mpeg3_new_demuxer(file, 0, 0, -1);
		if(file->is_ifo_file)
		{
			int i;
			mpeg3io_open_file(file->fs);
			mpeg3demux_read_ifo(file, demuxer, 1);
			mpeg3io_close_file(file->fs);

			for(i = 0; i < demuxer->total_titles; i++)
			{
				fprintf(output, "TOCVERSION %d\n", TOCVERSION);

				if(file->is_program_stream)
					fprintf(output, "PROGRAM_STREAM\n");
				else
				if(file->is_transport_stream)
					fprintf(output, "TRANSPORT_STREAM\n");

				fprintf(output, "PATH: %s\n"
					"SIZE: %ld\n"
					"PACKETSIZE: %ld\n",
					demuxer->titles[i]->fs->path,
					demuxer->titles[i]->total_bytes,
					file->packet_size);
				
/* Just print the first title's streams */
				if(i == 0)
					mpeg3demux_print_streams(demuxer, output);

				mpeg3demux_print_timecodes(demuxer->titles[i], output);
			}

			return 0;
		}
		else
		{
			char complete_path[MPEG3_STRLEN];
			mpeg3io_complete_path(complete_path, path);

			mpeg3demux_create_title(demuxer, timecode_search, output);

			fprintf(output, "TOCVERSION %d\n" 
				"PATH: %s\n", TOCVERSION, complete_path);

			if(file->is_program_stream)
				fprintf(output, "PROGRAM_STREAM\n");
			else
			if(file->is_transport_stream)
				fprintf(output, "TRANSPORT_STREAM\n");
			else
			if(file->is_video_stream)
				fprintf(output, "VIDEO_STREAM\n");
			else
			if(file->is_audio_stream)
				fprintf(output, "AUDIO_STREAM\n");

/* Just print the first title's streams */
			if(print_streams) mpeg3demux_print_streams(demuxer, output);

			if(file->is_transport_stream || file->is_program_stream)
			{
				fprintf(output, "SIZE: %ld\n", demuxer->titles[demuxer->current_title]->total_bytes);
				fprintf(output, "PACKETSIZE: %ld\n", file->packet_size);
			}

			mpeg3demux_print_timecodes(demuxer->titles[demuxer->current_title], output);
			return 0;
		}

		mpeg3_delete_demuxer(demuxer);
		mpeg3_close(file);
	}
	return 1;
}