[Live-devel] question about the multi-thread and scheduleDelayedTask

Jiang jian jiangjian at ict.ac.cn
Thu May 19 11:45:45 PDT 2005


Hi, Ross:
   
  I want streaming video from a usb camera, capture the source then use TMN 3.0 
encoding to H.263 frames, but the encoding efficiency is low, in order to eliminate the delay, 
I use multi-thread, so in the OnDemandServerMediaSubsession.cpp I change the codes and create 
two thread like that:

OnDemandServerMediaSubsession::startStream(){
..........
 hdH263Semaphore = CreateSemaphore(NULL,1,1,"mysemaphore");

 if(hdH263Semaphore == NULL){
  printf("error when create semaphore\n");
  exit(-1);
 }

 hdtmnenc = CreateThread(NULL,0,tmn_enc,hdH263Semaphore,0,&tmnthreadID);

 if(hdtmnenc ==  NULL){
  printf("error when create thread tmn\n");
  exit(-1);
 }

  
 hdH263session = CreateThread(NULL,0,startPlayingthread,(LPVOID)streamState,0,&h263sessionthreadID);

 if(hdH263session ==  NULL){
  printf("error when create thread tmn\n");
  exit(-1);
 }

.........................

the first thread used to H.263 encode, the second "startplayingthread" is used to execute the following procedure, 
and I write H263plusSource.cpp like Device source, the TMN encoded frames are feed to doGetNextFrame,
then wait for encode thread completion and going on ,

void H263plusSource::doGetNextFrame() {
.............
dwResult = WaitForSingleObject(hdH263Semaphore, INFINITE);
...................
mBuffer = read_tmn_h263str(h263temp);
...............
nextTask() = envir().taskScheduler().scheduleDelayedTask(fDurationInMicroseconds, 
(TaskFunc*)FramedSource::afterGetting, this);
}

but the last row, when use schduleDelayedTask the whole procedure will halt here, if replace the schduleDelayedTask 
just directly use "afterGetting(this)", the procedure could run, but at last will be wrong because stack overflow error, is 

the scheduleDelayedTask using for recursive return? so how did I resolve the paradox?

Thanks in advance for your help!


Best regards!¡¡¡¡¡¡¡¡¡¡


 ¡¡¡¡¡¡¡¡¡¡¡¡          Jiang jian
                       jiangjian at ict.ac.cn
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡  ¡¡   2005-05-19
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.live.com/pipermail/live-devel/attachments/20050519/3ccfa9d6/attachment.html


More information about the live-devel mailing list