2

我在 Android 上使用 nanohttpd 向我的 WebView 提供内容(KitKat 版本中的 ContentProvider 方法被破坏了,非常感谢 GOOGLE !!!),当我尝试发送 MP4 文件作为响应时,我的问题出现了,当第一个请求返回以下作为响应:

byte[] loData = [VIDEO_BYTES_IN MEMORY]; 
ByteArrayInputStream loBAIS = new ByteArrayInputStream(loData);
loResponse = new Response(Response.Status.OK, loMIME, loBAIS);
loResponse.addHeader("Content-Type", loMIME); // "video/mp4"
loResponse.addHeader("Content-Length", "" + loLength); // 21784780 bytes in total <-- NOTICE THIS !!!
loResponse.addHeader("Accept-Ranges", "bytes");
loResponse.addHeader("ETag", loETag);

当第二个请求到来时,标头如下所示:

Host: 127.0.0.1:8080
Connection: keep-alive
User-Agent: stagefright/1.2 (Linux;Android 4.4.4)
Accept-Encoding: gzip,deflate
Range: bytes=21389346-

现在这里的问题是,据我所知,来自客户端的第二个请求的范围是无效的。为什么我没有收到类似的范围:

Range: bytes=0-4999

在此之后,我收到了第二个请求,但我从未收到范围从 0 开始的“Starter”请求。有人对此行为有线索、评论、修复、路径、解决方法吗?

更多信息 :

第一个请求,页面加载时:

Host: 127.0.0.1:8080
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Linux; Android 4.4.4; GT-N5110 Build/KTU84Q) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Safari/537.36
Accept: */*
Referer: http://127.0.0.1:8080/html/index.html
Accept-Encoding: gzip,deflate
Accept-Language: es-US,en-US;q=0.8
X-Requested-With: com.myapp.browser

第二个请求,页面仍在加载:

Host: 127.0.0.1:8080
Connection: keep-alive
User-Agent: stagefright/1.2 (Linux;Android 4.4.4)
Accept-Encoding: gzip,deflate

第三次请求,页面仍在加载中,出现 Range 标头:

Host: 127.0.0.1:8080
Connection: keep-alive
User-Agent: stagefright/1.2 (Linux;Android 4.4.4)
Accept-Encoding: gzip,deflate
Range: bytes=21389346-

加载页面后,如果我尝试播放视频,则会收到以下请求。

第一个请求:

Host: 127.0.0.1:8080
Connection: keep-alive
User-Agent: stagefright/1.2 (Linux;Android 4.4.4)
Accept-Encoding: gzip,deflate

第二个请求 :

Host: 127.0.0.1:8080
Connection: keep-alive
User-Agent: stagefright/1.2 (Linux;Android 4.4.4)
Accept-Encoding: gzip,deflate

第三个要求:

Host: 127.0.0.1:8080
Connection: keep-alive
User-Agent: stagefright/1.2 (Linux;Android 4.4.4)
Accept-Encoding: gzip,deflate
Range: bytes=21389346-

第四次(也是最后一次)请求:

Host: 127.0.0.1:8080
Connection: keep-alive
User-Agent: stagefright/1.2 (Linux;Android 4.4.4)
Accept-Encoding: gzip,deflate
Range: bytes=21389346-

在此之后,可以听到音频但不能听到视频,logcat 显示以下错误:

09-16 13:34:41.565    2036-2702/com.myapp.browser W/System.err﹕ java.net.SocketException: sendto failed: ECONNRESET (Connection reset by peer)
09-16 13:34:41.570    2036-2702/com.myapp.browser W/System.err﹕ at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:499)
09-16 13:34:41.575    2036-2702/com.myapp.browser W/System.err﹕ at libcore.io.IoBridge.sendto(IoBridge.java:468)
09-16 13:34:41.575    2036-2702/com.myapp.browser W/System.err﹕ at java.net.PlainSocketImpl.write(PlainSocketImpl.java:508)
09-16 13:34:41.575    2036-2702/com.myapp.browser W/System.err﹕ at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)
09-16 13:34:41.580    2036-2702/com.myapp.browser W/System.err﹕ at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:270)
09-16 13:34:41.580    2036-2702/com.myapp.browser W/System.err﹕ at org.apache.http.impl.io.AbstractSessionOutputBuffer.write(AbstractSessionOutputBuffer.java:109)
09-16 13:34:41.585    2036-2702/com.myapp.browser W/System.err﹕ at org.apache.http.impl.io.IdentityOutputStream.write(IdentityOutputStream.java:86)
09-16 13:34:41.585    2036-2702/com.myapp.browser W/System.err﹕ at java.io.BufferedOutputStream.write(BufferedOutputStream.java:131)
09-16 13:34:41.590    2036-2702/com.myapp.browser W/System.err﹕ at com.myapp.browser.ContentServer.ContentHandler$3.writeTo(ContentHandler.java:165)
09-16 13:34:41.590    2036-2702/com.myapp.browser W/System.err﹕ at org.apache.http.entity.EntityTemplate.writeTo(EntityTemplate.java:76)
09-16 13:34:41.595    2036-2702/com.myapp.browser W/System.err﹕ at org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:97)
09-16 13:34:41.595    2036-2702/com.myapp.browser W/System.err﹕ at org.apache.http.impl.AbstractHttpServerConnection.sendResponseEntity(AbstractHttpServerConnection.java:182)
09-16 13:34:41.600    2036-2702/com.myapp.browser W/System.err﹕ at org.apache.http.protocol.HttpService.handleRequest(HttpService.java:209)
09-16 13:34:41.600    2036-2702/com.myapp.browser W/System.err﹕ at com.myapp.browser.ContentServer.ContentServer.run(ContentServer.java:89)
09-16 13:34:41.605    2036-2702/com.myapp.browser W/System.err﹕ Caused by: libcore.io.ErrnoException: sendto failed: ECONNRESET (Connection reset by peer)
09-16 13:34:41.610    2036-2702/com.myapp.browser W/System.err﹕ at libcore.io.Posix.sendtoBytes(Native Method)
09-16 13:34:41.615    2036-2702/com.myapp.browser W/System.err﹕ at libcore.io.Posix.sendto(Posix.java:156)
09-16 13:34:41.615    2036-2702/com.myapp.browser W/System.err﹕ at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
09-16 13:34:41.620    2036-2702/com.myapp.browser W/System.err﹕ at libcore.io.IoBridge.sendto(IoBridge.java:466)
09-16 13:34:41.620    2036-2702/com.myapp.browser W/System.err﹕ ... 12 more
09-16 13:34:41.635    2036-2702/com.myapp.browser D/ContentHandler﹕ Handling content request. video/shared-culture.mp4
09-16 13:34:41.890    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
09-16 13:34:41.890    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type
09-16 13:34:41.890    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniform1iv: wrong uniform function for type
09-16 13:34:45.760    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
09-16 13:34:45.760    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type
09-16 13:34:45.760    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniform1iv: wrong uniform function for type
09-16 13:34:45.795    2036-2036/com.myapp.browser I/Choreographer﹕ Skipped 60 frames!  The application may be doing too much work on its main thread.
09-16 13:34:46.020    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
09-16 13:34:46.020    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type
09-16 13:34:46.020    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniform1iv: wrong uniform function for type
09-16 13:34:46.105    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
09-16 13:34:46.105    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type
09-16 13:34:46.105    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniform1iv: wrong uniform function for type
09-16 13:34:46.200    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
09-16 13:34:46.200    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type
09-16 13:34:46.200    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniform1iv: wrong uniform function for type
09-16 13:34:46.380    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
09-16 13:34:46.380    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type
09-16 13:34:46.380    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniform1iv: wrong uniform function for type
09-16 13:34:46.630    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
09-16 13:34:46.630    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type
09-16 13:34:46.630    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniform1iv: wrong uniform function for type
09-16 13:34:46.900    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
09-16 13:34:46.900    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type
09-16 13:34:46.900    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniform1iv: wrong uniform function for type
09-16 13:34:47.155    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUseProgram: program not linked
09-16 13:34:47.155    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniformMatrix4fv: wrong uniform function for type
09-16 13:34:47.155    2036-2036/com.myapp.browser E/chromium﹕ [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x45422790]GL ERROR :GL_INVALID_OPERATION : glUniform1iv: wrong uniform function for type
09-16 13:34:47.215    2036-2036/com.myapp.browser E/MediaPlayer﹕ Should have subtitle controller already set
4

0 回答 0