From 777c3ee88a09ceab6d0769a79b1b8a11a683836e Mon Sep 17 00:00:00 2001 From: smorlat Date: Tue, 25 Nov 2008 20:44:38 +0000 Subject: [PATCH] merge patch from telezorg git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@180 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- linphone/coreapi/linphonecore.c | 11 +++++++++++ linphone/coreapi/linphonecore.h | 2 ++ .../include/mediastreamer2/mediastream.h | 3 +++ linphone/mediastreamer2/src/audiostream.c | 13 +++++++++---- linphone/mediastreamer2/src/msv4l2.c | 2 ++ 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/linphone/coreapi/linphonecore.c b/linphone/coreapi/linphonecore.c index 9115a2aa5..47bce6480 100644 --- a/linphone/coreapi/linphonecore.c +++ b/linphone/coreapi/linphonecore.c @@ -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 diff --git a/linphone/coreapi/linphonecore.h b/linphone/coreapi/linphonecore.h index 03a1b16c4..e26640090 100644 --- a/linphone/coreapi/linphonecore.h +++ b/linphone/coreapi/linphonecore.h @@ -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 diff --git a/linphone/mediastreamer2/include/mediastreamer2/mediastream.h b/linphone/mediastreamer2/include/mediastreamer2/mediastream.h index 0bb7b6731..b63f44613 100644 --- a/linphone/mediastreamer2/include/mediastreamer2/mediastream.h +++ b/linphone/mediastreamer2/include/mediastreamer2/mediastream.h @@ -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.*/ diff --git a/linphone/mediastreamer2/src/audiostream.c b/linphone/mediastreamer2/src/audiostream.c index 543eb39d2..7b0d6c5da 100644 --- a/linphone/mediastreamer2/src/audiostream.c +++ b/linphone/mediastreamer2/src/audiostream.c @@ -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); diff --git a/linphone/mediastreamer2/src/msv4l2.c b/linphone/mediastreamer2/src/msv4l2.c index 20416b8c7..267db5e3a 100644 --- a/linphone/mediastreamer2/src/msv4l2.c +++ b/linphone/mediastreamer2/src/msv4l2.c @@ -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