cine-io / cineio-broadcast-android

The cine.io Android Broadcast SDK
https://www.cine.io/products/broadcast
MIT License
52 stars 32 forks source link

Capture image #13

Closed lgorse closed 9 years ago

lgorse commented 9 years ago

I implemented a frame saving protocol that:

1) Allows the user to call save frames from BroadcastActivity 2) Gives him control over the size and destination of the screenshot (via a ScreenShot object). 3) Returns info to the BroadcastActivity to keep the client updated on the state of the screenshot 4) Occurs on a parrallel thread => minimum interference with user experience.

I'm considering this pull request more of a call for review - if you see errors in the code, want to run it by your test suites or anything, this'll be a great time for it.

To understand how this works, I'd suggest first checking out the ScreenShot class in android/streaming folder.

The follow the process to save the frame: 0) create Screenshot object with desired fields. 1) call saveframe from the BroadcastActivity 2) sends message to the encoder to saveframe 3) which calls inputWindowSurface.saveframe method (passing screenshot objects all the way through) 4) generates new bitmap on alternate thread, and sends messages to cameraHandler to inform about the status of the save. 5) Handling these callback messages from saveframe to the camera: the methods are easily overriden by the client so he/she can write his own interpretation of how the UI should react.

To see how it looks on a project, check out my cineios_test project on Github. What I do is send the screenshot (with some scaling), and then override the saveframe callbacks to update the color of a button based on the state of the frame save.

I hope this is clear and look forward to feedback.

trshafer commented 9 years ago

Thanks for the PR @lgorse. It looks like a lot of work went into this. I appreciate it. We'll have a look over here, run it on some devices, and then merge it in.

lgorse commented 9 years ago

Don't forget my last commit today (Feb 14) which fixed the issue with filenames getting re-generated because I grabbed them with a new Timestamp every time. Issue fixed.

trshafer commented 9 years ago

Hey @lgorse , it didn't break anything so I merged this in. I also updated to gradle 1.0.0 as you updated runProguard to minifyEnabled and it's a good thing to do. Can you update either the Readme and/or the example app (CineIOExampleApp) demonstrating the screenshot feature?

lgorse commented 9 years ago

Hey thanks!

I'll take care of updating the readme this week - sorry for the delay.

On Tue, Feb 17, 2015 at 8:14 PM, Thomas Shafer notifications@github.com wrote:

Hey @lgorse https://github.com/lgorse , it didn't break anything so I merged this in. I also updated to gradle 1.0.0 as you updated runProguard to minifyEnabled and it's a good thing to do. Can you update either the Readme and/or the example app (CineIOExampleApp) demonstrating the screenshot feature?

— Reply to this email directly or view it on GitHub https://github.com/cine-io/cineio-broadcast-android/pull/13#issuecomment-74808912 .


Laurent Gorse MBA, class of 2013 Stanford Graduate School of Business 650.644.9188 lgorse@stanford.edu gsb.stanford.edu|Facebook: StanfordGSB http://facebook.com/StanfordGSB |Twitter: @StanfordBiz http://twitter.com/StanfordBiz