Commit f92dc4d7 authored by Rafaël Carré's avatar Rafaël Carré
Browse files

* #6662 : Show current video codec in GUI

parent 82451345
......@@ -402,6 +402,14 @@
</arg>
</method>
<method name="getCurrentVideoCodecName" tp:name-for-bindings="getCurrentVideoCodecName">
<tp:docstring>
Unused
</tp:docstring>
<arg type="s" name="callID" direction="in"/>
<arg type="s" name="codecName" direction="out"/>
</method>
<method name="getCurrentAudioCodecName" tp:name-for-bindings="getCurrentAudioCodecName">
<tp:docstring>
Unused
......
......@@ -314,6 +314,12 @@ CallManager::getCurrentAudioCodecName (const std::string& callID)
return Manager::instance().getCurrentCodecName (callID).c_str();
}
std::string
CallManager::getCurrentVideoCodecName (const std::string& callID)
{
return Manager::instance().getCurrentVideoCodecName (callID).c_str();
}
std::map< std::string, std::string >
CallManager::getCallDetails (const std::string& callID)
......
......@@ -110,6 +110,7 @@ class CallManager
void setRecording (const std::string& callID);
bool getIsRecording (const std::string& callID);
std::string getCurrentAudioCodecName (const std::string& callID);
std::string getCurrentVideoCodecName (const std::string& callID);
void playDTMF (const std::string& key);
void startTone (const int32_t& start, const int32_t& type);
......
......@@ -598,6 +598,11 @@ IAXVoIPLink::sendTextMessage (sfl::InstantMessaging *module,
return true;
}
std::string
IAXVoIPLink::getCurrentVideoCodecName(const std::string& /*id*/)
{
return "";
}
std::string
IAXVoIPLink::getCurrentCodecName(const std::string& /*id*/)
......
......@@ -207,6 +207,7 @@ class IAXVoIPLink : public VoIPLink
* @param id The call identifier
*/
virtual std::string getCurrentCodecName(const std::string& id);
virtual std::string getCurrentVideoCodecName(const std::string& id);
public: // iaxvoiplink only
......
......@@ -2447,6 +2447,26 @@ std::string ManagerImpl::serialize (const std::vector<std::string> &v)
return res;
}
std::string ManagerImpl::getCurrentVideoCodecName (const std::string& id)
{
std::string accountid = getAccountFromCall (id);
VoIPLink* link = getAccountLink (accountid);
Call* call = link->getCall (id);
std::string codecName;
_debug("Manager: Get current video codec name");
if (call) {
Call::CallState state = call->getState();
if (state == Call::Active or state == Call::Conferencing) {
codecName = link->getCurrentVideoCodecName(id);
}
}
return codecName;
}
std::string ManagerImpl::getCurrentCodecName (const std::string& id)
{
......
......@@ -566,6 +566,13 @@ class ManagerImpl
*/
void removeAccount (const std::string& accountID);
/**
* Get current video codec name
* @param call id
* @return std::string The video codec name
*/
std::string getCurrentVideoCodecName (const std::string& id);
/**
* Get current codec name
* @param call id
......
......@@ -57,21 +57,16 @@ void getRemoteSdpMediaFromOffer (const pjmedia_sdp_session* remote_sdp,
pjmedia_sdp_media** r_media,
const std::string &media_type)
{
int count;
if (!remote_sdp)
return;
count = remote_sdp->media_count;
*r_media = NULL;
for (int i = 0; i < count; ++i) {
for (unsigned i = 0; i < remote_sdp->media_count; ++i) {
if (pj_stricmp2 (&remote_sdp->media[i]->desc.media, media_type.c_str()) == 0) {
*r_media = remote_sdp->media[i];
return;
}
}
*r_media = NULL;
}
}
......@@ -84,7 +79,7 @@ Sdp::Sdp (pj_pool_t *pool)
, activeRemoteSession_(NULL)
, localAudioMediaCap_(NULL)
, localVideoMediaCap_(NULL)
, sessionAudioMedia_(0)
, sessionAudioCodec_(NULL)
, localIpAddr_("")
, remoteIpAddr_("")
, localAudioPort_(0)
......@@ -99,58 +94,28 @@ Sdp::Sdp (pj_pool_t *pool)
void Sdp::setActiveLocalSdpSession (const pjmedia_sdp_session *sdp)
{
int nb_media, nb_codecs;
int port;
pjmedia_sdp_media *current;
sdpMedia *media = NULL;
std::string dir;
CodecsMap codecs_list;
pjmedia_sdp_attr *attribute = NULL;
pjmedia_sdp_rtpmap *rtpmap;
_debug ("SDP: Set active local SDP session");
activeLocalSession_ = (pjmedia_sdp_session*) sdp;
codecs_list = Manager::instance().getAudioCodecFactory().getCodecsMap();
CodecsMap audio_codecs_list = Manager::instance().getAudioCodecFactory().getCodecsMap();
// retrieve the media information
nb_media = activeLocalSession_->media_count;
for (int i = 0; i < nb_media ; i++) {
for (unsigned i = 0; i < activeLocalSession_->media_count ; i++) {
// Retrieve the media
current = activeLocalSession_->media[i];
pjmedia_sdp_media *current = activeLocalSession_->media[i];
std::string type (current->desc.media.ptr, current->desc.media.slen);
port = current->desc.port;
media = new sdpMedia (type, port);
// Retrieve the payload
nb_codecs = current->desc.fmt_count; // Must be one
for (int j = 0; j < nb_codecs; j++) {
attribute = pjmedia_sdp_media_find_attr(current, &STR_RTPMAP, NULL);
// pj_strtoul(attribute->pt)
if (!attribute)
{
delete media;
return;
}
pjmedia_sdp_attr_to_rtpmap (memPool_, attribute, &rtpmap);
CodecsMap::iterator iter = codecs_list.find ( (AudioCodecType) pj_strtoul (&rtpmap->pt));
if (iter == codecs_list.end())
{
delete media;
return;
}
media->add_codec (iter->second);
// Retrieve the payload
pjmedia_sdp_attr *attribute = pjmedia_sdp_media_find_attr(current, &STR_RTPMAP, NULL);
if (!attribute)
return;
pjmedia_sdp_rtpmap *rtpmap;
pjmedia_sdp_attr_to_rtpmap (memPool_, attribute, &rtpmap);
if (type == "audio") {
sessionAudioCodec_ = (sfl::AudioCodec*)audio_codecs_list[(AudioCodecType)pj_strtoul (&rtpmap->pt)];
} else if (type == "video") {
sessionVideoCodec_ = std::string(rtpmap->enc_name.ptr, rtpmap->enc_name.slen);
}
sessionAudioMedia_.push_back (media);
}
}
......@@ -163,38 +128,14 @@ void Sdp::setActiveRemoteSdpSession (const pjmedia_sdp_session *sdp)
getRemoteSdpTelephoneEventFromOffer(sdp);
}
bool Sdp::hasSessionMedia(void) const
sfl::AudioCodec* Sdp::getSessionAudioCodec (void)
{
return not sessionAudioMedia_.empty();
return sessionAudioCodec_;
}
sfl::AudioCodec* Sdp::getSessionMedia (void)
const std::string &Sdp::getSessionVideoCodec (void)
{
int nbMedia;
int nbCodec;
sfl::Codec *codec = NULL;
std::vector<sdpMedia *> mediaList;
_debug ("SDP: Get session media");
nbMedia = sessionAudioMedia_.size();
if (nbMedia <= 0) {
_error("SDP: Error: No media in session description");
throw SdpException("No media description for this SDP");
}
nbCodec = sessionAudioMedia_[0]->get_media_audio_codec_list().size();
if (nbCodec <= 0) {
_error("SDP: Error: No codec description for this media");
throw SdpException("No codec description for this media");
}
codec = sessionAudioMedia_[0]->get_media_audio_codec_list()[0];
return static_cast<sfl::AudioCodec *>(codec);
return sessionVideoCodec_;
}
void Sdp::setMediaDescriptorLine (sdpMedia *media)
......@@ -729,11 +670,6 @@ void Sdp::addZrtpAttribute (pjmedia_sdp_media* media, std::string hash)
Sdp::~Sdp()
{
std::vector<sdpMedia *>::iterator iter = sessionAudioMedia_.begin();
for (iter = sessionAudioMedia_.begin(); iter != sessionAudioMedia_.end(); ++iter)
delete *iter;
delete localAudioMediaCap_;
delete localVideoMediaCap_;
}
......
......@@ -129,7 +129,8 @@ class Sdp
* Return the codec of the first media after negotiation
* @throw SdpException
*/
sfl::AudioCodec* getSessionMedia (void);
sfl::AudioCodec* getSessionAudioCodec (void);
const std::string &getSessionVideoCodec (void);
/*
* On building an invite outside a dialog, build the local offer and create the
......@@ -254,13 +255,6 @@ class Sdp
return remoteVideoPort_;
}
/**
* Get media list for this session
*/
std::vector<sdpMedia *> getSessionMediaList (void) const {
return sessionAudioMedia_;
}
/**
*
*/
......@@ -348,9 +342,10 @@ class Sdp
sdpMedia *localVideoMediaCap_;
/**
* The media that will be used by the session (after the SDP negotiation)
* The codecs that will be used by the session (after the SDP negotiation)
*/
std::vector<sdpMedia *> sessionAudioMedia_;
sfl::AudioCodec *sessionAudioCodec_;
std::string sessionVideoCodec_;
/**
* IP address
......
......@@ -1009,7 +1009,7 @@ SIPVoIPLink::offhold (const std::string& id) throw (VoipLinkException)
try {
// Retreive previously selected codec
AudioCodecType pl;
sfl::Codec *sessionMedia = sdpSession->getSessionMedia();
sfl::Codec *sessionMedia = sdpSession->getSessionAudioCodec();
if (sessionMedia == NULL) {
// throw VoipLinkException("Could not find session media");
_warn("UserAgent: Session media not yet initialized, using default (ULAW)");
......@@ -1350,40 +1350,31 @@ SIPVoIPLink::refuse (const std::string& id)
}
std::string
SIPVoIPLink::getCurrentCodecName(const std::string& id)
SIPVoIPLink::getCurrentVideoCodecName(const std::string& id)
{
SIPCall *call = getSIPCall (id);
if(call == NULL) {
_error("UserAgent: Error: No current call");
return "";
}
SIPCall *call = NULL;
sfl::Codec *ac = NULL;
std::string name = "";
try {
// call = getSIPCall (Manager::instance().getCurrentCallId());
call = getSIPCall (id);
if(call == NULL) {
_error("UserAgent: Error: No current call");
// return empty string
return name;
}
if(call->getLocalSDP()->hasSessionMedia()) {
ac = call->getLocalSDP()->getSessionMedia();
}
else {
return name;
}
}
catch (const SdpException &e) {
_error("UserAgent: Exception: %s", e.what());
}
return call->getLocalSDP()->getSessionVideoCodec();
}
if (ac == NULL) {
_error("UserAgent: Error: No codec initialized for this session");
}
std::string
SIPVoIPLink::getCurrentCodecName(const std::string& id)
{
SIPCall *call = getSIPCall (id);
if(call == NULL) {
_error("UserAgent: Error: No current call");
return "";
}
name = ac->getMimeSubtype();
sfl::Codec *ac = call->getLocalSDP()->getSessionAudioCodec();
if (ac)
return ac->getMimeSubtype();
return name;
return "";
}
std::string SIPVoIPLink::getUseragentName (const std::string& id)
......@@ -3511,7 +3502,7 @@ void sdp_media_update_cb (pjsip_inv_session *inv, pj_status_t status)
if (!sdpSession)
return;
sfl::AudioCodec *sessionMedia = sdpSession->getSessionMedia();
sfl::AudioCodec *sessionMedia = sdpSession->getSessionAudioCodec();
if (!sessionMedia)
return;
......
......@@ -300,6 +300,7 @@ class SIPVoIPLink : public VoIPLink
* @param id The call identifier
*/
std::string getCurrentCodecName(const std::string& id);
std::string getCurrentVideoCodecName(const std::string& id);
/**
* Retrive useragent name from account
......
......@@ -189,6 +189,7 @@ class VoIPLink
* @param id The call identifier
*/
virtual std::string getCurrentCodecName(const std::string& id) = 0;
virtual std::string getCurrentVideoCodecName(const std::string& id) = 0;
bool initDone (void) {
return _initDone;
......
......@@ -158,7 +158,7 @@ void SDPTest::testInitialOfferFirstCodec ()
CPPUNIT_ASSERT(_session->getRemoteAudioPort() == 49920);
CPPUNIT_ASSERT(_session->getLocalIP() == "127.0.0.1");
CPPUNIT_ASSERT(_session->getRemoteIP() == "host.example.com");
CPPUNIT_ASSERT(_session->getSessionMedia()->getMimeSubtype() == "PCMU");
CPPUNIT_ASSERT(_session->getSessionAudioCodec()->getMimeSubtype() == "PCMU");
}
......@@ -199,7 +199,7 @@ void SDPTest::testInitialAnswerFirstCodec ()
CPPUNIT_ASSERT(_session->getRemoteAudioPort() == 49920);
CPPUNIT_ASSERT(_session->getLocalIP() == "127.0.0.1");
CPPUNIT_ASSERT(_session->getRemoteIP() == "host.example.com");
CPPUNIT_ASSERT(_session->getSessionMedia()->getMimeSubtype() == "PCMU");
CPPUNIT_ASSERT(_session->getSessionAudioCodec()->getMimeSubtype() == "PCMU");
}
......@@ -243,7 +243,7 @@ void SDPTest::testInitialOfferLastCodec ()
CPPUNIT_ASSERT(_session->getRemoteAudioPort() == 49920);
CPPUNIT_ASSERT(_session->getLocalIP() == "127.0.0.1");
CPPUNIT_ASSERT(_session->getRemoteIP() == "host.example.com");
CPPUNIT_ASSERT(_session->getSessionMedia()->getMimeSubtype() == "G722");
CPPUNIT_ASSERT(_session->getSessionAudioCodec()->getMimeSubtype() == "G722");
}
......@@ -284,7 +284,7 @@ void SDPTest::testInitialAnswerLastCodec ()
CPPUNIT_ASSERT(_session->getRemoteAudioPort() == 49920);
CPPUNIT_ASSERT(_session->getLocalIP() == "127.0.0.1");
CPPUNIT_ASSERT(_session->getRemoteIP() == "host.example.com");
CPPUNIT_ASSERT(_session->getSessionMedia()->getMimeSubtype() == "G722");
CPPUNIT_ASSERT(_session->getSessionAudioCodec()->getMimeSubtype() == "G722");
}
......@@ -330,7 +330,7 @@ void SDPTest::testReinvite ()
CPPUNIT_ASSERT(_session->getRemoteAudioPort() == 49920);
CPPUNIT_ASSERT(_session->getLocalIP() == "127.0.0.1");
CPPUNIT_ASSERT(_session->getRemoteIP() == "host.example.com");
CPPUNIT_ASSERT(_session->getSessionMedia()->getMimeSubtype() == "PCMU");
CPPUNIT_ASSERT(_session->getSessionAudioCodec()->getMimeSubtype() == "PCMU");
pjmedia_sdp_parse(_testPool, (char*)sdp_reinvite, strlen(sdp_reinvite), &reinviteOffer);
......
......@@ -78,6 +78,11 @@ gchar* call_get_peer_number (const gchar *format)
return number;
}
gchar* call_get_video_codec (callable_obj_t *obj)
{
return dbus_get_current_video_codec_name (obj);
}
gchar* call_get_audio_codec (callable_obj_t *obj)
{
gchar * const audio_codec = dbus_get_current_audio_codec_name (obj);
......
......@@ -232,6 +232,7 @@ gchar* convert_timestamp_to_gchar (time_t);
time_t convert_gchar_to_timestamp (const gchar*);
gchar* call_get_audio_codec (callable_obj_t *obj);
gchar* call_get_video_codec (callable_obj_t *obj);
gchar* get_peer_information (callable_obj_t *c);
......
......@@ -395,7 +395,8 @@ button_pressed (GtkWidget* widget, GdkEventButton *event, gpointer user_data UNU
static gchar *
calltree_display_call_info (callable_obj_t * c, CallDisplayType display_type, const gchar * const audio_codec)
calltree_display_call_info (callable_obj_t * c, CallDisplayType display_type,
const gchar * const audio_codec, const gchar * const video_codec)
{
gchar display_number[strlen(c->_peer_number) + 1];
strcpy(display_number, c->_peer_number);
......@@ -409,6 +410,7 @@ calltree_display_call_info (callable_obj_t * c, CallDisplayType display_type, co
display_number[hostname - c->_peer_number] = '\0';
}
char *codec;
// Different display depending on type
const gchar *name, *details = NULL;
if (*c->_peer_name) {
......@@ -428,12 +430,18 @@ calltree_display_call_info (callable_obj_t * c, CallDisplayType display_type, co
suffix = g_markup_printf_escaped ("\n<i>%s (%d)</i>", c->_state_code_description, c->_state_code);
break;
case DISPLAY_TYPE_STATE_CODE :
if (video_codec && *video_codec)
codec = g_strconcat(audio_codec, "/", video_codec, NULL);
else
codec = g_strdup(audio_codec);
if (c->_state_code)
suffix = g_markup_printf_escaped ("\n<i>%s (%d)</i> <i>%s</i>",
c->_state_code_description, c->_state_code,
audio_codec);
codec);
else
suffix = g_markup_printf_escaped ("\n<i>%s</i>", audio_codec);
suffix = g_markup_printf_escaped ("\n<i>%s</i>", codec);
free(codec);
break;
case DISPLAY_TYPE_CALL_TRANSFER:
suffix = g_markup_printf_escaped ("\n<i>Transfer to:%s</i> ", c->_trsft_to);
......@@ -705,16 +713,18 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent)
/* Update text */
gchar * description = NULL;
gchar * audio_codec = call_get_audio_codec (c);
gchar * video_codec = call_get_video_codec (c);
if (c->_state == CALL_STATE_TRANSFERT) {
description = calltree_display_call_info (c, DISPLAY_TYPE_CALL_TRANSFER, "");
description = calltree_display_call_info (c, DISPLAY_TYPE_CALL_TRANSFER, "", "");
} else {
if (c->_sas && display_sas && c->_srtp_state == SRTP_STATE_ZRTP_SAS_UNCONFIRMED && !c->_zrtp_confirmed)
description = calltree_display_call_info (c, DISPLAY_TYPE_SAS, "");
description = calltree_display_call_info (c, DISPLAY_TYPE_SAS, "", "");
else
description = calltree_display_call_info (c, DISPLAY_TYPE_STATE_CODE, audio_codec);
description = calltree_display_call_info (c, DISPLAY_TYPE_STATE_CODE, audio_codec, video_codec);
}
g_free(audio_codec);
g_free(video_codec);
/* Update icons */
if (tab == current_calls) {
......@@ -806,7 +816,7 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent)
gchar *old_description = description;
g_free (old_description);
description = calltree_display_call_info (c, DISPLAY_TYPE_HISTORY, "");
description = calltree_display_call_info (c, DISPLAY_TYPE_HISTORY, "", "");
gchar * date = get_formatted_start_timestamp (c->_time_start);
gchar *duration = get_call_duration (c);
gchar *full_duration = g_strconcat (date , duration , NULL);
......@@ -856,7 +866,7 @@ void calltree_add_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent)
// New call in the list
const gchar * description = calltree_display_call_info (c, DISPLAY_TYPE_CALL, "");
const gchar * description = calltree_display_call_info (c, DISPLAY_TYPE_CALL, "", "");
gtk_tree_store_prepend (tab->store, &iter, parent);
......@@ -955,7 +965,7 @@ void calltree_add_history_entry (callable_obj_t *c, GtkTreeIter *parent)
gchar *date = NULL;
gchar *duration = NULL;
gchar * description = calltree_display_call_info (c, DISPLAY_TYPE_HISTORY, "");
gchar * description = calltree_display_call_info (c, DISPLAY_TYPE_HISTORY, "", "");
gtk_tree_store_prepend (history->store, &iter, parent);
......
......@@ -402,6 +402,14 @@
</arg>
</method>
<method name="getCurrentVideoCodecName" tp:name-for-bindings="getCurrentVideoCodecName">
<tp:docstring>
Unused
</tp:docstring>
<arg type="s" name="callID" direction="in"/>
<arg type="s" name="codecName" direction="out"/>
</method>
<method name="getCurrentAudioCodecName" tp:name-for-bindings="getCurrentAudioCodecName">
<tp:docstring>
Unused
......
......@@ -1519,6 +1519,27 @@ dbus_video_codec_details (gchar *codec)
return array;
}
gchar*
dbus_get_current_video_codec_name (const callable_obj_t * c)
{
gchar* codecName = NULL;
GError* error = NULL;
org_sflphone_SFLphone_CallManager_get_current_video_codec_name (callManagerProxy,
c->_callID, &codecName, &error);
if (error) {
g_error_free (error);
g_free (codecName);
codecName = g_strdup("");
}
DEBUG ("%s: codecName : %s", __PRETTY_FUNCTION__, codecName);
return codecName;
}
gchar*
dbus_get_current_audio_codec_name (const callable_obj_t * c)
{
......
......@@ -251,6 +251,12 @@ gchar** dbus_get_active_video_codec_list (gchar *accountID);
*/
void dbus_set_active_video_codec_list (const gchar** list, const gchar*);
/**
* CallManager - return the video codec name
* @param callable_obj_t* current call
*/
gchar* dbus_get_current_video_codec_name (const callable_obj_t * c);
/**
* CallManager - return the audio codec name
* @param callable_obj_t* current call
......
Supports Markdown
0%