static void linphone_gtk_init_pipe(const char *name){ server_pipe=ortp_server_pipe_create(name); if (server_pipe==(ortp_pipe_t)-1){ g_warning("Fail to create server pipe for name %s: %s",name,strerror(errno)); } ms_thread_create(&pipe_thread,NULL,server_pipe_thread,NULL); }
static void winsnd_start_r(MSSndCard *card){ WinSndData *d=(WinSndData*)card->data; if (d->read_started==FALSE && d->write_started==FALSE){ d->read_started=TRUE; ms_thread_create(&d->thread,NULL,winsnd_thread,card); }else d->read_started=TRUE; }
static UDT_transport *UDT_transport_connecting(RtpSession *session) { RtpTransport * rtp_transport = NULL; libudt_init_check(); UDT_transport *udt = UDT_transport_new(); UDT_transport_set_rtp_session(udt,session); if(UDT_transport_connect(udt) < 0) { UDT_transport_disconnect(udt); ms_message("Can't start udt transport !!"); udt =NULL; return NULL; } else { rtp_transport = UDT_create_rtp_transport(udt); if(rtp_transport){ rtp_session_set_transports(session,rtp_transport,NULL); ms_message("enable mediastreamer2 udt transport !!"); udt->run = TRUE; ms_thread_create(&udt->monitor_thread,NULL,&monitor,udt); } return udt; } }
static void msv4l2_preprocess(MSFilter *f){ V4l2State *s=(V4l2State*)f->data; s->thread_run=TRUE; ms_thread_create(&s->thread,NULL,msv4l2_thread,s); s->th_frame_count=-1; s->mean_inter_frame=0; }
static bool_t fonis_init(void){ static bool_t initd=FALSE; if (!initd){ ms_thread_create(&fonis_thread,NULL,fonis_thread_func,NULL); initd=TRUE; } return TRUE; }
static void *msv4l2_thread(void *ptr){ V4l2State *s=(V4l2State*)ptr; int try=0; ms_message("msv4l2_thread starting"); if (s->fd==-1){ if( msv4l2_open(s)!=0){ ms_warning("msv4l2 could not be openned"); goto close; } } if (!s->configured && msv4l2_configure(s)!=0){ ms_warning("msv4l2 could not be configured"); goto close; } if (msv4l2_do_mmap(s)!=0) { ms_warning("msv4l2 do mmap"); goto close; } ms_message("V4L2 video capture started."); while(s->thread_run) { if (s->fd!=-1){ mblk_t *m; m=v4lv2_grab_image(s,50); if (m){ mblk_t *om=dupmsg(m); mblk_set_marker_info(om,(s->pix_fmt==MS_MJPEG)); ms_mutex_lock(&s->mutex); putq(&s->rq,om); ms_mutex_unlock(&s->mutex); } } } /*dequeue pending buffers so that we can properly unref them (avoids memleak )*/ while(s->queued && try<10){ v4l2_dequeue_ready_buffer(s,50); try++; } if (try==10) ms_warning("msv4l2: buffers not dequeued at exit !"); msv4l2_do_munmap(s); close: msv4l2_close(s); ms_message("msv4l2_thread exited."); ms_thread_exit(NULL); return NULL; } static void msv4l2_preprocess(MSFilter *f){ V4l2State *s=(V4l2State*)f->data; s->thread_run=TRUE; ms_thread_create(&s->thread,NULL,msv4l2_thread,s); s->th_frame_count=-1; s->mean_inter_frame=0; }
static void oss_start_r(MSSndCard *card){ OssData *d=(OssData*)card->data; ms_mutex_lock(&d->mutex); if (d->read_started==FALSE && d->write_started==FALSE){ d->read_started=TRUE; ms_thread_create(&d->thread,NULL,oss_thread,card); }else d->read_started=TRUE; flushq(&d->rq,0); ms_mutex_unlock(&d->mutex); }
EcCalibrator * ec_calibrator_new(MSSndCard *play_card, MSSndCard *capt_card, LinphoneEcCalibrationCallback cb, void *cb_data ){ EcCalibrator *ecc=ms_new0(EcCalibrator,1); ecc->cb=cb; ecc->cb_data=cb_data; ecc->capt_card=capt_card; ecc->play_card=play_card; ms_thread_create(&ecc->thread,NULL,ecc_thread,ecc); return ecc; }
static void oss_start_w(MSSndCard *card){ OssData *d=(OssData*)card->data; ms_mutex_lock(&d->mutex); if (d->read_started==FALSE && d->write_started==FALSE){ d->write_started=TRUE; ms_thread_create(&d->thread,NULL,oss_thread,card); }else{ d->write_started=TRUE; } _flush_buffer(d->bufferizer); ms_mutex_unlock(&d->mutex); }
static void _vfw_engine_configure(VfwEngine *obj){ if (_vfw_engine_setup(obj)==-1){ return; } if (_vfw_engine_select_format(obj)==-1){ return ; } capSetCallbackOnVideoStream(obj->capvideo, vfw_engine_stream_callback); if (!capCaptureSequenceNoFile(obj->capvideo)){ ms_error("vfw: fail to start capture !"); } ms_thread_create(&obj->thread,NULL,vfw_engine_thread,obj); obj->configured=TRUE; }
EcCalibrator * ec_calibrator_new(MSSndCard *play_card, MSSndCard *capt_card, unsigned int rate, LinphoneEcCalibrationCallback cb, LinphoneEcCalibrationAudioInit audio_init_cb, LinphoneEcCalibrationAudioUninit audio_uninit_cb, void *cb_data) { EcCalibrator *ecc=ms_new0(EcCalibrator,1); ecc->rate=rate; ecc->cb=cb; ecc->cb_data=cb_data; ecc->audio_init_cb=audio_init_cb; ecc->audio_uninit_cb=audio_uninit_cb; ecc->capt_card=capt_card; ecc->play_card=play_card; ms_thread_create(&ecc->thread,NULL,ecc_thread,ecc); return ecc; }
static void msv4l2_preprocess(MSFilter *f){ V4l2State *s=(V4l2State*)f->data; #ifdef V4L2_THREADED ms_thread_create(&s->thread,NULL,msv4l2_thread,s); #else if (s->fd==-1 && msv4l2_open(s)!=0) { return; } if (!s->configured && msv4l2_configure(s)!=0){ return; } if (msv4l2_do_mmap(s)==0){ ms_message("V4L2 video capture started."); }else{ msv4l2_close(s); } s->start_time=f->ticker->time; #endif }
static void sound_read_setup(MSFilter *f){ ms_debug("andsnd_read_preprocess"); msandroid_sound_read_data *d=(msandroid_sound_read_data*)f->data; jmethodID constructor_id=0; jmethodID min_buff_size_id; //jmethodID set_notification_period; int rc; JNIEnv *jni_env = ms_get_jni_env(); d->audio_record_class = (jclass)jni_env->NewGlobalRef(jni_env->FindClass("android/media/AudioRecord")); if (d->audio_record_class == 0) { ms_error("cannot find android/media/AudioRecord"); return; } constructor_id = jni_env->GetMethodID(d->audio_record_class,"<init>", "(IIIII)V"); if (constructor_id == 0) { ms_error("cannot find AudioRecord (int audioSource, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes)"); return; } min_buff_size_id = jni_env->GetStaticMethodID(d->audio_record_class,"getMinBufferSize", "(III)I"); if (min_buff_size_id == 0) { ms_error("cannot find AudioRecord.getMinBufferSize(int sampleRateInHz, int channelConfig, int audioFormat)"); return; } d->buff_size = jni_env->CallStaticIntMethod(d->audio_record_class,min_buff_size_id,d->rate,2/*CHANNEL_CONFIGURATION_MONO*/,2/* ENCODING_PCM_16BIT */); d->read_chunk_size = d->buff_size/4; d->buff_size*=2;/*double the size for configuring the recorder: this does not affect latency but prevents "AudioRecordThread: buffer overflow"*/ if (d->buff_size > 0) { ms_message("Configuring recorder with [%i] bits rate [%i] nchanels [%i] buff size [%i], chunk size [%i]" ,d->bits ,d->rate ,d->nchannels ,d->buff_size ,d->read_chunk_size); } else { ms_message("Cannot configure recorder with [%i] bits rate [%i] nchanels [%i] buff size [%i] chunk size [%i]" ,d->bits ,d->rate ,d->nchannels ,d->buff_size ,d->read_chunk_size); return; } d->read_buff = jni_env->NewByteArray(d->buff_size); d->read_buff = (jbyteArray)jni_env->NewGlobalRef(d->read_buff); if (d->read_buff == 0) { ms_error("cannot instanciate read buff"); return; } d->audio_record = jni_env->NewObject(d->audio_record_class ,constructor_id ,sdk_version<11?1/*MIC*/:7/*VOICE_COMMUNICATION*/ ,d->rate ,2/*CHANNEL_CONFIGURATION_MONO*/ ,2/* ENCODING_PCM_16BIT */ ,d->buff_size); d->audio_record = jni_env->NewGlobalRef(d->audio_record); if (d->audio_record == 0) { ms_error("cannot instantiate AudioRecord"); return; } d->min_avail=-1; d->read_samples=0; d->ticker_synchronizer = ms_ticker_synchronizer_new(); d->outgran_ms=20; d->start_time=-1; d->framesize=(d->outgran_ms*d->rate)/1000; d->started=true; // start reader thread rc = ms_thread_create(&d->thread_id, 0, (void*(*)(void*))msandroid_read_cb, d); if (rc){ ms_error("cannot create read thread return code is [%i]", rc); d->started=false; } }
void ec_calibrator_start(EcCalibrator *ecc){ ms_thread_create(&ecc->thread,NULL,ecc_thread,ecc); }
static void ms_ticker_start(MSTicker *s){ s->run=TRUE; ms_thread_create(&s->thread,NULL,ms_ticker_run,s); }
static void alsa_start_r(AlsaReadData *d){ if (d->read_started==FALSE){ d->read_started=TRUE; ms_thread_create(&d->thread,NULL,alsa_write_thread,d); }else d->read_started=TRUE; }
static int v4l_start(MSFilter *f, void *arg) { V4lState *s=(V4lState*)f->data; int err=0; if (v4l_fd>=0 && reuse_fd){ if (strcmp(v4l_devname,s->dev)==0 ){ /*use this one!*/ ms_message("v4l_start: reusing previous file descriptor."); s->fd=v4l_fd; }else{ ms_message("closing cached fd"); close(v4l_fd); v4l_fd=-1; ms_free(v4l_devname); v4l_devname=NULL; } } if (s->fd==-1){ s->fd=open(s->dev,O_RDWR); ms_message("v4l_start: open, fd=%i",s->fd); if (s->fd>=0){ v4l_fd=s->fd; v4l_devname=ms_strdup(s->dev); } } if (s->fd<0){ ms_error("MSV4l: cannot open video device (%s): %s.",s->dev,strerror(errno)); if (!s->usemire){ s->pix_fmt=MS_YUV420P; s->fps=1; } return -1; }else{ #ifdef HAVE_LINUX_VIDEODEV2_H if (s->force_v1 || v4lv2_configure(s)<0) {/*might not be V4LV2 */ #else if (1){ #endif struct video_capability vidcap; err=v4l_configure(s); if (err<0) { ms_error("MSV4l: could not get configuration of video device"); close(s->fd); s->fd=-1; return -1; } if (!s->force_v1) reuse_fd=TRUE; err=ioctl(s->fd, VIDIOCGCAP, &vidcap); if (err==0) { ms_message("MSV4l: Webcam is %s.", vidcap.name); if (strcasecmp(vidcap.name, "Logitech QuickCam USB")==0) { int comp_arg=0; err=ioctl(s->fd, VIDIOCQCSCOMPATIBLE, &comp_arg); if (err==0) { ms_message("MSV4l: compatibility mode disabled for %s.", vidcap.name); } } } }else{ ms_message("Device is a video4linux V2 one."); s->v4lv2=TRUE; reuse_fd=FALSE; } } return 0; } static void v4l_start_capture(V4lState *s){ if (s->fd>=0){ s->run=TRUE; ms_thread_create(&s->thread,NULL,v4l_thread,s); } } static int v4l_stop(MSFilter *f, void *arg){ V4lState *s=(V4lState*)f->data; if (s->fd>=0){ if (!reuse_fd){ if (close(s->fd)<0){ ms_warning("MSV4l: Could not close(): %s",strerror(errno)); } ms_message("v4l fd %i closed",s->fd); } s->fd=-1; s->frame_count=-1; } return 0; }
static int linphone_ldap_contact_provider_bind( LinphoneLDAPContactProvider* obj ) { // perform the bind in an alternate thread, so that we don't stall the main loop ms_thread_create(&obj->bind_thread, NULL, ldap_bind_thread_func, obj); return 0; }