danikula / danikula/AndroidVideoCache
Three Basic Qqestions Need Author's Kind Help
- 主要言語
- Java
- スター
- 5.5k
- フォーク
- 1.2k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Hi, Dear Alexey Danilov:
Quite perfect and useful lib for Android, thanks for sharing your efforts to make us conveniently coding.
There are three uncertainty from my side, it will be greate honor for me if I can get kindly help from you.
### When I want to learn this lib in detail, a mimesis was done. My purpose was to provide a mp4 file to a VideoView as a server.
#### First I start a ServerSocket:
ServerSocketFactory factory = ServerSocketFactory.getDefault();
InetAddress address = InetAddress.getByName("127.0.0.1");
serverSocket = factory.createServerSocket(30001, 9, address);
#### When the request from VideoView arrives:
while (!Thread.currentThread().isInterrupted()) {
Socket socket = serverSocket.accept();
InputStream inputStream = socket.getInputStream();
String read = Utils.read(inputStream);
// The same as your lib, make a OK reponse.
GetRequest request = new GetRequest(read);
BufferedOutputStream out = new BufferedOutputStream(socket.getOutputStream());
String responseHeaders = newResponseHeaders(request);
out.write(responseHeaders.getBytes("UTF-8"));
//read a mp4 file from storage
byte[] buffer = new byte[1024 * 512];
int readBytes;
int offset = 0;
while ((readBytes = read(buffer, offset, buffer.length)) != -1) {
out.write(buffer, 0, readBytes);
offset += readBytes;
}
out.flush();
}
#### The VideoView works well, but when I change the buffer size asbyte[] buffer = new byte[8192], the VideoView can not play ! I changed the BufferedOutputStream as OutputStream and I tried flush the stream, it still can not work, only I make the buffer size biger than 8192, it will work, Could you please help me to find this reason ?
### My second question based on the first one. when I use this lib, I saw two times request from VideoView in different threads when the source has alredy been cached, the logs as below:
#### This is the first request info form VideoView for the first time:
GET /http%3A%2F%2F192.168.27.9%3A8000%2Fadv.mp4 HTTP/1.1
Accept: */*
Range: bytes=0-
Connection: close
Host: 127.0.0.1:44663
User-Agent: Mozilla/4.0 (compatible; MS IE 6.0; (ziva))
#### We replaied like this :
HttpProxyCache.processRequest: HTTP/1.1 206 PARTIAL CONTENT
Accept-Ranges: bytes
Content-Length: 286255909
Content-Range: bytes 0-286255908/286255909
Content-Type: video/mp4
#### The second request arrives with offset:
/http%3A%2F%2F192.168.27.9%3A8000%2Fadv.mp4 HTTP/1.1
Accept: */*
Range: bytes=517067-
Connection: close
Host: 127.0.0.1:44663
User-Agent: Mozilla/4.0 (compatible; MS IE 6.0; (ziva))
#### And we replaied like this
HttpProxyCache.processRequest: HTTP/1.1 206 PARTIAL CONTENT
Accept-Ranges: bytes
Content-Length: 285738842
Content-Range: bytes 517067-286255908/286255909
Content-Type: video/mp4
#### Though the lib works well, I am still curious about why I can only see on time request from VidewView from my pervious question but see two times from your lib ? It takes me a long time to find the answer and still I did not , could you please help me to know the answer ?
### My last question is I saw when building HttpProxyCacheServer, we freeze thread, wait for server starts, is this necessary to freeze the main thread ?
Thanks again!
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
まず HttpProxyCacheServer の起動パスと HttpProxyCache.processRequest を読み、次にそれらを、提供されている ServerSocket と VideoView のフローと比較してください。この issue では、バッファサイズの挙動、繰り返される range リクエスト、起動スレッドの待機について説明することが求められています。3 つすべての質問に対する明確で文書化された回答ができれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- android, java
- 領域
- mobile-dev, networking
- issue の種類
- ドキュメント
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 15/100