ovikassingho / gstreamer-java

Automatically exported from code.google.com/p/gstreamer-java
0 stars 0 forks source link

Pipeline.queryDuration(TimeUnit unit) does not return value in 'TimeUnit unit' units. #121

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

pipeline.queryDuration(TimeUnit.seconds) returns the same number as 
pipeline.queryDuration(TimeUnit.milliseconds) and so on.

What is the expected output? What do you see instead?
The return value converted to the provided TimeUnit.

Have you tried to verify this is a gstreamer-java specific issue, and not a
problem with the gstreamer framework itself?
Yes, the problem appears to be in Pipeline.java (around line 348):

public long queryDuration(TimeUnit unit) {
        Format[] fmt = { Format.TIME };
        long[] duration = { 0 };
        gst.gst_element_query_duration(this, fmt, duration);
        return unit.convert(duration[0], TimeUnit.NANOSECONDS);
    }

Which should have this instead:

return unit.convert(duration[0], unit);

What version of the product are you using? On what operating system?
gstreamer-java r594
Windows 7x64
Java 1.7
Eclipse IDE

Original issue reported on code.google.com by nearw...@gmail.com on 15 Apr 2013 at 7:05

GoogleCodeExporter commented 8 years ago
queryPosition also seems to have this problem.

public long queryPosition(TimeUnit unit) {
        return unit.convert(queryPosition(Format.TIME), TimeUnit.NANOSECONDS);
    }

Original comment by nearw...@gmail.com on 15 Apr 2013 at 7:12

GoogleCodeExporter commented 8 years ago
imho this implementation is good. the return value of 
gst_element_query_duration always nanosec. and if we'd like to convert it to 
sec then it's a proper call to:
TimeUnit.seconds.convert(duration[0], TimeUnit.NANOSECONDS);

but feel free to comment it.

Original comment by lfar...@lfarkas.org on 15 Apr 2013 at 7:59

GoogleCodeExporter commented 8 years ago
Oh, I see. I was reading it backwards without noticing the 'unit.' prefix. 
thinking that the argument to convert was the destination unit.

Original comment by nearw...@gmail.com on 15 Apr 2013 at 8:11