Esempio n. 1
0
    static int InitialiseOPAL()
    {
      OpalMessageRef command;
      OpalMessageRef response;
      uint version;

      string OPALOptions = Opal_API.OPAL_PREFIX_H323  + " " +
                                    Opal_API.OPAL_PREFIX_SIP + " " +
                                    Opal_API.OPAL_PREFIX_IAX2 + " " +
#if LOCAL_MEDIA
                                    Opal_API.OPAL_PREFIX_LOCAL +
#else
                                    Opal_API.OPAL_PREFIX_PCSS +
#endif
                                    " " +
                                    Opal_API.OPAL_PREFIX_IVR +
                                    " TraceLevel=4 TraceFile=debugstream";

        ///////////////////////////////////////////////
        // Initialisation

        version = Opal_API.OPAL_C_API_VERSION;
  
        if (context.Initialise(OPALOptions, version) == version) 
        {
          Console.WriteLine("Could not initialise OPAL{0}", Environment.NewLine);
          return 0;
        }
  
        #if NULL
        // Test shut down and re-initialisation
        context.ShutDown();

        if (context.Initialise(OPALOptions, version) == version) 
        {
          Console.WriteLine("Could not reinitialise OPAL{0}", Environment.NewLine);
          return 0;
        }  
        #endif

        // General options
        command = new OpalMessageRef(Opal_API.OpalMessageType.OpalCmdSetGeneralParameters);  
        //command.m_param.m_general.m_audioRecordDevice = "Camera Microphone (2- Logitech";
        OpalParamGeneralRef m_general = command.GetGeneralParams();

        m_general.AutoRxMedia = m_general.AutoTxMedia = "audio";
        m_general.StunServer = "stun.voxgratia.org";
        m_general.MediaMask = "RFC4175*";

#if LOCAL_MEDIA
        m_general.MediaReadData = MyReadMediaData;
        m_general.MediaWriteData = MyWriteMediaData;
        m_general.MediaDataHeader = (uint)Opal_API.OpalMediaDataType.OpalMediaDataPayloadOnly;
#endif

        if ((response = MySendCommand(command, "Could not set general options")) == null)
          return 0;     
  
        // Options across all protocols
        command = new OpalMessageRef(Opal_API.OpalMessageType.OpalCmdSetProtocolParameters);
        OpalParamProtocolRef m_protocol = command.GetProtocolParams();

        m_protocol.UserName = "******";
        m_protocol.DisplayName = "Robert Jongbloed";
        m_protocol.InterfaceAddresses = "*";

        if ((response = MySendCommand(command, "Could not set protocol options")) == null)
          return 0; 

        command = new OpalMessageRef(Opal_API.OpalMessageType.OpalCmdSetProtocolParameters);
        m_protocol = command.GetProtocolParams();

        m_protocol.Prefix = "sip";
        m_protocol.DefaultOptions = "PRACK-Mode=0\nInitial-Offer=false";

        if ((response = MySendCommand(command, "Could not set SIP options")) == null)
          return 0;  

        return 1;
     }