Example #1
0
quicktime_t* quicktime_open(char *filename, int rd, int wr)
{
	quicktime_t *new_file = calloc(1, sizeof(quicktime_t));
	int result = 0;

//printf("quicktime_open 1\n");
	quicktime_init(new_file);
	new_file->wr = wr;
	new_file->rd = rd;
	new_file->mdat.atom.start = 0;

	result = quicktime_file_open(new_file, filename, rd, wr);

	if(!result)
	{
		if(rd)
		{
			if(quicktime_read_info(new_file))
			{
				quicktime_close(new_file);
				fprintf(stderr, "quicktime_open: error in header\n");
				new_file = 0;
			}
		}

/* start the data atom */
/* also don't want to do this if making a streamable file */
		if(wr)
		{
			quicktime_set_presave(new_file, 1);




// android requires the ftyp header
			const unsigned char ftyp_data[] =
			{
				0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70,
				0x6d, 0x70, 0x34, 0x32, 0x00, 0x00, 0x00, 0x01,
				0x6d, 0x70, 0x34, 0x32, 0x61, 0x76, 0x63, 0x31
			};
			quicktime_write_data(new_file, (char*)ftyp_data, sizeof(ftyp_data));

			quicktime_atom_write_header64(new_file,
				&new_file->mdat.atom,
				"mdat");
			quicktime_set_presave(new_file, 0);
		}
	}
	else
	{
//printf("quicktime_open 10\n");
		quicktime_close(new_file);
//printf("quicktime_open 100\n");
		new_file = 0;
	}


	return new_file;
}
Example #2
0
quicktime_t* quicktime_open(char *filename, int rd, int wr)
{
	quicktime_t *new_file = calloc(1, sizeof(quicktime_t));
	char flags[10];
	int result = 0;

//printf("quicktime_open 1\n");
	quicktime_init(new_file);
	new_file->wr = wr;
	new_file->rd = rd;
	new_file->mdat.atom.start = 0;

	result = quicktime_file_open(new_file, filename, rd, wr);

	if(!result)
	{
		if(rd)
		{
			if(quicktime_read_info(new_file))
			{
				quicktime_close(new_file);
				fprintf(stderr, "quicktime_open: error in header\n");
				new_file = 0;
			}
		}

/* start the data atom */
/* also don't want to do this if making a streamable file */
		if(wr)
		{
			quicktime_set_presave(new_file, 1);
			quicktime_atom_write_header64(new_file, 
				&new_file->mdat.atom, 
				"mdat");
			quicktime_set_presave(new_file, 0);
		}
	}
	else
	{
//printf("quicktime_open 10\n");
		quicktime_close(new_file);
//printf("quicktime_open 100\n");
		new_file = 0;
	}


	return new_file;
}
Example #3
0
int quicktime_check_sig(char *path)
{
	quicktime_t file;
	quicktime_atom_t leaf_atom;
	int result = 0, result1 = 0, result2 = 0;
	char avi_test[12];

	quicktime_init(&file);
	result = quicktime_file_open(&file, path, 1, 0);

	if(!result)
	{
// Check for Microsoft AVI
		quicktime_read_data(&file, avi_test, 12);
		quicktime_set_position(&file, 0);
		if(quicktime_match_32(avi_test, "RIFF") && 
			quicktime_match_32(avi_test + 8, "AVI "))
		{
			result2 = 1;
		}
		else
		{
			do
			{
				result1 = quicktime_atom_read_header(&file, &leaf_atom);

				if(!result1)
				{
/* just want the "moov" atom */
					if(quicktime_atom_is(&leaf_atom, "moov"))
					{
						result2 = 1;
					}
					else
						quicktime_atom_skip(&file, &leaf_atom);
				}
			}while(!result1 && !result2 && quicktime_position(&file) < file.total_length);
		}
	}

//printf(__FUNCTION__ " 2 %d\n", result2);
	quicktime_file_close(&file);
	quicktime_delete(&file);
	return result2;
}