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

Add support for large video file uploads (tus.io) #46

Merged
merged 70 commits into from
Oct 24, 2018
Merged

Conversation

juniorxsound
Copy link
Contributor

@juniorxsound juniorxsound commented Oct 5, 2018

Why?

  • Uploading big files in the current version of the plugin makes Unity freeze!
  • Chunked uploads open the plugin to resumable uploading as well
  • Chunked uploads could be faster if they employ concurrency

What was done?

  • Implemented VimeoUploader and VideoChunk to support the Vimeo tus.io upload API
  • Automatically attempts to resume your upload when your internet connection cuts out
  • VimeoUploader extends VimeoApi to avoid repetition and code duplication
  • Hiding all the internal components from the Unity inspector - leaving just VimeoRecorder and VimeoPlayer. Makes the UX much cleaner
  • Cleaner test timeout pattern using Unity's builtin [Timeout(ms)]
  • Massively increased test coverage and we even automate recording & uploading tests
    image

Future

  • More code cleanup: We need to eventually remove VimeoPublisher and dry it up with VimeoUploader since they are both kind of doing the same thing. Also need to give VimeoVideo more responsibility which will help untangle code.

Tested against the following versions
2018.2.13f1, 2018.2.9f1, 2018.2.6f1, 2018.2.4f1, 2018.2.1f1, 2018.1.6f1, 2017.1.5f1, 2017.1.4f1

For local development
If you are working off of master and not the latest release, you will need to delete the Assets/Tests folder and assemblies before building an executable. Our releases will not ship with these files.

@juniorxsound juniorxsound requested a review from caseypugh October 8, 2018 14:21
Copy link
Contributor

@caseypugh caseypugh left a comment

Choose a reason for hiding this comment

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

Ok, left feedback!

Assets/Vimeo/Scripts/Recorder/VimeoPublisher.cs Outdated Show resolved Hide resolved
Assets/Vimeo/Scripts/Recorder/VimeoPublisher.cs Outdated Show resolved Hide resolved
Assets/Vimeo/Scripts/Recorder/VimeoPublisher.cs Outdated Show resolved Hide resolved
Assets/Vimeo/Scripts/Recorder/VimeoPublisher.cs Outdated Show resolved Hide resolved
Assets/Vimeo/Scripts/Services/VimeoApi.cs Show resolved Hide resolved
Assets/Vimeo/Scripts/Services/VimeoUploader.cs Outdated Show resolved Hide resolved
Assets/Vimeo/Scripts/Services/VimeoUploader.cs Outdated Show resolved Hide resolved
Assets/Vimeo/Scripts/Utils/VideoChunk.cs Outdated Show resolved Hide resolved
Assets/Vimeo/Scripts/Utils/VideoChunk.cs Outdated Show resolved Hide resolved
…en created instead of at the end of an upload

This resolved situation where an error in upload makes the video uploaded "Untitled" and public
- Setting up the video (privacy/name/review page) at the begining of the upload
- Implementing VimeoUplader as a derived class from the VimeoApi base class
- Implementing events (OnUpload...)
- Fixing typos (e.g progress in VimeoUploader)
- Cleaning up whitespaces and comments
- Fixing misc PR comments
@caseypugh caseypugh changed the title Moving to chunked uploads using the Vimeo tus API Add support for large video file uploads (tus.io) Oct 17, 2018
Copy link
Contributor

@caseypugh caseypugh left a comment

Choose a reason for hiding this comment

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

Overall it's looking great! 🎉

Since we now have a real test suite, there is still one major todo here. You wrote two new classes: VimeoUploader and VideoChunk, both of which should come with unit tests.

Also one other thing we should do is hide all the Vimeo config settings while recording/uploading since it is all set in the beginning now.

Assets/Tests/Play/VimeoRecorderPlayTest.cs Outdated Show resolved Hide resolved
Assets/Vimeo/Scripts/Recorder/VimeoPublisher.cs Outdated Show resolved Hide resolved
Assets/Vimeo/Scripts/Recorder/VimeoPublisher.cs Outdated Show resolved Hide resolved
r.SetRequestHeader("Accept", "application/vnd.vimeo.*+json;version=" + apiVersion);
}

public static bool IsNetworkError(UnityWebRequest req) {
protected void TriggerDerivedOnProgress(string status, float progress)
Copy link
Contributor

Choose a reason for hiding this comment

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

What does TriggerDerived mean? is that a tus term?

@caseypugh caseypugh added this to the 0.9.3 milestone Oct 17, 2018
@@ -18,6 +18,12 @@ public class VimeoRecorder : RecorderSettings
public bool isRecording = false;
public bool isUploading = false;
public float uploadProgress = 0;
private int m_customByteChunkSize = 1024 * 1024 * 128;
public int customByteChunkSize {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just call this byteChunkSize ?


private bool HasChunksLeftToUpload()
{
if (currentChunkIndex < m_chunks.Count) {
Copy link
Contributor

Choose a reason for hiding this comment

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

a more future proof way of checking would be to create a method called GetTotalRemainingChunks which loops through to check status. e.g.

private bool HasPendingChunksToUpload()
{
   return GetTotalRemainingChunks() == 0;
}

@juniorxsound juniorxsound merged commit c4e392f into master Oct 24, 2018
@juniorxsound juniorxsound deleted the tus-upload branch October 24, 2018 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants