Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid seeking problem with proxy stream and stagefright player
    text
    copied!<p>I want to play an audiostream from a url that is only valid for a temporary amount of time. This doesn't play very well just by using the built in stagefright streaming functionality because of the buffering mechanism (the url will be dead by the time the buffer is filled for the second time), so I have implemented a proxy stream, similar to what is done in the npr app</p> <p><a href="http://code.google.com/p/npr-android-app/source/browse/trunk/Npr/src/org/npr/android/news/StreamProxy.java" rel="nofollow">http://code.google.com/p/npr-android-app/source/browse/trunk/Npr/src/org/npr/android/news/StreamProxy.java</a></p> <p>This actually works very nicely, with one exception, any seek call effectively breaks the proxy stream. I am having a hard time determining exactly how the seeking works in stagefright. Everytime I seek I get a message of </p> <pre><code>01-12 13:35:57.201: ERROR/(4870): Connection reset by peer 01-12 13:35:57.201: ERROR/(4870): java.net.SocketException: Connection reset by peer 01-12 13:35:57.201: ERROR/(4870): at org.apache.harmony.luni.platform.OSNetworkSystem.writeSocketImpl(Native Method) 01-12 13:35:57.201: ERROR/(4870): at org.apache.harmony.luni.platform.OSNetworkSystem.write(OSNetworkSystem.java:723) 01-12 13:35:57.201: ERROR/(4870): at org.apache.harmony.luni.net.PlainSocketImpl.write(PlainSocketImpl.java:578) 01-12 13:35:57.201: ERROR/(4870): at org.apache.harmony.luni.net.SocketOutputStream.write(SocketOutputStream.java:59) 01-12 13:35:57.201: ERROR/(4870): at com.soundcloud.utils.StreamProxy.processRequest(StreamProxy.java:209) </code></pre> <p>Then a pause for a few seconds, thafter which stagefright retries to connect to the same url, and usually throws an error (I would imagine because the proxy stream hasn't been reset). Another potential problem is that it seems as though the proxy stream will always read the data source linearly:</p> <pre><code>while (isRunning &amp;&amp; (readBytes = data.read(buff, 0, buff.length)) != -1) </code></pre> <p>And I am only guessing, but I would think that in order to support seeking, the proxy would have to be able to provide an offset when reading from the buffer. Is there a way to figure out the requested offset from the socket client (the intended seek position)? </p> <p>My experience with sockets is limited. Does anybody have suggestions on implementation here?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload