Skip to content

feat(sdp): mirror media direction in answer#68

Open
vlxdisluv wants to merge 2 commits into
livekit:mainfrom
vlxdisluv:answer-mirror-direction
Open

feat(sdp): mirror media direction in answer#68
vlxdisluv wants to merge 2 commits into
livekit:mainfrom
vlxdisluv:answer-mirror-direction

Conversation

@vlxdisluv

Copy link
Copy Markdown
Contributor

Generate the answer's direction by mirroring the offer per RFC 3264 §6.1
(sendonly↔recvonly, sendrecv/inactive unchanged) instead of always emitting
sendrecv. AnswerMedia now takes the direction as a parameter.

Added a table-driven test in offer_test.go covering all four directions
through Offer.Answer.

Follow-up to #67. Related to issue

Answer now reflects the offer's direction per RFC 3264
(sendonly↔recvonly, inactive/sendrecv unchanged) instead of
always emitting sendrecv. AnswerMedia takes the direction as
a parameter.
@vlxdisluv vlxdisluv requested review from a team as code owners June 24, 2026 15:26
Comment thread sdp/offer.go

// AnswerMedia creates a new SDP media description for an answer.
func AnswerMedia(rtpListenerPort int, audio *AudioConfig, crypt *srtp.Profile) *sdp.MediaDescription {
func AnswerMedia(rtpListenerPort int, audio *AudioConfig, crypt *srtp.Profile, dir sdp.Direction) *sdp.MediaDescription {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also allow passing empty direction and default to sendrecv?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Direction is iota+1, the zero value already represents "unset", so I'll take it by value and default 0 → sendrecv.

Comment thread sdp/offer.go Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could pass the direction here as well for consistency. Also, allow passing empty one and default to sendrecv.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, missed this one. Adding dir to OfferMediaWith too with the same 0 → sendrecv default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants