SIP voice call on originating call leg gets converted into v

Problem summary
----------------------

SIP voice call on originating call leg gets converted into video call on terminating call leg

Problem description
------------------------

For a voice only call, Asterisk is exhibiting following behavior:

  1. Originating leg: User A to Asterisk --> INVITE with audio codecs only
  2. Terminating leg: Asterisk to User B --> INVITE with audio and video codecs
  3. Terminating leg: User B to Asterisk --> 200 OK with audio and video codecs
  4. Originating leg: Asterisk to User A --> 200 OK with audio codecs only
  5. Terminating leg: Asterisk to User B --> ACK
  6. Originating leg: User A to Asterisk --> ACK

To summarize, Asterisk is advertising video codec on the terminating leg even when the videosupport option has been turned off and there is no video codec present in the SDP on the originating leg. This behavior is pretty similar to https://issues.asterisk.org/view.php?id=18880 except for the fact that we have tried turning off videosupport but it still does not help

Requirement
----------------

  1. It should be possible to make either a voice only call or a video call from SIP soft client A to SIP soft client B via Asterisk server
  2. Voice call on originating call leg should not be converted to video call on terminating call leg
  3. Media has to flow directly between user agents and not through Asterisk

Configuration done in sip.conf
------------------------------------

[userA]
type=friend
username=test
videosupport=yes
disallow=all
allow=ulaw
allow=alaw
allow=h263
canreinvite=yes
secret=123
host=dynamic
context=local_call

[userB]
type=friend
username=mds
videosupport=yes
disallow=all
allow=ulaw
allow=alaw
allow=h263
secret=123
host=dynamic
context=local_call

Configuration done in extenstions.conf
-----------------------------------------------

[local_call]
exten => 4321,1,Dial(SIP/userA)
exten => 1112,1,Dial(SIP/userB)

Question to the forum
---------------------------

Is there a way in which Asterix shall use originating call leg codecs on the terminating call leg and allow the media (voice/video) to flow directly between the 2 user agents?
Asterisk should be able to support voice as well as video codecs for the same set of terminals i.e. if call is a voice call then only voice codecs should be used and if it is a video call then video+voice codecs should be used. How can this be achieved with Asterisk?

canreinvite has been replaced by directmedia, and both sides need it for the media to bypass Asterisk. There are other constraints, no recordings and no features that require DTMF to be analysed.