Video Cache Question

  • 1
  • Question
  • Updated 4 years ago
  • Answered
This is for one of the developers to answer. I have caching in android working correctly for the most part. I have been doing some cleaning and updating to the code and notice a few things that needed to be fixed. The one issue I'm looking at my caching . The code i use is fairly close to the old native player cache you all use so if you need a reference thats close to it. 

My problem lies with when sending the info back to the viewer. For now i use the ResponseRedirect when i send the viewer the url of the video file. My issue is when i do that i seem to get a loop that happens several times after i send the response. After 3 or 4 loops it works and goes on. My though is that I'm not sending all the correct info or something is a miss with what i need to send back. My question is can a developer give me a better explanation to what all needs to be sent to the viewer when it request for the video. Its probably something I'm missing but if i can get that info that might help solve a small mystery I'm seeing. 
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Blake Freeman

Blake Freeman, Official Rep

  • 36,116 Points 20k badge 2x thumb
William,

Thanks for the question. I'll make sure a developer sees this post.
Photo of Blake Freeman

Blake Freeman, Official Rep

  • 36,116 Points 20k badge 2x thumb
William,

Before I send this on to development, can you clarify exactly what is happening visually on the display when this happens, and what should be happening?
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
It should just communicate with the server just once and process it one time. It seems like it processes 3 times before the video starts up. Example when ping command checking cache is sent, i send the correct info back saying its there and that ends the communication with ping. Then video with its url is sent because the cache is alive but when i send back the info it repeats the process 3 or 4 times before going on. It might be quick in time but its adding about a second delay into the video rotation. What I'm wondering from the developers is the correct print stream statements that need to be sent like url content and closing. Im using the printHeader_ResponseRedirectredirect for now but thats where i think the issue is at. 
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
I think i might have found a work around on the issue but i still would like to know what is sent using print stream after downloading the video is done and when the video file exist. Just so that i can get it correct and that cache would work better with rise.

Also on a side note, i have been working on a replacement webview for amazon fire tv since the stick came out. I was thinking of using amazons webview since its built in. My only issue is with video and I get these three errors. 

I was wondering if someone had seen something like that and what might be the cause. I have sent amazon a question about it since it only happens on there webview but i was wanting to see if you all had any ideas. I thought maybe it was the mime type but that isn't the case. 

Thanks for help. 
Photo of Muhammad Farooq

Muhammad Farooq

  • 250 Points 250 badge 2x thumb
William,

Are you saying the Viewer sends 3 to 4 requests to cache web server? If true, its possible the viewer is not waiting enough for cache to respond back while its downloading the file from remote server. And after 3 or 4 attempts, the file is downloaded in cache and its quick to serve to viewer.

Also do you see same behaviour with RiseCache running on any supported platform or not?

You may want to compare the network calls from viewer to your Cache server against Viewer and RiseCache on any supported platform and look for  differences.

How Rise Cache work:

when it receives the "video" request, it checks if the file exist in local cache or not
if it exist, it writes the file to output stream.

Otherwise it starts downloading the file, the download happens in chunks, and so RiseCache writes the received chunck of data in local cache and writes to output stream at the same time.


the second problem you posted re: amazon webivew I don't have anything to add. You may want to find inforamtion on jwplayer forums.

Regards,
Muhammad
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
Here is the sequence from start to finish. Request for cache is sent and a responces is made letting the viewer know it's alive. The viewer then sends the video url to be checked if it's there. If it's not it downloads without issue and plays. After it plays viewer checks video again and sees if it's there. Now here is where my issue is at. Instead of the server getting hit once with this request it loops 2 more times before the viewer catches the responce and goes on playing the video. It could be timing but that also has to do with the responces I'm sending. If you could give me a rough code in Java that is needed to be sent to the viewer when a video exist that would help out. This setup is close to your Java native player in responses so a quick run down of what is all sent when item exist would probably solve my issue. I looked at the native Java player but it's like looking at a maze with no indication on where everything is going or doing.

Anyway
The 2 extra loops I believe is causing about a second to two second delay in the video rotation and I'm trying to work toward helping the speed on my android apps for the community.
Photo of Muhammad Farooq

Muhammad Farooq

  • 250 Points 250 badge 2x thumb
William, you will need to monitor the communication between Viewer and Your Cache, its possible player component (jwplayer) in Viewer is first sending HEAD request and then GET request.

RiseCache responds with:

HEAD request:
  print file headers 
  • If-None-MatchIf-Modified-Since
  • Last-Modified
  • Content-Type
  • Content-Length
  • Cache-Control
  • User-Agent
  • Accept-Ranges
  • Content-Range
  • Date
  • Server
  • ETag
  • File-URL
and at end write EOL bytes

GET request:
    print headers,
    EOL bytes
    If range is requested, then send only the requested bytes
    otherwise send whole file
    finally disconnect
Photo of William Oneal

William Oneal, Champion

  • 13,770 Points 10k badge 2x thumb
That makes sense and i will see how that works out. Thanks for info and thanks for the support you all do. I will let you know if i have any other issues.