diff --git a/sflphone-gtk/src/actions.c b/sflphone-gtk/src/actions.c index 9de09864e00810da1d2df5e684e5fe5b824027f9..96a9db1111a4e0f945ff2517b0b915a53767fff2 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 */ @@ -733,6 +735,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() { @@ -754,6 +781,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 */ @@ -816,3 +846,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/dbus.c b/sflphone-gtk/src/dbus.c index 305a20bd91f27eae16fa6da8d3efbc1fd820c082..0e3ddd9303243797e15e108de9b3cac08b38d2c9 100644 --- a/sflphone-gtk/src/dbus.c +++ b/sflphone-gtk/src/dbus.c @@ -61,6 +61,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, @@ -265,6 +274,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); @@ -782,6 +799,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** @@ -1298,7 +1339,6 @@ dbus_set_record(const call_t * c) { g_error_free(error); } - g_print("called dbus_set_record on CallManager\n"); } void 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/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index e50cb2060bd2a4e12689133e5ba872c9d9334684..d294b8b7d4dc279f75a281dda39ef1c12f609451 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -410,6 +410,8 @@ 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 diff --git a/src/audio/audiortp.h b/src/audio/audiortp.h index 8b54fc1700cae0aea3e5a5fb5182e311da1462a9..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; @@ -170,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; }; /////////////////////////////////////////////////////////////////////////////// @@ -206,7 +202,7 @@ class AudioRtp { * Start recording */ void setRecording (); - + private: // copy constructor 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 688fd7f37b37ae16e3bd1372922d138694b7fc5f..99ab771c6e1fb9bc36024aa43f73f8b632ca2eef 100644 --- a/src/iaxvoiplink.cpp +++ b/src/iaxvoiplink.cpp @@ -213,6 +213,12 @@ IAXVoIPLink::getEvent() } _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(); @@ -220,12 +226,8 @@ IAXVoIPLink::getEvent() if (_nextRefreshStamp && _nextRefreshStamp - 2 < time(NULL)) { sendRegister(""); } - - if(call){ - // _debug("Are we recording"); - 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; @@ -239,6 +241,8 @@ IAXVoIPLink::getEvent() void IAXVoIPLink::sendAudioFromMic(void) { + // _debug("IAXVoIPLink::sendAudioFromMic"); + int maxBytesToGet, availBytesFromMic, bytesAvail, compSize; AudioCodec *ac; @@ -299,7 +303,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_ ); @@ -600,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) @@ -730,6 +746,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; 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/managerimpl.cpp b/src/managerimpl.cpp index 3352eeb3105d2d18b778c275b62d2c396094a0db..67653bb71a47c62faad8e97c1a6e0cbaff67bab7 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -239,6 +239,10 @@ ManagerImpl::answerCall(const CallID& id) removeCallAccount(id); return false; } + + 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()); // if it was waiting, it's waiting no more if (_dbus) _dbus->getCallManager()->callStateChanged(id, "CURRENT"); @@ -251,7 +255,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; @@ -635,6 +639,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 @@ -1186,6 +1194,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/sipvoiplink.cpp b/src/sipvoiplink.cpp index febcdf4ef129ff428580e00bced0c0d98c4b096c..e7223bfe4eb2cb953cfccf83114d3c6849a4dcbd 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -799,6 +799,20 @@ SIPVoIPLink::isRecording(const CallID& id) return call->isRecording(); } + +std::string +SIPVoIPLink::getCurrentCodecName() +{ + + // _debug("SIPVoIPLink::getCurrentCodecName : \n"); + + SIPCall *call = getSIPCall(Manager::instance().getCurrentCallId()); + + AudioCodec *ac = call->getCodecMap().getCodec(call->getAudioCodec()); + + return ac->getCodecName(); +} + bool SIPVoIPLink::carryingDTMFdigits(const CallID& id, char code) { 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; }