webrtc-rs / webrtc

A pure Rust implementation of WebRTC
https://webrtc.rs
Apache License 2.0
4.04k stars 359 forks source link

The customized HEVC track failed #518

Open shiqifeng2000 opened 9 months ago

shiqifeng2000 commented 9 months ago

hi

After RTP h265 codec is added, I try to add hevc track to this repo, but not successful, this is how I did.

claim a mime type pub const MIME_TYPE_HEVC: &str = "video/hevc";

register codec to MediaEngine m.register_codec( RTCRtpCodecParameters { capability: RTCRtpCodecCapability { mime_type: MIME_TYPE_HEVC.to_owned(), clock_rate: 90000, channels: 0, sdp_fmtp_line: "".to_owned(), rtcp_feedback: vec![], }, payload_type: 167, ..Default::default() }, RTPCodecType::Video, )?;

add a hevc payloader to RTP submodule **-->webrtc-0.9/rtp/src/codecs/h265/mod.rs

[derive(Default, Debug, Clone)]

pub struct HevcPayloader { vps_nalu: Option, sps_nalu: Option, pps_nalu: Option, } and of course, with impl Payloader for HevcPayloader**, it's a lot of code

add some code to get pass the constrain in the function -->webrtc-0.9/webrtc/src/rtp_transceiver/rtp_codec.rs

then I open a bi-direction program, exchanging sdp, and send rtp, got connected, seems working, but failed to have the receiver working

I saw the callback peer_connection.on_track wont work anyway

then I check the code in -->webrtc-0.9/webrtc/src/peer_connection/peer_connection_internal.rs it seems there's not any rtp received, so i guess either it's sender failed or receiver failed, maybe more work need to be done

could you check the work above and show me any inspiration? thank you

shiqifeng2000 commented 9 months ago

Update:

After installing wireshark, I found all the RTP pkt sent got the payload type as 38, but I actually set that to 167, it seems after I invoke the fn write_rtp from a TrackLocalWriter , it actually change my payload type into 38, thats pretty weird.

Then I try change my payload type to 38, it finally works, maybe it's a fallback reservation, I dont know. Please take a look to see if its a bug.

shiqifeng2000 commented 2 months ago

Update:

I have figured it out that the max rtp payload is 127, sorry for this miss, I am closing the issue