static int read_t140_data(RealTimeTextSinkData *stream, uint8_t *data, int readsize) {
	int buf_size = (int)TS_INBUF_SIZE - (int)stream->inbufsize;
	if (readsize < 0) {
		ms_warning("corrupt packet (readsize<0)");
		return -1;
	} else if (readsize > buf_size) {
		readsize = buf_size;
		ms_warning("reading less characters than in buffer");
		
		/*POTENTIAL BUG... if last char is a multi char but just parts of it get 
		in, next function fails and whole buf is ignored. */
	}
	if (readsize > 0) {
		ms_debug("Reading %i bytes\n", readsize);
		if (!is_utf8_buf_ok(data, readsize)) {
			text_stream_hexdump(data, readsize);
			ms_warning("not a valid utf8 payload");
			stream->inbufsize = 0;
			return -1;
		}
		memcpy(&stream->inbuf[stream->inbufsize], data, readsize);
		stream->inbufsize += readsize;
	}
	return 0; /* 0 on success */
}
Beispiel #2
0
static void au_detect(MSSndCardManager *m){
	ms_debug("au_detect");
	MSSndCard *card=au_card_new(AU_CARD_RECEIVER);
	ms_snd_card_manager_add_card(m,card);
	card=au_card_new(AU_CARD_SPEAKER);
	ms_snd_card_manager_add_card(m,card);	
}
Beispiel #3
0
static OSStatus writeRenderProc(void *inRefCon, 
						 AudioUnitRenderActionFlags *inActionFlags,
						 const AudioTimeStamp *inTimeStamp, 
						 UInt32 inBusNumber,
						 UInt32 inNumFrames, 
						 AudioBufferList *ioData)
{
	AUWrite *d=(AUWrite*)inRefCon;
	int read;

	if (ioData->mNumberBuffers!=1) ms_warning("writeRenderProc: %"UINT32_PRINTF" buffers",ioData->mNumberBuffers);
	ms_mutex_lock(&d->common.mutex);
	read=ms_bufferizer_read(d->buffer,ioData->mBuffers[0].mData,ioData->mBuffers[0].mDataByteSize);
	if (ms_bufferizer_get_avail(d->buffer) >10*inNumFrames*2) {
		ms_message("we are late, bufferizer sise is [%i] bytes in framezize is [%"UINT32_PRINTF"] bytes"
					,(int)ms_bufferizer_get_avail(d->buffer)
					,inNumFrames*2);
		ms_bufferizer_flush(d->buffer);
	}

	ms_mutex_unlock(&d->common.mutex);
	if (read==0){
		ms_debug("Silence inserted in audio output unit (%"UINT32_PRINTF" bytes)",ioData->mBuffers[0].mDataByteSize);
		memset(ioData->mBuffers[0].mData,0,ioData->mBuffers[0].mDataByteSize);
	}
	return 0;
}
Beispiel #4
0
static uint64_t winsnd_get_cur_time( void *data){
	WinSndData *d=(WinSndData*)data;
	uint64_t curtime=(d->bytes_read*1000)/(d->rate*(d->bits/8)*((d->stereo==FALSE) ? 1 : 2));
	ms_debug("winsnd_get_cur_time: bytes_read=%lu, rate=%i, bits=%i, stereo=%i return %lu\n",
	(unsigned long)d->bytes_read,d->rate,d->bits,d->stereo,(unsigned long)curtime);
	return curtime;
}
Beispiel #5
0
/* Send dummy STUN packet to open NAT ports ASAP. */
static void send_stun_packet(SenderData *d, bool_t enable_rtp, bool_t enable_rtcp)
{
	MSStunMessage *msg;
	mblk_t *mp;
	RtpSession *s = d->session;
	char *buf = NULL;
	int len;

	if (!d->stun_enabled) return;
	if (ms_is_multicast_addr((const struct sockaddr *)&s->rtcp.gs.loc_addr)) {
		ms_debug("Stun packet not sent for session [%p] because of multicast",s);
		return;
	}

	msg = ms_stun_binding_request_create();
	len = ms_stun_message_encode(msg, &buf);
	if (len > 0) {
		if (enable_rtp) {
			mp = allocb(len, BPRI_MED);
			memcpy(mp->b_wptr, buf, len);
			mp->b_wptr += len;
			ms_message("Stun packet sent for session [%p]",s);
			rtp_session_sendm_with_ts(s, mp, 0);
		}
		if (enable_rtcp) {
			mp = allocb(len, BPRI_MED);
			memcpy(mp->b_wptr, buf, len);
			mp->b_wptr += len;
			ms_message("Stun packet sent on rtcp for session [%p]",s);
			rtp_session_rtcp_sendm_raw(s,mp);
		}
	}
	if (buf != NULL) ms_free(buf);
	ms_stun_message_destroy(msg);
}
Beispiel #6
0
static mblk_t * v4lv2_grab_image(V4l2State *s, int poll_timeout_ms){
	struct v4l2_buffer buf;
	unsigned int k;
	memset(&buf,0,sizeof(buf));
	mblk_t *ret=NULL;

	buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	buf.memory = V4L2_MEMORY_MMAP;
	
	/*queue buffers whose ref count is 1, because they are not
	still used anywhere in the filter chain */
	for(k=0;k<s->frame_max;++k){
		if (s->frames[k]->b_datap->db_ref==1){
			buf.index=k;
			if (-1==v4l2_ioctl (s->fd, VIDIOC_QBUF, &buf))
				ms_warning("VIDIOC_QBUF %i failed: %s",k,  strerror(errno));
			else {
				ms_debug("v4l2: queue buf %i",k);
				/*increment ref count of queued buffer*/
				inc_ref(s->frames[k]);
				s->queued++;
			}
		}
	}

	if (s->queued){
		ret=v4l2_dequeue_ready_buffer(s,poll_timeout_ms);
	}
	return ret;
}
Beispiel #7
0
void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc) {
	LinphonePresenceModel *model;

	if (!fr->uri) {
		ms_warning("No sip url defined.");
		return;
	}

	if (fr->inc_subscribe_pending) {
		switch(fr->pol) {
			case LinphoneSPWait:
				model = linphone_presence_model_new_with_activity(LinphonePresenceActivityOther, "Waiting for user acceptance");
				linphone_friend_notify(fr, model);
				linphone_presence_model_unref(model);
				break;
			case LinphoneSPAccept:
				if (fr->lc)
					linphone_friend_notify(fr, fr->lc->presence_model);
				break;
			case LinphoneSPDeny:
				linphone_friend_notify(fr, NULL);
				break;
		}
		fr->inc_subscribe_pending = FALSE;
	}
	if (fr->lc) {
		linphone_friend_list_update_subscriptions(fr->friend_list, NULL, linphone_core_should_subscribe_friends_only_when_registered(fr->lc));
	}
	ms_debug("linphone_friend_apply() done.");
	lc->bl_refresh=TRUE;
	fr->commit=FALSE;
}
static void bb10display_createPixmap(BB10Display *d) {
    screen_pixmap_t pixmap;
    screen_buffer_t buffer;

    if (d->pixmap_created) {
        ms_warning("[bb10_display] pixmap is already created, skipping...");
        return;
    }

    screen_create_pixmap(&pixmap, d->context);

    int usage = SCREEN_USAGE_WRITE | SCREEN_USAGE_NATIVE;
    screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_USAGE, &usage);

    int format = SCREEN_FORMAT_YUV420;
    screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_FORMAT, &format);

    int dims[2] = { d->vsize.width, d->vsize.height };
    screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_BUFFER_SIZE, dims);

    screen_create_pixmap_buffer(pixmap);

    screen_get_pixmap_property_pv(pixmap, SCREEN_PROPERTY_RENDER_BUFFERS, (void**) &buffer);
    int stride;
    screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, &stride);

    d->pixmap = pixmap;
    d->pixmap_buffer = buffer;
    d->stride = stride;
    ms_debug("[bb10_display] bb10display_initPixmap pixmap created with buffer size %i,%i and stride %i", dims[0], dims[1], stride);
    d->pixmap_created = TRUE;
}
static void bb10display_createWindow(BB10Display *d) {
    screen_window_t window;

    if (d->window_created) {
        ms_warning("[bb10_display] window is already created, skipping...");
        return;
    }

    screen_create_window_type(&window, d->context, SCREEN_CHILD_WINDOW);

    int usage = SCREEN_USAGE_NATIVE;
    screen_set_window_property_iv(window, SCREEN_PROPERTY_USAGE, &usage);

    int wdims[2] = { d->wsize.width, d->wsize.height };
    screen_set_window_property_iv(window, SCREEN_PROPERTY_BUFFER_SIZE, wdims);
    screen_set_window_property_iv(window, SCREEN_PROPERTY_SOURCE_SIZE, wdims);

    int zorder = -5;
    screen_set_window_property_iv(window, SCREEN_PROPERTY_ZORDER, &zorder);

    screen_create_window_buffers(window, 1);
    ms_debug("[bb10_display] bb10display_createWindow window created with size %i,%i", wdims[0], wdims[1]);

    if (!d->pixmap_created) {
        bb10display_createPixmap(d);
    }

    d->window = window;
    d->window_created = TRUE;

    if (d->window_id != NULL && d->window_group != NULL) {
        bb10display_set_window_id_and_group(d);
    }
}
static void bb10display_init(MSFilter *f) {
    BB10Display *d = (BB10Display*) ms_new0(BB10Display, 1);
    MSVideoSize def_size, window_size;

    d->window = NULL;
    d->context = NULL;
    d->pixmap = NULL;
    d->pixmap_buffer = NULL;
    d->window_created = FALSE;
    d->pixmap_created = FALSE;
    def_size.width = MS_VIDEO_SIZE_CIF_W;
    def_size.height = MS_VIDEO_SIZE_CIF_H;
    d->vsize = def_size;
    window_size.width = MS_VIDEO_SIZE_CIF_W;
    window_size.height = MS_VIDEO_SIZE_CIF_H;
    d->wsize = window_size;
    d->window_id = NULL;
    d->window_group = NULL;
    d->stride = 0;
    d->destroy_and_recreate_window = FALSE;
    d->last_time_wsize_changed = 0;

    screen_create_context(&d->context, SCREEN_APPLICATION_CONTEXT);

    f->data = d;
    ms_debug("[bb10_display] init done");
}
Beispiel #11
0
static void au_init(MSSndCard *card){
	ms_debug("au_init");
	AUData *d=ms_new(AUData,1);
	//OSStatus auresult;
	d->bits=16;
	d->rate=PREFERRED_HW_SAMPLE_RATE;
	d->nchannels=1;
	
	d->read_started=FALSE;
	d->write_started=FALSE;
	d->bufferizer=ms_bufferizer_new();
	d->n_lost_frame=0;
	d->started=FALSE;
	d->io_unit_must_be_started=FALSE;
	qinit(&d->rq);
	d->readTimeStamp.mSampleTime=-1;
	ms_mutex_init(&d->mutex,NULL);
	
	if (strcmp(card->name,AU_CARD_SPEAKER)==0) {
		d->is_ringer=TRUE;
	} else {
		d->is_ringer=FALSE;
	}
	card->data=d;
}
Beispiel #12
0
static int set_nchannels(MSFilter *f, void *arg){
	ms_debug("set_nchannels %d", *((int*)arg));
	MSSndCard *card=(MSSndCard*)f->data;
	AUData *d=(AUData*)card->data;
	d->nchannels=*(int*)arg;
	return 0;
}
Beispiel #13
0
static void dec_process_frame(MSFilter *f, DecState *s, ogg_packet *op){
	yuv_buffer yuv;
	if (theora_decode_packetin(&s->tstate,op)==0){
		if (theora_decode_YUVout(&s->tstate,&yuv)==0){
			mblk_t *om;
			int i;
			int ylen=yuv.y_width*yuv.y_height;
			int uvlen=yuv.uv_width*yuv.uv_height;
			ms_debug("Got yuv buffer from theora decoder");
			if (s->yuv==NULL){
				int len=(ylen)+(2*uvlen);
				s->yuv=allocb(len,0);
			}
			om=dupb(s->yuv);
			for(i=0;i<yuv.y_height;++i){
				memcpy(om->b_wptr,yuv.y+yuv.y_stride*i,yuv.y_width);
				om->b_wptr+=yuv.y_width;
			}
			for(i=0;i<yuv.uv_height;++i){
				memcpy(om->b_wptr,yuv.u+yuv.uv_stride*i,yuv.uv_width);
				om->b_wptr+=yuv.uv_width;
			}
			for(i=0;i<yuv.uv_height;++i){
				memcpy(om->b_wptr,yuv.v+yuv.uv_stride*i,yuv.uv_width);
				om->b_wptr+=yuv.uv_width;
			}
			ms_queue_put(f->outputs[0],om);
		}
	}else{
		ms_warning("theora decoding error");
	}
}
Beispiel #14
0
static bool_t alsa_can_read(snd_pcm_t *dev, int frames)
{
	snd_pcm_sframes_t avail;
	int err;

	avail = snd_pcm_avail_update(dev);
	ms_debug("*** %s %d %d", __FUNCTION__, (long)avail, frames);
	if (avail < 0) {
		ms_error("snd_pcm_avail_update: %s\n", snd_strerror(avail));	// most probably -EPIPE
		/* overrun occured, snd_pcm_state() would return SND_PCM_STATE_XRUN
		 FIXME: handle other error conditions*/
		ms_error("*** alsa_can_read fixup, trying to recover");
		snd_pcm_drain(dev); /* Ignore possible error, at least -EAGAIN.*/
		err = snd_pcm_recover(dev, avail, 0);
		if (err){ 
			ms_error("snd_pcm_recover() failed with err %d: %s", err, snd_strerror(err));
			return FALSE;
		}
		err = snd_pcm_start(dev);
		if (err){ 
			ms_error("snd_pcm_start() failed with err %d: %s\n", err, snd_strerror(err)); 
			return FALSE; 
		}
		ms_message("Recovery done\n");
	}
	return avail >= frames;
}
Beispiel #15
0
static OSStatus au_render_cb (
							  void                        *inRefCon,
							  AudioUnitRenderActionFlags  *ioActionFlags,
							  const AudioTimeStamp        *inTimeStamp,
							  UInt32                      inBusNumber,
							  UInt32                      inNumberFrames,
							  AudioBufferList             *ioData
) {
	ms_debug("render cb");
	AUData *d=(AUData*)inRefCon;
	
	if (d->write_started == TRUE) {
		ioData->mBuffers[0].mDataByteSize=inNumberFrames*d->bits/8;
		ioData->mNumberBuffers=1;
		
		ms_mutex_lock(&d->mutex);
		if(ms_bufferizer_get_avail(d->bufferizer) >= inNumberFrames*d->bits/8) {
			ms_bufferizer_read(d->bufferizer, ioData->mBuffers[0].mData, inNumberFrames*d->bits/8);

			if (ms_bufferizer_get_avail(d->bufferizer) >10*inNumberFrames*d->bits/8) {
				ms_debug("we are late, bufferizer sise is %i bytes in framezize is %i bytes",ms_bufferizer_get_avail(d->bufferizer),inNumberFrames*d->bits/8);
				ms_bufferizer_flush(d->bufferizer);
			}
			ms_mutex_unlock(&d->mutex);
			
		} else {
			
			ms_mutex_unlock(&d->mutex);
			memset(ioData->mBuffers[0].mData, 0,ioData->mBuffers[0].mDataByteSize);
			ms_debug("nothing to write, pushing silences, bufferizer size is %i bytes in framezize is %i bytes mDataByteSize %i"
					 ,ms_bufferizer_get_avail(d->bufferizer)
					 ,inNumberFrames*d->bits/8
					 ,ioData->mBuffers[0].mDataByteSize);
			d->n_lost_frame+=inNumberFrames;
		}
	}
	if (!d->is_ringer) { // no need to read in ringer mode
		AudioBufferList readAudioBufferList;
		readAudioBufferList.mBuffers[0].mDataByteSize=inNumberFrames*d->bits/8; 
		readAudioBufferList.mNumberBuffers=1;
		readAudioBufferList.mBuffers[0].mData=NULL;
		readAudioBufferList.mBuffers[0].mNumberChannels=d->nchannels;
		AudioUnitElement inputBus = 1;
		au_read_cb(d, ioActionFlags, inTimeStamp, inputBus, inNumberFrames, &readAudioBufferList);
	}
	return 0;
}
Beispiel #16
0
static int ms_rtt_4103_sink_set_t140_payload(MSFilter *f, void *t140) {
	RealTimeTextSinkData *s = (RealTimeTextSinkData *)f->data;
	ms_filter_lock(f);
	s->pt_t140 = *(int *)t140;
	ms_debug("T140 payload number is %i", s->pt_t140);
	ms_filter_unlock(f);
	return 0;
}
static void audio_stream_configure_resampler(MSFilter *resampler,MSFilter *from,MSFilter *to) {
	int from_rate=0, to_rate=0;
	ms_filter_call_method(from,MS_FILTER_GET_SAMPLE_RATE,&from_rate);
	ms_filter_call_method(to,MS_FILTER_GET_SAMPLE_RATE,&to_rate);
	ms_filter_call_method(resampler,MS_FILTER_SET_SAMPLE_RATE,&from_rate);
	ms_filter_call_method(resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&to_rate);
	ms_debug("configuring from rate[%i] to rate [%i]",from_rate,to_rate);
}
Beispiel #18
0
static int ms_rtt_4103_sink_set_red_payload(MSFilter *f, void *red) {
	RealTimeTextSinkData *s = (RealTimeTextSinkData *)f->data;
	ms_filter_lock(f);
	s->pt_red = *(int *)red;
	ms_debug("RED payload number is %i", s->pt_red);
	ms_filter_unlock(f);
	return 0;
}
Beispiel #19
0
/*process NALUs and pack them into rtp payloads */
void rfc3984_pack(Rfc3984Context *ctx, MSQueue *naluq, MSQueue *rtpq, uint32_t ts){
	mblk_t *m,*prevm=NULL;
	int prevsz=0,sz;
	bool_t end;
	while((m=ms_queue_get(naluq))!=NULL){
		end=ms_queue_empty(naluq);
		sz=m->b_wptr-m->b_rptr;
		if (prevm!=NULL){
			if ((prevsz+sz)<(ctx->maxsz-2)){
				prevm=concat_nalus(prevm,m);
				m=NULL;
				prevsz+=sz+2;/*+2 for the stapa size field*/
				continue;
			}else{
				/*send prevm packet: either single nal or STAP-A*/
				if (prevm->b_cont!=NULL){
					ms_debug("Sending STAP-A");
				}else
					ms_debug("Sending previous msg as single NAL");
				send_packet(rtpq,ts,prevm,FALSE);
				prevm=NULL;
				prevsz=0;
			}
		}
		if (sz<(ctx->maxsz/2)){
			/*try to aggregate it with next packet*/
			prevm=m;
			prevsz=sz+3; /*STAP-A header + size*/
			m=NULL;
		}else{
			
			/*send as single nal or FU-A*/
			if (sz>ctx->maxsz){
				ms_debug("Sending FU-A packets");
				frag_nalu_and_send(rtpq,ts,m,end, ctx->maxsz);
			}else{
				ms_debug("Sending Single NAL");
				send_packet(rtpq,ts,m,end);
			}
		}
	}
	if (prevm){
		ms_debug("Sending Single NAL (2)");
		send_packet(rtpq,ts,prevm,TRUE);
	}
}
Beispiel #20
0
void linphone_core_migrate_friends_from_rc_to_db(LinphoneCore *lc) {
	LpConfig *lpc = NULL;
	LinphoneFriend *lf = NULL;
	LinphoneFriendList *lfl = linphone_core_get_default_friend_list(lc);
	int i;
#ifndef FRIENDS_SQL_STORAGE_ENABLED
	ms_warning("linphone has been compiled without sqlite, can't migrate friends");
	return;
#endif
	if (!lc) {
		return;
	}

	lpc = linphone_core_get_config(lc);
	if (!lpc) {
		ms_warning("this core has been started without a rc file, nothing to migrate");
		return;
	}
	if (lp_config_get_int(lpc, "misc", "friends_migration_done", 0) == 1) {
		ms_warning("the friends migration has already been done, skipping...");
		return;
	}

	if (ms_list_size(linphone_friend_list_get_friends(lfl)) > 0 && lfl->storage_id == 0) {
		linphone_core_remove_friend_list(lc, lfl);
		lfl = linphone_core_create_friend_list(lc);
		linphone_core_add_friend_list(lc, lfl);
		linphone_friend_list_unref(lfl);
	}

	for (i = 0; (lf = linphone_friend_new_from_config_file(lc, i)) != NULL; i++) {
		char friend_section[32];

		const LinphoneAddress *addr = linphone_friend_get_address(lf);
		if (addr) {
			const char *displayName = linphone_address_get_display_name(addr);
			if (!displayName) {
				displayName = linphone_address_get_username(addr);
			}

			if (!linphone_friend_create_vcard(lf, displayName)) {
				ms_warning("Couldn't create vCard for friend %s", linphone_address_as_string(addr));
			} else {
				linphone_vcard_add_sip_address(linphone_friend_get_vcard(lf), linphone_address_as_string_uri_only(addr));
			}

			linphone_friend_list_add_friend(lfl, lf);
			linphone_friend_unref(lf);

			snprintf(friend_section, sizeof(friend_section), "friend_%i", i);
			lp_config_clean_section(lpc, friend_section);
		}
	}

	ms_debug("friends migration successful: %i friends migrated", i);
	lp_config_set_int(lpc, "misc", "friends_migration_done", 1);
}
Beispiel #21
0
static float volume_agc_process(Volume *v, mblk_t *om) {
	static int counter;
	float gain_reduct = 1 + (v->level_pk * 2 * v->static_gain);  /* max. compr. factor */
	/* actual gain ramp timing the same as with echo limiter process */
	if (!(++counter % 20))
		ms_debug("level=%f, gain reduction=%f, gain=%f, ng_gain=%f",
				v->level_pk, gain_reduct, v->gain, v->ng_gain);
	return gain_reduct;
}
Beispiel #22
0
static void enc_process(MSFilter *f){
	mblk_t *im,*om;
	ogg_packet op;
	EncState *s=(EncState*)f->data;
	uint64_t timems=f->ticker->time;
	uint32_t timestamp=timems*90;
	uint64_t elapsed;

	
	while((im=ms_queue_get(f->inputs[0]))!=NULL){
		/*for the firsts frames only send theora packed conf*/
		om=NULL;
		if (s->nframes==0){
			s->start_time=timems;
		}
		elapsed=timems-s->start_time;

		if (need_send_conf(s,elapsed)){
			if (s->packed_conf) {
				om=dupmsg(s->packed_conf);
				ms_message("sending theora packed conf (%i bytes)",msgdsize(om));
				packetize_and_send(f,s,om,timestamp,THEORA_PACKED_CONF);
			}else {
				ms_error("No packed conf to send.");
			}
		}else{
			enc_fill_yuv(&s->yuv,im);
			ms_debug("subtmitting yuv frame to theora encoder...");
			if (theora_encode_YUVin(&s->tstate,&s->yuv)!=0){
				ms_error("theora_encode_YUVin error.");
			}else{
				if (theora_encode_packetout(&s->tstate,0,&op)==1){
					ms_debug("Got theora coded frame");
					om=allocb(op.bytes,0);
					memcpy(om->b_wptr,op.packet,op.bytes);
					om->b_wptr+=op.bytes;
					packetize_and_send(f,s,om,timestamp,THEORA_RAW_DATA);
				}
			}
		}
		freemsg(im);
		s->nframes++;
	}
}
static float volume_agc_process(Volume *v, mblk_t *om) {
	static int counter;
	// target is: 1
	float gain_reduct = (agc_threshold + v->level_pk) / 1;
	/* actual gain ramp timing the same as with echo limiter process */
	if (!(++counter % 20))
		ms_debug("_level=%f, gain reduction=%f, gain=%f, ng_gain=%f %f %f",
				v->level_pk, gain_reduct, v->gain, v->ng_gain, v->ng_threshold, v->static_gain);
	return gain_reduct;
}
/***********************************read filter********************/
static int set_read_rate(MSFilter *f, void *arg){
	unsigned int proposed_rate = *((unsigned int*)arg);
	ms_debug("set_rate %d",proposed_rate);
	msandroid_sound_data *d=(msandroid_sound_data*)f->data;
	d->rate=get_supported_rate(proposed_rate);
	if (d->rate == proposed_rate)
		return 0;
	else
		return -1;
}
Beispiel #25
0
static void bb10capture_stop_capture(BB10Capture *d) {
    if (!d->capture_started) {
        ms_warning("[bb10_capture] capture not started, skipping...");
        return;
    }

    camera_stop_viewfinder(d->cam_handle);
    d->capture_started = FALSE;
    ms_debug("[bb10_capture] capture stopped");
}
void ms_filter_process(MSFilter *f){
	ms_debug("Executing process of filter %s:%p",f->desc->name,f);
#ifdef DEBUG
	long start,stop;
	start = filter_get_cur_time(NULL);
#endif
	f->desc->process(f);
#ifdef DEBUG
	stop = filter_get_cur_time(NULL);
	if(stop-start > 10)
	{
		ms_warning("%s take too much time:%ldms\n",f->desc->name,stop-start);
	}
	else
	{
		ms_debug("%s take:%ldms\n",f->desc->name,stop-start);
	}
#endif
}
Beispiel #27
0
static void au_write_process(MSFilter *f){
	ms_debug("au_write_process");
	mblk_t *m;
	AUData *d=(AUData*)((MSSndCard*)f->data)->data;
	
	while((m=ms_queue_get(f->inputs[0]))!=NULL){
		ms_mutex_lock(&d->mutex);
		ms_bufferizer_put(d->bufferizer,m);
		ms_mutex_unlock(&d->mutex);
	}
}
Beispiel #28
0
static void bb10capture_close_camera(BB10Capture *d) {
    if (!d->camera_openned) {
        ms_warning("[bb10_capture] camera not openned, skipping...");
        return;
    }

    camera_close(d->cam_handle);
    d->camera_openned = FALSE;
    d->cam_handle = 0;
    ms_debug("[bb10_capture] camera closed");
}
Beispiel #29
0
static int set_rate(MSFilter *f, void *arg){
	int proposed_rate = *((int*)arg);
	ms_debug("set_rate %d",proposed_rate);
	/*if (proposed_rate != PREFERRED_HW_SAMPLE_RATE) {
		return -1;//only support 1 rate
	}*/
	MSSndCard *card=(MSSndCard*)f->data;
	AUData *d=(AUData*)card->data;
	d->rate=proposed_rate;
	return 0;
}
Beispiel #30
0
static void show_format(const char *name, AudioStreamBasicDescription * deviceFormat)
{
    ms_debug("Format for %s", name);
    ms_debug("mSampleRate = %g", deviceFormat->mSampleRate);
    unsigned int fcc= ntohl(deviceFormat->mFormatID);
    char outName[5];
    memcpy(outName,&fcc,4);
    outName[4] = 0;
    ms_debug("mFormatID = %s", outName);
    ms_debug("mFormatFlags = %08lX", deviceFormat->mFormatFlags);
    ms_debug("mBytesPerPacket = %ld", deviceFormat->mBytesPerPacket);
    ms_debug("mFramesPerPacket = %ld", deviceFormat->mFramesPerPacket);
    ms_debug("mChannelsPerFrame = %ld", deviceFormat->mChannelsPerFrame);
    ms_debug("mBytesPerFrame = %ld", deviceFormat->mBytesPerFrame);
    ms_debug("mBitsPerChannel = %ld", deviceFormat->mBitsPerChannel);
    ms_message("Format for [%s] rate [%g] channels [%ld]", outName,deviceFormat->mSampleRate,deviceFormat->mChannelsPerFrame);
}