signalwire / freeswitch

FreeSWITCH is a Software Defined Telecom Stack enabling the digital transformation from proprietary telecom switches to a versatile software implementation that runs on any commodity hardware. From a Raspberry PI to a multi-core server, FreeSWITCH can unlock the telecommunications potential of any device.
https://freeswitch.com/#getting-started
Other
3.32k stars 1.38k forks source link

Interoperate with linphone using vp8. #1818

Open bkirnum opened 1 year ago

bkirnum commented 1 year ago

Is your feature request related to a problem? Please describe. When using linphone with vp8 enabled, video fails to be decoded.

Describe the solution you'd like I would like freeswitch to properly handle vp8 streams from linphone.

Describe alternatives you've considered I have isolated the issue to vp8 partitioning. This is enabled by default in linphone but disabled by default in freeswitch. For encoding this is fine, linphone handles both cases as input. However, freeswitch only handles vp8 streams with partitioning disabled. I have modified linphone to disable vp8 partitioning which avoids the issue but the correct fix would be to support partitioning in freeswitch for ingress vp8 streams.

Additional context Add any other context or screenshots about the feature request here.

Package version or git hash

bkirnum commented 1 year ago

The following patch fixes the issue.

diff --git a/src/switch_vpx.c b/src/switch_vpx.c
index e35d87712f..3e07e2f182 100644
--- a/src/switch_vpx.c
+++ b/src/switch_vpx.c
@@ -993,7 +993,7 @@ static switch_status_t buffer_vp8_packets(vpx_context_t *context, switch_frame_t
        uint8_t *data = frame->data;
        uint8_t S;
        uint8_t DES;
-       //      uint8_t PID;
+       uint8_t PID;
        int len;

        if (context->debug > 0) {
@@ -1011,7 +1011,7 @@ static switch_status_t buffer_vp8_packets(vpx_context_t *context, switch_frame_t
        DES = *data;
        data++;
        S = (DES & 0x10);
-       //      PID = DES & 0x07;
+       PID = DES & 0x07;

        //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DATA LEN %d S BIT %d PID: %d\n", frame->datalen, S, PID);

@@ -1047,7 +1047,7 @@ static switch_status_t buffer_vp8_packets(vpx_context_t *context, switch_frame_t
                return SWITCH_STATUS_MORE_DATA;
        }

-       if (S) {
+       if (S && (PID == 0)) {
                switch_buffer_zero(context->vpx_packet_buffer);
                context->last_received_timestamp = frame->timestamp;
 #if 0