tmakkonen / sipcmd

sipcmd
327 stars 108 forks source link

Not usable with Fritz!OS 6.80 anymore - possible to reduce codec list in SDP? #52

Closed Woersty closed 7 years ago

Woersty commented 7 years ago

Hi, do you see a way to disable all codecs except the codecs I want to use?

For me it is okay to use PCM16 and G.711a-law. I would prefer an option to set sipcmd to use just these but I'm lost in C++

The Invite is quite huge due to the very long list:

INVITE sip:**611@fritz.box SIP/2.0
CSeq: 1 INVITE
v: SIP/2.0/UDP 169.254.80.70:5060;branch=z9hG4bK580685e7-f7f4-e611-8ef2-b827ebc64bf5;rport
User-Agent: text2sip/1.0.1
f: "Haustür" <sip:622@fritz.box>;tag=9a517ae7-f7f4-e611-8ef2-b827ebc64bf5
i: a87f7ae7-f7f4-e611-8ef2-b827ebc64bf5@loxberry
k: 100rel,replaces
Organization: LoxBerry Text2SIP
t: <sip:**611@fritz.box>
m: "Haustür" <sip:622@192.168.178.254:5060>
Allow: INVITE,ACK,OPTIONS,BYE,CANCEL,SUBSCRIBE,NOTIFY,REFER,MESSAGE,INFO,PING,PRACK
l: 1669
c: application/sdp
Max-Forwards: 70

v=0
o=- 1487498425 1 IN IP4 169.254.80.70
s=text2sip/1.0.1
c=IN IP4 169.254.80.70
t=0 0
m=audio 5000 RTP/AVP 120 93 126 3 121 122 123 124 0 8 9 117 118 89 116 125 92 115 101 100
a=sendrecv
a=rtpmap:120 AMR-WB/16000/1
a=fmtp:120 octet-align=1
a=rtpmap:93 AMR/8000/1
a=rtpmap:126 iLBC/8000/1
a=fmtp:126 mode=20
a=rtpmap:3 gsm/8000/1
a=rtpmap:121 G726-40/8000/1
a=rtpmap:122 G726-32/8000/1
a=rtpmap:123 G726-24/8000/1
a=rtpmap:124 G726-16/8000/1
a=rtpmap:0 PCMU/8000/1
a=rtpmap:8 PCMA/8000/1
a=rtpmap:9 G722/8000/1
a=rtpmap:117 G7221/16000/1
a=fmtp:117 bitrate=24000
a=rtpmap:118 G7221/16000/1
a=fmtp:118 bitrate=32000
a=rtpmap:89 SILK/16000/1
a=rtpmap:116 Speex/16000/1
a=rtpmap:125 lpc10/8000/1
a=rtpmap:92 SILK/8000/1
a=rtpmap:115 Speex/8000/1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16,32,36
a=rtpmap:100 NSE/8000
a=fmtp:100 192-193
a=maxptime:30
m=video 5002 RTP/AVP 103 104 91 34 105 31 97 90
b=AS:240000
b=TIAS:240000000
a=sendrecv
a=rtpmap:103 H264/90000
a=fmtp:103 packetization-mode=1;max-br=240000;max-fs=6336;max-mbps=380160;profile-level-id=42801e
a=rtpmap:104 H264/90000
a=fmtp:104 max-br=240000;max-fs=6336;max-mbps=380160;profile-level-id=42801e
a=rtpmap:91 MP4V-ES/90000
a=fmtp:91 profile-level-id=5
a=rtpmap:34 H263/90000
a=fmtp:34 F=1;CIF=1;CIF16=1;CIF4=1;maxbr=3276;QCIF=1;SQCIF=1
a=rtpmap:105 H263-1998/90000
a=fmtp:105 D=1;F=1;I=1;J=1;CIF=1;CIF4=1;maxbr=3276;QCIF=1;SQCIF=1
a=rtpmap:31 h261/90000
a=fmtp:31 CIF=1;QCIF=1
a=rtpmap:97 raw/90000
a=fmtp:97 rate=90000;height=288;width=352;colorimetry=BT601-5;depth=8;sampling=YCbCr-4:2:0
a=rtpmap:90 theora/90000
a=fmtp:90 height=576;width=704

BR Christian

pfandfrei commented 7 years ago

Please check pull request #50. It solved the problem for me.

Woersty commented 7 years ago

Thank you for this hint. Will try today and give feedback later. Haven't seen it but honestly I have not searched deeply.

BR Christian

Woersty commented 7 years ago

Wie ist die Syntax denn von -m ?

pfandfrei commented 7 years ago

add a pattern for the codecs you want to use, e.g. -m "G.711*", wildcards are supported. All other codecs will be removed before making an INVITE connection

Woersty commented 7 years ago

Ok, clear now. Thanks. Works. Geil 👍

Woersty commented 7 years ago

Ähm, wie gebe ich mehrere Codecs an? (How to enter more than one valid codec?) -m "G.711* G.722*" is not valid.

pfandfrei commented 7 years ago

More than one codec is not supported when not defined by a wildcard, because I did not think about it. I will try to make a better/extended solution in the next week. For your example you can use -m "G.7*"

Woersty commented 7 years ago

You saved my day anyway!

pfandfrei commented 7 years ago

@Woersty: Can you please replace Manager::AdjustMediaFormats in main.cpp by the following code:

void Manager::AdjustMediaFormats( bool local, const OpalConnection & connection, OpalMediaFormatList & mediaFormats ) const { PStringArray mask; std::string s; istringstream ss(mediaFilter); while (getline(ss, s, ';')) { mask.AppendString("!"+s); } mediaFormats.Remove(mask); }

Multiple codecs can now be defined separated by semicolon (e.g. -m "G.711*;G.722*") If you can confirm that it is working, I will create a new pull request

Woersty commented 7 years ago

I works partially. My problem is, that the name for the G.722 codes seems to be different from G.722 Where can I get a list of possible codecs names?

nethiker commented 7 years ago

Hello, I'm facing the same issue, from the opal libray log I've found this list: 0:00.266 sipcmd SIP Remote media formats set: G.722-64k,G.722.1-24k,G.722.1-32k,G.722.2,SILK-16,SpeexIETFWide-20.6k,SpeexWB,SpeexWide-20.6k,G.711-ALaw-64k,G.711-uLaw-64k,G.726-16k,G.726-24k,G.726-32k,G.726-40k,GSM-06.10,GSM-AMR,LPC-10,MS-GSM,MS-IMA-ADPCM,SILK-8,SpeexIETFNarrow-11k,SpeexIETFNarrow-15k,SpeexIETFNarrow-18.2k,SpeexIETFNarrow-24.6k,SpeexIETFNarrow-5.95k,SpeexIETFNarrow-8k,SpeexNB,SpeexWNarrow-8k,T.38,iLBC,iLBC-13k3,iLBC-15k2,UserInput/RFC2833,NamedSignalEvent,H.261,H.263,H.263plus,H.264,H.264-0,H.264-1,MPEG4,RFC4175_YCbCr-4:2:0,theora,MSRP,SIP-IM,T.140,H.224/H323AnnexQ

pfandfrei commented 7 years ago

if you use the -o "path-to-logfile" option without using the -m option, you will get a large debug output. make a grep 722 and you will get all available codec names for G.722 (4 in my FB7490) Other possibility is to output all available codecs when using -m option (or a different new option)

EDIT: Get a list of available and used Codecs when using -m option. Replace Manager::AdjustMediaFormats in main.cpp with: `
void Manager::AdjustMediaFormats( bool local, ///< Media formats a local ones to be presented to remote const OpalConnection & connection, ///< Connection that is about to use formats OpalMediaFormatList & mediaFormats ///< Media formats to use ) const { std::cout << "available codecs:" << std::endl; for (OpalMediaFormatList::iterator it1 = mediaFormats.begin(); it1!=mediaFormats.end(); it1++) { std::cout << " " << it1->GetName() << std::endl; }

PStringArray mask;
std::string s;   
istringstream ss(mediaFilter);
while (getline(ss, s, ';')) 
{
    mask.AppendString("!"+s);
}
mediaFormats.Remove(mask);

std::cout << "used codecs:" << std::endl;
for (OpalMediaFormatList::iterator it2 = mediaFormats.begin(); it2!=mediaFormats.end(); it2++)
{
    std::cout << "  " << it2->GetName() << std::endl;
}

}`

Woersty commented 7 years ago

Works. My fault. Sorry. **m=G.722*** = G.722-64k,G.722.1-24k,G.722.1-32k,G.722.2

v=0
o=- 1487530317 1 IN IP4 169.254.80.70
s=text2sip/1.0.1
c=IN IP4 169.254.80.70
t=0 0
m=audio 5000 RTP/AVP 9 117 118 120
a=sendrecv
a=rtpmap:9 G722/8000/1
a=rtpmap:117 G7221/16000/1
a=fmtp:117 bitrate=24000
a=rtpmap:118 G7221/16000/1
a=fmtp:118 bitrate=32000
a=rtpmap:120 AMR-WB/16000/1
a=fmtp:120 octet-align=1
a=maxptime:20

*m=G.711;G.722** = G.711-ALaw-64k,G.711-uLaw-64k,G.722-64k,G.722.1-24k,G.722.1-32k,G.722.2

v=0
o=- 1487530630 1 IN IP4 169.254.80.70
s=text2sip/1.0.1
c=IN IP4 169.254.80.70
t=0 0
m=audio 5000 RTP/AVP 8 0 9 117 118 120
a=sendrecv
a=rtpmap:8 PCMA/8000/1
a=rtpmap:0 PCMU/8000/1
a=rtpmap:9 G722/8000/1
a=rtpmap:117 G7221/16000/1
a=fmtp:117 bitrate=24000
a=rtpmap:118 G7221/16000/1
a=fmtp:118 bitrate=32000
a=rtpmap:120 AMR-WB/16000/1
a=fmtp:120 octet-align=1
a=maxptime:20

**m=G.711*** = G.711-ALaw-64k,G.711-uLaw-64k

v=0
o=- 1487530759 1 IN IP4 169.254.80.70
s=text2sip/1.0.1
c=IN IP4 169.254.80.70
t=0 0
m=audio 5000 RTP/AVP 8 0
a=sendrecv
a=rtpmap:8 PCMA/8000/1
a=rtpmap:0 PCMU/8000/1
a=maxptime:240

You can merge it. Many thanks!

Woersty commented 7 years ago

Just a comment: G.722 doesn't work with my FB7490 and Gigaset SL400 👎 So I will stay at G.711 only - but good that the option has multicodec support now. 🥇