Bug 1037626: Support Webrtc H.264 offers with only packetization mode 1 r=ehugg
authorRandell Jesup <rjesup@jesup.org>
Fri, 11 Jul 2014 16:35:36 -0400
changeset 215605 dac114b593f01a6d2520e99276953bf3454bb05b
parent 215604 34c44a0bc7067349b405fae3629df85af0217c36
child 215606 e0a49f64ef4f5e6d148abbca54bcacdd67f6b921
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehugg
bugs1037626
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1037626: Support Webrtc H.264 offers with only packetization mode 1 r=ehugg
media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.c
media/webrtc/signaling/src/sipcc/core/sdp/sdp_access.c
media/webrtc/signaling/src/sipcc/include/vcm.h
--- a/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
+++ b/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
@@ -2788,24 +2788,25 @@ int vcmGetVideoCodecList(int request_typ
         break;
     }
     CSFLogDebug(logTag, "GetVideoCodecList returning %X", codecMask);
     return codecMask;
 #endif
 }
 
 /**
- * Get max supported H.264 video packetization mode.
- * @return maximum supported video packetization mode for H.264. Value returned
- * must be 0 or 1. Value 2 is not supported yet.
+ * Get supported H.264 video packetization modes
+ * @return mask of supported video packetization modes for H.264. Value returned
+ * must be 1 to 3 (bit 0 is mode 0, bit 1 is mode 1.
+ * Bit 2 (Mode 2) is not supported yet.
  */
-int vcmGetVideoMaxSupportedPacketizationMode()
+int vcmGetH264SupportedPacketizationModes()
 {
-  // We support mode 1 packetization in webrtc
-  return 1;
+  // We support mode 1 packetization only in webrtc currently
+  return VCM_H264_MODE_1;
 }
 
 /**
  * Get supported H.264 profile-level-id
  * @return supported profile-level-id value
  */
 uint32_t vcmGetVideoH264ProfileLevelID()
 {
--- a/media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.c
+++ b/media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.c
@@ -601,22 +601,26 @@ sip_config_video_add_codecs (rtp_ptype a
   uint16_t count = 0;
 
   // All things being equal, prefer VP8 > H.264 p1 > H.264 p0 -> H.263
   if ( codec_mask & VCM_CODEC_RESOURCE_VP8) {
     aSupportedCodecs[count] = RTP_VP8;
     count++;
   }
   if ( codec_mask & VCM_CODEC_RESOURCE_H264) {
-    if (vcmGetVideoMaxSupportedPacketizationMode() == 1) {
+    int modes = vcmGetH264SupportedPacketizationModes();
+    // prefer mode 1 to mode 0
+    if (modes & VCM_H264_MODE_1) {
       aSupportedCodecs[count] = RTP_H264_P1;
       count++;
     }
-    aSupportedCodecs[count] = RTP_H264_P0;
-    count++;
+    if (modes & VCM_H264_MODE_0) {
+      aSupportedCodecs[count] = RTP_H264_P0;
+      count++;
+    }
   }
   if ( codec_mask & VCM_CODEC_RESOURCE_H263) {
     aSupportedCodecs[count] = RTP_H263;
     count++;
   }
   return count;
 }
 
--- a/media/webrtc/signaling/src/sipcc/core/sdp/sdp_access.c
+++ b/media/webrtc/signaling/src/sipcc/core/sdp/sdp_access.c
@@ -1739,22 +1739,28 @@ u32 sdp_get_media_payload_type (void *sd
                     }
                     if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_ISAC) == 0) {
                         return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_ISAC));
                     }
                     if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_OPUS) == 0) {
                         return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_OPUS));
                     }
                     if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_H264) == 0) {
-                        sdp_attr_get_fmtp_pack_mode(sdp_p, level, 0, (uint16_t) (i + 1), &pack_mode);
+                      int fmtp_inst = sdp_find_fmtp_inst(sdp_p, level,
+                                                         mca_p->payload_type[payload_num-1]);
+                      if (fmtp_inst < 0) {
+                        return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_H264_P0));
+                      } else {
+                        sdp_attr_get_fmtp_pack_mode(sdp_p, level, 0, (uint16_t) fmtp_inst, &pack_mode);
                         if (pack_mode == SDP_DEFAULT_PACKETIZATION_MODE_VALUE) {
                             return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_H264_P0));
                         } else {
                             return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_H264_P1));
                         }
+                      }
                     }
                     if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_VP8) == 0) {
                         return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_VP8));
                     }
                 }
             }
         }
     }
--- a/media/webrtc/signaling/src/sipcc/include/vcm.h
+++ b/media/webrtc/signaling/src/sipcc/include/vcm.h
@@ -61,16 +61,21 @@
 
 #define VCM_DSP_DECODEONLY  0
 #define VCM_DSP_ENCODEONLY  1
 #define VCM_DSP_FULLDUPLEX  2
 #define VCM_DSP_IGNORE      3
 #define VCM_DSP_FULLDUPLEX_HW 4 // HW codecs
 #define VCM_DSP_FULLDUPLEX_GMP 5 // GMP-loaded codecs
 
+// Bitmasks for vcmGetH264SupportedPacketizationMode()
+#define VCM_H264_MODE_0     1
+#define VCM_H264_MODE_1     2
+#define VCM_H264_MODE_2     4
+
 #define CC_KFACTOR_STAT_LEN   (256)
 
 /* Should be enough for any reasonable use-case */
 #define MAX_SSRCS_PER_MEDIA_LINE 16
 #define MAX_PTS_PER_MEDIA_LINE 16
 
 /**
  *  vcm_tones_t
@@ -876,21 +881,22 @@ int vcmGetAudioCodecList(int request_typ
  * #define VCM_RESOURCE_G711     0x00000001
  * #define VCM_RESOURCE_G729A    0x00000002
  * ....
  */
 
 int vcmGetVideoCodecList(int request_type);
 
 /**
- * Get max supported H.264 video packetization mode.
- * @return maximum supported video packetization mode for H.264. Value returned
- * must be 0 or 1. Value 2 is not supported yet.
+ * Get supported H.264 video packetization modes
+ * @return mask of supported video packetization modes for H.264. Value returned
+ * must be 1 to 3 (bit 0 is mode 0, bit 1 is mode 1.
+ * Bit 2 (Mode 2) is not supported yet.
  */
-int vcmGetVideoMaxSupportedPacketizationMode();
+int vcmGetH264SupportedPacketizationModes();
 
 /**
  * Get supported H.264 profile-level-id
  * @return supported profile-level-id value
  */
 uint32_t vcmGetVideoH264ProfileLevelID();
 
 /**