Commit 777c3ee8 authored by smorlat's avatar smorlat
Browse files

merge patch from telezorg



git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@180 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent f46b645b
......@@ -1352,6 +1352,12 @@ void linphone_core_init_media_streams(LinphoneCore *lc){
#endif
}
static void linphone_core_dtmf_received(RtpSession* s, int dtmf, void* user_data){
LinphoneCore* lc = (LinphoneCore*)user_data;
if (lc->vtable.dtmf_received != NULL)
lc->vtable.dtmf_received(lc, dtmf);
}
void linphone_core_start_media_streams(LinphoneCore *lc, LinphoneCall *call){
osip_from_t *me=linphone_core_get_primary_contact_parsed(lc);
const char *tool="linphone-" LINPHONE_VERSION;
......@@ -1396,6 +1402,11 @@ void linphone_core_start_media_streams(LinphoneCore *lc, LinphoneCall *call){
lc->play_file,
lc->rec_file);
}
if (lc->vtable.dtmf_received!=NULL){
/* replace by our default action*/
audio_stream_play_received_dtmfs(lc->audiostream,FALSE);
rtp_session_signal_connect(lc->audiostream->session,"telephone-event",(RtpCallback)linphone_core_dtmf_received,(unsigned long)lc);
}
audio_stream_set_rtcp_information(lc->audiostream, cname, tool);
}
#ifdef VIDEO_ENABLED
......
......@@ -404,6 +404,7 @@ typedef void (*AuthInfoRequested)(struct _LinphoneCore *lc, const char *realm, c
typedef void (*CallLogUpdated)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl);
typedef void (*TextMessageReceived)(struct _LinphoneCore *lc, LinphoneChatRoom *room, const char *from, const char *message);
typedef void (*GeneralStateChange)(struct _LinphoneCore *lc, LinphoneGeneralState *gstate);
typedef void (*DtmfReceived)(struct _LinphoneCore* lc, int dtmf);
typedef struct _LinphoneVTable
{
......@@ -425,6 +426,7 @@ typedef struct _LinphoneVTable
CallLogUpdated call_log_updated;
TextMessageReceived text_received;
GeneralStateChange general_state;
DtmfReceived dtmf_received;
} LinphoneCoreVTable;
typedef struct _LCCallbackObj
......
......@@ -43,6 +43,7 @@ struct _AudioStream
MSFilter *ec;/*echo canceler*/
unsigned int last_packet_count;
time_t last_packet_time;
bool_t play_dtmfs;
};
#ifdef __cplusplus
......@@ -78,6 +79,8 @@ void audio_stream_record(AudioStream *st, const char *name);
void audio_stream_set_rtcp_information(AudioStream *st, const char *cname, const char *tool);
void audio_stream_play_received_dtmfs(AudioStream *st, bool_t yesno);
/* those two function do the same as audio_stream_start() but in two steps
this is useful to make sure that sockets are open before sending an invite;
or to start to stream only after receiving an ack.*/
......
......@@ -62,14 +62,14 @@ static int dtmf_tab[16]={'0','1','2','3','4','5','6','7','8','9','*','#','A','B'
static void on_dtmf_received(RtpSession *s, int dtmf, void * user_data)
{
MSFilter *dtmfgen=(MSFilter*)user_data;
AudioStream *stream=(AudioStream*)user_data;
if (dtmf>15){
ms_warning("Unsupported telephone-event type.");
return;
}
ms_message("Receiving dtmf %c.",dtmf_tab[dtmf]);
if (dtmfgen!=NULL){
ms_filter_call_method(dtmfgen,MS_DTMF_GEN_PUT,&dtmf_tab[dtmf]);
if (stream->dtmfgen!=NULL && stream->play_dtmfs){
ms_filter_call_method(stream->dtmfgen,MS_DTMF_GEN_PUT,&dtmf_tab[dtmf]);
}
}
......@@ -209,7 +209,7 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char
stream->session=rtps;
stream->dtmfgen=ms_filter_new(MS_DTMF_GEN_ID);
rtp_session_signal_connect(rtps,"telephone-event",(RtpCallback)on_dtmf_received,(unsigned long)stream->dtmfgen);
rtp_session_signal_connect(rtps,"telephone-event",(RtpCallback)on_dtmf_received,(unsigned long)stream);
rtp_session_signal_connect(rtps,"payload_type_changed",(RtpCallback)payload_type_changed,(unsigned long)stream);
/* creates the local part */
......@@ -356,9 +356,14 @@ AudioStream *audio_stream_new(int locport, bool_t ipv6){
AudioStream *stream=(AudioStream *)ms_new0(AudioStream,1);
stream->session=create_duplex_rtpsession(locport,ipv6);
stream->rtpsend=ms_filter_new(MS_RTP_SEND_ID);
stream->play_dtmfs=TRUE;
return stream;
}
void audio_stream_play_received_dtmfs(AudioStream *st, bool_t yesno){
st->play_dtmfs=yesno;
}
int audio_stream_start_now(AudioStream *stream, RtpProfile * prof, const char *remip, int remport, int rem_rtcp_port, int payload_type, int jitt_comp, MSSndCard *playcard, MSSndCard *captcard, bool_t use_ec){
return audio_stream_start_full(stream,prof,remip,remport,rem_rtcp_port,
payload_type,jitt_comp,NULL,NULL,playcard,captcard,use_ec);
......
......@@ -17,7 +17,9 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "mediastreamer-config.h"
#endif
#ifdef HAVE_LINUX_VIDEODEV2_H
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment