OpenVidu / openvidu

OpenVidu Platform main repository
https://openvidu.io
Apache License 2.0
1.91k stars 462 forks source link

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=H264 doesn't work #653

Closed micaelgallego closed 3 years ago

micaelgallego commented 3 years ago

Describe the bug OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=H264 doesn't work. VP8 is always selected.

Expected behavior OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=H264 selected.

Wrong current behavior OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=H264 doesn't work. VP8 is always selected.

OpenVidu tutorial where to replicate the error Configure OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=H264 and test how VP8 is negotiated. If VP8 is disabled in KMS with

"videoCodecs": [
        { "///name": "VP8/90000" },
        { "name": "H264/90000" }
    ]

then the app crashes because the setRemoteDescription method returns an invalid SDP.

OpenVidu deployment info It is no relevant.

j1elo commented 3 years ago

So far, I'm not able to see the issue. tested with several combinations of web browsers and ForceCodec settings, and in all cases the SDP Offer messages are always mangled appropriately as needed, which causes the right selection of video codec.

Chrome (on Linux)

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=NONE

SUCCESSFUL: Selects the codec as per the default preference order given by the app.

SDP Offer from app

m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 121 127 120 125 107 108 109 35 36 124 119 123
a=rtpmap:96 VP8/90000
a=rtpmap:98 VP9/90000
a=rtpmap:100 VP9/90000
a=rtpmap:102 H264/90000
a=rtpmap:127 H264/90000
a=rtpmap:125 H264/90000
a=rtpmap:108 H264/90000
a=rtpmap:35 AV1X/90000

SDP Answer from Kurento

m=video 1 UDP/TLS/RTP/SAVPF 96 102 127 125 108
a=rtpmap:96 VP8/90000
a=rtpmap:102 H264/90000
a=rtpmap:127 H264/90000
a=rtpmap:125 H264/90000
a=rtpmap:108 H264/90000

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=H264

SUCCESSFUL: Filters the SDP Offer, leaving only the desired codec.

SDP Offer from app

m=video 9 UDP/TLS/RTP/SAVPF 102 121 127 120 125 107 108 109
a=rtpmap:102 H264/90000
a=rtpmap:127 H264/90000
a=rtpmap:125 H264/90000
a=rtpmap:108 H264/90000

SDP Answer from Kurento

m=video 1 UDP/TLS/RTP/SAVPF 102 127 125 108
a=rtpmap:102 H264/90000
a=rtpmap:127 H264/90000
a=rtpmap:125 H264/90000
a=rtpmap:108 H264/90000

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=VP8

SUCCESSFUL: Filters the SDP Offer, leaving only the desired codec.

SDP Offer from app

m=video 9 UDP/TLS/RTP/SAVPF 96 97
a=rtpmap:96 VP8/90000

SDP Answer from Kurento

m=video 1 UDP/TLS/RTP/SAVPF 96
a=rtpmap:96 VP8/90000

Safari (on MacOS)

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=NONE

SUCCESSFUL: Selects the codec as per the default preference order given by the app.

SDP Offer from app

m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 127 125 104
a=rtpmap:96 H264/90000
a=rtpmap:98 H264/90000
a=rtpmap:100 VP8/90000

SDP Answer from Kurento

m=video 1 UDP/TLS/RTP/SAVPF 96 98 100
a=rtpmap:96 H264/90000
a=rtpmap:98 H264/90000
a=rtpmap:100 VP8/90000

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=H264

SUCCESSFUL: Filters the SDP Offer, leaving only the desired codec.

SDP Offer from app

m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99
a=rtpmap:96 H264/90000
a=rtpmap:98 H264/90000

SDP Answer from Kurento

m=video 1 UDP/TLS/RTP/SAVPF 96 98
a=rtpmap:96 H264/90000
a=rtpmap:98 H264/90000

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=VP8

SUCCESSFUL: Filters the SDP Offer, leaving only the desired codec.

SDP Offer from app

m=video 9 UDP/TLS/RTP/SAVPF 100 101
a=rtpmap:100 VP8/90000

SDP Answer from Kurento

m=video 1 UDP/TLS/RTP/SAVPF 100
a=rtpmap:100 VP8/90000

Safari (on iPad Pro with iOS 14.3)

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=NONE

SUCCESSFUL: Selects the codec as per the default preference order given by the app.

SDP Offer from app

m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 127 125 104
a=rtpmap:96 H264/90000
a=rtpmap:98 H264/90000
a=rtpmap:100 VP8/90000

SDP Answer from Kurento

m=video 1 UDP/TLS/RTP/SAVPF 96 98 100
a=rtpmap:96 H264/90000
a=rtpmap:98 H264/90000
a=rtpmap:100 VP8/90000

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=H264

SUCCESSFUL: Filters the SDP Offer, leaving only the desired codec.

SDP Offer from app

m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99
a=rtpmap:96 H264/90000
a=rtpmap:98 H264/90000

SDP Answer from Kurento

m=video 1 UDP/TLS/RTP/SAVPF 96 98
a=rtpmap:96 H264/90000
a=rtpmap:98 H264/90000

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=VP8

SUCCESSFUL: Filters the SDP Offer, leaving only the desired codec.

SDP Offer from app

m=video 9 UDP/TLS/RTP/SAVPF 100 101
a=rtpmap:100 VP8/90000

SDP Answer from Kurento

m=video 1 UDP/TLS/RTP/SAVPF 100
a=rtpmap:100 VP8/90000

Swift native (on iPhone 7 with iOS 14.6)

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=NONE

SUCCESSFUL: Selects the codec as per the default preference order given by the app.

SDP Offer from app

m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 127 124 125
a=rtpmap:96 H264/90000
a=rtpmap:98 H264/90000
a=rtpmap:100 VP8/90000

SDP Answer from Kurento

m=video 1 UDP/TLS/RTP/SAVPF 96 98 100
a=rtpmap:96 H264/90000
a=rtpmap:98 H264/90000
a=rtpmap:100 VP8/90000

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=H264

SUCCESSFUL: Filters the SDP Offer, leaving only the desired codec.

Tested with both H.264 and VP8 enabled in Kurento:

"videoCodecs": [
    { "name": "VP8/90000" },
    { "name": "H264/90000" }
]

and also with VP8 disabled in Kurento:

"videoCodecs": [
    { "//name": "VP8/90000" },
    { "name": "H264/90000" }
]

SDP Offer from app

m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99
a=rtpmap:96 H264/90000
a=rtpmap:98 H264/90000

SDP Answer from Kurento

m=video 1 UDP/TLS/RTP/SAVPF 96 98
a=rtpmap:96 H264/90000
a=rtpmap:98 H264/90000

OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=VP8

SUCCESSFUL: Filters the SDP Offer, leaving only the desired codec.

SDP Offer from app

m=video 9 UDP/TLS/RTP/SAVPF 100 101
a=rtpmap:100 VP8/90000

SDP Answer from Kurento

m=video 1 UDP/TLS/RTP/SAVPF 100
a=rtpmap:100 VP8/90000
j1elo commented 3 years ago

I just updated the test results (https://github.com/OpenVidu/openvidu/issues/653#issuecomment-919021096) with also successful tests done with a Swift native application.

In all cases so far, OpenVidu Server is correctly parsing and removing unwanted codecs from the incoming SDP Offer from the application.

cruizba commented 3 years ago

@j1elo @micaelgallego Is this related with openvidu-node-client bug with force codec?

micaelgallego commented 3 years ago

Yes, please close it pointing to the commit fixing the issue.

cruizba commented 3 years ago

Fixed in https://github.com/OpenVidu/openvidu/commit/00792319676e9df94080fa89755764d97f0674f8