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 a synchronous method to MediaTranscoder #9

Closed
ralphpina opened this issue Jun 9, 2015 · 3 comments
Closed

Add a synchronous method to MediaTranscoder #9

ralphpina opened this issue Jun 9, 2015 · 3 comments

Comments

@ralphpina
Copy link

Currently, all transcodeVideo methods in MediaTranscoder are async methods. However, there are many situations where a synchronous method might be preferable. IntentServices and Handlers with their own HanderThread are two that quickly come to mind. Would you be open to a PR to add a synchronous method? I was thinking of pretty much copying/pasting the current work that transcodeVideo does, like so:

public void transcodeVideo(final FileDescriptor inFileDescriptor, final String outPath, final MediaFormatStrategy outFormatStrategy, final Listener listener) throws IOException, RuntimeException {
    MediaTranscoderEngine engine = new MediaTranscoderEngine();
    engine.setProgressCallback(new MediaTranscoderEngine.ProgressCallback( {
        @Override
         public void onProgress(final double progress) {
             listener.onTranscodeProgress(progress);
         }
    });
    engine.setDataSource(inFileDescriptor);
    engine.transcodeVideo(outPath, outFormatStrategy);
}

I figure that if you are running this synchronously you know what you are doing and you can handle your own Exceptions/failures. You'll know it was successful when it returned. The only listener call that you might be interested in is for progress?

@ypresto
Copy link
Owner

ypresto commented Jun 29, 2015

I have same issue on app which uses this library. Currently doing patch work with CountDownLatch...
I think it is good idea to provide sync version of methods.

Note that there are some reasons using async interface and thread pool:

So sync version would be better to use same thread pool than async version.

@ypresto
Copy link
Owner

ypresto commented Dec 4, 2015

We're currently working on Future (#12). It also can be passed to Observable.from()!

@ypresto
Copy link
Owner

ypresto commented Mar 18, 2016

v0.1.10 returns Future. Please use Future.get() to wait for result synchronously!

@ypresto ypresto closed this as completed Mar 18, 2016
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

No branches or pull requests

2 participants