Changeset 44
- Timestamp:
- 05/04/08 16:50:54
(4 months ago)
- Author:
- sip
- Message:
Minor fix and add watcher ouput
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r37 |
r44 |
|
| 36 | 36 | VideoInput* GetInput(int id); |
|---|
| 37 | 37 | VideoOutput* GetOutput(int id); |
|---|
| | 38 | int SetWatcher(VideoOutput* watcher); |
|---|
| 38 | 39 | int GetCompositionType(); |
|---|
| 39 | 40 | int SetSlot(int num,int id); |
|---|
| … | … | |
| 71 | 72 | int numSlots; |
|---|
| 72 | 73 | |
|---|
| | 74 | //Watcher output |
|---|
| | 75 | VideoOutput *watcher; |
|---|
| | 76 | |
|---|
| 73 | 77 | //Threads, mutex y condiciones |
|---|
| 74 | 78 | pthread_t mixVideoThread; |
|---|
| r34 |
r44 |
|
| 17 | 17 | mosaicPos = NULL; |
|---|
| 18 | 18 | numSlots = 0; |
|---|
| | 19 | |
|---|
| | 20 | //No watcher |
|---|
| | 21 | watcher = NULL; |
|---|
| 19 | 22 | |
|---|
| 20 | 23 | //Inciamos lso mutex y la condicion |
|---|
| … | … | |
| 97 | 100 | input->SetFrame(mosaic->GetFrame(),mosaic->GetWidth(),mosaic->GetHeight()); |
|---|
| 98 | 101 | } |
|---|
| | 102 | |
|---|
| | 103 | //If been watched |
|---|
| | 104 | if (watcher) |
|---|
| | 105 | //Put frame |
|---|
| | 106 | watcher->NextFrame(mosaic->GetFrame()); |
|---|
| | 107 | |
|---|
| | 108 | //Reset |
|---|
| | 109 | mosaic->Reset(); |
|---|
| 99 | 110 | } |
|---|
| 100 | 111 | |
|---|
| 101 | | //Reset |
|---|
| 102 | | mosaic->Reset(); |
|---|
| 103 | 112 | |
|---|
| 104 | 113 | //Desprotege la lista |
|---|
| … | … | |
| 107 | 116 | //Esperamos que nos seƱalicen |
|---|
| 108 | 117 | pthread_cond_wait(&mixVideoCond,&mixVideoMutex); |
|---|
| | 118 | |
|---|
| 109 | 119 | |
|---|
| 110 | 120 | //Protegemos la lista |
|---|
| … | … | |
| 127 | 137 | |
|---|
| 128 | 138 | //If it's visible |
|---|
| 129 | | if (pos!=1) |
|---|
| | 139 | if (pos!=-1) |
|---|
| 130 | 140 | //Change mosaic |
|---|
| 131 | | mosaic->Update(id-1,output->GetFrame(),output->GetWidth(),output->GetHeight()); |
|---|
| | 141 | mosaic->Update(pos,output->GetFrame(),output->GetWidth(),output->GetHeight()); |
|---|
| 132 | 142 | } |
|---|
| 133 | 143 | } |
|---|
| 134 | 144 | |
|---|
| | 145 | //Desprotege la lista |
|---|
| | 146 | lstVideosUse.DecUse(); |
|---|
| | 147 | |
|---|
| 135 | 148 | //Desbloqueamos |
|---|
| 136 | 149 | pthread_mutex_unlock(&mixVideoMutex); |
|---|
| 137 | | |
|---|
| 138 | | //Desprotege la lista |
|---|
| 139 | | lstVideosUse.DecUse(); |
|---|
| 140 | 150 | } |
|---|
| 141 | 151 | |
|---|
| … | … | |
| 159 | 169 | // Estamos mzclando |
|---|
| 160 | 170 | mixingVideo = true; |
|---|
| | 171 | |
|---|
| | 172 | //Calculate Init position |
|---|
| | 173 | CalculatePositions(); |
|---|
| 161 | 174 | |
|---|
| 162 | 175 | //Y arrancamoe el thread |
|---|
| … | … | |
| 199 | 212 | Log("<End videomixer\n"); |
|---|
| 200 | 213 | |
|---|
| | 214 | return 1; |
|---|
| | 215 | } |
|---|
| | 216 | |
|---|
| | 217 | /*********************** |
|---|
| | 218 | * CreateMixer |
|---|
| | 219 | * Crea una nuevo source de video para mezclar |
|---|
| | 220 | ***************************/ |
|---|
| | 221 | int VideoMixer::SetWatcher(VideoOutput* w) |
|---|
| | 222 | { |
|---|
| | 223 | //Protegemos la lista |
|---|
| | 224 | lstVideosUse.WaitUnusedAndLock(); |
|---|
| | 225 | |
|---|
| | 226 | //Set watcher |
|---|
| | 227 | watcher = w; |
|---|
| | 228 | |
|---|
| | 229 | //If it's not null |
|---|
| | 230 | if (watcher) |
|---|
| | 231 | //Set width |
|---|
| | 232 | watcher->SetVideoSize(mosaic->GetWidth(),mosaic->GetHeight()); |
|---|
| | 233 | |
|---|
| | 234 | //Desprotegemos la lista |
|---|
| | 235 | lstVideosUse.Unlock(); |
|---|
| | 236 | |
|---|
| | 237 | //Ok |
|---|
| 201 | 238 | return 1; |
|---|
| 202 | 239 | } |
|---|
| … | … | |
| 394 | 431 | } |
|---|
| 395 | 432 | |
|---|
| | 433 | //Signal for new video |
|---|
| | 434 | pthread_cond_signal(&mixVideoCond); |
|---|
| | 435 | |
|---|
| 396 | 436 | //Desprotegemos la lista |
|---|
| 397 | 437 | lstVideosUse.Unlock(); |
|---|
| … | … | |
| 552 | 592 | CalculatePositions(); |
|---|
| 553 | 593 | |
|---|
| | 594 | //If we have watcher |
|---|
| | 595 | if (watcher) |
|---|
| | 596 | //Set size |
|---|
| | 597 | watcher->SetVideoSize(mosaic->GetWidth(),mosaic->GetHeight()); |
|---|
| | 598 | |
|---|
| | 599 | //Signal for new video |
|---|
| | 600 | pthread_cond_signal(&mixVideoCond); |
|---|
| | 601 | |
|---|
| 554 | 602 | //Desprotegemos la lista |
|---|
| 555 | 603 | lstVideosUse.Unlock(); |
|---|
| … | … | |
| 601 | 649 | //Start after me next pass |
|---|
| 602 | 650 | first++; |
|---|
| | 651 | //It's locked |
|---|
| | 652 | firstFree = -1; |
|---|
| 603 | 653 | //Next |
|---|
| 604 | 654 | break; |
|---|
| … | … | |
| 635 | 685 | } |
|---|
| 636 | 686 | |
|---|
| 637 | | //For each slot |
|---|
| 638 | | for (int i=0;i<numSlots;i++) |
|---|
| 639 | | //If we empty slot |
|---|
| 640 | | if (mosaicPos[i]<=0) |
|---|
| 641 | | //Print it |
|---|
| 642 | | mosaic->Update(i,logo.GetFrame(),logo.GetWidth(),logo.GetHeight()); |
|---|
| 643 | | |
|---|
| 644 | 687 | //Log Slots |
|---|
| 645 | 688 | for (int i=0;i<numSlots;i++) |
|---|
| … | … | |
| 658 | 701 | Log("]\n"); |
|---|
| 659 | 702 | |
|---|
| | 703 | //For each slot |
|---|
| | 704 | for (int i=0;i<numSlots;i++) |
|---|
| | 705 | //If we empty slot |
|---|
| | 706 | if (mosaicPos[i]<=0) |
|---|
| | 707 | //Print it |
|---|
| | 708 | mosaic->Update(i,logo.GetFrame(),logo.GetWidth(),logo.GetHeight()); |
|---|
| | 709 | |
|---|
| | 710 | |
|---|
| 660 | 711 | Log("<CalculatePositions\n"); |
|---|
| 661 | 712 | } |
|---|
| … | … | |
| 676 | 727 | //Protegemos la lista |
|---|
| 677 | 728 | lstVideosUse.WaitUnusedAndLock(); |
|---|
| | 729 | |
|---|
| | 730 | //If we fix a participant |
|---|
| | 731 | if (id!=-1) |
|---|
| | 732 | //Chek if it was alredy a slot in use for this user |
|---|
| | 733 | for (int i=0;i<numSlots;i++) |
|---|
| | 734 | //It was the user? |
|---|
| | 735 | if (mosaicSlots[i]==id) |
|---|
| | 736 | { |
|---|
| | 737 | //Set it free |
|---|
| | 738 | mosaicSlots[i] = 0; |
|---|
| | 739 | //Break |
|---|
| | 740 | break; |
|---|
| | 741 | } |
|---|
| 678 | 742 | |
|---|
| 679 | 743 | //Set it |
|---|
Download in other formats:
|
|