示例#1
0
/*初始化视频端口连接插座*/
void video_slot_init(ConfVideoPort *slot,int index){

	slot->video_itc_sink = ms_filter_new(MS_CONF_ITC_SINK_ID);
	slot->video_itc_source = ms_filter_new(MS_CONF_ITC_SOURCE_ID);
	slot->video_input_join = ms_filter_new(MS_JOIN_ID);
	slot->index = index;
	ms_mutex_init(&slot->slotq_in.lock,NULL);
	ms_queue_init(&slot->slotq_in.q);
	ms_mutex_init(&slot->slotq_out.lock,NULL);
	ms_queue_init(&slot->slotq_out.q);

}
示例#2
0
ConfAudioPort *audio_slot_new(){

	ConfAudioPort *port = ms_new0(ConfAudioPort,1);
	port->index = -1;

	ms_mutex_init(&port->slotq_in.lock,NULL);
	ms_mutex_init(&port->slotq_out.lock,NULL);

	port->sink_connected = FALSE;
	port->source_connected = FALSE;

	return port;
}
示例#3
0
	AndroidReaderContext(MSFilter *f, MSWebCam *cam):filter(f), webcam(cam),frame(0),fps(5){
		ms_message("Creating AndroidReaderContext for Android VIDEO capture filter");
		ms_mutex_init(&mutex,NULL);
		androidCamera = 0;
		previewWindow = 0;
		rotation = rotationSavedDuringVSize = UNDEFINED_ROTATION;
	};
	AndroidReaderContext():frame(0),fps(5){
		ms_message("Creating AndroidReaderContext for Android VIDEO capture filter");

		ms_mutex_init(&mutex,NULL);

		JNIEnv *env = ms_get_jni_env();
		managerClass = env->FindClass("org/linphone/core/AndroidCameraRecordManager");
		managerClass = (jclass) env->NewGlobalRef(managerClass);
		if (managerClass == 0) {
			ms_fatal("cannot register android video record manager class\n");
			return;
		}

		jmethodID getInstanceMethod = env->GetStaticMethodID(managerClass,"getInstance", "()Lorg/linphone/core/AndroidCameraRecordManager;");
		if (getInstanceMethod == 0) {
			ms_fatal("cannot find  singleton getter method\n");
			return;
		}

		// Get singleton AndroidCameraRecordManager for the default camera
		recorder = env->CallStaticObjectMethod(managerClass, getInstanceMethod);
		if (recorder == 0) {
			ms_fatal("cannot instantiate  %s\n", recorder);
			return;
		}

		recorder = env->NewGlobalRef(recorder);
		if (recorder == 0) {
			ms_fatal("cannot register  %s\n", recorder);
			return;
		}

	};
示例#5
0
static void winsnd_init(MSFilter *f){
	WinSnd *d=(WinSnd *)ms_new0(WinSnd,1);
	d->wfx.wFormatTag = WAVE_FORMAT_PCM;
	d->wfx.cbSize = 0;
	d->wfx.nAvgBytesPerSec = 16000;
	d->wfx.nBlockAlign = 2;
	d->wfx.nChannels = 1;
	d->wfx.nSamplesPerSec = 8000;
	d->wfx.wBitsPerSample = 16;
	qinit(&d->rq);
	qinit(&d->write_rq);
#ifndef DISABLE_SPEEX
	d->pst=NULL;
	d->pst_frame_size=0;
#endif
	d->ready=0;
	d->workaround=0;
	ms_mutex_init(&d->mutex,NULL);
	f->data=d;

	d->stat_input=0;
	d->stat_output=0;
	d->stat_notplayed=0;
	d->stat_minimumbuffer=WINSND_MINIMUMBUFFER;
}
示例#6
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;
}
示例#7
0
static void v4w_init(MSFilter *f){
	V4wState *s=(V4wState *)ms_new0(V4wState,1);
	int idx;
	s->vsize.width=MS_VIDEO_SIZE_CIF_W;
	s->vsize.height=MS_VIDEO_SIZE_CIF_H;
	//s->pix_fmt=MS_RGB24;
	s->pix_fmt=MS_YUV420P;

	s->rotregvalue = 0;
	s->m_pGraph=NULL;
	s->m_pBuilder=NULL;
	s->m_pControl=NULL;
	s->m_pDXFilter=NULL;
	s->m_pIDXFilter=NULL;
	s->m_pDeviceFilter=NULL;

	qinit(&s->rq);
	for (idx=0;idx<10;idx++)
	{
		s->mire[idx]=NULL;
	}
	ms_mutex_init(&s->mutex,NULL);
	s->start_time=0;
	s->frame_count=-1;
	s->fps=15;

	f->data=s;
}
示例#8
0
static void itc_source_init(MSFilter *f){
	SourceState *s=ms_new(SourceState,1);
	ms_mutex_init(&s->mutex,NULL);
	ms_queue_init(&s->q);
	s->rate=44100;
	s->nchannels=1;
	f->data=s;
}
示例#9
0
static void h264_enc_init(MSFilter *f) {
	VTH264EncCtx *ctx = (VTH264EncCtx *)ms_new0(VTH264EncCtx, 1);
	ctx->conf.vsize = MS_VIDEO_SIZE_CIF;
	ms_mutex_init(&ctx->mutex, NULL);
	ms_queue_init(&ctx->queue);
	ctx->f = f;
	ctx->video_confs = h264_video_confs;
	f->data = ctx;
}
示例#10
0
MSEventQueue *ms_event_queue_new(){
	MSEventQueue *q=ms_new0(MSEventQueue,1);
	int bufsize=MS_EVENT_BUF_SIZE;
	ms_mutex_init(&q->mutex,NULL);
	q->lim=q->buffer+bufsize;
	q->freeroom=bufsize;
	q->wptr=q->rptr=q->buffer;
	q->endptr=q->lim;
	q->size=bufsize;
	return q;
}
示例#11
0
MSFilter *ms_filter_new_from_desc(MSFilterDesc *desc) {
    MSFilter *obj;
    obj=(MSFilter *)ms_new0(MSFilter,1);
    ms_mutex_init(&obj->lock,NULL);
    obj->desc=desc;
    if (desc->ninputs>0)	obj->inputs=(MSQueue**)ms_new0(MSQueue*,desc->ninputs);
    if (desc->noutputs>0)	obj->outputs=(MSQueue**)ms_new0(MSQueue*,desc->noutputs);
    if (obj->desc->init!=NULL)
        obj->desc->init(obj);
    return obj;
}
示例#12
0
MSMediaPlayer *ms_media_player_new(MSSndCard *snd_card, const char *video_display_name, void *window_id) {
	MSMediaPlayer *obj = (MSMediaPlayer *)ms_new0(MSMediaPlayer, 1);
	obj->ticker = ms_ticker_new();
	ms_mutex_init(&obj->cb_access, NULL);
	obj->snd_card = snd_card;
	if(video_display_name != NULL && strlen(video_display_name) > 0) {
		obj->video_display = ms_strdup(video_display_name);
		obj->window_id = window_id;
	}
	return obj;
}
示例#13
0
static void vfw_init(MSFilter *f){
	VfwState *s=(VfwState *)ms_new0(VfwState,1);
	s->vsize.width=MS_VIDEO_SIZE_CIF_W;
	s->vsize.height=MS_VIDEO_SIZE_CIF_H;
	qinit(&s->rq);
	ms_mutex_init(&s->mutex,NULL);
	s->start_time=0;
	s->frame_count=-1;
	s->fps=15;
	f->data=s;
}
示例#14
0
static int ms_dtls_srtp_initialise_polarssl_dtls_context(DtlsPolarsslContext *dtlsContext, MSDtlsSrtpParams *params, RtpSession *s){
	int ret;
	enum DTLS_SRTP_protection_profiles dtls_srtp_protection_profiles[2] = {SRTP_AES128_CM_HMAC_SHA1_80, SRTP_AES128_CM_HMAC_SHA1_32};
	
	memset( &(dtlsContext->ssl), 0, sizeof( ssl_context ) );
	//memset( &(dtlsContext->saved_session), 0, sizeof( ssl_session ) );
	ssl_cookie_init( &(dtlsContext->cookie_ctx) );
	x509_crt_init( &(dtlsContext->crt) );
	entropy_init( &(dtlsContext->entropy) );
	ctr_drbg_init( &(dtlsContext->ctr_drbg), entropy_func, &(dtlsContext->entropy), NULL, 0 );
	
	/* initialise certificate */
	ret = x509_crt_parse( &(dtlsContext->crt), (const unsigned char *) params->pem_certificate, strlen( params->pem_certificate ) );
	if( ret < 0 ) {
		return ret;
	}
	
	ret =  pk_parse_key( &(dtlsContext->pkey), (const unsigned char *) params->pem_pkey, strlen( params->pem_pkey ), NULL, 0 );
	if( ret != 0 ) {
		return ret;
	}

	/* ssl setup */
	ssl_init(&(dtlsContext->ssl));
	if( ret < 0 ) {
		return ret;
	}

	if (params->role == MSDtlsSrtpRoleIsClient) {
		ssl_set_endpoint(&(dtlsContext->ssl), SSL_IS_CLIENT);
	} else if (params->role == MSDtlsSrtpRoleIsServer) {
		ssl_set_endpoint(&(dtlsContext->ssl), SSL_IS_SERVER);
	}
	ssl_set_transport(&(dtlsContext->ssl), SSL_TRANSPORT_DATAGRAM);
	ssl_set_dtls_srtp_protection_profiles(  &(dtlsContext->ssl), dtls_srtp_protection_profiles, 2 ); /* TODO: get param from caller to select available profiles */

	/* set CA chain */
	ssl_set_authmode( &(dtlsContext->ssl), SSL_VERIFY_OPTIONAL ); /* this will force server to send his certificate to client as we need it to compute the fingerprint */
	ssl_set_rng(  &(dtlsContext->ssl), ctr_drbg_random, &(dtlsContext->ctr_drbg) );
	ssl_set_ca_chain( &(dtlsContext->ssl), &(dtlsContext->crt), NULL, NULL );
	ssl_set_own_cert( &(dtlsContext->ssl), &(dtlsContext->crt), &(dtlsContext->pkey) );
	if (params->role == MSDtlsSrtpRoleIsServer) {
		ssl_cookie_setup( &(dtlsContext->cookie_ctx), ctr_drbg_random, &(dtlsContext->ctr_drbg) );
		ssl_set_dtls_cookies( &(dtlsContext->ssl), ssl_cookie_write, ssl_cookie_check, &(dtlsContext->cookie_ctx) );
		ssl_session_reset( &(dtlsContext->ssl) );
		ssl_set_client_transport_id(&(dtlsContext->ssl), (const unsigned char *)(&(s->snd.ssrc)), 4);
	}

	ms_mutex_init(&dtlsContext->ssl_context_mutex, NULL);

	return 0;

}
示例#15
0
static void h264_dec_init(MSFilter *f) {
	VTH264DecCtx *ctx = ms_new0(VTH264DecCtx, 1);
	ms_queue_init(&ctx->queue);
	ms_mutex_init(&ctx->mutex, NULL);
	ctx->pixbuf_allocator = ms_yuv_buf_allocator_new();
	rfc3984_init(&ctx->unpacker);
	ctx->vsize = MS_VIDEO_SIZE_UNKNOWN;
	ms_average_fps_init(&ctx->fps, "VideoToolboxDecoder: decoding at %ffps");
	ctx->first_image = TRUE;
	ctx->f = f;
	f->data = ctx;
}
示例#16
0
static void ca_init(MSFilter *f){
	CAData *d = ms_new0(CAData, 1);
	d->read_started=FALSE;
	d->write_started=FALSE;
	d->bits=16;
	d->rate=8000;
	d->stereo=FALSE;
	qinit(&d->rq);
	d->bufferizer=ms_bufferizer_new();
	ms_mutex_init(&d->mutex,NULL);
	f->data=d;
}	
示例#17
0
MSFilter *ms_filter_new_from_desc(MSFilterDesc *desc){
	MSFilter *obj;
	obj=(MSFilter *)ms_new0(MSFilter,1);
	ms_mutex_init(&obj->lock,NULL);
	obj->desc=desc;
	if (desc->ninputs>0)	obj->inputs=(MSQueue**)ms_new0(MSQueue*,desc->ninputs);
	if (desc->noutputs>0)	obj->outputs=(MSQueue**)ms_new0(MSQueue*,desc->noutputs);

	if (statistics_enabled){
		obj->stats=find_or_create_stats(desc);
	}
	if (obj->desc->init!=NULL)
		obj->desc->init(obj);
	return obj;
}
示例#18
0
static void oss_init(MSSndCard *card){
	OssData *d=ms_new(OssData,1);
	d->pcmdev=NULL;
	d->mixdev=NULL;
	d->pcmfd=-1;
	d->read_started=FALSE;
	d->write_started=FALSE;
	d->bits=16;
	d->rate=8000;
	d->stereo=FALSE;
	qinit(&d->rq);
	d->bufferizer=ms_bufferizer_new();
	ms_mutex_init(&d->mutex,NULL);
	card->data=d;
}
示例#19
0
void alsa_read_init(MSFilter *obj){
	AlsaReadData *ad=ms_new(AlsaReadData,1);
	ad->pcmdev=NULL;
	ad->handle=NULL;
	ad->rate=8000;
	ad->nchannels=1;
	obj->data=ad;

#ifdef THREADED_VERSION
	ad->read_started=FALSE;
	ad->write_started=FALSE;
	ad->bufferizer=ms_bufferizer_new();
	ms_mutex_init(&ad->mutex,NULL);
	ad->thread=0;
#endif
}
示例#20
0
void ms_ticker_init(MSTicker *ticker)
{
	ms_mutex_init(&ticker->lock,NULL);
	ticker->execution_list=NULL;
	ticker->ticks=1;
	ticker->time=0;
	ticker->interval=10;
	ticker->run=FALSE;
	ticker->exec_id=0;
	ticker->get_cur_time_ptr=&get_cur_time_ms;
	ticker->get_cur_time_data=NULL;
	ticker->name=ms_strdup("MSTicker");
	ticker->av_load=0;
	ticker->prio=MS_TICKER_PRIO_NORMAL;
	ms_ticker_start(ticker);
}
示例#21
0
static void ms_ticker_init(MSTicker *ticker, const MSTickerParams *params)
{
	ms_mutex_init(&ticker->lock,NULL);
	ticker->execution_list=NULL;
	ticker->ticks=1;
	ticker->time=0;
	ticker->interval=10;
	ticker->run=FALSE;
	ticker->exec_id=0;
	ticker->get_cur_time_ptr=&get_cur_time_ms;
	ticker->get_cur_time_data=NULL;
	ticker->name=ms_strdup(params->name);
	ticker->av_load=0;
	ticker->prio=params->prio;
	ms_ticker_start(ticker);
}
示例#22
0
void ms_ticker_init(MSTicker *ticker)
{
	ms_mutex_init(&ticker->lock,NULL);
	ticker->execution_list=NULL;
	ticker->ticks=1;
	ticker->time=0;
	ticker->interval=10;
	ticker->run=FALSE;
	ticker->exec_id=0;
	ticker->get_cur_time_ptr=&get_cur_time;
	ticker->get_cur_time_data=NULL;
#ifdef WIN32_TIMERS
	ticker->TimeEvent=NULL;
#endif
	ms_ticker_start(ticker);
}
示例#23
0
static void conf_init(MSFilter *f){
	ConfState *s=(ConfState *)ms_new0(ConfState,1);
	int i;
	s->samplerate=8000;
	s->conf_gran=((16 * s->samplerate) / 800) *2;
	s->conf_nsamples=s->conf_gran/2;
    for (i=0;i<CONF_MAX_PINS;i++)
		channel_init(s, &s->channels[i], i);
	s->enable_directmode=FALSE;
	s->enable_vad=TRUE;
	s->agc_level=0;
	s->max_gain=30;
	s->mix_mode=TRUE;
	s->adaptative_msconf_buf=2;
	ms_mutex_init(&s->lock,NULL);
	f->data=s;
}
示例#24
0
void sipomatic_init(Sipomatic *obj, char *url, bool_t ipv6)
{
	osip_uri_t *uri=NULL;
	int port=5064;
	
	obj->ipv6=ipv6;
	
	if (url==NULL){
		url=getenv("SIPOMATIC_URL");
		if (url==NULL){
			if (ipv6) url="sip:robot@[::1]:5064";
			else url="sip:[email protected]:5064";
		}
	}
	if (url!=NULL) {
		osip_uri_init(&uri);
		if (osip_uri_parse(uri,url)==0){
			if (uri->port!=NULL) port=atoi(uri->port);
		}else{
			ms_warning("Invalid identity uri:%s",url);
		}	
	}
	ms_message("Starting using url %s",url);
	ms_mutex_init(&obj->lock,NULL);
	obj->calls=NULL;
	obj->acceptance_time=5;
	obj->max_call_time=300;
	obj->file_path8000hz=ms_strdup_printf("%s/%s",PACKAGE_SOUND_DIR,ANNOUCE_FILE8000HZ);
	obj->file_path16000hz=ms_strdup_printf("%s/%s",PACKAGE_SOUND_DIR,ANNOUCE_FILE16000HZ);
	osip_trace_initialize(OSIP_INFO1,stdout);
	osip_trace_initialize(OSIP_INFO2,stdout);
	osip_trace_initialize(OSIP_WARNING,stdout);
	osip_trace_initialize(OSIP_ERROR,stdout);
	osip_trace_initialize(OSIP_BUG,stdout);
	osip_trace_initialize(OSIP_FATAL,stdout);
	osip_trace_enable_level(OSIP_INFO1);
	osip_trace_enable_level(OSIP_INFO2);
	osip_trace_enable_level(OSIP_WARNING);
	osip_trace_enable_level(OSIP_ERROR);
	osip_trace_enable_level(OSIP_BUG);
	osip_trace_enable_level(OSIP_FATAL);
	eXosip_init();
	eXosip_set_user_agent("sipomatic-" LINPHONE_VERSION "/eXosip");
	eXosip_listen_addr(IPPROTO_UDP,NULL,port,ipv6 ? AF_INET6 : AF_INET,0);
}
示例#25
0
static void v4l_init(MSFilter *f){
	V4lState *s=ms_new0(V4lState,1);
	s->fd=-1;
	s->run=FALSE;
	s->v4lv2=FALSE;
	s->mmapdbuf=NULL;
	s->vsize.width=MS_VIDEO_SIZE_CIF_W;
	s->vsize.height=MS_VIDEO_SIZE_CIF_H;
	s->pix_fmt=MS_RGB24;
	s->dev=ms_strdup("/dev/video0");
	qinit(&s->rq);
	s->mire=NULL;
	ms_mutex_init(&s->mutex,NULL);
	s->start_time=0;
	s->frame_count=-1;
	s->fps=15;
	s->usemire=(getenv("DEBUG")!=NULL);
	s->queued=0;
	f->data=s;
}
示例#26
0
static void ms_ticker_init(MSTicker *ticker, const MSTickerParams *params)
{
	ms_mutex_init(&ticker->lock,NULL);
	ticker->execution_list=NULL;
	ticker->task_list=NULL;
	ticker->ticks=1;
	ticker->time=0;
	ticker->interval=TICKER_INTERVAL;
	ticker->run=FALSE;
	ticker->exec_id=0;
	ticker->get_cur_time_ptr=&get_cur_time_ms;
	ticker->get_cur_time_data=NULL;
	ticker->name=ms_strdup(params->name);
	ticker->av_load=0;
	ticker->prio=params->prio;
	ticker->wait_next_tick=wait_next_tick;
	ticker->wait_next_tick_data=ticker;
	ticker->late_event.lateMs = 0;
	ticker->late_event.time = 0;
	ticker->late_event.current_late_ms = 0;
	ms_ticker_start(ticker);
}
示例#27
0
static void v4m_init(MSFilter *f){
	V4lState *s=ms_new0(V4lState,1);
	s->seqgrab=NULL;
	s->sgchanvideo=NULL;
	s->pgworld=NULL;
	s->decomseq=0;

	s->run=FALSE;
	s->mmapdbuf=NULL;
	s->vsize.width=MS_VIDEO_SIZE_CIF_W;
	s->vsize.height=MS_VIDEO_SIZE_CIF_H;
	s->pix_fmt=MS_RGB24;
	qinit(&s->rq);
	s->mire=NULL;
	ms_mutex_init(&s->mutex,NULL);
	s->start_time=0;
	s->frame_count=-1;
	s->fps=15;
	s->usemire=(getenv("DEBUG")!=NULL);
	s->queued=0;
	f->data=s;
}
示例#28
0
static void winsnd_init(MSSndCard *card){
	WinSndData *d=(WinSndData*)ms_new(WinSndData,1);
    memset(d, 0, sizeof(WinSndData));
	d->bytes_read=0;
	d->pcmdev=NULL;
	d->mixdev=NULL;
    d->sound_err=-1; /* not opened */
	d->read_started=FALSE;
	d->write_started=FALSE;
	d->bits=16;
	d->rate=8000;
	d->stereo=FALSE;
	qinit(&d->rq);
	d->bufferizer=ms_bufferizer_new();
	ms_mutex_init(&d->mutex,NULL);
	card->data=d;
#ifndef DISABLE_SPEEX
	d->pst=0;
#endif
	d->stat_input=0;
	d->stat_output=0;
	d->stat_notplayed=0;
}
	msandroid_sound_data() : bits(16),rate(8000),nchannels(1),started(false),thread_id(0),forced_rate(false){
		ms_mutex_init(&mutex,NULL);
	};
示例#30
0
	msandroid_sound_data() : jvm(ms_andsnd_jvm),bits(16),rate(8000),nchannels(1),started(false),thread_id(0){
		ms_mutex_init(&mutex,NULL);
	};