[Live-devel] DeviceSource "not so clean" fix

Dixon Siu dixonsiu at mediaglue.co.jp
Mon May 24 19:57:06 PDT 2004


Hi everyone,

I found that if I try to access pointers within DeviceSource, it failed to
give me the correct content of the pointer. So I adjusted my code to
duplicate whatever the readBuffer is pointing to. And now, my code works.
The receiver end can correctly receives all content of the buffer. But
synchronization is needed at the end of doGetNextFrame() so that the speed
of writing to the buffer can be controlled by DeviceSource. Being able to do
synchronized read and write allow VBR while using Live.com library (Ross,
correct me if I am wrong here).

The reason I need VBR is that I want to control the bitrate of the encoder
by analyzing the RTT from RR.

void DeviceSource::doGetNextFrame() {
	//int remainSize = fPreferredFrameSize;
	// Waiting for the device to allow us to read the buffer.
	WaitForSingleObject(mgcReadBufferEvent, INFINITE);
	fMaxSize = fPreferredFrameSize;

	// Strange! I cannot use the pointer method.
	// So, I have to duplicate the content of my buffer.
	count = 0;
	while (count < fPreferredFrameSize){
		fTo[count] = fReadBuffer[count];
		count++;
	}

	//printf("fTo value is %x\n", fTo[3]);
	fFrameSize = fPreferredFrameSize;

    // We don't know a specific play time duration for this data,
    // so just record the current time as being the 'presentation time':
    gettimeofday(&fPresentationTime, &Idunno);

	deliverFrame();
}

Regards,
Dixon Siu
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.688 / Virus Database: 449 - Release Date: 2004/05/18



More information about the live-devel mailing list