Пример #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);
}
Пример #2
0
/* 
 * DEPRECATED!
 * returns the number of movie frames for a given sound stream
 *
 * This function returns the number of movie frames necessary to 
 * play the full sound stream. 
 * Works only if the sound stream object was added to a movie and the stream 
 * source is a mp3 file.
 *
 * Use SWFSoundStream_getDuration() instead.
 */
int SWFSoundStream_getFrames(SWFSoundStream stream)
{	
	int n, frameSize;
	if(stream->streamSource == STREAM_FLV || stream->samplesPerFrame == 0)
	{
		SWF_warn("SWFSoundStream_getFrames works only if stream was assigned to a movie\n");
		return -1;
	}
	
	if ( stream->sampleRate > 32000 )
		frameSize = 1152;
	else
		frameSize = 576;
	n = 0;
	while(nextMP3Frame(stream->source.mp3.input) > 0)
		n++;
	SWFSoundStream_rewind(stream);
	return n * frameSize / stream->samplesPerFrame;
}
Пример #3
0
static void 
fillStreamBlock_mp3(SWFSoundStream stream, SWFSoundStreamBlock block)
{
	int delay, wanted;

	/* see how many frames we can put in this block,
	 see how big they are */
	block->delay = stream->delay;
	delay = stream->delay + stream->samplesPerFrame;
	wanted = delay;
	block->length = getMP3Samples(stream->source.mp3.input, stream->flags, &delay);
	block->numSamples = delay;
	if(block->length <= 0)
	{
		stream->isFinished = TRUE;
		SWFSoundStream_rewind(stream);
	}
	stream->delay = wanted - delay;
}
Пример #4
0
static void 
fillStreamBlock_flv(SWFSoundStream stream, SWFSoundStreamBlock block)
{
	int ret;
	
	if(AUDIO_CODEC(stream) == AUDIO_CODEC_MP3)
		ret = fillBlock_flv_mp3(stream, block);
	else if(AUDIO_CODEC(stream) == AUDIO_CODEC_NELLY || 
		AUDIO_CODEC(stream) == AUDIO_CODEC_NELLY_MONO)
		ret = fillBlock_flv_nelly(stream, block);
	else
	{
		SWF_warn("unsupported codec %i\n", AUDIO_CODEC(stream));
		ret = -1;
	}
			
	if(ret < 0)
	{
		stream->isFinished = TRUE;
		SWFSoundStream_rewind(stream);
	}
}
Пример #5
0
static void 
fillStreamBlock_mp3(SWFSoundStream stream, SWFSoundStreamBlock block)
{
	int delay, wanted;
	static const int maxSC = 65535;

	/* see how many frames we can put in this block,
	 see how big they are */
	block->delay = stream->delay;
	delay = stream->delay + stream->samplesPerFrame;
	wanted = delay;
	block->length = getMP3Samples(stream->source.mp3.input, stream->flags, &delay);
	block->numSamples = delay;
	
	if ( block->numSamples > maxSC ) {
		SWF_warn("fillStreamBlock_mp3: number of samples in block (%d) exceed max allowed value of %d\n", block->numSamples, maxSC);
	}
	if(block->length <= 0)
	{
		stream->isFinished = TRUE;
		SWFSoundStream_rewind(stream);
	}
	stream->delay = wanted - delay;
}