Changeset 4

Show
Ignore:
Timestamp:
06/06/07 11:02:54 (1 year ago)
Author:
sip
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • config.mk

    r2 r4  
    66LOG             = yes 
    77DEBUG           = yes 
    8 SRCDIR          = /usr/mcu 
     8SRCDIR          = /root/mcu 
  • media/Makefile

    r2 r4  
    5353VPATH +=  %.cpp $(SRCDIR)/media/src/$(H263DIR) 
    5454 
    55 INCLUDE+= -I$(SRCDIR)/media/include/ -I$(SRCDIR)/xmlrpc/include 
     55INCLUDE+= -I$(SRCDIR)/media/include/ -I$(SRCDIR)/xmlrpc/include -I$(SRCDIR)/xmlrpc/lib/abyss/src 
    5656LDFLAGS+= -lavcodec -lgsm -lpthread 
    5757LDXMLFLAGS+= -lxmlrpc -lxmlrpc_xmlparse -lxmlrpc_xmltok -lxmlrpc_abyss -lxmlrpc_server -L$(SRCDIR)/xmlrpc/lib  
    5858LDFLAGS+= $(LDXMLFLAGS) 
     59 
     60#For abyss 
     61OPTS    += -D_UNIX 
    5962 
    6063CFLAGS  += $(INCLUDE) $(OPTS) 
  • media/include/audiomixer.h

    r1 r4  
    2929        AudioInput*  GetInput(int id); 
    3030        AudioOutput* GetOutput(int id); 
    31         void AudioMixer::Process(void); 
     31        void Process(void); 
    3232        int End(); 
    3333 
  • media/include/codecs.h

    r2 r4  
    44#include "config.h" 
    55 
    6 #define PCMA 8 
    7 #define PCMU 0 
    8 #define GSM  3 
    9 #define H261 31 
    10 #define H263 34 
    11 #define MPEG4 35 
     6#define PCMA            8 
     7#define PCMU            0 
     8#define GSM             3 
     9#define H261            31 
     10#define H263_1996       34 
     11#define H263_1998       96 
     12#define MPEG4           35 
    1213 
    1314class AudioCodec 
  • media/include/xmlrpcmcuclient.h

    r1 r4  
    11#ifndef _XMLRPCMCUCLIENT_H_ 
    22#define _XMLRPCMCUCLIENT_H_ 
     3 
     4#ifdef __cplusplus 
     5 
    36#include "xmlrpcclient.h" 
    47#include <string> 
     
    4144        XmlRpcClient rpc; 
    4245}; 
     46 
     47extern "C"  
     48{ 
     49 
     50void *  CreateMCUClient(char *url) 
     51        { return new XmlRpcMcuClient(url);      } 
     52void    DestroyMCUClient(void *mcu) 
     53        { delete (XmlRpcMcuClient*)mcu;         }        
     54         
     55int     CreateConference(void *mcu,char *name) 
     56        { return ((XmlRpcMcuClient*)mcu)->CreateConference(name);               } 
     57int     CreateParticipant(void *mcu,int confId) 
     58        { return ((XmlRpcMcuClient*)mcu)->CreateParticipant(confId);            } 
     59 
     60//Video 
     61int     SetVideoCodec(void *mcu,int confId,int partId,int codec,int mode,int fps,int bitrate) 
     62        { return ((XmlRpcMcuClient*)mcu)->SetVideoCodec(confId,partId,codec,mode,fps,bitrate);          }  
     63int     StartSendingVideo(void *mcu,int confId,int partId,char *sendVideoIp,int sendVideoPort) 
     64        { return ((XmlRpcMcuClient*)mcu)->StartSendingVideo(confId,partId,sendVideoIp,sendVideoPort);   } 
     65int     StopSendingVideo(void *mcu,int confId,int partId) 
     66        { return ((XmlRpcMcuClient*)mcu)->StopSendingVideo(confId,partId);                              } 
     67int     StartReceivingVideo(void *mcu,int confId,int partId,int *recVideoPort) 
     68        { return ((XmlRpcMcuClient*)mcu)->StartReceivingVideo(confId,partId,recVideoPort);              } 
     69int     StopReceivingVideo(void *mcu,int confId,int partId) 
     70        { return ((XmlRpcMcuClient*)mcu)->StopReceivingVideo(confId,partId);                            } 
     71int     IsSendingVideo(void *mcu,int confId,int partId,int *isSending) 
     72        { return ((XmlRpcMcuClient*)mcu)->IsSendingVideo(confId,partId,isSending);                      } 
     73int     IsReceivingVideo(void *mcu,int confId,int partId,int *isReceiving) 
     74        { return ((XmlRpcMcuClient*)mcu)->IsReceivingVideo(confId,partId,isReceiving);                  } 
     75 
     76//Audio 
     77int     SetAudioCodec(void *mcu,int confId,int partId,int codec) 
     78        { return ((XmlRpcMcuClient*)mcu)->SetAudioCodec(confId,partId,codec);                           } 
     79int     StartSendingAudio(void *mcu,int confId,int partId,char *sendAudioIp,int sendAudioPort) 
     80        { return ((XmlRpcMcuClient*)mcu)->StartSendingAudio(confId,partId,sendAudioIp,sendAudioPort);   } 
     81int     StopSendingAudio(void *mcu,int confId,int partId) 
     82        { return ((XmlRpcMcuClient*)mcu)->StopSendingAudio(confId,partId);                              } 
     83int     StartReceivingAudio(void *mcu,int confId,int partId,int *recAudioPort) 
     84        { return ((XmlRpcMcuClient*)mcu)->StartReceivingAudio(confId,partId,recAudioPort);              } 
     85int     StopReceivingAudio(void *mcu,int confId,int partId) 
     86        { return ((XmlRpcMcuClient*)mcu)->StopReceivingAudio(confId,partId);                            } 
     87int     IsSendingAudio(void *mcu,int confId,int partId,int *isSending) 
     88        { return ((XmlRpcMcuClient*)mcu)->IsSendingAudio(confId,partId,isSending);                      } 
     89int     IsReceivingAudio(void *mcu,int confId,int partId,int *isReceiving) 
     90        { return ((XmlRpcMcuClient*)mcu)->IsReceivingAudio(confId,partId,isReceiving);                  } 
     91 
     92int     DeleteParticipant(void *mcu,int confId,int partId) 
     93        { return ((XmlRpcMcuClient*)mcu)->DeleteParticipant(confId,partId);                             } 
     94int     DeleteConference(void *mcu,int confId) 
     95        { return ((XmlRpcMcuClient*)mcu)->DeleteConference(confId);                                     } 
     96} 
     97#else 
     98 
     99void *  CreateMCUClient(char *url); 
     100void    DestroyMCUClient(void *mcu); 
     101         
     102int     CreateConference(void *mcu,char *name); 
     103int     CreateParticipant(void *mcu,int confId); 
     104 
     105//Video 
     106int     SetVideoCodec(void *mcu,int confId,int partId,int codec,int mode,int fps,int bitrate); 
     107int     StartSendingVideo(void *mcu,int confId,int partId,char *sendVideoIp,int sendVideoPort); 
     108int     StopSendingVideo(void *mcu,int confId,int partId); 
     109int     StartReceivingVideo(void *mcu,int confId,int partId,int *recVideoPort); 
     110int     StopReceivingVideo(void *mcu,int confId,int partId); 
     111int     IsSendingVideo(void *mcu,int confId,int partId,int *isSending); 
     112int     IsReceivingVideo(void *mcu,int confId,int partId,int *isReceiving); 
     113 
     114//Audio 
     115int     SetAudioCodec(void *mcu,int confId,int partId,int codec); 
     116int     StartSendingAudio(void *mcu,int confId,int partId,char *sendAudioIp,int sendAudioPort); 
     117int     StopSendingAudio(void *mcu,int confId,int partId); 
     118int     StartReceivingAudio(void *mcu,int confId,int partId,int *recAudioPort); 
     119int     StopReceivingAudio(void *mcu,int confId,int partId); 
     120int     IsSendingAudio(void *mcu,int confId,int partId,int *isSending); 
     121int     IsReceivingAudio(void *mcu,int confId,int partId,int *isReceiving); 
     122int     DeleteParticipant(void *mcu,int confId,int partId); 
     123int     DeleteConference(void *mcu,int confId); 
     124 
     125 
     126#endif //__cplusplus 
     127 
    43128#endif 
    44129 
  • media/include/xmlrpcserver.h

    r1 r4  
    3232        int DispatchRequest(TSession * const r); 
    3333 
    34 public
     34private
    3535        typedef map<string,Handler *> LstHandlers; 
     36 
    3637        TServer srv; 
    3738        LstHandlers lstHandlers; 
  • media/src/cliente.cpp

    r1 r4  
    33#include "xmlrpcmcuclient.h" 
    44 
     5#define PCMA 8 
     6#define PCMU 0 
     7#define GSM  3 
     8#define H261 31 
     9#define H263 96 
     10#define MPEG4 35 
     11 
     12#define CIF 0 
     13#define QCIF 1 
     14 
    515int main() 
    616{ 
    7         XmlRpcMcuClient mcu("http://localhost:8080/mcu"); 
     17        XmlRpcMcuClient mcu("http://127.0.0.1:8080/mcu"); 
    818 
    9         mcu.CreateConference("Sergio"); 
     19        int confId = mcu.CreateConference("Sergio"); 
    1020 
     21        int partId = mcu.CreateParticipant(confId); 
     22 
     23        mcu.SetVideoCodec(confId,partId,H263,CIF,300,5,4,8); 
     24 
     25        mcu.SetAudioCodec(confId,partId,PCMU); 
     26 
     27        mcu.StartSendingAudio(confId,partId,"192.168.195.1",1234); 
     28        mcu.StartSendingVideo(confId,partId,"192.168.195.1",1236); 
     29        int port; 
     30        mcu.StartReceivingVideo(confId,partId,&port); 
     31        printf("%d",port); 
    1132} 
    1233 
  • media/src/h263/h263-1996codec.cpp

    r2 r4  
    3636        //Guardamos los valores por defecto 
    3737        codec = NULL; 
    38         type = H263
     38        type = H263_1996
    3939        bufLen = 0; 
    4040         
  • media/src/h263/h263codec.cpp

    r2 r4  
    2020        // Set default values 
    2121        codec   = NULL; 
    22         type    = H263
     22        type    = H263_1998
    2323        qMin    = qualityMin; 
    2424        qMax    = qualityMax; 
     
    2828        SetFrameRate(5,300); 
    2929 
     30        //Inicializamos la libreria 
     31        avcodec_init(); 
     32 
     33        //Register all 
     34        avcodec_register_all(); 
     35 
    3036        // Get encoder 
    3137        codec = avcodec_find_encoder(CODEC_ID_H263); 
     
    3339        // Check codec 
    3440        if(!codec) 
    35                 Error("No codec found"); 
     41                Error("No codec found\n"); 
    3642 
    3743        //No estamos abiertos 
     
    209215                memcpy(out+2, bufEncode+bufIni, len-2); 
    210216                //Set header 
    211                 out[0] = 0x04
     217                out[0] = 0x00
    212218                out[1] = 0x00; 
    213219                //Increase pointer 
     
    235241        //Guardamos los valores por defecto 
    236242        codec = NULL; 
    237         type = H263
     243        type = H263_1998
    238244        bufLen = 0; 
    239245         
     
    318324        if (p) 
    319325        { 
    320                 /* Decrease ini */ 
    321                 i -= 2; 
    322                 len += 2; 
    323326                /* Append 0s */ 
    324                 buffer[0] = 0; 
    325                 buffer[1] = 0; 
     327                buffer[bufLen] = 0; 
     328                buffer[bufLen+1] = 0; 
     329                /* Increase buffer */ 
     330                bufLen += 2; 
    326331        } 
    327332 
     
    339344 
    340345                //Decodificamos 
    341                 if (avcodec_decode_video(ctx,picture,&got_picture,buffer,bufLen)<0) 
    342                         return 0; 
     346                avcodec_decode_video(ctx,picture,&got_picture,buffer,bufLen); 
    343347 
    344348                //Y resetamos el buffer 
  • media/src/h263/mpeg4codec.cpp

    r2 r4  
    122122        // Set default values 
    123123        codec   = NULL; 
    124         type    = H263
     124        type    = MPEG4
    125125        qMin    = qualityMin; 
    126126        qMax    = qualityMax; 
  • media/src/multiconf.cpp

    r2 r4  
    8484 
    8585        //Ponemos el codec favorito 
    86         part->video.SetVideoCodec(H263,CIF,300,5,4,8); 
     86        part->video.SetVideoCodec(H263_1998,CIF,300,5,4,8); 
    8787        part->audio.SetAudioCodec(GSM); 
    8888         
  • media/src/pipevideoinput.cpp

    r1 r4  
    152152int PipeVideoInput::SetFrame(BYTE * buffer, int width, int height) 
    153153{ 
     154        Log("-SetFrame [%d]\n",capturing); 
     155 
    154156        //Protegemos 
    155157        pthread_mutex_lock(&newPicMutex); 
  • media/src/videomixer.cpp

    r1 r4  
    5959{ 
    6060        int id; 
    61         int mosaicChanged;
     61        int mosaicChanged = true
    6262        VideoSource *video; 
    6363 
     
    6666 
    6767        Log(">MixVideo\n"); 
    68          
     68 
    6969        //Mientras estemos mezclando 
    7070        while(mixingVideo) 
    7171        { 
     72                //Protegemos la lista 
     73                lstVideosUse.IncUse(); 
     74 
     75                //Si no ha cambiado el frame volvemos al principio 
     76                if (mosaicChanged) 
     77                { 
     78                        Log("-Updating\n"); 
     79 
     80                        //Nos recorremos los videos 
     81                        for (it=lstVideos.begin();it!=lstVideos.end();it++) 
     82                        { 
     83                                //Obtenemos el indice y el video  
     84                                id = (*it).first; 
     85                                video = (*it).second; 
     86 
     87                                //Colocamos el frame 
     88                                video->input->SetFrame(mosaic,mosaicTotalWidth,mosaicTotalHeight); 
     89                        } 
     90                } 
     91 
     92                //Reset 
     93                mosaicChanged = false; 
     94 
     95                //Desprotege la lista 
     96                lstVideosUse.DecUse(); 
     97 
    7298                //Esperamos que nos seƱalicen 
    7399                pthread_cond_wait(&mixVideoCond,&mixVideoMutex); 
    74  
    75                 //Iniciamos 
    76                 mosaicChanged = false; 
    77100 
    78101                //Protegemos la lista 
     
    99122                //Desbloqueamos 
    100123                pthread_mutex_unlock(&mixVideoMutex); 
    101  
    102                 //Si no ha cambiado el frame volvemos al principio 
    103                 if (mosaicChanged) 
    104                 { 
    105                         //Nos recorremos los videos 
    106                         for (it=lstVideos.begin();it!=lstVideos.end();it++) 
    107                         { 
    108                                 //Obtenemos el indice y el video  
    109                                 id = (*it).first; 
    110                                 video = (*it).second; 
    111  
    112                                 //Colocamos el frame 
    113                                 video->input->SetFrame(mosaic,mosaicTotalWidth,mosaicTotalHeight); 
    114                         } 
    115                 } 
    116  
     124                         
    117125                //Desprotege la lista 
    118126                lstVideosUse.DecUse(); 
  • media/src/videostream.cpp

    r2 r4  
    5858        switch(codec) 
    5959        { 
    60                 case H263
     60                case H263_1998
    6161                        videoQuality=1; 
    6262                        videoFillLevel=6; 
     
    131131        switch(codec) 
    132132        { 
    133                 case H263
     133                case H263_1998
    134134                        return 1; 
    135135        } 
     
    254254        Log("-StartReceiving Video [%d]\n",recVideoPort); 
    255255 
    256         return 1
     256        return recVideoPort
    257257} 
    258258 
     
    404404        gettimeofday(&lastCaptureTime,NULL); 
    405405 
     406        //Started 
     407        Log("-Sending video\n"); 
     408 
    406409        //Mientras tengamos que capturar 
    407410        while(sendingVideo) 
     
    409412                //Nos quedamos con el puntero antes de que lo cambien 
    410413                pic=videoInput->GrabFrame(); 
     414        Log("-PIC\n"); 
    411415 
    412416                //Si es nulo 
     
    436440                                bitRateControl=0; 
    437441                } 
     442        Log("-NEC\n"); 
    438443 
    439444                //Procesamos el frame 
    440445                videoEncoder->EncodeFrame(pic,videoInput->GetBufferSize()); 
     446        Log("-ENC\n"); 
    441447 
    442448                //Actualizamos el timepod e captura y codificacion del frame 
     
    710716                        encoder = (VideoEncoder*) new Mpeg4Encoder(videoQuality,videoFillLevel); 
    711717                        break; 
    712                 case H263
     718                case H263_1998
    713719                        encoder = (VideoEncoder*) new H263Encoder(videoQuality,videoFillLevel); 
    714720                        break; 
     
    733739        switch(type) 
    734740        { 
    735                 case H263
     741                case H263_1998
    736742                        videoDecoder = (VideoDecoder*) new H263Decoder(); 
     743                        break; 
     744                case H263_1996: 
     745                        videoDecoder = (VideoDecoder*) new H263Decoder1996(); 
    737746                        break; 
    738747                case MPEG4: 
  • media/src/xmlrpcserver.cpp

    r1 r4  
    2222 
    2323        //Le pasamos como nombre un puntero a nosotros mismos 
    24         sprintf(name,"%d",this);       
     24        sprintf(name,"0x%x",this);     
    2525 
    2626        //Creamos el servidor 
     
    5353int XmlRpcServer::Run() 
    5454{ 
    55         Log(">Run [%d]\n",this); 
     55        Log(">Run [0x%x]\n",this); 
    5656 
    5757        //Vamos a buscar en orden inverso 
     
    9696{ 
    9797        //Obtenemos el servidor 
    98         XmlRpcServer *serv = (XmlRpcServer *)atoi(r->server->name); 
     98        XmlRpcServer *serv; 
     99 
     100        //Get pointer 
     101        sscanf(r->server->name,"%x", &serv); 
    99102 
    100103        //Procesamos la llamada 
     
    133136/************************************** 
    134137* GetBody 
    135 *     Devuelve el body de una peticion 
     138      Devuelve el body de una peticion 
    136139**************************************/ 
    137140int XmlRpcServer::GetBody(TSession *r,char *body,short bodyLen) 
Copyright 2006 - Sergio García Murillo
Powered by Trac - Edgewall Software