@@ -916,7 +916,7 @@ gboolean janus_h265_is_keyframe(const char *buffer, int len) {
916
916
}
917
917
918
918
int janus_vp8_parse_descriptor (char * buffer , int len ,
919
- uint16_t * picid , uint8_t * tl0picidx , uint8_t * tid , uint8_t * y , uint8_t * keyidx ) {
919
+ gboolean * m , uint16_t * picid , uint8_t * tl0picidx , uint8_t * tid , uint8_t * y , uint8_t * keyidx ) {
920
920
if (!buffer || len < 6 )
921
921
return -1 ;
922
922
if (picid )
@@ -951,6 +951,8 @@ int janus_vp8_parse_descriptor(char *buffer, int len,
951
951
partpicid = (wholepicid & 0x7FFF );
952
952
buffer ++ ;
953
953
}
954
+ if (m )
955
+ * m = (mbit ? TRUE : FALSE);
954
956
if (picid )
955
957
* picid = partpicid ;
956
958
}
@@ -976,7 +978,7 @@ int janus_vp8_parse_descriptor(char *buffer, int len,
976
978
return 0 ;
977
979
}
978
980
979
- static int janus_vp8_replace_descriptor (char * buffer , int len , uint16_t picid , uint8_t tl0picidx ) {
981
+ static int janus_vp8_replace_descriptor (char * buffer , int len , gboolean m , uint16_t picid , uint8_t tl0picidx ) {
980
982
if (!buffer || len < 6 )
981
983
return -1 ;
982
984
uint8_t vp8pd = * buffer ;
@@ -994,7 +996,7 @@ static int janus_vp8_replace_descriptor(char *buffer, int len, uint16_t picid, u
994
996
buffer ++ ;
995
997
vp8pd = * buffer ;
996
998
uint8_t mbit = (vp8pd & 0x80 );
997
- if (!mbit ) {
999
+ if (!mbit || ! m ) {
998
1000
* buffer = picid ;
999
1001
} else {
1000
1002
uint16_t wholepicid = htons (picid );
@@ -1031,13 +1033,14 @@ void janus_vp8_simulcast_context_reset(janus_vp8_simulcast_context *context) {
1031
1033
void janus_vp8_simulcast_descriptor_update (char * buffer , int len , janus_vp8_simulcast_context * context , gboolean switched ) {
1032
1034
if (!buffer || len < 0 )
1033
1035
return ;
1036
+ gboolean m = FALSE;
1034
1037
uint16_t picid = 0 ;
1035
1038
uint8_t tlzi = 0 ;
1036
1039
uint8_t tid = 0 ;
1037
1040
uint8_t ybit = 0 ;
1038
1041
uint8_t keyidx = 0 ;
1039
1042
/* Parse the identifiers in the VP8 payload descriptor */
1040
- if (janus_vp8_parse_descriptor (buffer , len , & picid , & tlzi , & tid , & ybit , & keyidx ) < 0 )
1043
+ if (janus_vp8_parse_descriptor (buffer , len , & m , & picid , & tlzi , & tid , & ybit , & keyidx ) < 0 )
1041
1044
return ;
1042
1045
if (switched ) {
1043
1046
context -> base_picid_prev = context -> last_picid ;
@@ -1046,9 +1049,16 @@ void janus_vp8_simulcast_descriptor_update(char *buffer, int len, janus_vp8_simu
1046
1049
context -> base_tlzi = tlzi ;
1047
1050
}
1048
1051
context -> last_picid = (picid - context -> base_picid )+ context -> base_picid_prev + 1 ;
1052
+ if (!m && context -> last_picid > 127 ) {
1053
+ context -> last_picid -= 128 ;
1054
+ if (context -> last_picid > 127 )
1055
+ context -> last_picid = 0 ;
1056
+ } else if (m && context -> last_picid > 32767 ) {
1057
+ context -> last_picid -= 32768 ;
1058
+ }
1049
1059
context -> last_tlzi = (tlzi - context -> base_tlzi )+ context -> base_tlzi_prev + 1 ;
1050
1060
/* Overwrite the values in the VP8 payload descriptors with the ones we have */
1051
- janus_vp8_replace_descriptor (buffer , len , context -> last_picid , context -> last_tlzi );
1061
+ janus_vp8_replace_descriptor (buffer , len , m , context -> last_picid , context -> last_tlzi );
1052
1062
}
1053
1063
1054
1064
/* Helper method to parse a VP9 RTP video frame and get some SVC-related info:
0 commit comments