Skip to content

Interceptor Framework for RTP/RTCP Processing or Direct RTP/RTCP Access for Custom Packetization #220

Description

@kinsleykajiva

Is your feature request related to a problem? Please describe.

There's currently no way to intercept, modify, or inject custom encoders, transform packets, or interoperate into the RTP/RTCP packet processing pipeline. This prevents implementing:
Enhanced monitoring (inspect packet-level metrics (jitter, packet loss patterns, RTT)) , Custom FEC (forward error correction) schemes , Research and experimentation (Cannot prototype new RTP extensions or RTCP feedback mechanisms)

Describe the solution you'd like

Expose RTP/RTCP send and receive hooks via a MediaStreamTrack or RtpTransceiver API. This should allow access to RtpReceiver and RtpSender transport streams .

Implement a pluggable interceptor framework similar to Pion's interceptor package, allowing developers to insert custom processing logic into the media pipeline:

  1. Interceptor Interface:

    interface Interceptor {
        // Called for each outgoing RTP packet
        RTCRtpPacket interceptRTP(RTCRtpPacket packet, RTCRtpSender sender);
        
        // Called for each incoming RTP packet
        RTCRtpPacket interceptIncomingRTP(RTCRtpPacket packet, RTCRtpReceiver receiver);
        
        // Called for outgoing RTCP packets
        RTCRtcpPacket interceptRTCP(RTCRtcpPacket packet);
        
        // Called for incoming RTCP packets
        RTCRtcpPacket interceptIncomingRTCP(RTCRtcpPacket packet);
    }
  2. Interceptor Chain Management:

    interface InterceptorRegistry {
        void add(Interceptor interceptor);
        void remove(Interceptor interceptor);
        List<Interceptor> getInterceptors();
    }
    
    // Usage
    peerConnection.getInterceptorRegistry().add(new CustomInterceptor());
  3. Built-in Interceptors: Provide commonly-needed interceptors:

  4. Packet Access Objects: Expose packet structures:

    class RTCRtpPacket {
        RTCRtpHeader header;
        byte[] payload;
        List<RTCRtpHeaderExtension> extensions;
    }
    
    class RTCRtpHeader {
        int payloadType;
        int sequenceNumber;
        long timestamp;
        long ssrc;
        List<Long> csrcs;
    }

Describe alternatives you've considered

Tried to implement own interface but due to local dev complications with webrtc code base and JNI complexity but ran into a wall trying to do this , hence this request .

Additional context

Activity

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions