diff --git a/sflphone-gtk/src/actions.c b/sflphone-gtk/src/actions.c index 161935df460a4759343761a1d3ede8832d9d49a3..6d6bbe50b07bdde12073bf4567ab5dd476d2f2f5 100644 --- a/sflphone-gtk/src/actions.c +++ b/sflphone-gtk/src/actions.c @@ -135,6 +135,8 @@ sflphone_hung_up( call_t * c) #if GTK_CHECK_VERSION(2,10,0) status_tray_icon_blink( FALSE ); #endif + + statusbar_pop_message(__MSG_ACCOUNT_DEFAULT); } /** Internal to actions: Fill account list */ @@ -449,6 +451,10 @@ process_dialing(call_t * c, guint keyval, gchar * key) dbus_start_tone( FALSE , 0 ); //dbus_play_dtmf( key ); } + + g_print("process_dialing : keyval : %i \n",keyval); + g_print("process_dialing : key : %s \n",key); + switch (keyval) { case 65293: /* ENTER */ @@ -462,9 +468,10 @@ process_dialing(call_t * c, guint keyval, gchar * key) { /* Brackets mandatory because of local vars */ gchar * before = c->to; if(strlen(c->to) >= 1){ + c->to = g_strndup(c->to, strlen(c->to) -1); g_free(before); - g_print("TO: %s\n", c->to); + g_print("TO: backspace %s\n", c->to); if(c->state == CALL_STATE_DIALING) { @@ -487,14 +494,16 @@ process_dialing(call_t * c, guint keyval, gchar * key) case 65509: /* CAPS */ break; default: - if (keyval < 255 || (keyval >65453 && keyval < 65466)) + // if (keyval < 255 || (keyval >65453 && keyval < 65466)) + if (keyval < 127) { - if(c->state != CALL_STATE_TRANSFERT) + + if(c->state != CALL_STATE_TRANSFERT) dbus_play_dtmf( key ); gchar * before = c->to; c->to = g_strconcat(c->to, key, NULL); g_free(before); - g_print("TO: %s\n", c->to); + g_print("TO:default %s\n", c->to); if(c->state == CALL_STATE_DIALING) { @@ -512,6 +521,9 @@ process_dialing(call_t * c, guint keyval, gchar * key) call_t * sflphone_new_call() { + + sflphone_on_hold(); + // Play a tone when creating a new call if( call_list_get_size(current_calls) == 0 ) dbus_start_tone( TRUE , ( voice_mails > 0 )? TONE_WITH_MESSAGE : TONE_WITHOUT_MESSAGE) ; @@ -539,7 +551,7 @@ sflphone_new_call() void sflphone_keypad( guint keyval, gchar * key) { - + call_t * c = call_get_selected(current_calls); if(c) { @@ -548,6 +560,7 @@ sflphone_keypad( guint keyval, gchar * key) case CALL_STATE_DIALING: // Currently dialing => edit number process_dialing(c, keyval, key); break; + case CALL_STATE_RECORD: case CALL_STATE_CURRENT: switch (keyval) { @@ -681,7 +694,17 @@ sflphone_place_call ( call_t * c ) else { - account_t * current = account_list_get_current(); + account_t * current; + + if(c->accountID != 0) + current = account_list_get_by_id(c->accountID); + else + current = account_list_get_current(); + + // printf("sflphone_place_call :: c->accountID : %i \n",c->accountID); + + // account_t * current = c->accountID; + if( current ) { if(g_strcasecmp(g_hash_table_lookup( current->properties, "Status"),"REGISTERED")==0) @@ -724,6 +747,31 @@ sflphone_place_call ( call_t * c ) } +void +sflphone_display_selected_codec (const gchar* codecName) +{ + call_t * selectedCall = call_get_selected(current_calls); + gchar* msg; + account_t* acc; + if(selectedCall->accountID != NULL){ + acc = account_list_get_by_id(selectedCall->accountID); + msg = g_markup_printf_escaped(_("%s account- %s %s") , + (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_TYPE), + (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS), + codecName); + statusbar_push_message( msg , __MSG_ACCOUNT_DEFAULT); + g_free(msg); + } + +} + +gchar* +sflphone_get_current_codec_name() +{ + call_t * selectedCall = call_get_selected(current_calls); + return dbus_get_current_codec_name(selectedCall); +} + void sflphone_rec_call() { @@ -745,6 +793,9 @@ sflphone_rec_call() } update_call_tree(current_calls,selectedCall); update_menus(); + + // gchar* codname = sflphone_get_current_codec_name(); + // printf("sflphone_get_current_codec_name: %s \n",codname); } /* Internal to action - set the __CURRENT_ACCOUNT variable */ @@ -807,3 +858,4 @@ sflphone_fill_codec_list() exit(0); } } + diff --git a/sflphone-gtk/src/actions.h b/sflphone-gtk/src/actions.h index ebe0157fe885f0ba6293c45bf42cdf1d44ebfdc4..7c22eeb1b9cc7d9a57fb930ff14580bbc8294cf1 100644 --- a/sflphone-gtk/src/actions.h +++ b/sflphone-gtk/src/actions.h @@ -168,4 +168,8 @@ void sflphone_fill_codec_list(); void sflphone_record (call_t *c); void sflphone_rec_call (void); + +gchar* sflphone_get_current_codec_name(); + +void sflphone_display_selected_codec (const gchar* codecName); #endif diff --git a/sflphone-gtk/src/callmanager-glue.h b/sflphone-gtk/src/callmanager-glue.h index c4123cd1e39732f6931696431c5de88d78df6c31..1921fbb0e0b630413699dc5b7c71d2e308b4ba5c 100644 --- a/sflphone-gtk/src/callmanager-glue.h +++ b/sflphone-gtk/src/callmanager-glue.h @@ -529,6 +529,44 @@ org_sflphone_SFLphone_CallManager_get_current_call_id_async (DBusGProxy *proxy, stuff->userdata = userdata; return dbus_g_proxy_begin_call (proxy, "getCurrentCallID", org_sflphone_SFLphone_CallManager_get_current_call_id_async_callback, stuff, g_free, G_TYPE_INVALID); } +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +org_sflphone_SFLphone_CallManager_get_current_codec_name (DBusGProxy *proxy, const char * IN_callID, char ** OUT_codecName, GError **error) + +{ + return dbus_g_proxy_call (proxy, "getCurrentCodecName", error, G_TYPE_STRING, IN_callID, G_TYPE_INVALID, G_TYPE_STRING, OUT_codecName, G_TYPE_INVALID); +} + +typedef void (*org_sflphone_SFLphone_CallManager_get_current_codec_name_reply) (DBusGProxy *proxy, char * OUT_codecName, GError *error, gpointer userdata); + +static void +org_sflphone_SFLphone_CallManager_get_current_codec_name_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + char * OUT_codecName; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_codecName, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_CallManager_get_current_codec_name_reply)data->cb) (proxy, OUT_codecName, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +org_sflphone_SFLphone_CallManager_get_current_codec_name_async (DBusGProxy *proxy, const char * IN_callID, org_sflphone_SFLphone_CallManager_get_current_codec_name_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_new (DBusGAsyncData, 1); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "getCurrentCodecName", org_sflphone_SFLphone_CallManager_get_current_codec_name_async_callback, stuff, g_free, G_TYPE_STRING, IN_callID, G_TYPE_INVALID); +} #endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_sflphone_SFLphone_CallManager */ G_END_DECLS diff --git a/sflphone-gtk/src/calltree.c b/sflphone-gtk/src/calltree.c index 9b56a004f7abb92acc019f3d55b6b783adbe1809..dd205d3f099a39f380bcec71775097e706393aa0 100644 --- a/sflphone-gtk/src/calltree.c +++ b/sflphone-gtk/src/calltree.c @@ -37,7 +37,7 @@ GtkToolItem * hangupButton; GtkToolItem * holdButton; GtkToolItem * transfertButton; GtkToolItem * unholdButton; -GtkToolItem * historyButton; +// GtkToolItem * historyButton; GtkToolItem * mailboxButton; GtkToolItem * recButton; guint transfertButtonConnId; //The button toggled signal connection ID @@ -395,6 +395,7 @@ void row_activated(GtkTreeView *tree_view UNUSED, break; } } + // if history else { newCall = g_new0( call_t, 1 ); @@ -405,7 +406,8 @@ void row_activated(GtkTreeView *tree_view UNUSED, g_sprintf(newCall->callID, "%d", rand()); newCall->_start = 0; newCall->_stop = 0; - + printf("call : account : %s \n", selectedCall->accountID); + newCall->accountID = selectedCall->accountID; printf("call : from : %s to %s\n", newCall->from, newCall->to); call_list_add(current_calls, newCall); update_call_tree_add(current_calls, newCall); @@ -689,6 +691,7 @@ update_call_tree (calltab_t* tab, call_t * c) } else { + g_print("Stuff to be printed %s %s \n",call_get_number(c),call_get_name(c)); description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>", call_get_number(c), call_get_name(c)); diff --git a/sflphone-gtk/src/dbus.c b/sflphone-gtk/src/dbus.c index e56170f64f09f6f8824060f4ddacb015b7bcec1b..b58b4d667374ec1ca284dda6f251aaa1c64b7ab6 100644 --- a/sflphone-gtk/src/dbus.c +++ b/sflphone-gtk/src/dbus.c @@ -60,6 +60,15 @@ incoming_call_cb (DBusGProxy *proxy UNUSED, sflphone_incoming_call (c); } +static void +curent_selected_codec (DBusGProxy *proxy UNUSED, + const gchar* callID, + const gchar* codecName, + void * foo UNUSED ) +{ + g_print ("Codec decided! %s\n",codecName); + sflphone_display_selected_codec (codecName); +} static void volume_changed_cb (DBusGProxy *proxy UNUSED, @@ -232,6 +241,14 @@ dbus_connect () dbus_g_proxy_connect_signal (callManagerProxy, "incomingCall", G_CALLBACK(incoming_call_cb), NULL, NULL); + /* Current codec */ + dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_STRING_STRING, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, + "currentSelectedCodec", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, + "currentSelectedCodec", G_CALLBACK(curent_selected_codec), NULL, NULL); + /* Register a marshaller for STRING,STRING */ dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); @@ -649,6 +666,30 @@ dbus_codec_details( int payload ) return array; } +gchar* +dbus_get_current_codec_name(const call_t * c) +{ + + printf("dbus_get_current_codec_name : CallID : %s \n", c->callID); + + gchar* codecName; + GError* error = NULL; + + org_sflphone_SFLphone_CallManager_get_current_codec_name ( + callManagerProxy, + c->callID, + &codecName, + &error); + if(error) + { + g_error_free(error); + } + + printf("dbus_get_current_codec_name : codecName : %s \n", codecName); + + return codecName; +} + gchar** diff --git a/sflphone-gtk/src/dbus.h b/sflphone-gtk/src/dbus.h index b6c1ebddfd468a6baba24276a02d9aa19ce2d198..f347a4a47e4395900d8b4fb4edb9417e9b82a421 100644 --- a/sflphone-gtk/src/dbus.h +++ b/sflphone-gtk/src/dbus.h @@ -177,6 +177,12 @@ gchar** dbus_get_active_codec_list( void ); */ void dbus_set_active_codec_list( const gchar** list ); +/** + * CallManager - return the codec name + * @param call_t* current call + */ +gchar* dbus_get_current_codec_name(const call_t * c); + /** * ConfigurationManager - Get the list of available input audio plugins * @return gchar** The list of plugins diff --git a/sflphone-gtk/src/mainwindow.c b/sflphone-gtk/src/mainwindow.c index 9eb1a34fcc1d2b93831e84f630c6579fa0ffe5f3..6eaa0c0c723bed27ae928c77d4360422a6da2017 100644 --- a/sflphone-gtk/src/mainwindow.c +++ b/sflphone-gtk/src/mainwindow.c @@ -104,7 +104,7 @@ create_main_window () window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width (GTK_CONTAINER (window), 0); gtk_window_set_title (GTK_WINDOW (window), PACKAGE); - gtk_window_set_default_size (GTK_WINDOW (window), 260, 320); + gtk_window_set_default_size (GTK_WINDOW (window), 258, 320); gtk_window_set_default_icon_from_file (ICONS_DIR "/sflphone.png", NULL); gtk_window_set_position( GTK_WINDOW( window ) , GTK_WIN_POS_MOUSE); diff --git a/sflphone-gtk/src/menus.c b/sflphone-gtk/src/menus.c index fcd371ac0a430e6dada126b7339c3586be4eede3..c0a21e40f1238f66570060ba8f3a51c9d43c714a 100644 --- a/sflphone-gtk/src/menus.c +++ b/sflphone-gtk/src/menus.c @@ -38,6 +38,7 @@ GtkWidget * newCallMenu; GtkWidget * holdMenu; GtkWidget * copyMenu; GtkWidget * pasteMenu; +GtkWidget * recordMenu; guint holdConnId; //The hold_menu signal connection ID @@ -55,6 +56,7 @@ void update_menus() gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), FALSE); gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),FALSE); gtk_widget_set_sensitive( GTK_WIDGET(holdMenu), FALSE); + gtk_widget_set_sensitive( GTK_WIDGET(recordMenu), FALSE); gtk_widget_set_sensitive( GTK_WIDGET(copyMenu), FALSE); call_t * selectedCall = call_get_selected(active_calltree); @@ -83,20 +85,17 @@ void update_menus() gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),TRUE); break; case CALL_STATE_CURRENT: + case CALL_STATE_RECORD: gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE); gtk_widget_set_sensitive( GTK_WIDGET(holdMenu), TRUE); gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),TRUE); + gtk_widget_set_sensitive( GTK_WIDGET(recordMenu), TRUE); gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( holdMenu ), gtk_image_new_from_file( ICONS_DIR "/icon_hold.svg")); break; case CALL_STATE_BUSY: case CALL_STATE_FAILURE: gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE); break; - case CALL_STATE_RECORD: - gtk_widget_set_sensitive( GTK_WIDGET(hangUpMenu), TRUE); - gtk_widget_set_sensitive( GTK_WIDGET(holdMenu), TRUE); - gtk_widget_set_sensitive( GTK_WIDGET(newCallMenu),TRUE); - break; default: g_warning("Should not happen in update_menus()!"); break; @@ -225,6 +224,12 @@ call_hang_up ( void * foo UNUSED) sflphone_hang_up(); } +static void +call_record ( void * foo UNUSED) +{ + sflphone_rec_call(); +} + static void call_wizard ( void * foo UNUSED) { @@ -318,6 +323,16 @@ create_call_menu() NULL); gtk_widget_show (menu_items); + image = gtk_tool_button_new_from_stock (GTK_STOCK_MEDIA_RECORD); + recordMenu = gtk_image_menu_item_new_with_mnemonic(_("_Record")); + gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( recordMenu ), image ); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), recordMenu); + gtk_widget_set_sensitive( GTK_WIDGET(recordMenu), FALSE); + g_signal_connect_swapped (G_OBJECT (recordMenu), "activate", + G_CALLBACK (call_record), + NULL); + gtk_widget_show (recordMenu); + // Separator menu_items = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); @@ -682,7 +697,7 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event) { // TODO update the selection to make sure the call under the mouse is the call selected - gboolean pickup = FALSE, hangup = FALSE, hold = FALSE, copy = FALSE; + gboolean pickup = FALSE, hangup = FALSE, hold = FALSE, copy = FALSE, record = FALSE; gboolean accounts = FALSE; call_t * selectedCall = call_get_selected(current_calls); @@ -707,9 +722,11 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event) hangup = TRUE; accounts = TRUE; break; + case CALL_STATE_RECORD: case CALL_STATE_CURRENT: hangup = TRUE; hold = TRUE; + record = TRUE; break; case CALL_STATE_BUSY: case CALL_STATE_FAILURE: @@ -791,6 +808,18 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event) gtk_widget_show (menu_items); } + if(record) + { + menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Record")); + image = gtk_tool_button_new_from_stock (GTK_STOCK_MEDIA_RECORD); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items); + g_signal_connect (G_OBJECT (menu_items), "activate", + G_CALLBACK (call_record), + NULL); + gtk_widget_show (menu_items); + } + if(accounts) { menu_items = gtk_separator_menu_item_new (); diff --git a/sflphone-gtk/src/sflnotify.c b/sflphone-gtk/src/sflnotify.c index a71ba9ea0e17b49a45934995aad9972ff4fa095a..b00123dfda655cc4da441d78b46ce37bdb59695e 100644 --- a/sflphone-gtk/src/sflnotify.c +++ b/sflphone-gtk/src/sflnotify.c @@ -205,8 +205,10 @@ notify_no_registered_accounts( ) gchar* body=""; notify_init("sflphone"); + body = g_markup_printf_escaped(_("You have no registered accounts")); + title = g_markup_printf_escaped(_("Error")); pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/sflphone.png", NULL); @@ -223,9 +225,10 @@ notify_no_registered_accounts( ) notify_notification_set_timeout( notification , NOTIFY_EXPIRES_DEFAULT ); notify_notification_add_action( notification , "setup" , _("Setup Accounts") , (NotifyActionCallback) setup_accounts_cb , NULL , NULL ); - if (!notify_notification_show (notification, NULL)) { - g_print("notify(), failed to send notification\n"); - } + if (!notify_notification_show (notification, NULL)) { + g_print("notify(), failed to send notification\n"); + } + } void diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index 319ba0d92626666004fe4da8aa5509e599129746..4a35ebca25329ed9d07b9bd6ffa8e9b42db9a34f 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -116,6 +116,7 @@ AudioRtpRTX::AudioRtpRTX (SIPCall *sipcall, bool sym) : time(new ost::Time()), _ _sym(sym), micData(NULL), micDataConverted(NULL), micDataEncoded(NULL), spkrDataDecoded(NULL), spkrDataConverted(NULL), converter(NULL), _layerSampleRate(),_codecSampleRate(), _layerFrameSize(), _audiocodec(NULL) { + setCancel(cancelDefault); // AudioRtpRTX should be close if we change sample rate // TODO: Change bind address according to user settings. @@ -150,6 +151,7 @@ AudioRtpRTX::~AudioRtpRTX () { delete _session; _session = NULL; } + delete [] micData; micData = NULL; delete [] micDataConverted; micDataConverted = NULL; delete [] micDataEncoded; micDataEncoded = NULL; @@ -163,6 +165,8 @@ AudioRtpRTX::~AudioRtpRTX () { } + + void AudioRtpRTX::initBuffers() { @@ -248,6 +252,7 @@ AudioRtpRTX::initAudioRtpSession (void) _debugException("! ARTP Failure: initialisation failed"); throw; } + } void @@ -312,14 +317,18 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) { + if (_ca == 0) { return; } //try { + AudioLayer* audiolayer = Manager::instance().getAudioDriver(); if (!audiolayer) { return; } const ost::AppDataUnit* adu = NULL; // Get audio data stream + // printf("AudioRtpRTX::receiveSessionForSpkr() %i \n",_session->getFirstTimestamp()); + if (!_sym) { adu = _sessionRecv->getData(_sessionRecv->getFirstTimestamp()); } else { @@ -330,10 +339,14 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) return; } + + //int payload = adu->getType(); // codec type unsigned char* spkrData = (unsigned char*)adu->getData(); // data in char unsigned int size = adu->getSize(); // size in char + // printf("AudioRtpRTX::receiveSessionForSpkr() Size of data from %i \n",size); + // Decode data with relevant codec unsigned int max = (unsigned int)(_codecSampleRate * _layerFrameSize / 1000); @@ -359,6 +372,7 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) // Do sample rate conversion int nb_sample_down = nbSample; nbSample = reSampleData(_codecSampleRate , nb_sample_down, UP_SAMPLING); + #ifdef DATAFORMAT_IS_FLOAT #else #endif @@ -403,17 +417,23 @@ AudioRtpRTX::reSampleData(int sampleRate_codec, int nbSamples, int status) return 0; } + + void AudioRtpRTX::run () { - //mic, we receive from soundcard in stereo, and we send encoded - //encoding before sending - AudioLayer *audiolayer = Manager::instance().getAudioDriver(); - _layerFrameSize = audiolayer->getFrameSize(); // en ms - _layerSampleRate = audiolayer->getSampleRate(); - initBuffers(); - int step; - //try { + //mic, we receive from soundcard in stereo, and we send encoded + //encoding before sending + AudioLayer *audiolayer = Manager::instance().getAudioDriver(); + _layerFrameSize = audiolayer->getFrameSize(); // en ms + _layerSampleRate = audiolayer->getSampleRate(); + initBuffers(); + int step; + + int sessionWaiting; + + //try { + // Init the session initAudioRtpSession(); step = (int) (_layerFrameSize * _codecSampleRate / 1000); @@ -433,27 +453,58 @@ AudioRtpRTX::run () { audiolayer->startStream(); _start.post(); - _debug("- ARTP Action: Start\n"); + _debug("- ARTP Action: Start call %s\n",_ca->getCallId().c_str()); while (!testCancel()) { - //////////////////////////// - // Send session - //////////////////////////// - sendSessionFromMic(timestamp); - timestamp += step; - //////////////////////////// - // Recv session - //////////////////////////// - receiveSessionForSpkr(countTime); - // Let's wait for the next transmit cycle + + // printf("AudioRtpRTX::run() _session->getFirstTimestamp() %i \n",_session->getFirstTimestamp()); + + // printf("AudioRtpRTX::run() _session->isWaiting() %i \n",_session->isWaiting()); + ///////////////////// + //////////////////////////// + // Send session + //////////////////////////// + + sessionWaiting = _session->isWaiting(); + + sendSessionFromMic(timestamp); + timestamp += step; + + //////////////////////////// + // Recv session + //////////////////////////// + receiveSessionForSpkr(countTime); + + // Let's wait for the next transmit cycle + + + if(sessionWaiting == 1){ + // _debug("Record TWO buffer \n"); _ca->recAudio.recData(spkrDataConverted,micData,_nSamplesSpkr,_nSamplesMic); - - Thread::sleep(TimerPort::getTimer()); - TimerPort::incTimer(_layerFrameSize); // 'frameSize' ms + } + else { + // _debug("Record ONE buffer \n"); + _ca->recAudio.recData(micData,_nSamplesMic); + } + + Thread::sleep(TimerPort::getTimer()); + TimerPort::incTimer(_layerFrameSize); // 'frameSize' ms + } - + + // _debug("stop stream for audiortp loop\n"); audiolayer->stopStream(); - _debug("- ARTP Action: Stop\n"); + _debug("- ARTP Action: Stop call %s\n",_ca->getCallId().c_str()); + //} catch(std::exception &e) { + //_start.post(); + //_debug("! ARTP: Stop %s\n", e.what()); + //throw; + //} catch(...) { + //_start.post(); + //_debugException("* ARTP Action: Stop"); + //throw; + //} + } diff --git a/src/audio/audiortp.h b/src/audio/audiortp.h index fe75441c0ee6ad36a84f77a103707e5daf2c8064..a0a3cf6846ec858ed6ec342b80b5a624d503e842 100644 --- a/src/audio/audiortp.h +++ b/src/audio/audiortp.h @@ -69,7 +69,7 @@ class AudioRtpRTX : public ost::Thread, public ost::TimerPort { /** * Audio recording object */ - AudioRecord recAudio; + // AudioRecord recAudio; /** A SIP call */ SIPCall* _ca; @@ -128,7 +128,10 @@ class AudioRtpRTX : public ost::Thread, public ost::TimerPort { */ int _nSamplesMic; - + /** + * Maximum number of sample for audio buffers (mic and spkr) + */ + int nbSamplesMax; /** * Init the RTP session. Create either symmetric or double sessions to manage data transport @@ -167,10 +170,6 @@ class AudioRtpRTX : public ost::Thread, public ost::TimerPort { /** The audio codec used during the session */ AudioCodec* _audiocodec; - /** - * Audio recording object - */ - // AudioRecord recAudio; }; /////////////////////////////////////////////////////////////////////////////// @@ -203,7 +202,7 @@ class AudioRtp { * Start recording */ void setRecording (); - + private: // copy constructor diff --git a/src/call.cpp b/src/call.cpp index e3a4f43cce078937e76271b8316205e8de4d4f20..32cc4d7bcda73c5da7f5fb5f38d4eac563d92f33 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -42,16 +42,16 @@ Call::Call(const CallID& id, Call::CallType type) SOUND_FORMAT soundFormat = INT16; recAudio.setRecordingOption(fileType,soundFormat,44100, Manager::instance().getConfigString (AUDIO, RECORD_PATH),id); - _debug("CALL::Constructor for this clss is called \n"); + // _debug("CALL::Constructor for this clss is called \n"); } Call::~Call() { - _debug("CALL::~Call(): Destructor for this clss is called \n"); + // _debug("CALL::~Call(): Destructor for this clss is called \n"); if(recAudio.isOpenFile()) { - _debug("CALL::~Call(): A recording file is open, close it \n"); + // _debug("CALL::~Call(): A recording file is open, close it \n"); recAudio.closeFile(); } } @@ -122,7 +122,6 @@ Call::getRemoteIp() AudioCodecType Call::getAudioCodec() { - ost::MutexLock m(_callMutex); return _audioCodec; } @@ -146,6 +145,11 @@ Call::setRecording() recAudio.setRecording(); } +void +Call::initRecFileName() { + recAudio.initFileName(_peerNumber); +} + void Call::stopRecording() { diff --git a/src/call.h b/src/call.h index f0ad6b02eff1439155d710f9a99b709a5c997348..6b247e036017d684056f9db64a59d8a1460d35ae 100644 --- a/src/call.h +++ b/src/call.h @@ -237,6 +237,11 @@ class Call{ */ bool isRecording(); + /** + * + */ + void initRecFileName(); + protected: /** Protect every attribute that can be changed by two threads */ ost::Mutex _callMutex; diff --git a/src/dbus/callmanager-glue.h b/src/dbus/callmanager-glue.h index 4abf94d05cbb97ae8bb735547f9d401f251307aa..71dd6b5170eca847ee33cbc5d457c7593c2c9f44 100644 --- a/src/dbus/callmanager-glue.h +++ b/src/dbus/callmanager-glue.h @@ -34,6 +34,7 @@ public: register_method(CallManager_adaptor, setRecording, _setRecording_stub); register_method(CallManager_adaptor, getCallDetails, _getCallDetails_stub); register_method(CallManager_adaptor, getCurrentCallID, _getCurrentCallID_stub); + register_method(CallManager_adaptor, getCurrentCodecName, _getCurrentCodecName_stub); } ::DBus::IntrospectedInterface *const introspect() const @@ -115,6 +116,18 @@ public: { "callID", "s", false }, { 0, 0, 0 } }; + static ::DBus::IntrospectedArgument getCurrentCodecName_args[] = + { + { "callID", "s", true }, + { "codecName", "s", false }, + { 0, 0, 0 } + }; + static ::DBus::IntrospectedArgument currentSelectedCodec_args[] = + { + { "callID", "s", false }, + { "codecName", "s", false }, + { 0, 0, 0 } + }; static ::DBus::IntrospectedArgument incomingCall_args[] = { { "accountID", "s", false }, @@ -167,10 +180,12 @@ public: { "setRecording", setRecording_args }, { "getCallDetails", getCallDetails_args }, { "getCurrentCallID", getCurrentCallID_args }, + { "getCurrentCodecName", getCurrentCodecName_args }, { 0, 0 } }; static ::DBus::IntrospectedMethod CallManager_adaptor_signals[] = { + { "currentSelectedCodec", currentSelectedCodec_args }, { "incomingCall", incomingCall_args }, { "incomingMessage", incomingMessage_args }, { "callStateChanged", callStateChanged_args }, @@ -218,11 +233,20 @@ public: virtual void setRecording(const std::string& callID) = 0; virtual std::map< std::string, std::string > getCallDetails(const std::string& callID) = 0; virtual std::string getCurrentCallID() = 0; + virtual std::string getCurrentCodecName(const std::string& callID) = 0; public: /* signal emitters for this interface */ + void currentSelectedCodec(const std::string& arg1, const std::string& arg2) + { + ::DBus::SignalMessage sig("currentSelectedCodec"); + ::DBus::MessageIter wi = sig.writer(); + wi << arg1; + wi << arg2; + emit_signal(sig); + } void incomingCall(const std::string& arg1, const std::string& arg2, const std::string& arg3) { ::DBus::SignalMessage sig("incomingCall"); @@ -412,6 +436,17 @@ private: wi << argout1; return reply; } + ::DBus::Message _getCurrentCodecName_stub(const ::DBus::CallMessage &call) + { + ::DBus::MessageIter ri = call.reader(); + + std::string argin1; ri >> argin1; + std::string argout1 = getCurrentCodecName(argin1); + ::DBus::ReturnMessage reply(call); + ::DBus::MessageIter wi = reply.writer(); + wi << argout1; + return reply; + } }; } } } diff --git a/src/dbus/callmanager-introspec.xml b/src/dbus/callmanager-introspec.xml index 6e415f9bfb71c26a48d3495733a9ced0545b1f32..9c503cac8dcd7c6a84d784b82d6854c2fcad029b 100644 --- a/src/dbus/callmanager-introspec.xml +++ b/src/dbus/callmanager-introspec.xml @@ -64,6 +64,16 @@ <method name="getCurrentCallID"> <arg type="s" name="callID" direction="out"/> </method> + + <method name="getCurrentCodecName"> + <arg type="s" name="callID" direction="in"/> + <arg type="s" name="codecName" direction="out"/> + </method> + + <signal name="currentSelectedCodec"> + <arg type="s" name="callID" direction="out" /> + <arg type="s" name="codecName" direction="out"/> + </signal> <signal name="incomingCall"> <arg type="s" name="accountID" /> @@ -91,7 +101,6 @@ <arg type="s" name="device" direction="out"/> <arg type="d" name="value" direction="out"/> </signal> - <signal name="error"> diff --git a/src/dbus/callmanager.cpp b/src/dbus/callmanager.cpp index d516dba31b305fe9c8e30e30cbb7ed5b8d628e46..126b7ef3b69ff5ed5a4afa8df9af05c545d5914f 100644 --- a/src/dbus/callmanager.cpp +++ b/src/dbus/callmanager.cpp @@ -101,7 +101,7 @@ CallManager::setVolume( const std::string& device, const double& value ) double CallManager::getVolume( const std::string& device ) { - _debug("CallManager::getVolume received\n"); + _debug("CallManager::getVolume received \n"); if(device == "speaker") { _debug("Current speaker = %d\n", Manager::instance().getSpkrVolume()); @@ -123,6 +123,14 @@ CallManager::setRecording(const std::string& callID) } +std::string +CallManager::getCurrentCodecName(const std::string& callID) +{ + _debug("CallManager::getCurrentCodecName received %s \n",Manager::instance().getCurrentCodecName(callID).c_str()); + return Manager::instance().getCurrentCodecName(callID).c_str(); +} + + std::map< std::string, std::string > CallManager::getCallDetails( const std::string& callID UNUSED ) { diff --git a/src/dbus/callmanager.h b/src/dbus/callmanager.h index a8c4c0c2ed8dba4bc841d258ab7fa6a9c70bc2bc..7f2e7e689f5c6e2dc0f65cbe21d29c1492885e24 100644 --- a/src/dbus/callmanager.h +++ b/src/dbus/callmanager.h @@ -49,6 +49,7 @@ public: void setVolume( const std::string& device, const double& value ); double getVolume( const std::string& device ); void setRecording( const std::string& callID ); + std::string getCurrentCodecName(const std::string& callID); std::map< std::string, std::string > getCallDetails( const std::string& callID ); std::string getCurrentCallID( ); void playDTMF( const std::string& key ); diff --git a/src/iaxvoiplink.cpp b/src/iaxvoiplink.cpp index f5c65eea29615baf338a9346a120ab5c87d06fd1..231e024d4619433cbc8ad291411a1155a1183150 100644 --- a/src/iaxvoiplink.cpp +++ b/src/iaxvoiplink.cpp @@ -43,6 +43,7 @@ IAXVoIPLink::IAXVoIPLink(const AccountID& accountID) : VoIPLink(accountID) { + // _debug("IAXVoIPLink::IAXVoIPLink : creating eventhread \n "); _evThread = new EventThread(this); _regSession = NULL; _nextRefreshStamp = 0; @@ -89,7 +90,7 @@ IAXVoIPLink::init() return false; bool returnValue = false; - //_localAddress = "127.0.0.1"; + // _localAddress = "127.0.0.1"; // port 0 is default // iax_enable_debug(); have to enable debug when compiling iax... int port = IAX_DEFAULT_PORTNO; @@ -207,10 +208,18 @@ IAXVoIPLink::getEvent() iaxHandlePrecallEvent(event); } + // _debug("IAXVoIPLink::getEvent() : timestamp %i \n",event->ts); + iax_event_free(event); } _mutexIAX.leaveMutex(); + + if(call){ + // _debug("Are we recording"); + call->recAudio.recData(spkrDataConverted,micData,nbSampleForRec_,nbSampleForRec_); + } + // Do the doodle-moodle to send audio from the microphone to the IAX channel. sendAudioFromMic(); @@ -218,9 +227,13 @@ IAXVoIPLink::getEvent() if (_nextRefreshStamp && _nextRefreshStamp - 2 < time(NULL)) { sendRegister(""); } - if(call){ - call->recAudio.recData(spkrDataConverted,micData,nbSampleForRec_,nbSampleForRec_); - } + + // _debug("IAXVoIPLink::getEvent() \n"); + // reinitialize speaker buffer for recording (when recording a voice mail) + for (int i = 0; i < nbSampleForRec_; i++) + spkrDataConverted[i] = 0; + + // thread wait 3 millisecond _evThread->sleep(3); free(event); @@ -229,6 +242,8 @@ IAXVoIPLink::getEvent() void IAXVoIPLink::sendAudioFromMic(void) { + // _debug("IAXVoIPLink::sendAudioFromMic"); + int maxBytesToGet, availBytesFromMic, bytesAvail, compSize; AudioCodec *ac; @@ -289,7 +304,9 @@ IAXVoIPLink::sendAudioFromMic(void) nbSample_ = audiolayer->getMic( micData, bytesAvail ) / sizeof(SFLDataFormat); // Store the number of samples for recording - nbSampleForRec_ = nbSample_; + nbSampleForRec_ = nbSample_; + + // _debug("IAXVoIPLink::sendAudioFromMic : %i \n",nbSampleForRec_); // resample nbSample_ = converter->downsampleData( micData , micDataConverted , (int)ac ->getClockRate() , (int)audiolayer->getSampleRate() , nbSample_ ); @@ -400,7 +417,8 @@ IAXVoIPLink::newOutgoingCall(const CallID& id, const std::string& toUrl) if (call) { call->setPeerNumber(toUrl); - + call->initRecFileName(); + if ( iaxOutgoingInvite(call) ) { call->setConnectionState(Call::Progressing); call->setState(Call::Active); @@ -588,6 +606,16 @@ IAXVoIPLink::carryingDTMFdigits(const CallID& id, char code) } +std::string +IAXVoIPLink::getCurrentCodecName() +{ + IAXCall *call = getIAXCall(Manager::instance().getCurrentCallId()); + + AudioCodec *ac = call->getCodecMap().getCodec(call->getAudioCodec()); + + return ac->getCodecName(); +} + bool IAXVoIPLink::iaxOutgoingInvite(IAXCall* call) @@ -717,6 +745,7 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call) case IAX_EVENT_VOICE: //if (!audiolayer->isCaptureActive ()) // audiolayer->startStream (); + // _debug("IAX_EVENT_VOICE: \n"); iaxHandleVoiceEvent(event, call); break; @@ -924,8 +953,11 @@ IAXVoIPLink::iaxHandlePrecallEvent(iax_event* event) if (event->ies.calling_number) call->setPeerNumber(std::string(event->ies.calling_number)); - if (event->ies.calling_name) + if (event->ies.calling_name) call->setPeerName(std::string(event->ies.calling_name)); + + // if peerNumber exist append it to the name string + call->initRecFileName(); if (Manager::instance().incomingCall(call, getAccountID())) { /** @todo Faudra considérer éventuellement le champ CODEC PREFS pour diff --git a/src/iaxvoiplink.h b/src/iaxvoiplink.h index 7cdaeaa5439782e9b2855b357eccdb549c8f45fd..2cd4d16357dab62162080f9d7003bd8a759aac6c 100644 --- a/src/iaxvoiplink.h +++ b/src/iaxvoiplink.h @@ -190,6 +190,13 @@ class IAXVoIPLink : public VoIPLink bool isContactPresenceSupported() { return false; } + /** + * Return the codec protocol used for this call + * @param id The call identifier + */ + std::string getCurrentCodecName(); + + public: // iaxvoiplink only void updateAudiolayer( void ); diff --git a/src/main.cpp b/src/main.cpp index 7ae724194b4ae53525d0587e490195b6e7772dc9..85f9170e5782cd44b28a9b4297447f4a2408c3ad 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -110,6 +110,7 @@ main (int argc, char **argv) { } bool initOK = false; try { + _debug("Initialize manager in main \n"); Manager::instance().initConfigFile(); Manager::instance().init(); initOK = true; diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 7a98835bace3e7b923e73aae58c80ebd22052105..7afaf2aab64f8c498cc7921342cb66b753e5c039 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -188,6 +188,8 @@ ManagerImpl::switchCall(const CallID& id ) { bool ManagerImpl::outgoingCall(const std::string& accountid, const CallID& id, const std::string& to) { + _debug("ManagerImpl::outgoingCall() method \n"); + if (!accountExists(accountid)) { _debug("! Manager Error: Outgoing Call: account doesn't exist\n"); return false; @@ -219,6 +221,7 @@ ManagerImpl::outgoingCall(const std::string& accountid, const CallID& id, const bool ManagerImpl::answerCall(const CallID& id) { + stopTone(false); _debug("Try to answer call: %s\n", id.data()); AccountID accountid = getAccountFromCall( id ); @@ -237,11 +240,16 @@ ManagerImpl::answerCall(const CallID& id) removeCallAccount(id); return false; } - + // if it was waiting, it's waiting no more if (_dbus) _dbus->getCallManager()->callStateChanged(id, "CURRENT"); removeWaitingCall(id); switchCall(id); + + std::string codecName = getCurrentCodecName(id); + _debug("ManagerImpl::hangupCall(): broadcast codec name %s \n",codecName.c_str()); + if (_dbus) _dbus->getCallManager()->currentSelectedCodec(id,codecName.c_str()); + return true; } @@ -249,7 +257,7 @@ ManagerImpl::answerCall(const CallID& id) bool ManagerImpl::hangupCall(const CallID& id) { - _debug("ManagerImpl::hangupCall(): This function is called when user hangup \n"); + _debug("ManagerImpl::hangupCall(): This function is called when user hangup \n"); PulseLayer *pulselayer; AccountID accountid; bool returnValue; @@ -361,6 +369,10 @@ ManagerImpl::offHoldCall(const CallID& id) } switchCall(id); + std::string codecName = getCurrentCodecName(id); + _debug("ManagerImpl::hangupCall(): broadcast codec name %s \n",codecName.c_str()); + if (_dbus) _dbus->getCallManager()->currentSelectedCodec(id,codecName.c_str()); + return returnValue; } @@ -574,7 +586,7 @@ ManagerImpl::isWaitingCall(const CallID& id) { // Management of event peer IP-phone //////////////////////////////////////////////////////////////////////////////// // SipEvent Thread - bool +bool ManagerImpl::incomingCall(Call* call, const AccountID& accountId) { PulseLayer *pulselayer; @@ -633,6 +645,10 @@ ManagerImpl::peerAnsweredCall(const CallID& id) stopTone(false); } if (_dbus) _dbus->getCallManager()->callStateChanged(id, "CURRENT"); + + std::string codecName = getCurrentCodecName(id); + _debug("ManagerImpl::hangupCall(): broadcast codec name %s \n",codecName.c_str()); + if (_dbus) _dbus->getCallManager()->currentSelectedCodec(id,codecName.c_str()); } //THREAD=VoIP Call=Outgoing @@ -738,7 +754,7 @@ bool ManagerImpl::playATone(Tone::TONEID toneId) return false; audiolayer = getAudioDriver(); - + if (_telephoneTone != 0) { _toneMutex.enterMutex(); _telephoneTone->setCurrentTone(toneId); @@ -1184,6 +1200,15 @@ ManagerImpl::getCodecDetails( const int32_t& payload ) return v; } +std::string +ManagerImpl::getCurrentCodecName(const CallID& id) +{ + // _debug("ManagerImpl::getCurrentCodecName method called \n"); + AccountID accountid = getAccountFromCall(id); + // _debug("ManagerImpl::getCurrentCodecName : %s \n",getAccountLink(accountid)->getCurrentCodecName().c_str()); + return getAccountLink(accountid)->getCurrentCodecName(); +} + /** * Get list of supported input audio plugin */ diff --git a/src/managerimpl.h b/src/managerimpl.h index 51fefa04968eb802444b42e477edc4fcc1ffe884..0765bac47619e05229a9f0fbca829f97a17611f1 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -326,6 +326,13 @@ class ManagerImpl { */ std::vector< ::std::string > getCodecDetails( const int32_t& payload); + /** + * Get current codec name + * @param call id + * @return std::string The codec name + */ + std::string getCurrentCodecName(const CallID& id); + /** * Get a list of supported input audio plugin * @return std::vector<std::string> List of names diff --git a/src/plug-in/audiorecorder/audiorecord.cpp b/src/plug-in/audiorecorder/audiorecord.cpp index 5e73d442db62a69cc449c199e7983fc8905977cb..4b0077a92cb1107801a41fccae5b639efb1c1f84 100644 --- a/src/plug-in/audiorecorder/audiorecord.cpp +++ b/src/plug-in/audiorecorder/audiorecord.cpp @@ -56,7 +56,7 @@ void AudioRecord::setSndSamplingRate(int smplRate){ void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path, std::string id){ - std::string fName; + // std::string fName; fileType_ = type; sndFormat_ = format; @@ -64,10 +64,10 @@ void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sn sndSmplRate_ = sndSmplRate; call_id_ = id; - fName = fileName_; - fName.append("-"+call_id_); - + // fName = fileName_; + // fName.append("-"+call_id_); + /* if (fileType_ == FILE_RAW){ if ( strstr(fileName_, ".raw") == NULL){ printf("AudioRecord::openFile::concatenate .raw file extension: name : %s \n", fileName_); @@ -80,8 +80,34 @@ void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sn fName.append(".wav"); } } + */ savePath_ = path + "/"; + // savePath_.append(fName); +} + + + +void AudioRecord::initFileName( std::string peerNumber){ + + std::string fName; + + fName = fileName_; + fName.append("-"+peerNumber); + + if (fileType_ == FILE_RAW){ + if ( strstr(fileName_, ".raw") == NULL){ + printf("AudioRecord::openFile::concatenate .raw file extension: name : %s \n", fileName_); + fName.append(".raw"); + } + } + else if (fileType_ == FILE_WAV){ + if ( strstr(fileName_, ".wav") == NULL){ + printf("AudioRecord::openFile::concatenate .wav file extension: name : %s \n", fileName_); + fName.append(".wav"); + } + } + savePath_.append(fName); } @@ -434,8 +460,8 @@ void AudioRecord::recData(SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int if ( sndFormat_ == INT16 ) { // TODO change INT16 to SINT16 for (int k=0; k<nSamples_1; k++){ - mixBuffer_[k] = (buffer_1[k]+buffer_2[k])/2; - + // mixBuffer_[k] = ((buffer_1[k]+buffer_2[k])/2)/32767; + mixBuffer_[k] = (buffer_1[k]+buffer_2[k]); // dsp.getRMS(mixBuffer_[k]); if ( fwrite(&buffer_1[k], 2, 1, fp) != 1) diff --git a/src/plug-in/audiorecorder/audiorecord.h b/src/plug-in/audiorecorder/audiorecord.h index d0d75465e234b0773db68339ecccad0cf1050fd2..532c96e4bd784dc96dfe31a05bf099f9d1380685 100644 --- a/src/plug-in/audiorecorder/audiorecord.h +++ b/src/plug-in/audiorecorder/audiorecord.h @@ -45,6 +45,8 @@ public: void setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path, std::string id); + void initFileName( std::string peerNumber ); + /** * Check if no otehr file is opened, then create a new one * @param fileName A string containing teh file (with/without extension) diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index 112d2d49692030ae9f31411e348acf5b38a94caa..bf7ac01b377f0a7c4a7ce515bb8021ba240eee64 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -420,6 +420,9 @@ SIPVoIPLink::newOutgoingCall(const CallID& id, const std::string& toUrl) } //call->setPeerNumber(toUrl); call->setPeerNumber(getSipTo(toUrl, account->getHostname())); + + call->initRecFileName(); + _debug("Try to make a call to: %s with call ID: %s\n", toUrl.data(), id.data()); // we have to add the codec before using it in SIPOutgoingInvite... call->setCodecMap(Manager::instance().getCodecDescriptorMap()); @@ -443,7 +446,7 @@ SIPVoIPLink::answer(const CallID& id) pj_status_t status; pjsip_tx_data *tdata; - _debug("- SIP Action: start answering\n"); + _debug("SIPVoIPLink::answer: start answering \n"); call = getSIPCall(id); @@ -455,22 +458,23 @@ SIPVoIPLink::answer(const CallID& id) // User answered the incoming call, tell peer this news if (call->startNegociation(_pool)) { // Create and send a 200(OK) response - _debug("UserAgent: Negociation success!\n"); + _debug("SIPVoIPLink::answer:UserAgent: Negociation success! : call %s \n", call->getCallId().c_str()); status = pjsip_inv_answer(call->getInvSession(), PJSIP_SC_OK, NULL, NULL, &tdata); PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); status = pjsip_inv_send_msg(call->getInvSession(), tdata); PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); - _debug("* SIP Info: Starting AudioRTP when answering\n"); + _debug("SIPVoIPLink::answer: Starting AudioRTP when answering : call %s \n", call->getCallId().c_str()); if (_audiortp->createNewSession(call) >= 0) { call->setAudioStart(true); call->setConnectionState(Call::Connected); call->setState(Call::Active); return true; } else { - _debug("! SIP Failure: Unable to start sound when answering %s/%d\n", __FILE__, __LINE__); + _debug("SIPVoIPLink::answer: Unable to start sound when answering %s/%d\n", __FILE__, __LINE__); } } + _debug("SIPVoIPLink::answer: fail terminate call %s \n",call->getCallId().c_str()); terminateOneCall(call->getCallId()); removeCall(call->getCallId()); return false; @@ -796,6 +800,26 @@ SIPVoIPLink::isRecording(const CallID& id) return call->isRecording(); } + +std::string +SIPVoIPLink::getCurrentCodecName() +{ + + _debug("SIPVoIPLink::getCurrentCodecName Ok 1 : \n"); + + printf("AAAAAAAAAAAAAHHHHHHH!!!!!!:: %s \n",Manager::instance().getCurrentCallId().c_str()); + + SIPCall *call = getSIPCall(Manager::instance().getCurrentCallId()); + + _debug("SIPVoIPLink::getCurrentCodecName Ok 2 : \n"); + + printf("OOOOOOOUUUUUUPPPPPPPPPPSSSSSSSSSSS!!!!!!:: %s \n",call->getCallId().c_str()); + + AudioCodec *ac = call->getCodecMap().getCodec(call->getAudioCodec()); + + return ac->getCodecName(); +} + bool SIPVoIPLink::carryingDTMFdigits(const CallID& id, char code) { @@ -1077,8 +1101,8 @@ std::string SIPVoIPLink::getSipTo(const std::string& to_url, std::string hostnam } - SIPCall* - SIPVoIPLink::getSIPCall(const CallID& id) +SIPCall* +SIPVoIPLink::getSIPCall(const CallID& id) { Call* call = getCall(id); if (call) { @@ -1087,9 +1111,11 @@ std::string SIPVoIPLink::getSipTo(const std::string& to_url, std::string hostnam return NULL; } - void SIPVoIPLink::setStunServer( const std::string &server ) - { - if(server != "") { + +void SIPVoIPLink::setStunServer( const std::string &server ) +{ + if(server != "") { + useStun(true); _stunServer = server; } else { @@ -1838,6 +1864,8 @@ std::string SIPVoIPLink::getSipTo(const std::string& to_url, std::string hostnam call->setIp(link->getLocalIPAddress()); call->setPeerNumber(peerNumber); + call->initRecFileName(); + /* Call the SIPCallInvite function to generate the local sdp, * remote sdp and negociator. * This function is also used to set the parameters of audio RTP, including: diff --git a/src/sipvoiplink.h b/src/sipvoiplink.h index ac889c9493c6f69bc20e6a64cdc93dbdc91f6dbb..fef56310f9c5f8fe66c24d0d9d1c72c8d30ea320 100644 --- a/src/sipvoiplink.h +++ b/src/sipvoiplink.h @@ -298,6 +298,13 @@ class SIPVoIPLink : public VoIPLink */ bool isRecording(const CallID& id); + /** + * Return the codec protocol used for this call + * @param id The call identifier + */ + std::string getCurrentCodecName(); + + private: /** * Constructor diff --git a/src/voiplink.h b/src/voiplink.h index 92b7795eb479a987674e71cc9d75a88fcd181565..6de21106b354a5cab3e1694e3728742b0fb87b6e 100644 --- a/src/voiplink.h +++ b/src/voiplink.h @@ -173,6 +173,12 @@ class VoIPLink { */ virtual bool isRecording(const CallID& id) = 0; + /** + * Return the codec protocol used for this call + * @param id The call identifier + */ + virtual std::string getCurrentCodecName() = 0; + bool initDone (void) { return _initDone; } void initDone (bool state) { _initDone = state; }