-
-
Notifications
You must be signed in to change notification settings - Fork 338
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
MediaStream.addTrack does not accept CanvasCaptureMediaStreamTrack #506
Comments
First, This plugin is not suposed to be used ourside of WKWebview and will not support any other enviroment. Second, You have captureStream on Canvas working on iOS WKWebview ? |
In any case, even if WKWebview was allowing Canvas.captureStream that I'm pretty sure it does not, It will require enormous work to enable converting a "Native" MediaStream to an iosRTC WebRTC MediaStream. But again I already think this is irrelevant since CaptureStream is not even working in Safari therefor it will not work in WKWebview. This is a free software, I will not implement such features for your blue eyes ;) |
I mentioned other browsers only to show that
It works in Safari and WKWebView at least on iOS 13.4.1 and 13.3.1 (iPhone XS), I don't know about earlier versions. I can send |
I'm not asking you to implement any features for me. I've already managed this without intermediate local stream. I'm just reporting an incompatibility issue in You did a lot of work to make this plugin compatible with W3C WebRTC standard. I thought reporting this issue would help in this. Also, CanvasCaptureMediaStreamTrack is a good way to implement collaboration features like whiteboard, bringing new user experience in cordova apps, which is also good. |
Thank you @abardik I can address the fact that it support an instance of MediaStreamTrack for pure MediaStream the problem is that it will not work when you add that stream to the iOSRTC PeerConnection do you understand that ? Note: until an issue is close any status like wonfix can change. I update label to reflect the last status, not the final. |
"It works in Safari and WKWebView" "but not in WKWebView." Sorry I'm confused by your answer, it does work in WKWebView or it does not, OR it does not because you use iosRTC ? |
Let say it does in WKWebView, let say I allow it to work on native MediaStream (should actually already works with new MediaStream BTW). what should be the behavior when you add this stream to the RTCPeerConnection in term of failure? |
Ok I confirm captureStream landed on iOS WKWebView.
This example is not even logic, you ask for video and audio from iosRTC and add a new video Native MediaStreamTrack on the same iosRTC MediaStream (so you have 2 video tracks on MediaStream). Let say that you want to capture the VideoStream to draw on the canvas, If so you will need iOSRTC Renderer.save https://github.com/cordova-rtc/cordova-plugin-iosrtc/blob/master/extra/renderer-and-libwebrtc-tests.js#L385, but even with that you will only be able to display the MediaStream on a video tag, not sending it to RTCPeerConnection anyway. Why use navigator.mediaDevices.getUserMedia in your example that will provide an iosRTC MediaStream that will not support your You expect to be able to send a MediaStream from iosRTC getUserMedia to the Canvas then create an iosRTC MediaStream from it ? That is a features that will require lot of development, mainly converting the video of CanvasCaptureMediaStreamTrack to a WebRTC MediaStreamTrack inside the plugin. Finally, if what you want is to add CanvasCaptureMediaStreamTrack, to a MediaStream, you can already, you need to use https://github.com/cordova-rtc/cordova-plugin-iosrtc/blob/master/js/MediaStream.js#L47 This work today on iosrtc and result in a "NativeMediaStreamTrack"
But the stream or the track will not be compatible with WebRTC, that would require to convert NativeMediaStreamTrack or NativeMediaStream to iosRTC MediaStreamTrack or MediaStream and I will not implement that features for the moment due that this is a free software I maintain on my spare time. |
"I'm not asking you to implement any features for me. " You create a iosRTC MediaStream with If you want a "native" Stream with "native" MediaTrack use |
Also you have to realize that not all WKWebView are equals for example on iOS 10 "Native" MediaStream does not even exist and iOS 11 and 12 and less recent 13 will not have CaptureStream implemented. |
No it's not a "good way" to implement whiteboard, you want to have people draw over compressed video stream? The best way is to implement SVG to canvas (via |
Thank you for the detailed explanation about iosRTC MediaStream.
The first part was about
Yes, I do now. But it wasn't clear at the first time, that I can't send canvas stream to peer connection. It was looking like I can't send it to
Sorry, I don't understand, what do you mean "in term of failure"? I can explain the expected behavior when it's succeeded, because I already have this behavior in other browsers. You just send
Yes. What exactly is not logic - having more than one video tracks in one media stream which then will be sent over one peer connection? For example, if I want to send camera track (in small resolution, to show in the upper left corner of the recepient's screen, with the ability for him to hide the camera separately from other video tracks) + screen capture track (in maximum resolution, to show in full screen) + canvas capture track (which can be shown separately from camera and screen) - it does not make any sence?
I proposed a working WebRTC scenario from other browsers, before you explained that it's not possible in iosRTC because
No. I expected to combine two or more video tracks from different sources (camera, screen, canvas) in one media stream and then send it via one peer connection.
Yes, thank you for the example.
Now, it's totally clear, after you explained that it's a way deeply than just a type incompatibility issue.
This is exactly what I expected and why I opened this issue.
Yes, of course.
Yes, but it is not the reason to not deliver new features to up-to-dated users, especially if the market share of iOS 13+ is 93% (98% for iOS 11+, where
No, I don't, why would I? I want two separate and compressed video tracks - one for the screen and another one for the witeboard, which will eat a minimum amount of traffic because it will be static almost all the time. I'm not saying this is the best way to implement a whiteboard. I'm just saying this way is good enough to live, at least from the first look.
Yes, this is probably the best way in terms of traffic and performance, thank you. But it's a way more complicated than just adding additional video (canvas) track into the already established peer connection and then just attach it to Thank you. |
The issue here is 2 video track on one MediaStream, it may cause issue depending how you use peerConnection.addTrack or addStream, I recomand you group per stream with addTrack(track, stream1), addTrack(canvasTrack, canvasStream) on browser that support canvasCapture. |
Thank you for the suggestion. But could you please briefly explain why? I already moved from addStream/removeStream to addTrack/removeTrack. And replaceTrack was added recently for some cases. |
Notice that Using addTrack with Stream allow to group tack by stream it play nice with many other WebRTC implementtion and |
Maybe I have to try some examples, because it's still not clear for me what are the benefits of using one-track streams instead of multi-track streams or stream-less tracks. Anyway, thank you for the suggestions. |
I may have found a solution. |
@PeterXu I think it's may be time for me to bring your websocket+canvas video renderer fork's changes (https://github.com/PeterXu/cordova-plugin-iosrtc/blob/master/src/PluginMediaStreamRenderer.swift#L335) to the official repository combined with audioContext this time on top of it based on https://github.com/edimuj/cordova-plugin-audioinput. |
@hthetiot , Please ping me if need my help. |
This is good way and I will prepare a PR for it. |
You may merge master if you can, I landed a better track management in Peer injection @PeterXu |
PR is here #623 |
Expected behavior
MediaStream.addTrack
should allow to use as a first argument an instance ofCanvasCaptureMediaStreamTrack
captured from<canvas>
bycaptureStream
method.Observerd behavior
MediaStream.addTrack
throws an exception "argument must be an instance of MediaStreamTrack" if the first argument is an instance ofCanvasCaptureMediaStreamTrack
.In Chrome/Firefox/Safari an instance of
CanvasCaptureMediaStreamTrack
inherits fromMediaStreamTrack
, so it can be used inMediaStream.addTrack
method. In cordova app using iosrtc pluginCanvasCaptureMediaStreamTrack
is not an instance ofMediaStreamTrack
, so we have an aforementioned exception inMediaStream.addTrack
:cordova-plugin-iosrtc/js/MediaStream.js
Lines 258 to 263 in b1bb4cb
Steps to reproduce the problem
Platform information
The text was updated successfully, but these errors were encountered: