danikula / danikula/AndroidVideoCache
Three Basic Qqestions Need Author's Kind Help
- Langage dominant
- Java
- Étoiles
- 5.5k
- Forks
- 1.2k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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!
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.