Ejemplo n.º 1
0
static bool_t compare_files(const char *path1, const char *path2) {
	bool_t res;
	size_t size1;
	size_t size2;
	uint8_t *buf1;
	uint8_t *buf2;
	FILE *f1 = fopen(path1, "rb");
	FILE *f2 = fopen(path2, "rb");
	fseek(f1, 0, SEEK_END);
	size1 = ftell(f1);
	fseek(f1, 0, SEEK_SET);
	fseek(f2, 0, SEEK_END);
	size2 = ftell(f2);
	fseek(f2, 0, SEEK_SET);
	if (size1 != size2) {
		fclose(f1);
		fclose(f2);
		return FALSE;
	}
	buf1 = ms_malloc(size1);
	buf2 = ms_malloc(size2);
	if (fread(buf1, size1, 1, f1)!=size1){
		ms_error("fread() error");
	}
	if (fread(buf2, size2, 1, f2)!=size2){
		ms_error("fread() error");
	}
	fclose(f1);
	fclose(f2);
	res = (memcmp(buf1, buf2, size1) == 0) ? TRUE : FALSE;
	ms_free(buf1);
	ms_free(buf2);
	return res;
}
Ejemplo n.º 2
0
void linphone_auth_info_write_config(LpConfig *config, LinphoneAuthInfo *obj, int pos)
{
	char key[50];
	sprintf(key,"auth_info_%i",pos);
	lp_config_clean_section(config,key);
	
	if (obj==NULL || lp_config_get_int(config, "sip", "store_auth_info", 1) == 0){
		return;
	}
	if (!obj->ha1 && obj->realm && obj->passwd && (obj->username||obj->userid)) {
		/*compute ha1 to avoid storing clear text password*/
		obj->ha1=ms_malloc(33);
		sal_auth_compute_ha1(obj->userid?obj->userid:obj->username,obj->realm,obj->passwd,obj->ha1);
	}
	if (obj->username!=NULL){
		lp_config_set_string(config,key,"username",obj->username);
	}
	if (obj->userid!=NULL){
		lp_config_set_string(config,key,"userid",obj->userid);
	}
	if (obj->ha1!=NULL){
		lp_config_set_string(config,key,"ha1",obj->ha1);
	} else if (obj->passwd!=NULL){ /*only write passwd if no ha1*/
		lp_config_set_string(config,key,"passwd",obj->passwd);
	}
	if (obj->realm!=NULL){
		lp_config_set_string(config,key,"realm",obj->realm);
	}
}
Ejemplo n.º 3
0
static int linphone_remote_provisioning_load_file( LinphoneCore* lc, const char* file_path){
	int status = -1;
	FILE* f = fopen(file_path, "r");

	if( f ){
		long fsize;
		char* provisioning;

		fseek(f, 0, SEEK_END);
		fsize = ftell(f);
		fseek(f, 0, SEEK_SET);

		provisioning = ms_malloc(fsize + 1);
		provisioning[fsize]='\0';
		if (fread(provisioning, fsize, 1, f)==0){
			ms_error("Could not read xml provisioning file from %s",file_path);
			status=-1;
		}else{
			linphone_remote_provisioning_apply(lc, provisioning);
			status = 0;
		}
		ms_free(provisioning);
		fclose(f);
	} else {
		ms_error("Couldn't open file %s for provisioning", file_path);
	}

	return status;
}
Ejemplo n.º 4
0
static void filter_init(MSFilter *f){
	ISACFIX_MainStruct* isac_mainstruct = NULL;
	isac_decoder_t *obj = NULL;
	int instance_size;
	WebRtc_Word16 ret;

	f->data = ms_new0(isac_decoder_t, 1);
	obj = (isac_decoder_t*)f->data;

	ret = WebRtcIsacfix_AssignSize( &instance_size );
	if( ret ) {
		ms_error("WebRtcIsacfix_AssignSize returned size %d", instance_size);
	}
	isac_mainstruct = ms_malloc(instance_size);

	ret = WebRtcIsacfix_Assign(&obj->isac, isac_mainstruct);
	if( ret ) {
		ms_error("WebRtcIsacfix_Create failed (%d)", ret);
	}

	ret = WebRtcIsacfix_DecoderInit(obj->isac);
	if( ret ) {
		ms_error("WebRtcIsacfix_DecoderInit failed (%d)", ret);
	}

	obj->ptime = 30; // default ptime is 30ms per packet
}
Ejemplo n.º 5
0
static void filter_process ( MSFilter *f ) {
    isac_encoder_struct_t* obj = (isac_encoder_struct_t*)f->data;

    mblk_t *im;
    mblk_t *om=NULL;
    u_int8_t* input_buf = NULL;
    WebRtc_Word16 ret;
    static int out_count = 0;

    // get the input data and put it into our buffered input
    while( (im = ms_queue_get( f->inputs[0] ) ) != NULL ) {
        ms_bufferizer_put( obj->bufferizer, im );
    }

    // feed the encoder with 160 16bit samples, until it has reached enough data
    // to produce a packet
    while( ms_bufferizer_get_avail(obj->bufferizer) > ISAC_SAMPLES_PER_ENCODE*2 ){

        om = allocb( WebRtcIsacfix_GetNewFrameLen(obj->isac), 0 );
        if(!input_buf) input_buf = ms_malloc( ISAC_SAMPLES_PER_ENCODE*2 );
        ms_bufferizer_read(obj->bufferizer, input_buf, ISAC_SAMPLES_PER_ENCODE*2);

        ret = WebRtcIsacfix_Encode(obj->isac,
                                   (const WebRtc_Word16*)input_buf,
                                   (WebRtc_Word16*)om->b_wptr);

        if( ret < 0) {

            ms_error( "WebRtcIsacfix_Encode error: %d", WebRtcIsacfix_GetErrorCode(obj->isac) );
            freeb(om);

        } else if( ret == 0 ) {
            // Encode() buffered the input, not yet able to produce a packet, continue feeding it
            // 160 samples per-call
            obj->ts += ISAC_SAMPLES_PER_ENCODE;
            freeb(om);

        } else {

            // a new packet has been encoded, send it
            obj->ts += ISAC_SAMPLES_PER_ENCODE;
            om->b_wptr += ret;
            out_count++;
//            ms_message("packet %d out, samples %d", out_count, obj->ts);

            mblk_set_timestamp_info( om, obj->ts );
            ms_queue_put(f->outputs[0], om);

            om = NULL;
        }

    }

    if( input_buf ){
        ms_free(input_buf);
    }
}
Ejemplo n.º 6
0
static void writeCallback(void *aqData,
						  AudioQueueRef inAQ, AudioQueueBufferRef inBuffer)
{
	AQData *d = (AQData *) aqData;
	OSStatus err;

	int len =
		(d->writeBufferByteSize * d->writeAudioFormat.mSampleRate / 1) /
		d->devicewriteFormat.mSampleRate /
		d->devicewriteFormat.mChannelsPerFrame;

	ms_mutex_lock(&d->mutex);
	if (d->write_started == FALSE) {
		ms_mutex_unlock(&d->mutex);
		return;
	}
	if (d->bufferizer->size >= len) {
#if 0
		UInt32 bsize = d->writeBufferByteSize;
		uint8_t *pData = ms_malloc(len);

		ms_bufferizer_read(d->bufferizer, pData, len);
		err = AudioConverterConvertBuffer(d->writeAudioConverter,
										  len,
										  pData,
										  &bsize, inBuffer->mAudioData);
		if (err != noErr) {
			ms_error("writeCallback: AudioConverterConvertBuffer %d", err);
		}
		ms_free(pData);

		if (bsize != d->writeBufferByteSize)
			ms_warning("d->writeBufferByteSize = %i len = %i bsize = %i",
					   d->writeBufferByteSize, len, bsize);
#else
		ms_bufferizer_read(d->bufferizer, inBuffer->mAudioData, len);
#endif
	} else {
		memset(inBuffer->mAudioData, 0, d->writeBufferByteSize);
	}
	inBuffer->mAudioDataByteSize = d->writeBufferByteSize;

	if (gain_changed_out == true)
	  {
	    AudioQueueSetParameter (d->writeQueue,
				    kAudioQueueParam_Volume,
				    gain_volume_out);
	    gain_changed_out = false;
	  }

	err = AudioQueueEnqueueBuffer(d->writeQueue, inBuffer, 0, NULL);
	if (err != noErr) {
		ms_error("AudioQueueEnqueueBuffer %d", err);
	}
	ms_mutex_unlock(&d->mutex);
}
Ejemplo n.º 7
0
void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, LinphoneProxyConfig *cfg, bool_t only_when_registered) {
	const bctbx_list_t *elem;
	if (list->rls_uri != NULL) {
		if (list->enable_subscriptions) {
			LinphoneAddress *address = linphone_address_new(list->rls_uri);
			char *xml_content = create_resource_list_xml(list);
			if ((address != NULL) && (xml_content != NULL) && (linphone_friend_list_has_subscribe_inactive(list) == TRUE)) {
				unsigned char digest[16];
				bctbx_md5((unsigned char *)xml_content, strlen(xml_content), digest);
				if ((list->event != NULL) && (list->content_digest != NULL) && (memcmp(list->content_digest, digest, sizeof(digest)) == 0)) {
					/* The content has not changed, only refresh the event. */
					linphone_event_refresh_subscribe(list->event);
				} else {
					LinphoneContent *content;
					int expires = lp_config_get_int(list->lc->config, "sip", "rls_presence_expires", 3600);
					list->expected_notification_version = 0;
					if (list->content_digest != NULL) ms_free(list->content_digest);
					list->content_digest = ms_malloc(sizeof(digest));
					memcpy(list->content_digest, digest, sizeof(digest));
					if (list->event != NULL) {
						linphone_event_terminate(list->event);
						linphone_event_unref(list->event);
					}
					list->event = linphone_core_create_subscribe(list->lc, address, "presence", expires);
					linphone_event_ref(list->event);
					linphone_event_set_internal(list->event, TRUE);
					linphone_event_add_custom_header(list->event, "Require", "recipient-list-subscribe");
					linphone_event_add_custom_header(list->event, "Supported", "eventlist");
					linphone_event_add_custom_header(list->event, "Accept", "multipart/related, application/pidf+xml, application/rlmi+xml");
					linphone_event_add_custom_header(list->event, "Content-Disposition", "recipient-list");
					content = linphone_core_create_content(list->lc);
					linphone_content_set_type(content, "application");
					linphone_content_set_subtype(content, "resource-lists+xml");
					linphone_content_set_string_buffer(content, xml_content);
					if (linphone_core_content_encoding_supported(list->lc, "deflate")) {
						linphone_content_set_encoding(content, "deflate");
						linphone_event_add_custom_header(list->event, "Accept-Encoding", "deflate");
					}
					linphone_event_send_subscribe(list->event, content);
					linphone_content_unref(content);
					linphone_event_set_user_data(list->event, list);
				}
			}
			if (address != NULL) linphone_address_unref(address);
			if (xml_content != NULL) ms_free(xml_content);
		} else {
			ms_message("Friends list [%p] subscription update skipped since subscriptions not enabled yet", list);
		}
	} else if (list->enable_subscriptions) {
		for (elem = list->friends; elem != NULL; elem = elem->next) {
			LinphoneFriend *lf = (LinphoneFriend *)elem->data;
			linphone_friend_update_subscribes(lf, cfg, only_when_registered);
		}
	}
}
Ejemplo n.º 8
0
static void linphone_vcard_import_a_lot_of_friends_test(void) {
	LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE);
	LinphoneFriendList *lfl = linphone_core_get_default_friend_list(manager->lc);
	char *import_filepath = bc_tester_res("vcards/thousand_vcards.vcf");
	clock_t start, end;
	double elapsed = 0;
	const bctbx_list_t *friends = NULL;
	FILE    *infile = NULL;
	char    *buffer = NULL;
	long    numbytes = 0;
	size_t readbytes;

	start = clock();
	linphone_friend_list_import_friends_from_vcard4_file(lfl, import_filepath);
	end = clock();

	friends = linphone_friend_list_get_friends(lfl);
	BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(friends), 1000, unsigned int, "%u"); // Now that we accept Friends without a SIP URI, the result must be equal to 1000

	elapsed = (double)(end - start);
	ms_message("Imported a thousand of vCards from file in %f seconds", elapsed / CLOCKS_PER_SEC);

	lfl = linphone_core_create_friend_list(manager->lc);
	infile = fopen(import_filepath, "rb");
	BC_ASSERT_PTR_NOT_NULL(infile);
	if (infile) {
		fseek(infile, 0L, SEEK_END);
		numbytes = ftell(infile);
		fseek(infile, 0L, SEEK_SET);
		buffer = (char*)ms_malloc((numbytes + 1) * sizeof(char));
		readbytes = fread(buffer, sizeof(char), numbytes, infile);
		fclose(infile);
		buffer[readbytes] = '\0';

		start = clock();
		linphone_friend_list_import_friends_from_vcard4_buffer(lfl, buffer);
		end = clock();
		ms_free(buffer);
	}

	friends = linphone_friend_list_get_friends(lfl);
	BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(friends), 1000, unsigned int, "%u"); // Now that we accept Friends without a SIP URI, the result must be equal to 1000

	elapsed = (double)(end - start);
	ms_message("Imported a thousand of vCards from buffer in %f seconds", elapsed / CLOCKS_PER_SEC);

	linphone_friend_list_unref(lfl);

	ms_free(import_filepath);
	linphone_core_manager_destroy(manager);
}
Ejemplo n.º 9
0
MSList *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int startm, int endm){
	LinphoneCore *lc=linphone_chat_room_get_core(cr);
	MSList *ret;
	char *buf,*buf2;
	char *peer;
	uint64_t begin,end;
	int buf_max_size = 512;

	if (lc->db==NULL) return NULL;
	peer = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));

	cr->messages_hist = NULL;

	/*since we want to append query parameters depending on arguments given, we use malloc instead of sqlite3_mprintf*/
	buf=ms_malloc(buf_max_size);
	buf=sqlite3_snprintf(buf_max_size-1,buf,"SELECT * FROM history WHERE remoteContact = %Q ORDER BY id DESC",peer);


	if (startm<0) startm=0;

	if ((endm>0&&endm>=startm) || (startm == 0 && endm == 0) ){
		buf2=ms_strdup_printf("%s LIMIT %i ",buf,endm+1-startm);
		ms_free(buf);
		buf = buf2;
	}else if(startm>0){
		ms_message("%s(): end is lower than start (%d < %d). Assuming no end limit.",__FUNCTION__,endm,startm);
		buf2=ms_strdup_printf("%s LIMIT -1",buf);
		ms_free(buf);
		buf = buf2;
	}

	if (startm>0){
		buf2=ms_strdup_printf("%s OFFSET %i ",buf,startm);
		ms_free(buf);
		buf = buf2;
	}
	
	begin=ortp_get_cur_time_ms();
	linphone_sql_request_message(lc->db,buf,cr);
	end=ortp_get_cur_time_ms();
	
	if (endm+1-startm > 1) {
		//display message only if at least 2 messages are loaded
		ms_message("%s(): completed in %i ms",__FUNCTION__, (int)(end-begin));
	}
	ms_free(buf);
	ret=cr->messages_hist;
	cr->messages_hist=NULL;
	ms_free(peer);
	return ret;
}
Ejemplo n.º 10
0
static void aq_put(MSFilter * f, mblk_t * m)
{
	AQData *d = (AQData *) f->data;
	ms_mutex_lock(&d->mutex);
	ms_bufferizer_put(d->bufferizer, m);
	ms_mutex_unlock(&d->mutex);

	int len =
		(d->writeBufferByteSize * d->writeAudioFormat.mSampleRate / 1) /
		d->devicewriteFormat.mSampleRate /
		d->devicewriteFormat.mChannelsPerFrame;
	if (d->write_started == FALSE && d->bufferizer->size >= len) {
		AudioQueueBufferRef curbuf = d->writeBuffers[d->curWriteBuffer];
#if 0
		OSStatus err;
		UInt32 bsize = d->writeBufferByteSize;
		uint8_t *pData = ms_malloc(len);

		ms_bufferizer_read(d->bufferizer, pData, len);
		err = AudioConverterConvertBuffer(d->writeAudioConverter,
										  len,
										  pData,
										  &bsize, curbuf->mAudioData);
		if (err != noErr) {
			ms_error("writeCallback: AudioConverterConvertBuffer %d", err);
		}
		ms_free(pData);

		if (bsize != d->writeBufferByteSize)
			ms_warning("d->writeBufferByteSize = %i len = %i bsize = %i",
					   d->writeBufferByteSize, len, bsize);
#else
		ms_bufferizer_read(d->bufferizer, curbuf->mAudioData, len);
#endif
		curbuf->mAudioDataByteSize = d->writeBufferByteSize;
		putWriteAQ(d, d->curWriteBuffer);
		++d->curWriteBuffer;
	}
	if (d->write_started == FALSE
		&& d->curWriteBuffer == kNumberAudioOutDataBuffers - 1) {
		OSStatus err;
		err = AudioQueueStart(d->writeQueue, NULL	// start time. NULL means ASAP.
			);
		if (err != noErr) {
			ms_error("AudioQueueStart -write- %d", err);
		}
		d->write_started = TRUE;

	}
}
Ejemplo n.º 11
0
static bool_t check_card_capability(AudioDeviceID id, bool_t is_input, char * devname, char *uidname, size_t name_len) {
    unsigned int slen=name_len;
    Boolean writable=0;
    CFStringRef dUID=NULL;
    bool_t ret=FALSE;

    int err =AudioDeviceGetProperty(id, 0, is_input, kAudioDevicePropertyDeviceName, &slen,devname);
    if (err != kAudioHardwareNoError) {
        ms_error("get kAudioDevicePropertyDeviceName error %ld", err);
        return FALSE;
    }
    err =AudioDeviceGetPropertyInfo(id, 0, is_input, kAudioDevicePropertyStreamConfiguration, &slen, &writable);
    if (err != kAudioHardwareNoError) {
        ms_error("get kAudioDevicePropertyDeviceName error %ld", err);
        return FALSE;
    }

    AudioBufferList *buflist = ms_malloc(slen);

    err =
        AudioDeviceGetProperty(id, 0, is_input, kAudioDevicePropertyStreamConfiguration, &slen, buflist);
    if (err != kAudioHardwareNoError) {
        ms_error("get kAudioDevicePropertyDeviceName error %ld", err);
        ms_free(buflist);
        return FALSE;
    }

    UInt32 j;
    for (j = 0; j < buflist->mNumberBuffers; j++) {
        if (buflist->mBuffers[j].mNumberChannels > 0) {
            ret=TRUE;
            break;
        }
    }
    ms_free(buflist);
    if (ret==FALSE) return FALSE;

    slen = sizeof(CFStringRef);
    err =AudioDeviceGetProperty(id, 0, is_input, kAudioDevicePropertyDeviceUID, &slen,&dUID);
    if (err != kAudioHardwareNoError) {
        ms_error("get kAudioHardwarePropertyDevices error %ld", err);
        return FALSE;
    }
    CFStringGetCString(dUID, uidname, sizeof(uidname),CFStringGetSystemEncoding());
    ms_message("CA: devname:%s uidname:%s", devname, uidname);


    return ret;
}
Ejemplo n.º 12
0
static void linphone_vcard_import_a_lot_of_friends_test(void) {
	LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE);
	LinphoneFriendList *lfl = linphone_core_get_default_friend_list(manager->lc);
	char *import_filepath = bc_tester_res("vcards/thousand_vcards.vcf");
	clock_t start, end;
	double elapsed = 0;
	const MSList *friends = NULL;
	FILE    *infile = NULL;
	char    *buffer = NULL;
	long    numbytes = 0;

	start = clock();
	linphone_friend_list_import_friends_from_vcard4_file(lfl, import_filepath);
	end = clock();

	friends = linphone_friend_list_get_friends(lfl);
	BC_ASSERT_EQUAL(ms_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI

	elapsed = (double)(end - start);
	ms_error("Imported a thousand of vCards from file (only %i friends with SIP address found) in %f seconds", ms_list_size(friends), elapsed / CLOCKS_PER_SEC);

	lfl = linphone_core_create_friend_list(manager->lc);
	infile = fopen(import_filepath, "rb");
	BC_ASSERT_PTR_NOT_NULL(infile);
	if (infile) {
		fseek(infile, 0L, SEEK_END);
		numbytes = ftell(infile);
		fseek(infile, 0L, SEEK_SET);
		buffer = (char*)ms_malloc(numbytes * sizeof(char));
		numbytes = fread(buffer, sizeof(char), numbytes, infile);
		fclose(infile);

		start = clock();
		linphone_friend_list_import_friends_from_vcard4_buffer(lfl, buffer);
		end = clock();
		ms_free(buffer);
	}

	friends = linphone_friend_list_get_friends(lfl);
	BC_ASSERT_EQUAL(ms_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI

	elapsed = (double)(end - start);
	ms_error("Imported a thousand of vCards from buffer (only %i friends with SIP address found) in %f seconds", ms_list_size(friends), elapsed / CLOCKS_PER_SEC);

	linphone_friend_list_unref(lfl);

	ms_free(import_filepath);
	linphone_core_manager_destroy(manager);
}
Ejemplo n.º 13
0
Archivo: enum.c Proyecto: CTA/linphone
static char *create_enum_domain(const char *number){
	long len=(long)strlen(number);
	char *domain=ms_malloc((len*2)+10);
	long i,j;

	for (i=0,j=len-1;j>=0;j--){
		domain[i]=number[j];
		i++;
		domain[i]='.';
		i++;
	}
	strcpy(&domain[i],"e164.arpa");
	ms_message("enum domain for %s is %s",number,domain);
	return domain;
}
Ejemplo n.º 14
0
LinphoneLDAPContactSearch* linphone_ldap_contact_search_create(LinphoneLDAPContactProvider* cp, const char* predicate, ContactSearchCallback cb, void* cb_data)
{
	LinphoneLDAPContactSearch* search = belle_sip_object_new(LinphoneLDAPContactSearch);
	LinphoneContactSearch* base = LINPHONE_CONTACT_SEARCH(search);

	linphone_contact_search_init(base, predicate, cb, cb_data);

	search->ld = cp->ld;

	search->filter = ms_malloc(FILTER_MAX_SIZE);
	snprintf(search->filter, FILTER_MAX_SIZE-1, cp->filter, predicate);
	search->filter[FILTER_MAX_SIZE-1] = 0;

	return search;
}
Ejemplo n.º 15
0
void generic_plc_update_continuity_buffer(plc_context_t *context, unsigned char *data, size_t data_len) {
	size_t transitionBufferSize = context->sample_rate*sizeof(int16_t)*TRANSITION_DELAY/1000;
	unsigned char *buffer=ms_malloc(transitionBufferSize);

	/* get the last TRANSITION_DELAY ms in a temp buffer */
	memcpy(buffer, data+data_len-transitionBufferSize, transitionBufferSize);
	/* move by TRANSITION_DELAY ms the signal in msg toward future crashing the end of the msg we just saved in buf */
	memmove(data+transitionBufferSize, data, data_len - transitionBufferSize);
	/* retrieve from continuity buffer the last TRANSITION_DELAY ms of previous message and insert them at the begining of current msg */
	memcpy(data, context->continuity_buffer, transitionBufferSize);
	/* store in context for next msg the last TRANSITION_DELAY ms of current msg */
	memcpy(context->continuity_buffer, buffer, transitionBufferSize);

	ms_free(buffer);
}
Ejemplo n.º 16
0
void linphone_content_copy(LinphoneContent *obj, const LinphoneContent *ref){
	SET_STRING(obj,type,ref->type);
	SET_STRING(obj,subtype,ref->subtype);
	SET_STRING(obj,encoding,ref->encoding);
	SET_STRING(obj,name,ref->name);
	if (obj->data) {
		ms_free(obj->data);
		obj->data=NULL;
	}
	if (ref->data){
		obj->data=ms_malloc(ref->size+1);
		memcpy(obj->data, ref->data, ref->size);
		((char*)obj->data)[ref->size]='\0';
	}
	obj->size=ref->size;
}
Ejemplo n.º 17
0
LinphoneContent *linphone_content_copy_from_sal_body(LinphoneContent *obj, const SalBody *ref){
	SET_STRING(obj,type,ref->type);
	SET_STRING(obj,subtype,ref->subtype);
	SET_STRING(obj,encoding,ref->encoding);
	if (obj->data) {
		ms_free(obj->data);
		obj->data=NULL;
	}
	if (ref->data){
		obj->data=ms_malloc(ref->size+1);
		memcpy(obj->data, ref->data, ref->size);
		((char*)obj->data)[ref->size]='\0';
	}
	obj->size=ref->size;
	return obj;
}
Ejemplo n.º 18
0
void linphone_auth_info_write_config(LpConfig *config, LinphoneAuthInfo *obj, int pos) {
	char key[50];
	bool_t store_ha1_passwd = lp_config_get_int(config, "sip", "store_ha1_passwd", 1);

	sprintf(key, "auth_info_%i", pos);
	lp_config_clean_section(config, key);

	if (obj == NULL || lp_config_get_int(config, "sip", "store_auth_info", 1) == 0) {
		return;
	}
	if (!obj->ha1 && obj->realm && obj->passwd && (obj->username || obj->userid) && store_ha1_passwd) {
		/*compute ha1 to avoid storing clear text password*/
		obj->ha1 = ms_malloc(33);
		sal_auth_compute_ha1(obj->userid ? obj->userid : obj->username, obj->realm, obj->passwd, obj->ha1);
	}
	if (obj->username != NULL) {
		lp_config_set_string(config, key, "username", obj->username);
	}
	if (obj->userid != NULL) {
		lp_config_set_string(config, key, "userid", obj->userid);
	}
	if (obj->ha1 != NULL) {
		lp_config_set_string(config, key, "ha1", obj->ha1);
	}
	if (obj->passwd != NULL) {
		if (store_ha1_passwd && obj->ha1) {
			/*if we have our ha1 and store_ha1_passwd set to TRUE, then drop the clear text password for security*/
			linphone_auth_info_set_passwd(obj, NULL);
		} else {
			/*we store clear text password only if store_ha1_passwd is FALSE AND we have an ha1 to store. Otherwise, passwd would simply be removed, which might bring major auth issue*/
			lp_config_set_string(config, key, "passwd", obj->passwd);
		}
	}
	if (obj->realm != NULL) {
		lp_config_set_string(config, key, "realm", obj->realm);
	}
	if (obj->domain != NULL) {
		lp_config_set_string(config, key, "domain", obj->domain);
	}
	if (obj->tls_cert_path != NULL) {
		lp_config_set_string(config, key, "client_cert_chain", obj->tls_cert_path);
	}
	if (obj->tls_key_path != NULL) {
		lp_config_set_string(config, key, "client_cert_key", obj->tls_key_path);
	}
}
Ejemplo n.º 19
0
bool_t lp_spawn_command_line_sync(const char *command, char **result,int *command_ret){
	FILE *f=popen(command,"r");
	if (f!=NULL){
		int err;
		*result=ms_malloc(4096);
		err=fread(*result,1,4096-1,f);
		if (err<0){
			ms_warning("Error reading command output:%s",strerror(errno));
			ms_free(result);
			return FALSE;
		}
		(*result)[err]=0;
		err=pclose(f);
		if (command_ret!=NULL) *command_ret=err;
		return TRUE;
	}
	return FALSE;
}
Ejemplo n.º 20
0
char *ms_load_file_content(FILE *f, size_t *nbytes){
	size_t bufsize=2048;
	size_t step=bufsize;
	size_t pos=0;
	size_t count;
	char *buffer=ms_malloc(bufsize+1);
	
	while((count=fread(buffer+pos, 1, step, f))>0){
		pos+=count;
		if (pos+step>=bufsize){
			bufsize*=2;
			buffer=ms_realloc(buffer, bufsize+1);
		}
	}
	if (nbytes) *nbytes=pos;
	buffer[pos]='\0';
	return buffer;
}
Ejemplo n.º 21
0
/*
 * function called when the file transfer is initiated. file content should be feed into object LinphoneContent
 * */
LinphoneBuffer * file_transfer_send(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t size){
	LinphoneBuffer *lb;
	size_t file_size;
	size_t size_to_send;
	FILE *file_to_send;
	uint8_t *buf;
	if (size == 0) return linphone_buffer_new(); /*end of file*/
	file_to_send = linphone_chat_message_get_user_data(message);
	fseek(file_to_send, 0, SEEK_END);
	file_size = ftell(file_to_send);
	fseek(file_to_send, offset, SEEK_SET);
	size_to_send = MIN(size, file_size - offset);
	buf = ms_malloc(size_to_send);
	if (fread(buf, size_to_send, 1, file_to_send)!=size_to_send){
		ms_error("fread error");
	}
	lb = linphone_buffer_new_from_data(buf, size_to_send);
	ms_free(buf);
	return lb;
}
Ejemplo n.º 22
0
static void guess_display_name(LinphoneAddress *from){
	char *dn=(char*)ms_malloc(strlen(linphone_address_get_username(from))+3);
	const char *it;
	char *wptr=dn;
	bool_t begin=TRUE;
	bool_t surname=0;
	for(it=linphone_address_get_username(from);*it!='\0';++it){
		if (begin){
			*wptr=toupper(*it);
			begin=FALSE;
		}else if (*it=='.'){
			if (surname) break;
			*wptr=' ';
			begin=TRUE;
			surname=TRUE;
		}else *wptr=*it;
		wptr++;
	}
	linphone_address_set_display_name(from,dn);
	ms_free(dn);
}
Ejemplo n.º 23
0
static char *load_file_content(const char *path){
	FILE *f=fopen(path,"rb");
	size_t bufsize=2048;
	size_t step=bufsize;
	size_t pos=0;
	size_t count;
	char *buffer=ms_malloc(bufsize+1);
	if (!f) {
		ms_error("load_file_content(): could not open [%s]",path);
		return NULL;
	}
	while((count=fread(buffer+pos, 1, step, f))>0){
		pos+=count;
		if (pos+step>=bufsize){
			bufsize*=2;
			buffer=ms_realloc(buffer, bufsize+1);
		}
	}
	buffer[pos]='\0';
	fclose(f);
	return buffer;
}
Ejemplo n.º 24
0
static void video_capture_detect(MSWebCamManager *obj){
	ms_message("Detecting Android VIDEO cards");
	JNIEnv *env = ms_get_jni_env();
	jclass helperClass = getHelperClassGlobalRef(env);
	
	if (helperClass==NULL) return;

	// create 3 int arrays - assuming 2 webcams at most
	jintArray indexes = (jintArray)env->NewIntArray(2);
	jintArray frontFacing = (jintArray)env->NewIntArray(2);
	jintArray orientation = (jintArray)env->NewIntArray(2);

	jmethodID method = env->GetStaticMethodID(helperClass,"detectCameras", "([I[I[I)I");

	int count = env->CallStaticIntMethod(helperClass, method, indexes, frontFacing, orientation);

	ms_message("%d cards detected", count);
	for(int i=0; i<count; i++) {
		MSWebCam *cam = ms_web_cam_new(&ms_android_video_capture_desc);
		AndroidWebcamConfig* c = new AndroidWebcamConfig();
		env->GetIntArrayRegion(indexes, i, 1, &c->id);
		env->GetIntArrayRegion(frontFacing, i, 1, &c->frontFacing);
		env->GetIntArrayRegion(orientation, i, 1, &c->orientation);
		cam->data = c;
		cam->name = ms_strdup("Android video name");
		char* idstring = (char*) ms_malloc(15);
		snprintf(idstring, 15, "Android%d", c->id);
		cam->id = idstring;
		ms_web_cam_manager_add_cam(obj,cam);
		ms_message("camera created: id=%d frontFacing=%d orientation=%d [msid:%s]\n", c->id, c->frontFacing, c->orientation, idstring);
	}
	env->DeleteLocalRef(indexes);
	env->DeleteLocalRef(frontFacing);
	env->DeleteLocalRef(orientation);

	env->DeleteGlobalRef(helperClass);
	ms_message("Detection of Android VIDEO cards done");
}
Ejemplo n.º 25
0
char *int2str(int number)
{
	char *numstr=ms_malloc(10);
	snprintf(numstr,10,"%i",number);
	return numstr;
}
Ejemplo n.º 26
0
static LpSection* lp_config_parse_line(LpConfig* lpconfig, const char* line, LpSection* cur) {
	LpSectionParam *params = NULL;
	char *pos1,*pos2;
	int nbs;
	int size=strlen(line)+1;
	char *secname=ms_malloc(size);
	char *key=ms_malloc(size);
	char *value=ms_malloc(size);
	LpItem *item;

	pos1=strchr(line,'[');
	if (pos1!=NULL && is_first_char(line,pos1) ){
		pos2=strchr(pos1,']');
		if (pos2!=NULL){
			secname[0]='\0';
			/* found section */
			*pos2='\0';
			nbs = sscanf(pos1+1, "%s", secname);
			if (nbs >= 1) {
				if (strlen(secname) > 0) {
					cur = lp_config_find_section (lpconfig,secname);
					if (cur == NULL) {
						cur = lp_section_new(secname);
						lp_config_add_section(lpconfig, cur);
					}

					if (pos2 > pos1 + 1 + strlen(secname)) {
						/* found at least one section param */
						pos2 = pos1 + 1 + strlen(secname) + 1; // Remove the white space after the secname
						pos1 = strchr(pos2, '=');
						while (pos1 != NULL) {
							/* for each section param */
							key[0] = '\0';
							value[0] = '\0';
							*pos1 = ' ';
							if (sscanf(pos2, "%s %s", key, value) == 2) {
								params = lp_section_param_new(key, value);
								lp_config_add_section_param(cur, params);

								pos2 += strlen(key) + strlen(value) + 2; // Remove the = sign + the white space after each param
								pos1 = strchr(pos2, '=');
							} else {
								ms_warning("parse section params error !");
								pos1 = NULL;
							}
						}
					}
				}
			} else {
				ms_warning("parse error!");
			}
		}
	}else {
		if (is_a_comment(line)){
			if (cur){
				LpItem *comment=lp_comment_new(line);
				lp_section_add_item(cur,comment);
			}
		}else{
			pos1=strchr(line,'=');
			if (pos1!=NULL){
				key[0]='\0';

				*pos1='\0';
				if (sscanf(line,"%s",key)>0){

					pos1++;
					pos2=strchr(pos1,'\r');
					if (pos2==NULL)
						pos2=strchr(pos1,'\n');
					if (pos2==NULL) pos2=pos1+strlen(pos1);
					else {
						*pos2='\0'; /*replace the '\n' */
					}
					/* remove ending white spaces */
					for (; pos2>pos1 && pos2[-1]==' ';pos2--) pos2[-1]='\0';

					if (pos2-pos1>0){
						/* found a pair key,value */

						if (cur!=NULL){
							item=lp_section_find_item(cur,key);
							if (item==NULL){
								lp_section_add_item(cur,lp_item_new(key,pos1));
							}else{
								ortp_free(item->value);
								item->value=ortp_strdup(pos1);
							}
							/*ms_message("Found %s=%s",key,pos1);*/
						}else{
							ms_warning("found key,item but no sections");
						}
					}
				}
			}
		}
	}
	ms_free(key);
	ms_free(value);
	ms_free(secname);
	return cur;
}
static void test_video_processing_base (bool_t downscaling,bool_t rotate_clock_wise,bool_t flip) {
	MSVideoSize src_size = { MS_VIDEO_SIZE_VGA_W, MS_VIDEO_SIZE_VGA_H };
	MSVideoSize dest_size = src_size;
	
	mblk_t * yuv_block2;
	YuvBuf yuv;
	int y_bytes_per_row = src_size.width + src_size.width%32 ;
	uint8_t* y = (uint8_t*)ms_malloc(y_bytes_per_row*src_size.height); /*to allow bloc to work with multiple of 32*/
	int crcb_bytes_per_row = src_size.width/2 + (src_size.width/2)%32 ;
	uint8_t* cbcr = (uint8_t*)ms_malloc(crcb_bytes_per_row*src_size.height);
	int i,j;
	MSYuvBufAllocator *yba = ms_yuv_buf_allocator_new();
	int factor=downscaling?2:1;
	int rotation = 0;
	if (rotate_clock_wise && flip) {
		ms_fatal("fix you test");
	}
	if (rotate_clock_wise) {
		rotation = 90;
		dest_size.height=src_size.width;
		dest_size.width=src_size.height;
	} else if (flip) {
		rotation = 180;
	}
	dest_size.height = dest_size.height/factor;
	dest_size.width=dest_size.width/factor;
	
	for (i=0;i<src_size.height*src_size.width;i++) {
		y[i]=i%256;
	}
	for (i=0;i<src_size.height*src_size.width/2;i++) {
		cbcr[i]=i%256;
	}

	yuv_block2 = copy_ycbcrbiplanar_to_true_yuv_with_rotation_and_down_scale_by_2(yba,	y
																					,cbcr
																					,rotation
																					, dest_size.width
																					, dest_size.height
																					, y_bytes_per_row
																					, crcb_bytes_per_row
																					, 1
																					, downscaling);

	BC_ASSERT_FALSE(ms_yuv_buf_init_from_mblk(&yuv, yuv_block2));
	BC_ASSERT_EQUAL(dest_size.width,yuv.w, int, "%d");
	BC_ASSERT_EQUAL(dest_size.height,yuv.h, int, "%d");

	if (rotate_clock_wise) {
		/*check y*/
		for (i=0;i<yuv.h;i++) {
			for (j=0;j<yuv.w;j++)
				if (yuv.planes[0][i*yuv.strides[0]+j] != y[(yuv.w-1-j)*factor*y_bytes_per_row+i*factor]) {
					ms_error("Wrong value  [%i] at ofset [%i], should be [%i]",yuv.planes[0][i*yuv.strides[0]+j],i*yuv.strides[0]+j,y[(yuv.w-1-j)*factor*y_bytes_per_row+i*factor]);
					BC_FAIL("bad y value");
					break;
				}
			
		}
		/*check cb*/
		for (i=0;i<yuv.h/2;i++) {
			for (j=0;j<yuv.w/2;j++) {
				if (yuv.planes[1][i*yuv.strides[1]+j] != cbcr[(yuv.w/2-1-j)*factor*crcb_bytes_per_row+2*i*factor]) {
					ms_error("Wrong value  [%i] at ofset [%i], should be [%i]",yuv.planes[1][i*yuv.strides[1]+j],i*yuv.strides[1]+j,cbcr[(yuv.w/2-1-j)*factor*crcb_bytes_per_row+2*i*factor]);
					BC_FAIL("bad cb value");
					break;
				}
				if (yuv.planes[2][i*yuv.strides[2]+j] != cbcr[(yuv.w/2-1-j)*factor*crcb_bytes_per_row+2*i*factor+1]) {
					ms_error("Wrong value  [%i] at ofset [%i], should be [%i]",yuv.planes[2][i*yuv.strides[2]+j],i*yuv.strides[2]+j,cbcr[(yuv.w/2-1-j)*factor*crcb_bytes_per_row+2*i*factor+1]);
					BC_FAIL("bad cr value");
					break;
				}
			}
		}
	} else if (flip) {
		
		/*check y*/
		for (i=0;i<yuv.h;i++) {
			for (j=0;j<yuv.w;j++)
				if (yuv.planes[0][i*yuv.strides[0]+j] != y[(yuv.h-1-i)*factor*y_bytes_per_row+(yuv.w-1-j)*factor]) {
					ms_error("Wrong value  [%i] at ofset [%i], should be [%i]",yuv.planes[0][i*yuv.strides[0]+j],i*yuv.strides[0]+j,y[(yuv.h-1-i)*factor*y_bytes_per_row+(yuv.w-1-j)*factor]);
					BC_FAIL("bad y value");
					break;
				}
		}
		
		for (i=0;i<yuv.h/2;i++) {
			for (j=0;j<yuv.w/2;j++) {
				/*check cb*/
				if (yuv.planes[1][i*yuv.strides[1]+j] != cbcr[(yuv.h/2-1-i)*factor*crcb_bytes_per_row+2*(yuv.w/2-1-j)*factor]) {
					ms_error("Wrong value  [%i] at ofset [%i], should be [%i]",yuv.planes[1][i*yuv.strides[1]+j],i*yuv.strides[1]+j,cbcr[(yuv.h/2-1-i)*factor*crcb_bytes_per_row+2*(yuv.w/2-1-j)*factor]);
					BC_FAIL("bad cb value");
					break;
				}
				/*check cr*/
				if (yuv.planes[2][i*yuv.strides[2]+j] != cbcr[(yuv.h/2-1-i)*factor*crcb_bytes_per_row+2*(yuv.w/2-1-j)*factor+1]) {
					ms_error("Wrong value  [%i] at ofset [%i], should be [%i]",yuv.planes[2][i*yuv.strides[2]+j],i*yuv.strides[2]+j,cbcr[(yuv.h/2-1-i)*factor*crcb_bytes_per_row+2*(yuv.w/2-1-j)*factor+1]);
					BC_FAIL("bad cr value");
					break;
				}
				
			}
		}
	}
	else {
		/*check y*/
		for (i=0;i<yuv.h;i++) {
			for (j=0;j<yuv.w;j++)
				if (yuv.planes[0][i*yuv.strides[0]+j] != y[i*factor*y_bytes_per_row+j*factor]) {
					ms_error("Wrong value  [%i] at ofset [%i], should be [%i]",yuv.planes[0][i*yuv.strides[0]+j],i*yuv.strides[0]+j,y[i*factor*y_bytes_per_row+j*factor]);
					BC_FAIL("bad y value");
					break;
				}
		}
		
		for (i=0;i<yuv.h/2;i++) {
			for (j=0;j<yuv.w/2;j++) {
				/*check cb*/
				if (yuv.planes[1][i*yuv.strides[1]+j] != cbcr[i*factor*crcb_bytes_per_row+2*j*factor]) {
					ms_error("Wrong value  [%i] at ofset [%i], should be [%i]",yuv.planes[1][i*yuv.strides[1]+j],i*yuv.strides[1]+j,cbcr[i*factor*crcb_bytes_per_row+2*j*factor]);
					BC_FAIL("bad cb value");
					break;
				}
				/*check cr*/
				if (yuv.planes[2][i*yuv.strides[2]+j] != cbcr[i*factor*crcb_bytes_per_row+2*j*factor+1]) {
					ms_error("Wrong value  [%i] at ofset [%i], should be [%i]",yuv.planes[2][i*yuv.strides[2]+j],i*yuv.strides[2]+j,cbcr[i*factor*crcb_bytes_per_row+2*j*factor+1]);
					BC_FAIL("bad cr value");
					break;
				}

			}
		}
	}
	freemsg(yuv_block2);
	ms_free(y);
	ms_free(cbcr);
	ms_yuv_buf_allocator_free(yba);

}
Ejemplo n.º 28
0
static void ms_opus_enc_process(MSFilter *f) {
	OpusEncData *d = (OpusEncData *)f->data;
	mblk_t *im;
	mblk_t *om = NULL;
	int i;
	int frameNumber, packet_size;
	uint8_t *signalFrameBuffer = NULL;
	uint8_t *codedFrameBuffer[MAX_INPUT_FRAMES];
	OpusRepacketizer *rp = opus_repacketizer_create();
	opus_int32 ret = 0;
	opus_int32 totalLength = 0;
	int frame_size = d->samplerate * FRAME_LENGTH / 1000; /* in samples */

	// lock the access while getting ptime
	ms_filter_lock(f);
	frameNumber = d->ptime/FRAME_LENGTH; /* encode 20ms frames, ptime is a multiple of 20ms */
	packet_size = d->samplerate * d->ptime / 1000; /* in samples */
	ms_filter_unlock(f);


	while ((im = ms_queue_get(f->inputs[0])) != NULL) {
		ms_bufferizer_put(d->bufferizer, im);
	}

	for (i=0; i<MAX_INPUT_FRAMES; i++) {
		codedFrameBuffer[i]=NULL;
	}
	while (ms_bufferizer_get_avail(d->bufferizer) >= (d->channels * packet_size * SIGNAL_SAMPLE_SIZE)) {
		totalLength = 0;
		opus_repacketizer_init(rp);
		for (i=0; i<frameNumber; i++) { /* encode 20ms by 20ms and repacketize all of them together */
			if (!codedFrameBuffer[i]) codedFrameBuffer[i] = ms_malloc(MAX_BYTES_PER_FRAME); /* the repacketizer need the pointer to packet to remain valid, so we shall have a buffer for each coded frame */
			if (!signalFrameBuffer) signalFrameBuffer = ms_malloc(frame_size * SIGNAL_SAMPLE_SIZE * d->channels);

			ms_bufferizer_read(d->bufferizer, signalFrameBuffer, frame_size * SIGNAL_SAMPLE_SIZE * d->channels);
			ret = opus_encode(d->state, (opus_int16 *)signalFrameBuffer, frame_size, codedFrameBuffer[i], MAX_BYTES_PER_FRAME);
			if (ret < 0) {
				ms_error("Opus encoder error: %s", opus_strerror(ret));
				break;
			}
			if (ret > 0) {
				int err = opus_repacketizer_cat(rp, codedFrameBuffer[i], ret); /* add the encoded frame into the current packet */
				if (err != OPUS_OK) {
					ms_error("Opus repacketizer error: %s", opus_strerror(err));
					break;
				}
				totalLength += ret;
			}
		}

		if (ret > 0) {
			om = allocb(totalLength+frameNumber + 1, 0); /* opus repacktizer API: allocate at leat number of frame + size of all data added before */
			ret = opus_repacketizer_out(rp, om->b_wptr, totalLength+frameNumber);

			om->b_wptr += ret;
			mblk_set_timestamp_info(om, d->ts);
			ms_queue_put(f->outputs[0], om);
			d->ts += packet_size*48000/d->samplerate; /* RFC payload RTP opus 03 - section 4: RTP timestamp multiplier : WARNING works only with sr at 48000 */
			ret = 0;
		}
	}

	opus_repacketizer_destroy(rp);

	if (signalFrameBuffer != NULL) {
		ms_free(signalFrameBuffer);
	}
	for (i=0; i<frameNumber; i++) {
		if (codedFrameBuffer[i] != NULL) {
			ms_free(codedFrameBuffer[i]);
		}
	}
}
Ejemplo n.º 29
0
static char *append_prefix(const char *number, const char *prefix){
	char *res=ms_malloc(strlen(number)+strlen(prefix)+1);
	strcpy(res,prefix);
	return strcat(res,number);
}
Ejemplo n.º 30
0
void check_sound_device(LinphoneCore *lc)
{
#ifdef _linux
	int fd=0;
	int len;
	int a;
	char *file=NULL;
	char *i810_audio=NULL;
	char *snd_pcm_oss=NULL;
	char *snd_mixer_oss=NULL;
	char *snd_pcm=NULL;
	fd=open("/proc/modules",O_RDONLY);

	if (fd>0){
		/* read the entire /proc/modules file and check if sound conf seems correct */
		/*a=fstat(fd,&statbuf);
		if (a<0) ms_warning("Can't stat /proc/modules:%s.",strerror(errno));
		len=statbuf.st_size;
		if (len==0) ms_warning("/proc/modules has zero size!");
		*/
		/***** fstat does not work on /proc/modules for unknown reason *****/
		len=6000;
		file=ms_malloc(len+1);
		a=read(fd,file,len);
		if (a<len) file=ms_realloc(file,a+1);
		file[a]='\0';
		i810_audio=strstr(file,"i810_audio");
		if (i810_audio!=NULL){
			/* I'm sorry i put this warning in comments because
			 * i don't use yet the right driver !! */
/*			lc->vtable.display_warning(lc,_("You are currently using the i810_audio driver.\nThis driver is buggy and so does not work with Linphone.\nWe suggest that you replace it by its equivalent ALSA driver,\neither with packages from your distribution, or by downloading\nALSA drivers at http://www.alsa-project.org."));*/
			goto end;
		}
		snd_pcm=strstr(file,"snd-pcm");
		if (snd_pcm!=NULL){
			snd_pcm_oss=strstr(file,"snd-pcm-oss");
			snd_mixer_oss=strstr(file,"snd-mixer-oss");
			if (snd_pcm_oss==NULL){
				lc->vtable.display_warning(lc,_("Your computer appears to be using ALSA sound drivers.\nThis is the best choice. However the pcm oss emulation module\nis missing and linphone needs it. Please execute\n'modprobe snd-pcm-oss' as root to load it."));
			}
			if (snd_mixer_oss==NULL){
				lc->vtable.display_warning(lc,_("Your computer appears to be using ALSA sound drivers.\nThis is the best choice. However the mixer oss emulation module\nis missing and linphone needs it. Please execute\n 'modprobe snd-mixer-oss' as root to load it."));
			}
		}
	}else {

		ms_warning("Could not open /proc/modules.");
	}
	/* now check general volume. Some user forget to rise it and then complain that linphone is
	not working */
	/* but some other users complain that linphone should not change levels...
	if (lc->sound_conf.sndcard!=NULL){
		a=snd_card_get_level(lc->sound_conf.sndcard,SND_CARD_LEVEL_GENERAL);
		if (a<50){
			ms_warning("General level is quite low (%i). Linphone rises it up for you.",a);
			snd_card_set_level(lc->sound_conf.sndcard,SND_CARD_LEVEL_GENERAL,80);
		}
	}
	*/
	end:
	if (file!=NULL) ms_free(file);
	if (fd>0) close(fd);
#endif
}