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

H.265, VP9, AV1 support #70

Open
longnguyen2004 opened this issue Feb 29, 2024 · 5 comments
Open

H.265, VP9, AV1 support #70

longnguyen2004 opened this issue Feb 29, 2024 · 5 comments

Comments

@longnguyen2004
Copy link
Collaborator

longnguyen2004 commented Feb 29, 2024

H.265 also uses Annex B, VP9 and AV1 also uses IVF, so maybe we can reuse code here...
PRs made:

@longnguyen2004
Copy link
Collaborator Author

longnguyen2004 commented Feb 29, 2024

Notes for people who want to follow along:

  1. H265 is only available on mobile, is it limited based on the user agent in the WebSocket connection?

@dank074
Copy link
Owner

dank074 commented Feb 29, 2024

Could be sent as an option in the SELECT_PROTOCOL message. Maybe the mobile app sends it but desktop app doesn't

@longnguyen2004
Copy link
Collaborator Author

Found a way to enable H265 on desktop. You need to have an NVIDIA card with H265 encoding support (not sure if this is a hard requirement or it can gracefully fall back to software encoding). Then enable the following experiment

image

After which, the following is sent by the client

{
    "d": {
        "address": "(redacted)",
        "codecs": [
            {
                "name": "opus",
                "payload_type": 120,
                "priority": 1000,
                "type": "audio"
            },
            {
                "decode": true,
                "encode": false,
                "name": "AV1",
                "payload_type": 101,
                "priority": 1000,
                "rtx_payload_type": 102,
                "type": "video"
            },
            {
                "decode": true,
                "encode": true,
                "name": "H265",
                "payload_type": 103,
                "priority": 2000,
                "rtx_payload_type": 104,
                "type": "video"
            },
            {
                "decode": true,
                "encode": true,
                "name": "H264",
                "payload_type": 105,
                "priority": 3000,
                "rtx_payload_type": 106,
                "type": "video"
            },
            {
                "decode": true,
                "encode": true,
                "name": "VP8",
                "payload_type": 107,
                "priority": 4000,
                "rtx_payload_type": 108,
                "type": "video"
            },
            {
                "decode": true,
                "encode": true,
                "name": "VP9",
                "payload_type": 109,
                "priority": 5000,
                "rtx_payload_type": 110,
                "type": "video"
            }
        ],
        "data": {
            "address": "(redacted)",
            "mode": "aead_aes256_gcm_rtpsize",
            "port": 48542
        },
        "experiments": [
            "fixed_keyframe_interval",
            "bandwidth_estimation/trendline-window-duration-3750,robust-estimator/trendline-window-duration-3750,robust-estimator"
        ],
        "mode": "aead_aes256_gcm_rtpsize",
        "port": 48542,
        "protocol": "udp",
        "rtc_connection_id": "7dc912bc-22fd-4ea2-8265-658ac2b40f6a"
    },
    "op": 1
}

@longnguyen2004
Copy link
Collaborator Author

@dank074 The comment here said that the packet type is STAP-A, but after reading and re-reading the spec, I determined that the actual packet type is Single NAL Unit Packet, due to the lack of the NALU size in the packet data, which STAP-A requires. Can you confirm it?

if (nalu.length <= this.mtu) {
// Send as Single-Time Aggregation Packet (STAP-A).
const packetHeader = this.makeRtpHeader(isLastNal);
const packetData = Buffer.concat([
this.createHeaderExtension(),
nalu,
]);
const nonceBuffer = this.mediaUdp.getNewNonceBuffer();
const packet = Buffer.concat([
packetHeader,
this.encryptData(packetData, nonceBuffer),
nonceBuffer.subarray(0, 4),
]);
this.mediaUdp.sendPacket(packet);
packetsSent++;
bytesSent += packet.length;
} else {

@dank074
Copy link
Owner

dank074 commented Mar 1, 2024

@dank074 The comment here said that the packet type is STAP-A, but after reading and re-reading the spec, I determined that the actual packet type is Single NAL Unit Packet, due to the lack of the NALU size in the packet data, which STAP-A requires. Can you confirm it?

if (nalu.length <= this.mtu) {
// Send as Single-Time Aggregation Packet (STAP-A).
const packetHeader = this.makeRtpHeader(isLastNal);
const packetData = Buffer.concat([
this.createHeaderExtension(),
nalu,
]);
const nonceBuffer = this.mediaUdp.getNewNonceBuffer();
const packet = Buffer.concat([
packetHeader,
this.encryptData(packetData, nonceBuffer),
nonceBuffer.subarray(0, 4),
]);
this.mediaUdp.sendPacket(packet);
packetsSent++;
bytesSent += packet.length;
} else {

You're actually right. Not sure why I wrote that 🤔

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

No branches or pull requests

2 participants