|
|
@@ -617,10 +617,11 @@ const SDPUtil = {
|
|
617
|
617
|
* Sets the given codecName as the preferred codec by moving it to the beginning
|
|
618
|
618
|
* of the payload types list (modifies the given mline in place). All instances
|
|
619
|
619
|
* of the codec are moved up.
|
|
620
|
|
- * @param {object} mLine the mline object from an sdp as parsed by transform.parse
|
|
621
|
|
- * @param {string} codecName the name of the preferred codec
|
|
|
620
|
+ * @param {object} mLine the mline object from an sdp as parsed by transform.parse.
|
|
|
621
|
+ * @param {string} codecName the name of the preferred codec.
|
|
|
622
|
+ * @param {boolean} sortPayloadTypes whether the payloadtypes need to be sorted for a given codec.
|
|
622
|
623
|
*/
|
|
623
|
|
- preferCodec(mline, codecName) {
|
|
|
624
|
+ preferCodec(mline, codecName, sortPayloadTypes = false) {
|
|
624
|
625
|
if (!mline || !codecName) {
|
|
625
|
626
|
return;
|
|
626
|
627
|
}
|
|
|
@@ -630,6 +631,28 @@ const SDPUtil = {
|
|
630
|
631
|
.map(rtp => rtp.payload);
|
|
631
|
632
|
|
|
632
|
633
|
if (matchingPayloadTypes) {
|
|
|
634
|
+ if (sortPayloadTypes && codecName === CodecMimeType.H264) {
|
|
|
635
|
+ // Move all the H.264 codecs with packetization-mode=0 to top of the list.
|
|
|
636
|
+ const payloadsWithMode0 = matchingPayloadTypes.filter(payload => {
|
|
|
637
|
+ const fmtp = mline.fmtp.find(item => item.payload === payload);
|
|
|
638
|
+
|
|
|
639
|
+ if (fmtp) {
|
|
|
640
|
+ return fmtp.config.includes('packetization-mode=0');
|
|
|
641
|
+ }
|
|
|
642
|
+
|
|
|
643
|
+ return false;
|
|
|
644
|
+ });
|
|
|
645
|
+
|
|
|
646
|
+ for (const pt of payloadsWithMode0.reverse()) {
|
|
|
647
|
+ const idx = matchingPayloadTypes.findIndex(payloadType => payloadType === pt);
|
|
|
648
|
+
|
|
|
649
|
+ if (idx >= 0) {
|
|
|
650
|
+ matchingPayloadTypes.splice(idx, 1);
|
|
|
651
|
+ matchingPayloadTypes.unshift(pt);
|
|
|
652
|
+ }
|
|
|
653
|
+ }
|
|
|
654
|
+ }
|
|
|
655
|
+
|
|
633
|
656
|
// Call toString() on payloads to get around an issue within SDPTransform that sets
|
|
634
|
657
|
// payloads as a number, instead of a string, when there is only one payload.
|
|
635
|
658
|
const payloadTypes
|
|
|
@@ -686,7 +709,7 @@ const SDPUtil = {
|
|
686
|
709
|
if (codec) {
|
|
687
|
710
|
return codec.toLowerCase() === CodecMimeType.VP9
|
|
688
|
711
|
? !item.config.includes('profile-id=0')
|
|
689
|
|
- : item.config.includes('profile-level-id=64');
|
|
|
712
|
+ : !item.config.includes('profile-level-id=42');
|
|
690
|
713
|
}
|
|
691
|
714
|
|
|
692
|
715
|
return false;
|