Changeset 31
- Timestamp:
- 02/10/08 22:16:27
(6 months ago)
- Author:
- sip
- Message:
Implemented mosaic position logic.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r20 |
r31 |
|
| 3 | 3 | ########################################### |
|---|
| 4 | 4 | include ../config.mk |
|---|
| | 5 | |
|---|
| | 6 | OPTS+= -fPIC -DPIC |
|---|
| 5 | 7 | |
|---|
| 6 | 8 | #DEBUG |
|---|
| r17 |
r31 |
|
| 9 | 9 | #define log_error Error |
|---|
| 10 | 10 | |
|---|
| 11 | | inline void LogFile(char *msg, ...) |
|---|
| | 11 | inline void LogFile(const char *msg, ...) |
|---|
| 12 | 12 | { |
|---|
| 13 | 13 | |
|---|
| … | … | |
| 28 | 28 | } |
|---|
| 29 | 29 | |
|---|
| 30 | | inline void Out(char *msg, ...) |
|---|
| | 30 | inline void Out(const char *msg, ...) |
|---|
| 31 | 31 | { |
|---|
| 32 | 32 | va_list ap; |
|---|
| … | … | |
| 38 | 38 | } |
|---|
| 39 | 39 | |
|---|
| 40 | | inline void Log(char *msg, ...) |
|---|
| | 40 | inline void Log(const char *msg, ...) |
|---|
| 41 | 41 | { |
|---|
| 42 | 42 | va_list ap; |
|---|
| … | … | |
| 49 | 49 | } |
|---|
| 50 | 50 | |
|---|
| 51 | | inline void Debug(char *msg, ...) |
|---|
| | 51 | inline void Debug(const char *msg, ...) |
|---|
| 52 | 52 | { |
|---|
| 53 | 53 | va_list ap; |
|---|
| … | … | |
| 58 | 58 | } |
|---|
| 59 | 59 | |
|---|
| 60 | | inline int Error(char *msg, ...) |
|---|
| | 60 | inline int Error(const char *msg, ...) |
|---|
| 61 | 61 | { |
|---|
| 62 | 62 | va_list ap; |
|---|
| r6 |
r31 |
|
| 12 | 12 | virtual void Reset(); |
|---|
| 13 | 13 | |
|---|
| | 14 | virtual int GetSlots()=0; |
|---|
| 14 | 15 | virtual BYTE* GetFrame() = 0; |
|---|
| 15 | 16 | virtual int GetWidth() = 0; |
|---|
| r6 |
r31 |
|
| 18 | 18 | int CreateParticipant(); |
|---|
| 19 | 19 | int SetCompositionType(int comp,int size); |
|---|
| | 20 | int SetMosaicSlot(int num,int id); |
|---|
| 20 | 21 | |
|---|
| 21 | 22 | //Video |
|---|
| r6 |
r31 |
|
| 11 | 11 | PartedMosaic(int num, int size); |
|---|
| 12 | 12 | virtual ~PartedMosaic(); |
|---|
| | 13 | |
|---|
| | 14 | virtual int GetSlots(); |
|---|
| 13 | 15 | |
|---|
| 14 | 16 | virtual BYTE* GetFrame(); |
|---|
| r6 |
r31 |
|
| 33 | 33 | VideoOutput* GetOutput(int id); |
|---|
| 34 | 34 | int GetCompositionType(); |
|---|
| | 35 | int SetSlot(int num,int id); |
|---|
| 35 | 36 | int SetCompositionType(CompositionType comp,int size); |
|---|
| 36 | 37 | int End(); |
|---|
| … | … | |
| 38 | 39 | protected: |
|---|
| 39 | 40 | int MixVideo(); |
|---|
| | 41 | int CalculatePositions(); |
|---|
| | 42 | int GetPosition(int id); |
|---|
| 40 | 43 | |
|---|
| 41 | 44 | private: |
|---|
| … | … | |
| 60 | 63 | BYTE *logo; |
|---|
| 61 | 64 | Mosaic *mosaic; |
|---|
| | 65 | int *mosaicSlots; |
|---|
| | 66 | int *mosaicPos; |
|---|
| | 67 | int numSlots; |
|---|
| 62 | 68 | |
|---|
| 63 | 69 | //Threads, mutex y condiciones |
|---|
| r17 |
r31 |
|
| 4 | 4 | #include "xmlrpcserver.h" |
|---|
| 5 | 5 | |
|---|
| 6 | | xmlrpc_value* xmlerror (xmlrpc_env *env,char *msg); |
|---|
| | 6 | xmlrpc_value* xmlerror (xmlrpc_env *env,const char *msg); |
|---|
| 7 | 7 | xmlrpc_value* xmlok (xmlrpc_env *env,xmlrpc_value *array=NULL); |
|---|
| 8 | 8 | |
|---|
| r6 |
r31 |
|
| 31 | 31 | int CreateParticipant(int confId); |
|---|
| 32 | 32 | int SetCompositionType(int confId,int comp,int size); |
|---|
| | 33 | int SetMosaicSlot(int confId,int num,int id); |
|---|
| 33 | 34 | |
|---|
| 34 | 35 | //Video |
|---|
| … | … | |
| 54 | 55 | |
|---|
| 55 | 56 | private: |
|---|
| 56 | | int MakeCall(xmlrpc_env *env,char *method,xmlrpc_value* param,xmlrpc_value **result); |
|---|
| | 57 | int MakeCall(xmlrpc_env *env,const char *method,xmlrpc_value* param,xmlrpc_value **result); |
|---|
| 57 | 58 | //Atributos |
|---|
| 58 | 59 | string serverUrl; |
|---|
| … | … | |
| 74 | 75 | int SetCompositionType(void *mcu,int confId,int comp,int size) |
|---|
| 75 | 76 | { return ((XmlRpcMcuClient*)mcu)->SetCompositionType(confId,comp,size); } |
|---|
| | 77 | int SetMosaicSlot(void *mcu,int confId,int num,int id) |
|---|
| | 78 | { return ((XmlRpcMcuClient*)mcu)->SetCompositionType(confId,num,id); } |
|---|
| 76 | 79 | |
|---|
| 77 | 80 | //Video |
|---|
| … | … | |
| 120 | 123 | int CreateParticipant(void *mcu,int confId); |
|---|
| 121 | 124 | int SetCompositionType(void *mcu,int confId,int comp,int size); |
|---|
| | 125 | int SetMosaicSlot(void *mcu,int confId,int num,int id); |
|---|
| 122 | 126 | |
|---|
| 123 | 127 | //Video |
|---|
| r8 |
r31 |
|
| 16 | 16 | { |
|---|
| 17 | 17 | public: |
|---|
| 18 | | XmlRpcServer(); |
|---|
| | 18 | XmlRpcServer(int port); |
|---|
| 19 | 19 | |
|---|
| 20 | 20 | int AddHandler(string base,Handler* hnd); |
|---|
| r6 |
r31 |
|
| 139 | 139 | pthread_mutex_lock(&tickerMutex); |
|---|
| 140 | 140 | } |
|---|
| | 141 | |
|---|
| | 142 | //Y desprotegemos |
|---|
| | 143 | pthread_mutex_unlock(&tickerMutex); |
|---|
| 141 | 144 | |
|---|
| 142 | 145 | //Logeamos |
|---|
| … | … | |
| 163 | 166 | void AudioMixer::Process(void) |
|---|
| 164 | 167 | { |
|---|
| 165 | | |
|---|
| 166 | 168 | LstAudios::iterator it; |
|---|
| 167 | 169 | |
|---|
| … | … | |
| 338 | 340 | |
|---|
| 339 | 341 | //Si esta devolvemos el input |
|---|
| 340 | | return true;; |
|---|
| | 342 | return true; |
|---|
| 341 | 343 | } |
|---|
| 342 | 344 | |
|---|
| r17 |
r31 |
|
| 13 | 13 | #endif |
|---|
| 14 | 14 | |
|---|
| 15 | | int main() |
|---|
| | 15 | int main(int argc,char **argv) |
|---|
| 16 | 16 | { |
|---|
| 17 | | XmlRpcServer server; |
|---|
| | 17 | int port = 8080; |
|---|
| | 18 | |
|---|
| | 19 | //Get port |
|---|
| | 20 | if(argc>1) |
|---|
| | 21 | port = atoi(argv[1]); |
|---|
| | 22 | |
|---|
| | 23 | XmlRpcServer server(port); |
|---|
| 18 | 24 | StatusHandler status; |
|---|
| 19 | 25 | MCU mcu; |
|---|
| r10 |
r31 |
|
| 61 | 61 | //POnemos el tipo de video mixer |
|---|
| 62 | 62 | return videoMixer.SetCompositionType((CompositionType)comp,size); |
|---|
| | 63 | } |
|---|
| | 64 | |
|---|
| | 65 | /************************ |
|---|
| | 66 | * SetMosaicSlot |
|---|
| | 67 | * Set slot position on mosaic |
|---|
| | 68 | *************************/ |
|---|
| | 69 | int MultiConf::SetMosaicSlot(int num,int id) |
|---|
| | 70 | { |
|---|
| | 71 | Log("-SetMosaicSlot [%d,%d]\n",num,id); |
|---|
| | 72 | |
|---|
| | 73 | //Set it |
|---|
| | 74 | return videoMixer.SetSlot(num,id); |
|---|
| 63 | 75 | } |
|---|
| 64 | 76 | |
|---|
| r6 |
r31 |
|
| 64 | 64 | //Free memory |
|---|
| 65 | 65 | free(resizer); |
|---|
| | 66 | } |
|---|
| | 67 | /***************************** |
|---|
| | 68 | * GetSlots |
|---|
| | 69 | * Get number of slots |
|---|
| | 70 | *****************************/ |
|---|
| | 71 | int PartedMosaic::GetSlots() |
|---|
| | 72 | { |
|---|
| | 73 | return mosaicNum; |
|---|
| 66 | 74 | } |
|---|
| 67 | 75 | |
|---|
| r6 |
r31 |
|
| 12 | 12 | { |
|---|
| 13 | 13 | //Incializamos a cero |
|---|
| 14 | | mosaic = NULL; |
|---|
| | 14 | mosaic = NULL; |
|---|
| | 15 | mosaicSlots = NULL; |
|---|
| | 16 | mosaicPos = NULL; |
|---|
| | 17 | numSlots = 0; |
|---|
| 15 | 18 | |
|---|
| 16 | 19 | //Inciamos lso mutex y la condicion |
|---|
| … | … | |
| 25 | 28 | VideoMixer::~VideoMixer() |
|---|
| 26 | 29 | { |
|---|
| | 30 | //If we've got mosaic |
|---|
| | 31 | if (mosaic) |
|---|
| | 32 | //Delete it |
|---|
| | 33 | delete mosaic; |
|---|
| | 34 | |
|---|
| | 35 | //If already have slot list |
|---|
| | 36 | if (mosaicSlots) |
|---|
| | 37 | //Delete it |
|---|
| | 38 | free(mosaicSlots); |
|---|
| | 39 | |
|---|
| | 40 | //If already have position list |
|---|
| | 41 | if (mosaicPos) |
|---|
| | 42 | //Delete it |
|---|
| | 43 | free(mosaicPos); |
|---|
| | 44 | |
|---|
| 27 | 45 | //Liberamos los mutex |
|---|
| 28 | 46 | pthread_mutex_destroy(&mixVideoMutex); |
|---|
| 29 | 47 | pthread_cond_destroy(&mixVideoCond); |
|---|
| | 48 | |
|---|
| 30 | 49 | } |
|---|
| 31 | 50 | |
|---|
| … | … | |
| 54 | 73 | int VideoMixer::MixVideo() |
|---|
| 55 | 74 | { |
|---|
| 56 | | int id; |
|---|
| 57 | | VideoSource *video; |
|---|
| 58 | | |
|---|
| 59 | | //El iterador para los videos |
|---|
| | 75 | //Video Iterator |
|---|
| 60 | 76 | LstVideos::iterator it; |
|---|
| 61 | 77 | |
|---|
| … | … | |
| 72 | 88 | { |
|---|
| 73 | 89 | //Nos recorremos los videos |
|---|
| 74 | | for (it=lstVideos.begin();it!=lstVideos.end();it++) |
|---|
| | 90 | for (it=lstVideos.begin();it!=lstVideos.end();++it) |
|---|
| 75 | 91 | { |
|---|
| 76 | | //Obtenemos el indice y el video |
|---|
| 77 | | id = (*it).first; |
|---|
| 78 | | video = (*it).second; |
|---|
| | 92 | //Get input |
|---|
| | 93 | PipeVideoInput *input = (*it).second->input; |
|---|
| 79 | 94 | |
|---|
| 80 | 95 | //Colocamos el frame |
|---|
| 81 | | video->input->SetFrame(mosaic->GetFrame(),mosaic->GetWidth(),mosaic->GetHeight()); |
|---|
| | 96 | input->SetFrame(mosaic->GetFrame(),mosaic->GetWidth(),mosaic->GetHeight()); |
|---|
| 82 | 97 | } |
|---|
| 83 | 98 | } |
|---|
| … | … | |
| 96 | 111 | |
|---|
| 97 | 112 | //Nos recorremos los videos |
|---|
| 98 | | for (it=lstVideos.begin();it!=lstVideos.end();it++) |
|---|
| | 113 | for (it=lstVideos.begin();it!=lstVideos.end();++it) |
|---|
| 99 | 114 | { |
|---|
| 100 | | //Obtenemos el indice y el video |
|---|
| 101 | | id = (*it).first; |
|---|
| 102 | | video = (*it).second; |
|---|
| | 115 | //Get Id |
|---|
| | 116 | int id = (*it).first; |
|---|
| | 117 | |
|---|
| | 118 | //Get output |
|---|
| | 119 | PipeVideoOutput *output = (*it).second->output; |
|---|
| 103 | 120 | |
|---|
| 104 | 121 | //If we've got a new frame on source |
|---|
| 105 | | if (video->output->IsChanged()) |
|---|
| 106 | | //Change mosaic |
|---|
| 107 | | mosaic->Update(id-1,video->output->GetFrame(),video->output->GetWidth(),video->output->GetHeight()); |
|---|
| | 122 | if (output->IsChanged()) |
|---|
| | 123 | { |
|---|
| | 124 | //Get position |
|---|
| | 125 | int pos = GetPosition(id); |
|---|
| | 126 | |
|---|
| | 127 | //If it's visible |
|---|
| | 128 | if (pos!=1) |
|---|
| | 129 | //Change mosaic |
|---|
| | 130 | mosaic->Update(id-1,output->GetFrame(),output->GetWidth(),output->GetHeight()); |
|---|
| | 131 | } |
|---|
| 108 | 132 | } |
|---|
| 109 | 133 | |
|---|
| … | … | |
| 175 | 199 | |
|---|
| 176 | 200 | //Recorremos la lista |
|---|
| 177 | | for (it =lstVideos.begin();it!=lstVideos.end();it++) |
|---|
| | 201 | for (it =lstVideos.begin();it!=lstVideos.end();++it) |
|---|
| 178 | 202 | //Borramos el video |
|---|
| 179 | 203 | DeleteMixer((*it).first); |
|---|
| 180 | | |
|---|
| 181 | | //If we've got mosaic |
|---|
| 182 | | if (mosaic) |
|---|
| 183 | | //Delete it |
|---|
| 184 | | delete mosaic; |
|---|
| 185 | | |
|---|
| 186 | | //Y el logo |
|---|
| 187 | | //free(logo); |
|---|
| 188 | 204 | |
|---|
| 189 | 205 | Log("<End videomixer\n"); |
|---|
| … | … | |
| 220 | 236 | //Y lo aƱadimos a la lista |
|---|
| 221 | 237 | lstVideos[id] = video; |
|---|
| | 238 | |
|---|
| | 239 | //Calculate it's position |
|---|
| | 240 | for (int i=0; i<numSlots; i++) |
|---|
| | 241 | //It's free? |
|---|
| | 242 | if(mosaicPos[i]==0 && mosaicSlots[i]==0) |
|---|
| | 243 | { |
|---|
| | 244 | //Here we are |
|---|
| | 245 | mosaicPos[i]=id; |
|---|
| | 246 | //Exit |
|---|
| | 247 | break; |
|---|
| | 248 | } |
|---|
| | 249 | |
|---|
| | 250 | //Log Slots |
|---|
| | 251 | for (int i=0;i<numSlots;i++) |
|---|
| | 252 | if (i==0) |
|---|
| | 253 | Log("-Slots [%d",mosaicSlots[i]); |
|---|
| | 254 | else |
|---|
| | 255 | Log(",%d",mosaicSlots[i]); |
|---|
| | 256 | Log("]\n"); |
|---|
| | 257 | |
|---|
| | 258 | //Log postions |
|---|
| | 259 | for (int i=0;i<numSlots;i++) |
|---|
| | 260 | if (i==0) |
|---|
| | 261 | Log("-Pos [%d",mosaicPos[i]); |
|---|
| | 262 | else |
|---|
| | 263 | Log(",%d",mosaicPos[i]); |
|---|
| | 264 | Log("]\n"); |
|---|
| 222 | 265 | |
|---|
| 223 | 266 | //Desprotegemos la lista |
|---|
| … | … | |
| 322 | 365 | if (it == lstVideos.end()) |
|---|
| 323 | 366 | { |
|---|
| 324 | | //DDesprotegemos la lista |
|---|
| | 367 | //Desprotegemos la lista |
|---|
| 325 | 368 | lstVideosUse.Unlock(); |
|---|
| 326 | 369 | //Salimos |
|---|
| … | … | |
| 333 | 376 | //Lo quitamos de la lista |
|---|
| 334 | 377 | lstVideos.erase(id); |
|---|
| | 378 | |
|---|
| | 379 | //If still mixing video |
|---|
| | 380 | if (mixingVideo) |
|---|
| | 381 | //Reset positions |
|---|
| | 382 | for (int i=0;i<numSlots;i++) |
|---|
| | 383 | //it's me? |
|---|
| | 384 | if (mosaicPos[i]==id) |
|---|
| | 385 | { |
|---|
| | 386 | //was fixed? |
|---|
| | 387 | if (mosaicSlots[i]==id) |
|---|
| | 388 | //lock it |
|---|
| | 389 | mosaicSlots[i]=-1; |
|---|
| | 390 | else |
|---|
| | 391 | //Recalculate participant positions |
|---|
| | 392 | CalculatePositions(); |
|---|
| | 393 | |
|---|
| | 394 | //Finish |
|---|
| | 395 | break; |
|---|
| | 396 | } |
|---|
| 335 | 397 | |
|---|
| 336 | 398 | //Desprotegemos la lista |
|---|
| … | … | |
| 412 | 474 | int VideoMixer::SetCompositionType(CompositionType comp, int type) |
|---|
| 413 | 475 | { |
|---|
| 414 | | |
|---|
| 415 | 476 | Log(">SetCompositionType [%d,%d]\n",comp,type); |
|---|
| 416 | 477 | |
|---|
| … | … | |
| 446 | 507 | compositionType = comp; |
|---|
| 447 | 508 | |
|---|
| | 509 | //Save old values |
|---|
| | 510 | int oldNumSlots = numSlots; |
|---|
| | 511 | int *oldSlots = mosaicSlots; |
|---|
| | 512 | int *oldPos = mosaicPos; |
|---|
| | 513 | |
|---|
| | 514 | //Get number of participants visible |
|---|
| | 515 | numSlots = mosaic->GetSlots(); |
|---|
| | 516 | |
|---|
| | 517 | //Malloc lists |
|---|
| | 518 | mosaicSlots = (int*) malloc(numSlots*sizeof(int)); |
|---|
| | 519 | mosaicPos = (int*) malloc(numSlots*sizeof(int)); |
|---|
| | 520 | |
|---|
| | 521 | //Reset slot list |
|---|
| | 522 | memset(mosaicSlots,0,numSlots*sizeof(int)); |
|---|
| | 523 | |
|---|
| | 524 | //If we have old slots |
|---|
| | 525 | if (oldSlots) |
|---|
| | 526 | { |
|---|
| | 527 | //Which was bigger? |
|---|
| | 528 | if (oldNumSlots<numSlots) |
|---|
| | 529 | //Copy |
|---|
| | 530 | memcpy(mosaicSlots,oldSlots,oldNumSlots*sizeof(int)); |
|---|
| | 531 | else |
|---|
| | 532 | //Copy |
|---|
| | 533 | memcpy(mosaicSlots,oldSlots,numSlots*sizeof(int)); |
|---|
| | 534 | } |
|---|
| | 535 | |
|---|
| | 536 | |
|---|
| | 537 | //If already have slot list |
|---|
| | 538 | if (oldSlots) |
|---|
| | 539 | //Delete it |
|---|
| | 540 | free(oldSlots); |
|---|
| | 541 | |
|---|
| | 542 | //If already have position list |
|---|
| | 543 | if (oldPos) |
|---|
| | 544 | //Delete it |
|---|
| | 545 | free(oldPos); |
|---|
| | 546 | |
|---|
| | 547 | //Recalculate positions |
|---|
| | 548 | CalculatePositions(); |
|---|
| | 549 | |
|---|
| 448 | 550 | //Desprotegemos la lista |
|---|
| 449 | 551 | lstVideosUse.Unlock(); |
|---|
| … | … | |
| 454 | 556 | } |
|---|
| 455 | 557 | |
|---|
| | 558 | /************************ |
|---|
| | 559 | * CalculatePosition |
|---|
| | 560 | * Calculate positions for participants |
|---|
| | 561 | *************************/ |
|---|
| | 562 | int VideoMixer::CalculatePositions() |
|---|
| | 563 | { |
|---|
| | 564 | LstVideos::iterator it; |
|---|
| | 565 | |
|---|
| | 566 | Log(">CalculatePositions\n"); |
|---|
| | 567 | |
|---|
| | 568 | //First erase positions |
|---|
| | 569 | memset(mosaicPos,0,numSlots*sizeof(int)); |
|---|
| | 570 | |
|---|
| | 571 | //Start from the begining |
|---|
| | 572 | int first = 0; |
|---|
| | 573 | |
|---|
| | 574 | |
|---|
| | 575 | //Iterate Videos |
|---|
| | 576 | for (it=lstVideos.begin(); it!=lstVideos.end(); ++it) |
|---|
| | 577 | { |
|---|
| | 578 | //Get id |
|---|
| | 579 | int id = (*it).first; |
|---|
| | 580 | |
|---|
| | 581 | //Not found the first free one |
|---|
| | 582 | int firstFree = -1; |
|---|
| | 583 | |
|---|
| | 584 | //Look in the slots |
|---|
| | 585 | for (int i=first;i<numSlots;i++) |
|---|
| | 586 | { |
|---|
| | 587 | //It's lock for me? |
|---|
| | 588 | if (mosaicSlots[i]==id) |
|---|
| | 589 | { |
|---|
| | 590 | //Set our position |
|---|
| | 591 | mosaicPos[i]=id; |
|---|
| | 592 | //If we were the first one |
|---|
| | 593 | if (first==i) |
|---|
| | 594 | //Start after me next pass |
|---|
| | 595 | first++; |
|---|
| | 596 | //Next |
|---|
| | 597 | break; |
|---|
| | 598 | } else if (mosaicSlots[i]==-1 && i==first) { |
|---|
| | 599 | //If the first one was a locked one skip it next time |
|---|
| | 600 | first++; |
|---|
| | 601 | } else if (mosaicSlots[i]==0 && mosaicPos[i]==0 && firstFree==-1) { |
|---|
| | 602 | //If it's free and we have still not a free one save it |
|---|
| | 603 | firstFree=i; |
|---|
| | 604 | } else if (mosaicPos[i]>0 && i==first) { |
|---|
| | 605 | //The first one was already calculated |
|---|
| | 606 | first++; |
|---|
| | 607 | } |
|---|
| | 608 | |
|---|
| | 609 | } |
|---|
| | 610 | |
|---|
| | 611 | //I have not fixed position check if there is any free slot |
|---|
| | 612 | if (firstFree!=-1) |
|---|
| | 613 | { |
|---|
| | 614 | //Here we are |
|---|
| | 615 | mosaicPos[firstFree]=id; |
|---|
| | 616 | //If we were the first one |
|---|
| | 617 | if (first==firstFree) |
|---|
| | 618 | //Start after me next pass |
|---|
| | 619 | first++; |
|---|
| | 620 | } |
|---|
| | 621 | |
|---|
| | 622 | //If we have been over the end |
|---|
| | 623 | if (first==numSlots) |
|---|
| | 624 | //Exit |
|---|
| | 625 | break; |
|---|
| | 626 | } |
|---|
| | 627 | |
|---|
| | 628 | //Log Slots |
|---|
| | 629 | for (int i=0;i<numSlots;i++) |
|---|
| | 630 | if (i==0) |
|---|
| | 631 | Log("-Slots [%d",mosaicSlots[i]); |
|---|
| | 632 | else |
|---|
| | 633 | Log(",%d",mosaicSlots[i]); |
|---|
| | 634 | Log("]\n"); |
|---|
| | 635 | |
|---|
| | 636 | //Log postions |
|---|
| | 637 | for (int i=0;i<numSlots;i++) |
|---|
| | 638 | if (i==0) |
|---|
| | 639 | Log("-Pos [%d",mosaicPos[i]); |
|---|
| | 640 | else |
|---|
| | 641 | Log(",%d",mosaicPos[i]); |
|---|
| | 642 | Log("]\n"); |
|---|
| | 643 | |
|---|
| | 644 | Log("<CalculatePositions\n"); |
|---|
| | 645 | } |
|---|
| | 646 | |
|---|
| | 647 | /************************ |
|---|
| | 648 | * SetSlot |
|---|
| | 649 | * Set slot participant |
|---|
| | 650 | *************************/ |
|---|
| | 651 | int VideoMixer::SetSlot(int num,int id) |
|---|
| | 652 | { |
|---|
| | 653 | Log(">SetPosition"); |
|---|
| | 654 | |
|---|
| | 655 | //Check num |
|---|
| | 656 | if (num>numSlots-1) |
|---|
| | 657 | //Exit |
|---|
| | 658 | return Error("Slot not in mosaic \n"); |
|---|
| | 659 | |
|---|
| | 660 | //Protegemos la lista |
|---|
| | 661 | lstVideosUse.WaitUnusedAndLock(); |
|---|
| | 662 | |
|---|
| | 663 | //Set it |
|---|
| | 664 | mosaicSlots[num] = id; |
|---|
| | 665 | |
|---|
| | 666 | //Calculate positions |
|---|
| | 667 | CalculatePositions(); |
|---|
| | 668 | |
|---|
| | 669 | //Desprotegemos la lista |
|---|
| | 670 | lstVideosUse.Unlock(); |
|---|
| | 671 | |
|---|
| | 672 | Log("<SetPosition"); |
|---|
| | 673 | |
|---|
| | 674 | return 1; |
|---|
| | 675 | } |
|---|
| | 676 | |
|---|
| | 677 | /************************ |
|---|
| | 678 | * GetPosition |
|---|
| | 679 | * Get position for participant |
|---|
| | 680 | *************************/ |
|---|
| | 681 | int VideoMixer::GetPosition(int id) |
|---|
| | 682 | { |
|---|
| | 683 | //Check if it has a fixed position |
|---|
| | 684 | for (int i=0;i<numSlots;i++) |
|---|
| | 685 | //If it's this participant |
|---|
| | 686 | if (mosaicPos[i]==id) |
|---|
| | 687 | //Return it |
|---|
| | 688 | return i; |
|---|
| | 689 | |
|---|
| | 690 | //Not found |
|---|
| | 691 | return -1; |
|---|
| | 692 | } |
|---|
| | 693 | |
|---|
| r17 |
r31 |
|
| 5 | 5 | #include "xmlhandler.h" |
|---|
| 6 | 6 | |
|---|
| 7 | | xmlrpc_value* xmlerror (xmlrpc_env *env,char *msg) |
|---|
| | 7 | xmlrpc_value* xmlerror (xmlrpc_env *env,const char *msg) |
|---|
| 8 | 8 | { |
|---|
| 9 | 9 | return xmlrpc_build_value(env,"{s:i,s:s}","returnCode",0,"errorMsg",msg); |
|---|
| r17 |
r31 |
|
| 588 | 588 | //La borramos |
|---|
| 589 | 589 | int res = conf->SetCompositionType(comp,size); |
|---|
| | 590 | |
|---|
| | 591 | //Liberamos la referencia |
|---|
| | 592 | mcu->ReleaseConferenceRef(confId); |
|---|
| | 593 | |
|---|
| | 594 | //Salimos |
|---|
| | 595 | if(!res) |
|---|
| | 596 | return xmlerror(env,"Error\n"); |
|---|
| | 597 | |
|---|
| | 598 | //Devolvemos el resultado |
|---|
| | 599 | return xmlok(env); |
|---|
| | 600 | } |
|---|
| | 601 | |
|---|
| | 602 | xmlrpc_value* SetMosaicSlot(xmlrpc_env *env, xmlrpc_value *param_array, void *user_data) |
|---|
| | 603 | { |
|---|
| | 604 | MCU *mcu = (MCU *)user_data; |
|---|
| | 605 | MultiConf *conf = NULL; |
|---|
| | 606 | |
|---|
| | 607 | //Parseamos |
|---|
| | 608 | int confId; |
|---|
| | 609 | int num; |
|---|
| | 610 | int id; |
|---|
| | 611 | xmlrpc_parse_value(env, param_array, "(iii)", &confId,&num,&id); |
|---|
| | 612 | |
|---|
| | 613 | //Comprobamos si ha habido error |
|---|
| | 614 | if(env->fault_occurred) |
|---|
| | 615 | return 0; |
|---|
| | 616 | |
|---|
| | 617 | //Obtenemos la referencia |
|---|
| | 618 | if(!mcu->GetConferenceRef(confId,&conf)) |
|---|
| | 619 | return xmlerror(env,"La conferencia no existe\n"); |
|---|
| | 620 | |
|---|
| | 621 | //Set slot |
|---|
| | 622 | int res = conf->SetMosaicSlot(num,id); |
|---|
| 590 | 623 | |
|---|
| 591 | 624 | //Liberamos la referencia |
|---|
| … | … | |
| 621 | 654 | {"IsReceivingAudio",IsReceivingAudio}, |
|---|
| 622 | 655 | {"SetCompositionType",SetCompositionType}, |
|---|
| | 656 | {"SetMosaicSlot",SetMosaicSlot}, |
|---|
| 623 | 657 | {NULL,NULL} |
|---|
| 624 | 658 | }; |
|---|
| r8 |
r31 |
|
| 29 | 29 | * Realiza una llamada a un procedimiento remoto y parsea la respuesta |
|---|
| 30 | 30 | ***************************************/ |
|---|
| 31 | | int XmlRpcMcuClient::MakeCall(xmlrpc_env *env,char *method,xmlrpc_value* param,xmlrpc_value **result) |
|---|
| | 31 | int XmlRpcMcuClient::MakeCall(xmlrpc_env *env,const char *method,xmlrpc_value* param,xmlrpc_value **result) |
|---|
| 32 | 32 | { |
|---|
| 33 | 33 | Log(">MakeCall [%s]\n",method); |
|---|
| … | … | |
| 149 | 149 | return true; |
|---|
| 150 | 150 | } |
|---|
| | 151 | |
|---|
| 151 | 152 | /************************************ |
|---|
| 152 | 153 | * SetCompositionType |
|---|
| … | … | |
| 181 | 182 | } |
|---|
| 182 | 183 | |
|---|
| | 184 | /************************************ |
|---|
| | 185 | * SetMosaicSlot |
|---|
| | 186 | * MosaicSlot |
|---|
| | 187 | ***************************************/ |
|---|
| | 188 | int XmlRpcMcuClient::SetMosaicSlot(int confId,int num,int id) |
|---|
| | 189 | { |
|---|
| | 190 | //Logeamos |
|---|
| | 191 | Log(">SetMosaicSlot [%d,%d,%d]\n",confId,num,id); |
|---|
| | 192 | |
|---|
| | 193 | //Los parametros |
|---|
| | 194 | xmlrpc_env env; |
|---|
| | 195 | xmlrpc_env_init(&env); |
|---|
| | 196 | xmlrpc_value *result = NULL; |
|---|
| | 197 | xmlrpc_value *params = xmlrpc_build_value(&env,"(iii)",confId,num,id); |
|---|
| | 198 | |
|---|
| | 199 | //Llamamos |
|---|
| | 200 | if (!MakeCall(&env,"SetMosaicSlot",params,&result)) |
|---|
| | 201 | return Error("Error al realizar la operacion\n"); |
|---|
| | 202 | |
|---|
| | 203 | //Liberamos |
|---|
| | 204 | if (result) |
|---|
| | 205 | xmlrpc_DECREF(result); |
|---|
| | 206 | if (params) |
|---|
| | 207 | xmlrpc_DECREF(params); |
|---|
| | 208 | xmlrpc_env_clean(&env); |
|---|
| | 209 | |
|---|
| | 210 | Log("<SetMosaicSlot\n",confId); |
|---|
| | 211 | |
|---|
| | 212 | //Salimos |
|---|
| | 213 | return true; |
|---|
| | 214 | } |
|---|
| 183 | 215 | |
|---|
| 184 | 216 | /************************************ |
|---|
| r8 |
r31 |
|
| 11 | 11 | * Constructor |
|---|
| 12 | 12 | **************************************/ |
|---|
| 13 | | XmlRpcServer::XmlRpcServer() |
|---|
| | 13 | XmlRpcServer::XmlRpcServer(int port) |
|---|
| 14 | 14 | { |
|---|
| 15 | 15 | char name[65]; |
|---|
| … | … | |
| 22 | 22 | |
|---|
| 23 | 23 | //Le pasamos como nombre un puntero a nosotros mismos |
|---|
| 24 | | sprintf(name,"0x%x",this); |
|---|
| | 24 | sprintf(name,"%p",this); |
|---|
| 25 | 25 | |
|---|
| 26 | 26 | //Creamos el servidor |
|---|
| 27 | | ServerCreate(&srv,name, 8080, DEFAULT_DOCS, NULL); |
|---|
| | 27 | ServerCreate(&srv,name, port, DEFAULT_DOCS, NULL); |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | //Leemos el fichero de configuracion |
|---|
| … | … | |
| 43 | 43 | int XmlRpcServer::Start() |
|---|
| 44 | 44 | { |
|---|
| | 45 | Log("-Start [%p]\n",this); |
|---|
| 45 | 46 | |
|---|
| 46 | 47 | return 1; |
|---|
| … | … | |
| 53 | 54 | int XmlRpcServer::Run() |
|---|
| 54 | 55 | { |
|---|
| 55 | | Log(">Run [0x%x]\n",this); |
|---|
| | 56 | Log(">Run [%p]\n",this); |
|---|
| 56 | 57 | |
|---|
| 57 | 58 | //Vamos a buscar en orden inverso |
|---|
| … | … | |
| 77 | 78 | int XmlRpcServer::Stop() |
|---|
| 78 | 79 | { |
|---|
| | 80 | Log("-Stop [%p]\n",this); |
|---|
| | 81 | |
|---|
| 79 | 82 | return 1; |
|---|
| 80 | 83 | } |
|---|
| … | … | |
| 99 | 102 | |
|---|
| 100 | 103 | //Get pointer |
|---|
| 101 | | sscanf(r->server->name,"%x", &serv); |
|---|
| | 104 | sscanf(r->server->name,"%p", &serv); |
|---|
| 102 | 105 | |
|---|
| 103 | 106 | //Procesamos la llamada |
|---|
Download in other formats:
|
|