diff --git a/sflphone-client-gnome/src/contacts/searchbar.c b/sflphone-client-gnome/src/contacts/searchbar.c index 0cdf4d5a08e58771c52106c2c7089962e4d7de02..06f1d281c3ad6679c3c88ccba0c5865604fb9d37 100644 --- a/sflphone-client-gnome/src/contacts/searchbar.c +++ b/sflphone-client-gnome/src/contacts/searchbar.c @@ -54,7 +54,7 @@ static void search_all (GtkWidget *item, GtkEntry *entry) static void search_by_missed (GtkWidget *item, GtkEntry *entry) { HistorySearchType = SEARCH_MISSED; - + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/missed.svg", NULL); gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, pixbuf); gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, @@ -65,7 +65,7 @@ static void search_by_missed (GtkWidget *item, GtkEntry *entry) static void search_by_incoming (GtkWidget *item, GtkEntry *entry) { HistorySearchType = SEARCH_INCOMING; - + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/incoming.svg", NULL); gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, pixbuf); gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, @@ -76,7 +76,7 @@ static void search_by_incoming (GtkWidget *item, GtkEntry *entry) static void search_by_outgoing (GtkWidget *item, GtkEntry *entry) { HistorySearchType = SEARCH_OUTGOING; - + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/outgoing.svg", NULL); gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_PRIMARY, pixbuf); gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, @@ -140,10 +140,10 @@ GtkWidget* history_searchbar_new (void) searchbox = gtk_entry_new(); gtk_entry_set_icon_from_stock (GTK_ENTRY (searchbox), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR); - + // Set the clean insensitive text_changed_cb (GTK_ENTRY (searchbox), NULL); - + g_signal_connect (searchbox, "icon-press", G_CALLBACK (icon_press_cb), NULL); g_signal_connect (searchbox, "notify::text", G_CALLBACK (text_changed_cb), NULL); //g_signal_connect (searchbox, "activate", G_CALLBACK (activate_cb), NULL); @@ -210,7 +210,7 @@ GtkWidget* contacts_searchbar_new () { ret = gtk_hbox_new(FALSE, 0); #if GTK_CHECK_VERSION(2,16,0) - + GdkPixbuf *pixbuf; searchbox = gtk_entry_new(); @@ -218,13 +218,13 @@ GtkWidget* contacts_searchbar_new () { pixbuf = gdk_pixbuf_new_from_file (ICONS_DIR "/stock_person.svg", NULL); gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (searchbox), GTK_ENTRY_ICON_PRIMARY, pixbuf); gtk_entry_set_icon_tooltip_text (GTK_ENTRY (searchbox), GTK_ENTRY_ICON_PRIMARY, - "Search contacts\n" - "GNOME evolution backend"); + "Search contacts\n" + "GNOME evolution backend"); + - // Set the clean insensitive text_changed_cb (GTK_ENTRY (searchbox), NULL); - + g_signal_connect (searchbox, "notify::text", G_CALLBACK (text_changed_cb), NULL); g_signal_connect (searchbox, "icon-press", G_CALLBACK (icon_press_cb), NULL); diff --git a/sflphone-common/src/audio/audiortp.cpp b/sflphone-common/src/audio/audiortp.cpp index b6882e604892383f057996dcec7200c5d4e0d554..cd9906b0ac370f6f068a001a5211330f43c2ea0b 100644 --- a/sflphone-common/src/audio/audiortp.cpp +++ b/sflphone-common/src/audio/audiortp.cpp @@ -276,6 +276,107 @@ AudioRtpRTX::computeNbByteAudioLayer(float codecFrameSize) return (int)((float)_layerSampleRate * codecFrameSize * (float)sizeof(SFLDataFormat) / 1000.0); } + +int +AudioRtpRTX::processDataEncode(AudioLayer* audiolayer) +{ + + // compute codec framesize in ms + float fixed_codec_framesize = computeCodecFrameSize(_audiocodec->getFrameSize(), _audiocodec->getClockRate()); + + // compute nb of byte to get coresponding to 20 ms at audio layer frame size (44.1 khz) + int maxBytesToGet = computeNbByteAudioLayer(fixed_codec_framesize); + + // available bytes inside ringbuffer + int availBytesFromMic = audiolayer->canGetMic(); + + // set available byte to maxByteToGet + int bytesAvail = (availBytesFromMic < maxBytesToGet) ? availBytesFromMic : maxBytesToGet; + + if (bytesAvail == 0) + return 0; + + // Get bytes from micRingBuffer to data_from_mic + int nbSample = audiolayer->getMic( micData , bytesAvail ) / sizeof(SFLDataFormat); + + // nb bytes to be sent over RTP + int compSize = 0; + + // test if resampling is required + if (_audiocodec->getClockRate() != _layerSampleRate) { + + int nb_sample_up = nbSample; + // _debug("_nbSample audiolayer->getMic(): %i \n", nbSample); + + // Store the length of the mic buffer in samples for recording + _nSamplesMic = nbSample; + + + // int nbSamplesMax = _layerFrameSize * _audiocodec->getClockRate() / 1000; + nbSample = reSampleData(micData , micDataConverted, _audiocodec->getClockRate(), nb_sample_up, DOWN_SAMPLING); + + compSize = _audiocodec->codecEncode( micDataEncoded, micDataConverted, nbSample*sizeof(int16)); + + } else { + // no resampling required + + // int nbSamplesMax = _codecFrameSize; + compSize = _audiocodec->codecEncode( micDataEncoded, micData, nbSample*sizeof(int16)); + + } + + return compSize; +} + + +void +AudioRtpRTX::processDataDecode(AudioLayer* audiolayer, unsigned char* spkrData, unsigned int size, int& countTime) +{ + + if (_audiocodec != NULL) { + + // Return the size of data in bytes + int expandedSize = _audiocodec->codecDecode( spkrDataDecoded , spkrData , size ); + + // buffer _receiveDataDecoded ----> short int or int16, coded on 2 bytes + int nbSample = expandedSize / sizeof(SFLDataFormat); + + // test if resampling is required + if (_audiocodec->getClockRate() != _layerSampleRate) { + + // Do sample rate conversion + int nb_sample_down = nbSample; + nbSample = reSampleData(spkrDataDecoded , spkrDataConverted, _codecSampleRate , nb_sample_down, UP_SAMPLING); + + // Store the number of samples for recording + _nSamplesSpkr = nbSample; + + // put data in audio layer, size in byte + audiolayer->putMain (spkrDataConverted, nbSample * sizeof(SFLDataFormat)); + + } else { + + // Stor the number of samples for recording + _nSamplesSpkr = nbSample; + + // put data in audio layer, size in byte + audiolayer->putMain (spkrDataDecoded, nbSample * sizeof(SFLDataFormat)); + } + + // Notify (with a beep) an incoming call when there is already a call + countTime += time->getSecond(); + if (Manager::instance().incomingCallWaiting() > 0) { + countTime = countTime % 500; // more often... + if (countTime == 0) { + Manager::instance().notificationIncomingCall(); + } + } + + } else { + countTime += time->getSecond(); + } +} + void AudioRtpRTX::sendSessionFromMic(int timestamp) { @@ -295,6 +396,9 @@ AudioRtpRTX::sendSessionFromMic(int timestamp) if (!_audiocodec) { _debug(" !ARTP: No audiocodec available for mic\n"); return; } + int compSize = processDataEncode(audiolayer); + + /* // compute codec framesize in ms float fixed_codec_framesize = computeCodecFrameSize(_audiocodec->getFrameSize(), _audiocodec->getClockRate()); @@ -338,6 +442,7 @@ AudioRtpRTX::sendSessionFromMic(int timestamp) compSize = _audiocodec->codecEncode( micDataEncoded, micData, nbSample*sizeof(int16)); } + */ // putData put the data on RTP queue, sendImmediate bypass this queue if (!_sym) { @@ -350,12 +455,11 @@ AudioRtpRTX::sendSessionFromMic(int timestamp) } - void + +void AudioRtpRTX::receiveSessionForSpkr (int& countTime) { - - if (_ca == 0) { return; } @@ -378,6 +482,8 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) unsigned char* spkrData = (unsigned char*)adu->getData(); // data in char unsigned int size = adu->getSize(); // size in char + processDataDecode(audiolayer, spkrData, size, countTime); + /* if (_audiocodec != NULL) { // Return the size of data in bytes @@ -421,7 +527,7 @@ AudioRtpRTX::receiveSessionForSpkr (int& countTime) countTime += time->getSecond(); } delete adu; adu = NULL; - + */ } diff --git a/sflphone-common/src/audio/audiortp.h b/sflphone-common/src/audio/audiortp.h index 2a418ec4dddb5411a9309a675e6bf8f76cd4bf16..b0466afa18d2b6ccc1dae91160ebda8131cc03ed 100644 --- a/sflphone-common/src/audio/audiortp.h +++ b/sflphone-common/src/audio/audiortp.h @@ -157,6 +157,12 @@ class AudioRtpRTX : public ost::Thread, public ost::TimerPort { int computeNbByteAudioLayer(float codecFrameSize); + int processDataEncode(AudioLayer* audiolayer); + + + void processDataDecode(AudioLayer* audiolayer, unsigned char* spkrData, unsigned int size, int& countTime); + + /** * Get the data from the mic, encode it and send it through the RTP session * @param timestamp To manage time and synchronizing