Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates code to replace mp4 downloads and use hls streams instead #554

Merged
merged 6 commits into from Apr 21, 2021

Conversation

VegetarianZombie
Copy link
Contributor

This pull request removes the mp4 downloads and uses HLS downloads instead. It creates AVAssetDownload tasks instead of standard download task. It also requires a new way to calculate progress. The pull request gets rid of the DownloadVideoRequest and replaces it with the DownloadStreamVideoRequest which is designed to handle hls streams. I also had to remove the code for download resuming as that isn't handled by hls downloads.

@0xTim
Copy link
Contributor

0xTim commented Mar 11, 2021

@sammyd I seem to remember there was a reason we didn't support HLS downloads from the start - can you remember it?

@sammyd
Copy link
Collaborator

sammyd commented Mar 11, 2021

@0xTim the primary reason was that I didn't realise it was a thing. The secondary reason is that it means we can no longer gate downloads on the backend. i.e. anybody that downloads the source for the app would be able to tweak it to download videos they have access to view. I've decided that this is a much lower risk than first thought, and we should standardise on HLS for simplicity, and the benefits we get with subtitles.

I'll take a look through this PR as well, but since you have a lot more experience with HLS downloading, if you could review it that'd be great! Thanks (=

@0xTim
Copy link
Contributor

0xTim commented Mar 15, 2021

@VegetarianZombie Is this ready for review? There's a fair bit of commented out code and the tests aren't passing

@VegetarianZombie
Copy link
Contributor Author

@0xTim When I submitted this, we were migrating off Auth0 so the failed I ran into were login issues. Those appeared to have been corrected. I also deleted the deprecated tests (commented out).

There is one test that is inconsistently failing: testDownloadQueueStreamRespectsTheMaxLimit

Sometimes this passes when given enough time. Other times I get it to pass by running all the DownloadQueueManagerTests. I'm having a little difficulty making heads or tails of this one. 1

@sammyd, do you have any insight on this test?

@VegetarianZombie VegetarianZombie linked an issue Mar 19, 2021 that may be closed by this pull request
@sammyd
Copy link
Collaborator

sammyd commented Mar 22, 2021

These might be fixed once #557 is merged and this is rebased on top of that?

Can we get that merged please @0xTim and then revisit this.

@sammyd
Copy link
Collaborator

sammyd commented Mar 23, 2021

I've merged #557. I'm gonna merge development into this to see if the tests are fixed.

Copy link
Contributor

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor change to remove what I'm assuming is a debug statement and we're good to go. Looks like CI is all fixed as well.

This should definitely improve the download experience for users

@@ -85,7 +85,7 @@ class Service {
func prepare<R: Request>(request: R,
parameters: [Parameter]?) -> URLRequest? {
let pathURL = networkClient.environment.baseURL.appendingPathComponent(request.path)

print("pathURL: \(pathURL)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit remove

@VegetarianZombie VegetarianZombie changed the title Updates code to replace mp4 downsloads and use hls streams instead Updates code to replace mp4 downloads and use hls streams instead Apr 9, 2021
@VegetarianZombie
Copy link
Contributor Author

Hi @0xTim - I removed the print statement and found a few others. Should be all set now.

Copy link
Contributor

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last nit and we're good to go. I'm assuming that we don't have different quantity options for HLS?

@@ -150,7 +150,7 @@ final class VideoPlaybackViewModel {
}
// If we're online then, that's all good
if sessionController.sessionState == .online {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're commenting out this return we should just remove the whole if block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Tim,

I went added that code back in. As for the SD vs HD quality options, I have those in place. For SD streams, I'm downloading the streams at a lower bitrate (250,000). The SD file sizes ended up being half the size as the HD files.

0xTim
0xTim previously approved these changes Apr 21, 2021
Copy link
Contributor

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@0xTim
Copy link
Contributor

0xTim commented Apr 21, 2021

@VegetarianZombie final task before this is merged 😞 the conflicts need to be resolved

@sammyd I think this is good to go - there's nothing we need to prepare on the backend for everyone downloading HLS streams etc going forward is there? I'm assuming not but worth asking in case the MP4 allotment has special capacity etc

@0xTim
Copy link
Contributor

0xTim commented Apr 21, 2021

@VegetarianZombie scrap that, the merge conflict was dead simple so I fixed it

@sammyd
Copy link
Collaborator

sammyd commented Apr 21, 2021

@0xTim nothing to change on the backend, no. We'll want to test this once we get a TestFlight release, cos it removes the need for the API_KEY—and no longer gates downloads on the backend.

I will try to fix CI very soon so that we can start having TestFlight releases again. It's just a bit of a coordination nightmare to actually log in to ASC.

@0xTim
Copy link
Contributor

0xTim commented Apr 21, 2021

@sammyd do you want me to hold off merging until Testflight is fixed?

@sammyd
Copy link
Collaborator

sammyd commented Apr 21, 2021

nah...go for it. I'll retrigger once I fix it

@0xTim 0xTim merged commit ff3a2be into development Apr 21, 2021
@0xTim 0xTim deleted the hls-download branch April 21, 2021 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Downloaded videos don't have subtitles
3 participants