Esempio n. 1
0
void
writeSWFSoundWithSoundStreamToMethod(SWFSoundStream stream,
                            SWFByteOutputMethod method, void *data)
{
	int source = stream->streamSource;
	struct SWFSoundStreamBlock_s streamblock;

	/* need to get the sample count && and rewind */
	SWFSoundStream_getLength(stream, &streamblock);
	SWFSoundStream_rewind(stream);

	methodWriteUInt32(streamblock.numSamples, method, data);
	methodWriteUInt16(stream->initialDelay, method, data);
	if(source == STREAM_MP3)
		write_mp3(&streamblock, method, data);
	else if(source == STREAM_FLV)
		write_flv(&streamblock, method, data);
}
Esempio n. 2
0
void
writeSWFSoundStreamToMethod(SWFBlock block,
                            SWFByteOutputMethod method, void *data)
{
	SWFSoundStreamBlock streamblock = (SWFSoundStreamBlock)block;
	int source = streamblock->stream->streamSource;
	
	if(source == STREAM_MP3)
	{
		methodWriteUInt16(streamblock->numSamples, method, data);
		methodWriteUInt16(streamblock->delay, method, data);
		write_mp3(streamblock, method, data);
	}
	else if(source == STREAM_FLV)
	{
		if(AUDIO_CODEC(streamblock->stream) == AUDIO_CODEC_MP3)
		{
			methodWriteUInt16(streamblock->numSamples, method, data);
			methodWriteUInt16(streamblock->delay, method, data);
		}
		write_flv(streamblock, method, data);
	}
}
Esempio n. 3
0
int main(int argc, char **argv)
{
	wave_t         wave;
	time_t         start_time, end_time;
	int16_t        buffer[2][samp_per_frame];
	shine_config_t config;
	shine_t        s;
	long           written;
	unsigned char  *data;

	time(&start_time);

	/* Set the default MPEG encoding paramters - basically init the struct */
	set_defaults(&config);

	if (!parse_command(argc, argv, &config)) {
		print_usage();
		exit(1);
	}

	quiet = quiet || !strcmp(outfname, "-");

	if (!quiet) print_name();

	/* Open the input file and fill the config shine_wave_t header */
	if (!wave_open(infname, &wave, &config, quiet))
		error("Could not open WAVE file");

	infile = wave.file;

	/* See if samplerate is valid */
	if (L3_find_samplerate_index(config.wave.samplerate) < 0) error("Unsupported samplerate");

	/* See if bitrate is valid */
	if (L3_find_bitrate_index(config.mpeg.bitr) < 0) error("Unsupported bitrate");

	/* open the output file */
	if (!strcmp(outfname, "-"))
		outfile = stdout;
	else
		outfile = fopen(outfname, "wb");
	if (!outfile) {
		fprintf(stderr, "Could not create \"%s\".\n", outfname);
		exit(1);
	}

	/* Set to stereo mode if wave data is stereo, mono otherwise. */
	if (config.wave.channels > 1)
		config.mpeg.mode = STEREO;
	else
		config.mpeg.mode = MONO;

	/* Print some info about the file about to be created (optional) */
	if (!quiet) check_config(&config);

	/* Initiate encoder */
	s = L3_initialise(&config);

	/* All the magic happens here */
	while (wave_get(buffer, &wave, &config)) {
		data = L3_encode_frame(s, buffer, &written);
		write_mp3(written, data, &config);
	}

	/* Flush and write remaining data. */
	data = L3_flush(s, &written);
	write_mp3(written, data, &config);

	/* Close encoder. */
	L3_close(s);

	/* Close the wave file (using the wav reader) */
	wave_close(&wave);

	/* Close the MP3 file */
	fclose(outfile);

	time(&end_time);
	end_time -= start_time;
	if (!quiet)
		printf("Finished in %02ld:%02ld:%02ld (%01.1fx realtime)\n", end_time / 3600, (end_time / 60) % 60, end_time % 60, (float)wave.duration / (float)end_time);

	return 0;
}