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 MediaStreamTrack.clone() method #474

Closed
akume opened this issue Mar 1, 2020 · 9 comments
Closed

Add support for MediaStreamTrack.clone() method #474

akume opened this issue Mar 1, 2020 · 9 comments
Assignees
Milestone

Comments

@akume
Copy link

akume commented Mar 1, 2020

MediaStreamTrack.clone method hasn't been implemented but it's in the spec.

https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-clone

@hthetiot
Copy link
Contributor

hthetiot commented Mar 2, 2020

MediaStream.prototype.clone is implemented, test it and let me know.

@hthetiot hthetiot self-assigned this Mar 2, 2020
@hthetiot hthetiot added this to the 6.0.x milestone Mar 2, 2020
@hthetiot hthetiot closed this as completed Mar 2, 2020
@hthetiot
Copy link
Contributor

hthetiot commented Mar 2, 2020

You right MediaStreamTrack is missing.
I will see what I can do.

@hthetiot
Copy link
Contributor

hthetiot commented Mar 2, 2020

This should works partially.

MediaStreamTrack.prototype.clone = function () {
	debug('clone()');
	return new MediaStreamTrack(this);
};

@hthetiot hthetiot reopened this Mar 2, 2020
@hthetiot hthetiot added the webrtc-api webrtc-api related label Mar 2, 2020
@stolzda
Copy link

stolzda commented Mar 5, 2020

I also encountered this issue today. I tried to fix it based on your suggestion @hthetiot , but so far I wasn't successful.

The first thing is that the new track needs a new Id - I could achieve that by just adding a new Id on the javascript side, analogous to MediaStream clone.

However, it doesn't really work because on the swift side the newly cloned MediaStreamTrack should for example be in pluginMediaStreamTracks I guess?

And I don't really understand what the spec means when they write:

Let trackClone's underlying source be the source of track.

Set trackClone's constraints to the active constrains of track.

Is the underlying souce the MediaStream? But what needs to be associated with what?

Can you give so me some hints what is missing there, or do you plan to add this function soon @hthetiot ? Thanks

@hthetiot
Copy link
Contributor

hthetiot commented Mar 6, 2020

Thank you @stolzda.
We would need something like MediaStream_init (https://github.com/cordova-rtc/cordova-plugin-iosrtc/blob/master/src/iosrtcPlugin.swift#L686) but with the capability of using a source pluginMediaStreamTrack to be clone somewhat before calling MediaStreamTrack_setListener on the new track (https://github.com/cordova-rtc/cordova-plugin-iosrtc/blob/master/src/iosrtcPlugin.swift#L798).

I will look into it when i have a moment, but PR are welcome.

@stolzda
Copy link

stolzda commented Mar 6, 2020

Yes I was thinking something similar.

In similar terms I think the MediaStream.clone() functionality may be not correct as well - as the specification states, that the associated MediaStreamTracks need to be cloned as well, and since we do not have a method to clone them, probably the current implementation is not correct?

@hthetiot
Copy link
Contributor

hthetiot commented Mar 6, 2020

@stolzda Yeah MediaStream.clone work but it's a SHAM ;)

@hthetiot
Copy link
Contributor

TODO "the specification states, that the associated MediaStreamTracks need to be cloned"

@hthetiot
Copy link
Contributor

Please try this PR see testing instructions:

#587

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

3 participants