⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 h323.h

📁 这是一个OPENH323中的MCU程序
💻 H
📖 第 1 页 / 共 2 页
字号:
/*
 * mcu.h
 *
 * H323 routines for a simple MCU
 *
 * Copyright (C) 1993-1998 Equivalence Pty. Ltd.
 * Copyright (C) 2006 Post Increment
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 *
 * The Original Code is Portable Windows Library.
 *
 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
 *
 * Portions of ths code were written by by Post Increment (http://www.postincrement.com) 
 * with the assistance of funding from Stonevoice, slc. http://www.stonevoice.com
 *
 * Portions of this code were written by Post Increment (http://www.postincrement.com) 
 * with the assistance of funding from Citron Networks (http://www.citron.com.tw)
 *
 * Contributor(s): Derek J Smithies (derek@indranet.co.nz)
 *                 Craig Southeren (craig@postincrement.com)
 *
 * $Log: h323.h,v $
 * Revision 1.1  2007/10/17 19:44:30  shorne
 * Initial Commit
 *
 * Revision 2.6.2.1  2007/08/16 20:29:01  shorne
 * Better Gatekeeper anf Gateway prefix support
 *
 * Revision 2.6  2006/08/02 06:24:53  csoutheren
 * Add provision for recording input audio
 *
 * Revision 2.5  2006/07/21 08:01:40  csoutheren
 * Fixed conference member detect
 * Re-factored video mixer code slightly
 *
 * Revision 2.4  2006/07/21 05:52:51  csoutheren
 * Add flag to indicate if remote endpoint is an MCU
 *
 * Revision 2.3  2006/07/21 05:08:03  csoutheren
 * Stability fixes and more inline documentation
 * Thanks to Paolo Amadini of Stonevoice
 *
 * Revision 2.2  2006/06/21 06:11:36  csoutheren
 * Fixes for latest pwlib
 *
 * Revision 2.1  2006/06/09 04:39:59  csoutheren
 * Migrated VideoBranch to main trunk
 *
 * Revision 1.1.2.6  2006/05/31 08:48:02  csoutheren
 * Fixed crash on second call when entry/exit files do not exist
 * Fix crash when Cisco HOLD used. Thanks to Christian Bongiovanni of Stonevoice
 *
 * Revision 1.1.2.5  2006/04/26 13:09:08  csoutheren
 * Fix problem when connecting file not available
 * Add optional time limit for rooms
 *
 * Revision 1.1.2.4  2006/04/06 08:20:29  csoutheren
 * Retyped conference member identifier to epxlicit type
 * Added support for H.245 terminal added and terminal left
 *
 * Revision 1.1.2.3  2006/04/06 01:11:16  csoutheren
 * Latest sources include
 *   - premedia blanking and optional image display
 *   - ablity to defer conference join for authentication if required
 *   - more bulletproofing on conference join
 *   - new video copy/fill functions
 *
 * Revision 1.3  2006/04/04 08:18:11  craigs
 * Latest version with titling and fixed PINs
 *
 * Revision 1.2  2006/04/03 12:52:54  craigs
 * Add GUI switch for custom mixer
 * Add fix for QCIF pre-media frame
 * Add start of code for room switch
 *
 * Revision 1.1  2006/03/31 07:36:12  craigs
 * New version with PINs and premedia blanking
 *
 * Revision 1.1.2.1  2006/03/28 05:13:38  csoutheren
 * Normalised file headers
 * Fixed problem with QCIF video
 * Seperated H.323 and MCU process functions into seperate files
 *
 */

#ifndef _OpenMCU_H323_H
#define _OpenMCU_H323_H

#ifdef _WIN32
#pragma warning(disable:4786)
#endif

#include <ptlib.h>
#include <ptlib/videoio.h>
#include <opalwavfile.h>

#include "config.h"
class OpenMCUH323EndPoint : public H323EndPoint
{
  PCLASSINFO(OpenMCUH323EndPoint, H323EndPoint);

  public:
    OpenMCUH323EndPoint(ConferenceManager & conferenceManager);
    
    PString IncomingConferenceRequest(H323Connection & connection, 
                                      const H323SignalPDU & setupPDU);

    BOOL OutgoingConferenceRequest(const PString & room);

    // overrides from H323EndPoint
    virtual H323Connection * CreateConnection(unsigned callReference,void * userData,H323Transport * transport,H323SignalPDU * setupPDU);
    virtual void TranslateTCPAddress(PIPSocket::Address &localAddr, const PIPSocket::Address &remoteAddr);

    BOOL behind_masq;
    PIPSocket::Address *masqAddressPtr;

    // new functions
    void Initialise(PConfig & cfg, PConfigPage * rsrc);

    PString GetRoomStatus(const PString & block);
    PString GetMonitorText();

    ConferenceManager & GetConferenceManager()
    { return conferenceManager; }

#if OPENMCU_VIDEO
    unsigned GetVideoTxQuality() const
    { return videoTxQuality; }

    unsigned GetVideoFrameRate() const
    { return videoRate; }
#endif

  protected:
#if OPENMCU_VIDEO
    BOOL enableVideo;
    unsigned videoRate;
    unsigned videoTxQuality;
#endif
	
	PString gkAlias;
	PStringList PrefixList;
	PStringList AliasList;


  protected:
    ConferenceManager & conferenceManager;
};

////////////////////////////////////////////////////

class OpenMCUH323Connection;

class OutgoingAudio : public PChannel
{
  PCLASSINFO(OutgoingAudio, PChannel);

  public:
    OutgoingAudio(H323EndPoint & ep, OpenMCUH323Connection & conn);
    
    BOOL Read(void * buffer, PINDEX amount);
    BOOL Close();

  protected:
    void CreateSilence(void * buffer, PINDEX amount);

    H323EndPoint & ep;
    OpenMCUH323Connection & conn;

    PAdaptiveDelay delay;
    PMutex audioChanMutex;
};

////////////////////////////////////////////////////

class IncomingAudio : public PChannel
{
  PCLASSINFO(IncomingAudio, PChannel);

  public:
    IncomingAudio(H323EndPoint & ep, OpenMCUH323Connection & conn);

    BOOL Write(const void * buffer, PINDEX amount);
    BOOL Close();

  protected:
    H323EndPoint & ep;
    OpenMCUH323Connection & conn;
    PMutex audioChanMutex;
    PAdaptiveDelay delay;
};

////////////////////////////////////////////////////

class NotifyH245Thread : public PThread
{
  public:
    NotifyH245Thread(Conference & conference, BOOL _join, ConferenceMember * _memberToIgnore);
    void Main();

  protected:
    BOOL join;
    ConferenceMember * memberToIgnore;
    PStringArray tokens;
    int mcuNumber;
    int terminalIdToSend;
};

////////////////////////////////////////////////////

class H323Connection_ConferenceMember;
class PVideoInputDevice_OpenMCU;
class PVideoOutputDevice_OpenMCU;

class OpenMCUH323Connection : public H323Connection
{
  PCLASSINFO(OpenMCUH323Connection, H323Connection);

  public:
    OpenMCUH323Connection(OpenMCUH323EndPoint &, unsigned, void *);
    ~OpenMCUH323Connection();

    virtual void LeaveConference();

    // overrides from H323Connection
    virtual BOOL OpenAudioChannel(BOOL, unsigned,   H323AudioCodec & codec);
#if OPENMCU_VIDEO
    virtual BOOL OpenVideoChannel(BOOL isEncoding, H323VideoCodec & codec);
#endif
		virtual void CleanUpOnCallEnd();
    virtual void OnEstablished();
    virtual AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &);
    virtual void OnUserInputString(const PString & value);
    virtual BOOL OnReceivedSignalSetup(const H323SignalPDU & setupPDU);
    virtual BOOL OnReceivedCallProceeding(const H323SignalPDU & proceedingPDU);

    virtual BOOL OnIncomingAudio(const void * buffer, PINDEX amount);
    virtual BOOL OnOutgoingAudio(void * buffer, PINDEX amount);
    virtual PString GetAudioTransmitCodecName() const { return audioTransmitCodecName; }
    virtual PString GetAudioReceiveCodecName() const  { return audioReceiveCodecName; }
    virtual PString GetRemoteName() const             { return remoteName; }

#if OPENMCU_VIDEO
    virtual BOOL OnIncomingVideo(const void * buffer, int width, int height, PINDEX amount);
    virtual BOOL OnOutgoingVideo(void * buffer, int width, int height, PINDEX & amount);
    virtual PString GetVideoTransmitCodecName() const { return videoTransmitCodecName; }
    virtual PString GetVideoReceiveCodecName() const  { return videoReceiveCodecName; }
    virtual BOOL GetPreMediaFrame(void * buffer, int width, int height, PINDEX & amount);
#endif

  protected:
    virtual void LogCall(const BOOL accepted = TRUE);
    virtual void JoinConference(const PString & room);

#if OPENMCU_VIDEO
    virtual BOOL InitGrabber(PVideoInputDevice  * grabber, int frameWidth, int frameHeight);
#endif

    PMutex connMutex;
    OpenMCUH323EndPoint & ep;

    // Name of the room to join when the welcome procedure ends.
    //  This is usually initialized when the call is answered,
    //  before the welcome procedure begins.
    PString requestedRoom;

    // Room the connection is joined to. It is NULL before the
    //  welcome procedure ends, or after the member is disconnected
    //  from the conference.
    Conference * conference;

    // Object used to treat the connection as a conference member.
    //  It is NULL before the connection is joined to the conference,
    //  or after the member is disconnected from the conference.
    H323Connection_ConferenceMember * conferenceMember;

    // Valid states for the welcome procedure. Note that new states may
    //  be added because the procedure can be customized by subclassing.
    enum WelcomeStates {
      // Reserved, never switch to this state
      NotStartedYet,

      // First state, by default jumps to PlayingConnecting
      PlayingWelcome,

      // Plays connecting wave file, then jumps to CompleteConnection
      PlayingConnecting,

      // Jumping here causes the connection to be joined to requestedRoom
      CompleteConnection,

      // The system jumps here if the join to the conference fails
      JoinFailed,

      // The system jumps here when the member is disconnected
      ConferenceEnded,

      // Use this as the starting value for custom sates in subclasses
      CustomWelcome_FirstUsableValue
    };

    // This is the current state of the welcome procedure. It is not
    //  declared using type WelcomeStates to allow the use of custom
    //  enumerated values.
    int welcomeState;

    // Use this function to change the current state. This call fires
    //  the OnWelcomeStateChanged callback immediately.
    void ChangeWelcomeState(int newState);

    // Call this function during the OnWelcomeStateChanged callback
    //  to play a new wave file during the welcome procedure. If
    //  useTheFile is FALSE, fileToPlay is empty or the file does
    //  not exist, the currently playing wave file is stopped and
    //  the OnWelcomeWaveEnded callback will be called anyway (as
    //  if an empty wave file has been played).
    void PlayWelcomeFile(BOOL useTheFile, PFilePath & fileToPlay);

    // Called whenever the current state changes. Use welcomeState
    //  to know the current (new) state.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -