Hi Vadim,

Regarding my suggestion below, let me post here some code blocks so you can have a better idea of what I'm planning to do:

1- First of all members "ptime" created on "eXosip_event_t" and "ph_mstream_params_s" (on version 2.2 if I'm not wrong), won't be necessary any more. And the changes on method "eXosip_get_sdp_media_info" to return "ptime" value won't be necessary as well. Method "eXosip_get_sdp_audio_ptime" stay and become public;

2- Method "osip_negotiation_ctx_execute_negotiation" will call a new method called "osip_negotiation_execute_media_negotiation" responsible for make a kind of packetization negotiation considering for now the "ptime" attribute and "mode" paramater of iLBC payload. This negotiation will be placed only on "audio" type medias, and codes for this negotiation can be seen on "packet_negoc.txt" attached file;

3- All info extraction and assignment to "ptime" and "fmtp" fields of respective "ph_media_payload_s" for "opayloads" and "ipaylodas" will take place at "ph_call_media_start" method. Just one place will be responsible for all data extraction and assignment of necessary fields to be used at "ph_msession_audio_stream_hardstart" method for codecs initialization and for buffer allocation along the life time of the coding/decoding process. Code that returns the right "ptime" for incoming and outgoing scenarios is on "ptime_get.txt" attached file;

I'm working now on a similar method to retrieve the "fmtp" modifiers so I can use them and "in_ptime" and "out_ptime" retrieve with above method to set the "ph_media_payload_s" respective infos.

As we agreed before, the codec will be responsible for analyse the content of "fmtp" field, but I think it will be better if we update the "mode" field of "ph_media_payload_s" structure (instead of "ptime" one) after this analysis and let the computing of final packetization to be assigned on "phastream_t" for a calculation that will take place on "ph_msession_audio_stream_hardstart" method.
And I suggest that "ptime" field from "phastream_t" will be replaced by "in_ptime" and "out_ptime" fields to be used on buffer allocation.

Right after I intend to make the necessary adjustments on "ph_msession_audio_stream_hardstart" and on every buffer allocation point (if necessary).

Please let me know if you have any doubts or disagreements about what I've described above ok?
I confess I'm not very secure about what I can and I can't do... so I need your advise for sure on it, mainly on negotiation procedure codes I've sent.

Thanks, best regards and have a good weekend!
Mauro.




Mauro Sérgio Ferreira Brasil escreveu:
Hi Vadim,

No problem about the delay.
It was good in fact because I was involved on other demands here, and I had a chance to make a new reading of necessary RFC's.

After reading the RFC's and giving a better look on code, I think the last patch will need some adjustments and new patch I was working with too.

The main points are:

1- We need to work with 2 packetization indication scenarios (initiating call and receiving call);
2- When initiating a call we have the possibility to work with different packetization on incoming and outgoing channels (this will affect buffer allocation and codec initialization);
3- Some packetization paramaters (like "mode" of iLBC) are bi-directional what will demand additional care, as explained here "http://www.rfc-editor.org/rfc/rfc3952.txt";

My suggestion is to create a patch with following premisses:

1- Only "ptime" and iLBC "mode" packetization indicators will be handled for now;
2- As suggested by you, we will work with same packetization on call receiving scenario, and accept different packetization on call initiation (if the other part indicates a different value of course);

Considering what was described above, I would like to suggest the following adjustments/validations:

1- Add parameter "int bIsIncomingCall" (indicating that the call was received or not) to method "osip_negotiation_ctx_execute_negotiation" that will be used on a kind of "packetization parameters negotiation" on such a way that our local SDP will be updated with according "ptime" and/or "fmtp" attributes;

2- Add the "ptime:20" attribute on method "eXosip_initiate_call" so the INVITE always indicate the preferred Qutecom packetization;

3- Make the necessary changes on previous patch, and on work that was already done about handle of "ptime" and iLBC "mode" on call receiving, to consider the scenario of different packetinzation for incoming and outgoing channel so we can have final and correct values to "in_ptime" and "out_ptime" that will be the new fields of "phastream_t" used on buffer allocation and audio initialization for both channels;

4- Validate all points where the method "ph_astream_decoded_framesize_get" is used to validate whether the changes to consider different packetization won't cause any problems;

That's it.
I think this will cover all changes necessary to have Qutecom libraries working with packetization parameters as dinamicaly as possible for now.

Could you please send me your impressions about all I've suggested above ?

Thanks and best regards,
Mauro.



--
TQI - Technology and Quality on Information
At.,                                                                                                                               
 
Technology and Quality on Information
Mauro Sérgio Ferreira Brasil
Coordenador de Projetos e Analista de Sistemas
+ [email protected]
: www.tqi.com.br
( + 55 (34)3291-1700
( + 55 (34)9971-2572
/*
 * @param attr_name         Name of local and remote SDP's field that will be 
compared.
 * @param local_attr_value  Value of local SDP field.
 * @param remote_attr_value Value of remote SDP field.
 * Return:
 *   -1 : indicates remote attrib don't need to be added to local SDP;
 *   0  : indicates remote attrib must be added to local SDP;
 *   1  : indicates remote attrib must replace the one on local SDP;
 */
static int 
osip_negotiation_execute_attrib_negotiation(char *attr_name, char 
*local_attr_value, char *remote_attr_value)
{
  int max_cmp_size = 0;
  
  if (strcmp(attr_name, "fmtp") == 0)
  {
    char* local_mode_str = NULL;
    char* remote_mode_str = NULL;
    
    if ( ((local_mode_str = strstr(local_attr_value, " mode=")) != NULL) && 
        ((remote_mode_str = strstr(remote_attr_value, " mode=")) != NULL) )
    {
      int local_mode = 0;
      int remote_mode = 0;
      
      sscanf(local_attr_value, " mode=\"%d\"", &local_mode);
      sscanf(remote_attr_value, " mode=\"%d\"", &remote_mode);
      
      if (remote_mode > local_mode)
      {
        return 1;
      }
    }
  }
  
  return -1;
}

static void 
osip_negotiation_execute_media_negotiation(sdp_message_t *local, 
                                                                                
   sdp_media_t *local_media, 
                                                                                
   int local_media_index, 
                                                                                
   sdp_message_t *remote, 
                                                                                
   int bIsIncomingCall)
{
  sdp_attribute_t *remote_attrib = NULL;
  sdp_attribute_t *local_attrib = NULL;
  int attrib_index = 0;
  int remote_media_pos = -1;
  int bAddAttrib = 0;
  int bIncIndex = 1;
  int iAttribRet;
  char *payload_id = NULL;
  
  payload_id = sdp_message_m_payload_get(local, local_media_index, 0);
  
  if (payload_id != NULL)
  {
    remote_media_pos = sdp_message_get_media_pos(
        remote, local_media->m_media, payload_id);
  }
  
  if (remote_media_pos != -1)
  {
    while ((remote_attrib = sdp_message_attribute_get(
        remote, remote_media_pos, attrib_index)) != NULL)
    {
      // Negotiation involves only packetization attributes and 
      // parameters.
      //
      if (strcmp(remote_attrib->a_att_field, "ptime") == 0)
      {
        if ((local_attrib = sdp_message_att_find(local, local_media_index, 
            remote_attrib->a_att_field, payload_id)) == NULL)
            {
          if (bIsIncomingCall)
          {
            sdp_message_a_attribute_add(local, local_media_index, 
                osip_strdup(remote_attrib->a_att_field), 
                osip_strdup(remote_attrib->a_att_value));
          }
          else
          {
            sdp_message_a_attribute_add(local, local_media_index, 
                osip_strdup(remote_attrib->a_att_field), 
                osip_strdup("20"));
          }
            }
            else
            {
          sdp_message_a_attribute_add(local, local_media_index, 
              osip_strdup(remote_attrib->a_att_field), 
              osip_strdup(remote_attrib->a_att_value));
            }
          }
      
      if (strcmp(remote_attrib->a_att_field, "fmtp") == 0)
      {
        int bAddAttrib = 0;
        
            if ((local_attrib = sdp_message_att_find(local, local_media_index, 
            remote_attrib->a_att_field, payload_id)) == NULL)
            {
          if (strstr(remote_attrib->a_att_value, " mode=") != NULL)
          {
                bAddAttrib = 1;
          }
            }
            else if ((iAttribRet = osip_negotiation_execute_attrib_negotiation(
            remote_attrib->a_att_field, remote_attrib->a_att_value, 
            local_attrib->a_att_value)) >= 0)
            {
          bAddAttrib = 1;
          
          if (iAttribRet == 1)
          {
            sdp_message_a_attribute_del(local, 
                local_media_index, local_attrib->a_att_field);
          }
        }
        
        if (bAddAttrib == 1)
        {
          sdp_message_a_attribute_add(local, local_media_index, 
              osip_strdup(remote_attrib->a_att_field), 
              osip_strdup(remote_attrib->a_att_value));
        }
      }
      
      attrib_index++;
    }
  }
}

int
osip_negotiation_ctx_execute_negotiation (osip_negotiation_t * config,
                                          osip_negotiation_ctx_t * context, int 
bIsIncomingCall)

/*
 * @param source_id  From which SDP info must be retrieved. "0" indicates local 
SDP 
 *                   and "1" remote SDP.
 * @param is_incomming_call  Indicates whether we should get "ptime" 
considering 
 *                           a receiveing call or a call initiated localy.
 */
int eXosip_get_audio_ptime_from_call(int jid, int source_id, int 
is_incomming_call)
{
  eXosip_dialog_t *jd = NULL;
  eXosip_call_t *jc = NULL;
  
  if (jid>0)
  {
    eXosip_call_dialog_find(jid, &jc, &jd);
  }
  
  if (jd==NULL)
  {
     OSIP_TRACE (osip_trace
       (__FILE__, __LINE__, OSIP_ERROR, NULL,
       "eXosip: No call here?\n"));
      return 20;
  }
  
  if (source_id == 0)
  {
    return eXosip_get_sdp_audio_ptime(
        osip_negotiation_ctx_get_local_sdp(jc->c_ctx));
  }
  else if (is_incomming_call == 0)
  {
    return eXosip_get_sdp_audio_ptime(
        osip_negotiation_ctx_get_remote_sdp(jc->c_ctx));
  }
  else
  {
    return eXosip_get_sdp_audio_ptime(
        eXosip_get_remote_sdp(jc->c_inc_tr));
  }
}
_______________________________________________
QuteCom-dev mailing list
[email protected]
http://lists.qutecom.org/mailman/listinfo/qutecom-dev

Reply via email to