Sophie

Sophie

distrib > Fedora > 13 > i386 > media > updates-src > by-pkgid > fb904b9be4cdef94018794d3bc861b5f > files > 3

gstreamer-java-1.4-4.fc13.src.rpm

diff -ur /home/lfarkas/rpm/BUILD/gstreamer-java/src/org/gstreamer/elements/RGBDataFileSink.java ./src/org/gstreamer/elements/RGBDataFileSink.java
--- /home/lfarkas/rpm/BUILD/gstreamer-java/src/org/gstreamer/elements/RGBDataFileSink.java	2010-05-03 16:25:55.000000000 +0200
+++ ./src/org/gstreamer/elements/RGBDataFileSink.java	2010-06-27 22:21:38.249747135 +0200
@@ -24,6 +24,7 @@
 import java.util.concurrent.ScheduledExecutorService;
 import com.sun.jna.Pointer;
 
+import org.gstreamer.Format;
 import org.gstreamer.Gst;
 import org.gstreamer.ClockTime;
 import org.gstreamer.Buffer;
@@ -90,8 +91,18 @@
 
         // Building pipeline.
         source = (AppSrc)ElementFactory.make("appsrc", "source");
-        source.set("is-live", true);
-        source.set("format", 3); // GST_FORMAT_TIME = 3
+        
+        source.setLive(true);
+        
+        // Using either BUFFERS or TIME doesn't seem
+        // to make a difference, but BUFFERS make more
+        // sense with the buffer timestamping. See comments
+        // in pushBuffer() method below.
+        source.setFormat(Format.BUFFERS);
+        //source.setFormat(Format.TIME);
+        
+        source.setLatency(-1, 0);
+        source.setSize(-1);
         source.setCaps(videoCaps);
         source.setMaxBytes(QUEUED_FRAMES * sourceWidth * sourceHeight * 4);
 
@@ -259,10 +270,21 @@
                 Buffer buf = bufferList.remove(0);
                 frameCount++;
 
-                long f = frameCount * NANOS_PER_FRAME;
                 buf.setCaps(videoCaps);
-                buf.setTimestamp(ClockTime.fromNanos(f));
-                buf.setDuration(ClockTime.fromNanos(NANOS_PER_FRAME));
+                
+                // For some reason this duration and timestamp setting works 
+                // with all encoders I tried so far (theora, x264, dirac),
+                // although doesn't make much sense (frame duration 1 nano?)...
+                buf.setTimestamp(ClockTime.fromNanos(frameCount));
+                buf.setDuration(ClockTime.fromNanos(1));
+                
+                // ... this other one, which is logically correc, doesn't work for
+                // theora (frames are dropped for no apparent reason each 
+                // two seconds):
+                //long f = frameCount * NANOS_PER_FRAME;
+                //buf.setTimestamp(ClockTime.fromNanos(f));
+                //buf.setDuration(ClockTime.fromNanos(NANOS_PER_FRAME));
+                
                 source.pushBuffer(buf);
                 buf.dispose();
             }