[sip-comm-dev] Re: svn commit: r6577 - trunk/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/ImageStream.java


#1

Seb,

Thank you for the quick action upon my note!

I'm afraid I have a few minor notes regarding the implementation of
ImageStream in r6577. Now we don't have RingBuffer and captureThread
just overwrites #buf with one and the same instance.

- There's no synchronization on our side when reading and writing
#buf. Presuming JMF will read it when we call #transferData() is fine
and it's likely the way it will always happen. But I don't think it'll
hurt if we make it explicit because by looking at the code we
currently have one thread reading from the Buffer instance while the
other writes to it.

- There's no check in #read whether buf is null. Again, JMF will
likely not call #read before we call #transferData. I'd personally
stick to "better safe than sorry" in the case though.

- #read just keeps on reading from #buf regardless of whether it's
reading a new screen capture or an old one. Yet again, JMF will likely
not call #read without us first calling #transferData so #read will
likely always read a new screen capture. But it's not like this
behavior is explicitly stated in the JMF docs. I'd rather have #read
clear #buf once its read in order to make it obvious that we're not
providing one and the same frame multiple times.

Anyway, there are not really serious because we don't currently have a
user of ImageStream other than JMF. I wanted to note though that the
PushBufferStream interface doesn't require than one calls #read in
#transferData.

Thank you,
Lubo

ยทยทยท

On Thu, Jan 7, 2010 at 1:39 PM, <s_vincent@dev.java.net> wrote:

Author: s_vincent
Date: 2010-01-07 11:39:09+0000
New Revision: 6577

Modified:
trunk/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/ImageStream.java

Log:
Remove use of RingBuffer for desktop streaming.

Modified: trunk/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/ImageStream.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/ImageStream.java?view=diff&rev=6577&p1=trunk/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/ImageStream.java&p2=trunk/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/ImageStream.java&r1=6576&r2=6577

--- trunk/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/ImageStream.java (original)
+++ trunk/src/net/java/sip/communicator/impl/neomedia/jmfext/media/protocol/imgstreaming/ImageStream.java 2010-01-07 11:39:09+0000
@@ -15,8 +15,6 @@
import javax.media.format.*;
import javax.media.protocol.*;

-import net.sf.fmj.utility.*;
-
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.impl.neomedia.imgstreaming.*;

@@ -74,9 +72,9 @@
private boolean started = false;

/\*\*

- * Buffer container.
+ * Buffer for the last image.
*/
- private RingBuffer ringBuffer = null;
+ private Buffer buf = null;

/\*\*
 \* Destkop interaction \(screen capture, key press, \.\.\.\)\.

@@ -129,9 +127,6 @@
{
try
{
- /* get the next data */
- Buffer buf = (Buffer)ringBuffer.get();
-
buffer.setData(buf.getData());
buffer.setOffset(0);
buffer.setLength(buf.getLength());
@@ -257,7 +252,6 @@
logger.info("Start stream");
captureThread = new Thread(this);
captureThread.start();
- ringBuffer = new RingBuffer(5);
started = true;
}
}
@@ -315,9 +309,7 @@
/* get raw bytes */
data = ImageStreamingUtils.getImageByte(scaledScreen);

- /* add it to a RingBuffer and notify JMF that new data
- * is available
- */
+ /* notify JMF that new data is available */
buffer.setData(data);
buffer.setOffset(0);
buffer.setLength(data.length);
@@ -328,7 +320,7 @@
buffer.setFlags(Buffer.FLAG_LIVE_DATA | Buffer.FLAG_SYSTEM_TIME);
seqNo++;

- ringBuffer.put(buffer);
+ buf = buffer;

        /\* pass to JMF handler \*/
        if\(transferHandler \!= null\)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: commits-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net