Review Board 1.7.16


Improve behavior of ast_answer() to not lose incoming frames

Review Request #196 - Created March 16, 2009 and submitted

Kevin Fleming
trunk
Reviewers
asterisk-dev
Asterisk
ast_answer(), when supplied a delay before returning to the caller, use ast_safe_sleep() to implement the delay. Unfortunately during this time any incoming frames are discarded, which is problematic for T.38 re-INVITES and other sorts of channel operations.

When a delay is not passed to ast_answer(), it still delays for up to 500 milliseconds, waiting for media to arrive. Again, though, it discards any control frames, or non-voice media frames.

This patch rectifies this situation, by storing all incoming frames during the delay period on a list, and then requeuing them onto the channel before returning to the caller.
Compile testing only.

Diff revision 2

This is not the most recent revision of the diff. The latest diff is revision 3. See what's changed.

1 2 3
1 2 3

  1. /trunk/include/asterisk/channel.h: Loading...
  2. /trunk/main/channel.c: Loading...
  3. /trunk/main/features.c: Loading...
/trunk/include/asterisk/channel.h
Revision 182399 New Change
[20] 1007 lines
[+20] [+] void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset);
1008
 * This function answers a channel and handles all necessary call
1008
 * This function answers a channel and handles all necessary call
1009
 * setup functions.
1009
 * setup functions.
1010
 *
1010
 *
1011
 * \note The channel passed does not need to be locked.
1011
 * \note The channel passed does not need to be locked.
1012
 *
1012
 *

    
   
1013
 * \note This function will wait up to 500 milliseconds for media to

    
   
1014
 * arrive on the channel before returning to the caller, so that the

    
   
1015
 * caller can properly assume the channel is 'ready' for media flow.

    
   
1016
 *
1013
 * \retval 0 on success
1017
 * \retval 0 on success
1014
 * \retval non-zero on failure
1018
 * \retval non-zero on failure
1015
 */
1019
 */
1016
int ast_answer(struct ast_channel *chan);
1020
int ast_answer(struct ast_channel *chan);

    
   
1021

   

    
   
1022
/*!

    
   
1023
 * \brief Answer a channel

    
   
1024
 *

    
   
1025
 * \param chan channel to answer

    
   
1026
 * \param cdr_answer flag to control whether any associated CDR should be marked as 'answered'

    
   
1027
 *

    
   
1028
 * This function answers a channel and handles all necessary call

    
   
1029
 * setup functions.

    
   
1030
 *

    
   
1031
 * \note The channel passed does not need to be locked.

    
   
1032
 *

    
   
1033
 * \note Unlike ast_answer(), this function will not wait for media

    
   
1034
 * flow to begin. The caller should be careful before sending media

    
   
1035
 * to the channel before incoming media arrives, as the outgoing

    
   
1036
 * media may be lost.

    
   
1037
 *

    
   
1038
 * \retval 0 on success

    
   
1039
 * \retval non-zero on failure

    
   
1040
 */

    
   
1041
int ast_raw_answer(struct ast_channel *chan, int cdr_answer);

    
   
1042

   

    
   
1043
/*!

    
   
1044
 * \brief Answer a channel, with a selectable delay before returning

    
   
1045
 *

    
   
1046
 * \param chan channel to answer

    
   
1047
 * \param delay maximum amount of time to wait for incoming media

    
   
1048
 * \param cdr_answer flag to control whether any associated CDR should be marked as 'answered'

    
   
1049
 *

    
   
1050
 * This function answers a channel and handles all necessary call

    
   
1051
 * setup functions.

    
   
1052
 *

    
   
1053
 * \note The channel passed does not need to be locked.

    
   
1054
 *

    
   
1055
 * \note This function will wait up to 'delay' milliseconds for media to

    
   
1056
 * arrive on the channel before returning to the caller, so that the

    
   
1057
 * caller can properly assume the channel is 'ready' for media flow. If

    
   
1058
 * 'delay' is less than 500, the function will wait up to 500 milliseconds.

    
   
1059
 *

    
   
1060
 * \retval 0 on success

    
   
1061
 * \retval non-zero on failure

    
   
1062
 */
1017
int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer);
1063
int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer);
1018

    
   
1064

   
1019
/*! \brief Make a call
1065
/*! \brief Make a call
1020
 * \param chan which channel to make the call on
1066
 * \param chan which channel to make the call on
1021
 * \param addr destination of the call
1067
 * \param addr destination of the call
[+20] [20] 705 lines
/trunk/main/channel.c
Revision 182399 New Change
 
/trunk/main/features.c
Revision 182399 New Change
 
  1. /trunk/include/asterisk/channel.h: Loading...
  2. /trunk/main/channel.c: Loading...
  3. /trunk/main/features.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.