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

Exposure of mediaStreamRenderers dictionary #253

Closed
yogaboy opened this issue Jan 30, 2017 · 6 comments
Closed

Exposure of mediaStreamRenderers dictionary #253

yogaboy opened this issue Jan 30, 2017 · 6 comments

Comments

@yogaboy
Copy link

yogaboy commented Jan 30, 2017

I'm trying to write an extension to address issue #116 to allow screen capture of particular UIViews holding a video.

I'm not sure where the mediaStreamRenderers is located and how to match a particular video on the webView to the underlying UIView showing the attached media.

Any advice would help.

@saghul
Copy link
Collaborator

saghul commented Jan 31, 2017

Can you please elaborate on how that would work? Would it be a standalone module or do you plan to contribute it to this plugin?

@yogaboy
Copy link
Author

yogaboy commented Jan 31, 2017

I didn't want to de-rail anything for the core iosrtc system, but would be happy to contribute. In the core, it should be much easier to extend. The extensions seem to take okay on the build, but I can't seem to address the mediaStreamRenderers object. Here's the SWIFT code for the extension:

import UIKit
import Foundation
import AVFoundation


extension PluginMediaStreamRenderer {
	func getStillURI() -> String {
		// Create the UIImage
		UIGraphicsBeginImageContextWithOptions(self.elementView.bounds.size, true, 0.0)
		self.elementView.drawViewHierarchyInRect(self.elementView.bounds, afterScreenUpdates: true)

		self.elementView.layer.renderInContext(UIGraphicsGetCurrentContext()!)
		let image = UIGraphicsGetImageFromCurrentImageContext()
		UIGraphicsEndImageContext()
		let imageData : NSData = UIImageJPEGRepresentation(image!, 0.8)!
		let strBase64 : String = imageData.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)
		return strBase64
    }
}

extension iosrtcPlugin {
	func captureStillAsURI(id : Int) -> String {
		let pluginMediaStreamRenderer = self.pluginMediaStreamRenderers[id]
		if pluginMediaStreamRenderer == nil {
			NSLog("iosrtcPlugin#captureStillAsURI() | ERROR: pluginMediaStreamRenderer with id=%@ does not exist", String(id))
			return ""
		}
		return self.pluginMediaStreamRenderers[id]!.getStillURI()
	}
}

The JS methods to call this is where I get a little hazy.

@ibc
Copy link
Collaborator

ibc commented Mar 28, 2017

JS MediaStreamRenderers container is in the main js/iosrtc.js.

@cometta
Copy link

cometta commented Jun 24, 2017

any plan to add this feature into iosrtc to take snapshot?

@hthetiot
Copy link
Contributor

I don't think we should add API that are not in WebRTC spec.
Will leave open for now anyway.

@hthetiot
Copy link
Contributor

hthetiot commented Oct 1, 2019

See #116 (comment)

@hthetiot hthetiot closed this as completed Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants