simple-peer icon indicating copy to clipboard operation
simple-peer copied to clipboard

Remove distinction between offer/answer constraints in constructor

Open feross opened this issue 6 years ago • 4 comments

This issue was raised in a comment by @nazar-pc and didn't want it to get lost:

I have a generic concern about constraints separation. Second argument constraints in RTCPeerConnection was removed from the spec a long time ago. At the same time answer/offer constraints are obvious from the context.

I'd like to see a single peer.setConstraints() method that under the hood resolves to either offerConstraints or answerConstraints and do not even expose this separation for the user. In future major version I'd remove this separation entirely in constructor options too.

Originally posted by @nazar-pc in https://github.com/feross/simple-peer/pull/324#issuecomment-396762783

feross avatar Aug 11 '19 07:08 feross

It was actually implemented in mentioned PR with a subsequent commit: https://github.com/feross/simple-peer/pull/324/commits/692d18ea6e8afbb715cdb9b1bd84966de7cba2ae Also constraints were replaced with options in https://github.com/feross/simple-peer/pull/440 and peer.setConstraints() is gone.

So it seems there is nothing left to do here.

nazar-pc avatar Aug 11 '19 11:08 nazar-pc

Thanks for the response @nazar-pc. I actually opened this issue because I was wondering if it's possible to eliminate the distinction between offerOptions and answerOptions. It seems that that can be determined purely based on the value of the initiator option.

In fact, setting { initiator: true, answerOptions: { ... } will cause answerOptions to be ignored. It's a minor API detail, but wondering if we can't make this cleaner?

feross avatar Aug 12 '19 01:08 feross

Yes, the options objects should be merged into one.

The fact there is two objects is a leftover from when I planned to have non-initiators also send offers during renegotiation.

It's unfortunate to kick off a major version for something so trivial though.

t-mullen avatar Sep 11 '19 22:09 t-mullen

#530 is not released yet, so it can be released together

nazar-pc avatar Sep 11 '19 23:09 nazar-pc