00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef OPAL_H323_CHANNELS_H
00035 #define OPAL_H323_CHANNELS_H
00036
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040
00041 #include <opal/buildopts.h>
00042
00043 #if OPAL_H323
00044
00045 #include <rtp/rtp.h>
00046 #include <h323/transaddr.h>
00047 #include <opal/mediastrm.h>
00048
00049
00050 class H245_OpenLogicalChannel;
00051 class H245_OpenLogicalChannelAck;
00052 class H245_OpenLogicalChannel_forwardLogicalChannelParameters;
00053 class H245_OpenLogicalChannel_reverseLogicalChannelParameters;
00054 class H245_H2250LogicalChannelParameters;
00055 class H245_H2250LogicalChannelAckParameters;
00056 class H245_MiscellaneousCommand_type;
00057 class H245_MiscellaneousIndication_type;
00058
00059 class H323EndPoint;
00060 class H323Connection;
00061 class H323Capability;
00062 class H323_RTP_Session;
00063
00064
00066
00070 class H323ChannelNumber : public PObject
00071 {
00072 PCLASSINFO(H323ChannelNumber, PObject);
00073
00074 public:
00075 H323ChannelNumber() { number = 0; fromRemote = PFalse; }
00076 H323ChannelNumber(unsigned number, PBoolean fromRemote);
00077
00078 virtual PObject * Clone() const;
00079 virtual PINDEX HashFunction() const;
00080 virtual void PrintOn(ostream & strm) const;
00081 virtual Comparison Compare(const PObject & obj) const;
00082
00083 H323ChannelNumber & operator++(int);
00084 operator unsigned() const { return number; }
00085 PBoolean IsFromRemote() const { return fromRemote; }
00086
00087 protected:
00088 unsigned number;
00089 PBoolean fromRemote;
00090 };
00091
00092
00099 class H323Channel : public PObject
00100 {
00101 PCLASSINFO(H323Channel, PObject);
00102
00103 public:
00108 H323Channel(
00109 H323Connection & connection,
00110 const H323Capability & capability
00111 );
00112
00117 ~H323Channel();
00119
00122 virtual void PrintOn(
00123 ostream & strm
00124 ) const;
00126
00129 enum Directions {
00130 IsBidirectional,
00131 IsTransmitter,
00132 IsReceiver,
00133 NumDirections
00134 };
00135 #if PTRACING
00136 friend ostream & operator<<(ostream & out, Directions dir);
00137 #endif
00138
00143 virtual Directions GetDirection() const = 0;
00144
00150 virtual unsigned GetSessionID() const;
00151
00158 virtual PBoolean GetMediaTransportAddress(
00159 OpalTransportAddress & data,
00160 OpalTransportAddress & control
00161 ) const;
00162
00170 virtual PBoolean SetInitialBandwidth() = 0;
00171
00176 virtual PBoolean Open();
00177
00180 virtual PBoolean Start() = 0;
00181
00184 virtual void Close();
00185
00188 PBoolean IsOpen() const { return opened && !terminating; }
00189
00197 virtual OpalMediaStreamPtr GetMediaStream() const;
00198
00199
00202 virtual PBoolean OnSendingPDU(
00203 H245_OpenLogicalChannel & openPDU
00204 ) const = 0;
00205
00211 virtual void OnSendOpenAck(
00212 const H245_OpenLogicalChannel & open,
00213 H245_OpenLogicalChannelAck & ack
00214 ) const;
00215
00222 virtual PBoolean OnReceivedPDU(
00223 const H245_OpenLogicalChannel & pdu,
00224 unsigned & errorCode
00225 );
00226
00233 virtual PBoolean OnReceivedAckPDU(
00234 const H245_OpenLogicalChannelAck & pdu
00235 );
00236
00240 virtual void OnFlowControl(
00241 long bitRateRestriction
00242 );
00243
00247 virtual void OnMiscellaneousCommand(
00248 const H245_MiscellaneousCommand_type & type
00249 );
00250
00254 virtual void OnMiscellaneousIndication(
00255 const H245_MiscellaneousIndication_type & type
00256 );
00257
00261 virtual void OnJitterIndication(
00262 DWORD jitter,
00263 int skippedFrameCount,
00264 int additionalBuffer
00265 );
00267
00272 const H323ChannelNumber & GetNumber() const { return number; }
00273
00276 void SetNumber(const H323ChannelNumber & num) { number = num; }
00277
00280 const H323ChannelNumber & GetReverseChannel() const { return reverseChannel; }
00281
00284 void SetReverseChannel(const H323ChannelNumber & num) { reverseChannel = num; }
00285
00288 unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00289
00292 PBoolean SetBandwidthUsed(
00293 unsigned bandwidth
00294 );
00295
00298 const H323Capability & GetCapability() const { return *capability; }
00299
00308 PBoolean IsPaused() const { return paused; }
00309
00318 void SetPause(
00319 PBoolean pause
00320 ) { paused = pause; }
00322
00323 virtual void OnMediaCommand(OpalMediaCommand &) { }
00324
00325 protected:
00326 H323EndPoint & endpoint;
00327 H323Connection & connection;
00328 H323Capability * capability;
00329 H323ChannelNumber number;
00330 H323ChannelNumber reverseChannel;
00331 PBoolean opened;
00332 PBoolean paused;
00333 PBoolean terminating;
00334
00335 private:
00336 unsigned bandwidthUsed;
00337 };
00338
00339
00340 PLIST(H323LogicalChannelList, H323Channel);
00341
00342
00343
00350 class H323UnidirectionalChannel : public H323Channel
00351 {
00352 PCLASSINFO(H323UnidirectionalChannel, H323Channel);
00353
00354 public:
00359 H323UnidirectionalChannel(
00360 H323Connection & connection,
00361 const H323Capability & capability,
00362 Directions direction
00363 );
00364
00367 ~H323UnidirectionalChannel();
00369
00376 virtual Directions GetDirection() const;
00377
00385 virtual PBoolean SetInitialBandwidth();
00386
00389 virtual PBoolean Open();
00390
00395 virtual PBoolean Start();
00396
00399 virtual void Close();
00400
00404 virtual void OnMiscellaneousCommand(
00405 const H245_MiscellaneousCommand_type & type
00406 );
00408
00414 virtual OpalMediaStreamPtr GetMediaStream() const;
00416
00417 void OnMediaCommand(OpalMediaCommand & command);
00418
00419 protected:
00420 bool receiver;
00421 OpalMediaStreamPtr mediaStream;
00422 };
00423
00424
00431 class H323BidirectionalChannel : public H323Channel
00432 {
00433 PCLASSINFO(H323BidirectionalChannel, H323Channel);
00434
00435 public:
00440 H323BidirectionalChannel(
00441 H323Connection & connection,
00442 const H323Capability & capability
00443 );
00445
00452 virtual Directions GetDirection() const;
00453
00458 virtual PBoolean Start();
00460 };
00461
00462
00464
00467 class H323_RealTimeChannel : public H323UnidirectionalChannel
00468 {
00469 PCLASSINFO(H323_RealTimeChannel, H323UnidirectionalChannel);
00470
00471 public:
00476 H323_RealTimeChannel(
00477 H323Connection & connection,
00478 const H323Capability & capability,
00479 Directions direction
00480 );
00482
00487 virtual PBoolean OnSendingPDU(
00488 H245_OpenLogicalChannel & openPDU
00489 ) const;
00490
00494 virtual void OnSendOpenAck(
00495 const H245_OpenLogicalChannel & open,
00496 H245_OpenLogicalChannelAck & ack
00497 ) const;
00498
00506 virtual PBoolean OnReceivedPDU(
00507 const H245_OpenLogicalChannel & pdu,
00508 unsigned & errorCode
00509 );
00510
00518 virtual PBoolean OnReceivedAckPDU(
00519 const H245_OpenLogicalChannelAck & pdu
00520 );
00522
00527 virtual PBoolean OnSendingPDU(
00528 H245_H2250LogicalChannelParameters & param
00529 ) const = 0;
00530
00534 virtual void OnSendOpenAck(
00535 H245_H2250LogicalChannelAckParameters & param
00536 ) const = 0;
00537
00544 virtual PBoolean OnReceivedPDU(
00545 const H245_H2250LogicalChannelParameters & param,
00546 unsigned & errorCode
00547 ) = 0;
00548
00555 virtual PBoolean OnReceivedAckPDU(
00556 const H245_H2250LogicalChannelAckParameters & param
00557 ) = 0;
00558
00561 virtual PBoolean SetDynamicRTPPayloadType(
00562 int newType
00563 );
00564
00565 RTP_DataFrame::PayloadTypes GetDynamicRTPPayloadType() const { return rtpPayloadType; }
00567
00568 protected:
00569 RTP_DataFrame::PayloadTypes rtpPayloadType;
00570 };
00571
00572
00574
00577 class H323_RTPChannel : public H323_RealTimeChannel
00578 {
00579 PCLASSINFO(H323_RTPChannel, H323_RealTimeChannel);
00580
00581 public:
00586 H323_RTPChannel(
00587 H323Connection & connection,
00588 const H323Capability & capability,
00589 Directions direction,
00590 RTP_Session & rtp
00591 );
00592
00594 ~H323_RTPChannel();
00596
00603 virtual unsigned GetSessionID() const;
00605
00610 virtual PBoolean OnSendingPDU(
00611 H245_H2250LogicalChannelParameters & param
00612 ) const;
00613
00617 virtual void OnSendOpenAck(
00618 H245_H2250LogicalChannelAckParameters & param
00619 ) const;
00620
00627 virtual PBoolean OnReceivedPDU(
00628 const H245_H2250LogicalChannelParameters & param,
00629 unsigned & errorCode
00630 );
00631
00638 virtual PBoolean OnReceivedAckPDU(
00639 const H245_H2250LogicalChannelAckParameters & param
00640 );
00642
00643 protected:
00644 RTP_Session & rtpSession;
00645 H323_RTP_Session & rtpCallbacks;
00646 };
00647
00648
00650
00654 class H323_ExternalRTPChannel : public H323_RealTimeChannel
00655 {
00656 PCLASSINFO(H323_ExternalRTPChannel, H323_RealTimeChannel);
00657
00658 public:
00663 H323_ExternalRTPChannel(
00664 H323Connection & connection,
00665 const H323Capability & capability,
00666 Directions direction,
00667 unsigned sessionID
00668 );
00671 H323_ExternalRTPChannel(
00672 H323Connection & connection,
00673 const H323Capability & capability,
00674 Directions direction,
00675 unsigned sessionID,
00676 const H323TransportAddress & data,
00677 const H323TransportAddress & control
00678 );
00681 H323_ExternalRTPChannel(
00682 H323Connection & connection,
00683 const H323Capability & capability,
00684 Directions direction,
00685 unsigned sessionID,
00686 const PIPSocket::Address & ip,
00687 WORD dataPort
00688 );
00690
00697 virtual unsigned GetSessionID() const;
00698
00705 virtual PBoolean GetMediaTransportAddress(
00706 OpalTransportAddress & data,
00707 OpalTransportAddress & control
00708 ) const;
00709
00712 virtual PBoolean Start();
00713
00720 virtual void Receive();
00721
00728 virtual void Transmit();
00730
00735 virtual PBoolean OnSendingPDU(
00736 H245_H2250LogicalChannelParameters & param
00737 ) const;
00738
00742 virtual void OnSendOpenAck(
00743 H245_H2250LogicalChannelAckParameters & param
00744 ) const;
00745
00752 virtual PBoolean OnReceivedPDU(
00753 const H245_H2250LogicalChannelParameters & param,
00754 unsigned & errorCode
00755 );
00756
00763 virtual PBoolean OnReceivedAckPDU(
00764 const H245_H2250LogicalChannelAckParameters & param
00765 );
00767
00768 void SetExternalAddress(
00769 const H323TransportAddress & data,
00770 const H323TransportAddress & control
00771 );
00772
00773 const H323TransportAddress & GetRemoteMediaAddress() const { return remoteMediaAddress; }
00774 const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; }
00775
00776 PBoolean GetRemoteAddress(
00777 PIPSocket::Address & ip,
00778 WORD & dataPort
00779 ) const;
00780
00781 protected:
00782 void Construct(H323Connection & conn, unsigned id);
00783
00784 unsigned sessionID;
00785 H323TransportAddress externalMediaAddress;
00786 H323TransportAddress externalMediaControlAddress;
00787 H323TransportAddress remoteMediaAddress;
00788 H323TransportAddress remoteMediaControlAddress;
00789 };
00790
00791
00793
00800 class H323DataChannel : public H323UnidirectionalChannel
00801 {
00802 PCLASSINFO(H323DataChannel, H323UnidirectionalChannel);
00803
00804 public:
00809 H323DataChannel(
00810 H323Connection & connection,
00811 const H323Capability & capability,
00812 Directions direction,
00813 unsigned sessionID
00814 );
00815
00818 ~H323DataChannel();
00820
00825 virtual void Close();
00826
00831 virtual unsigned GetSessionID() const;
00832
00835 virtual PBoolean OnSendingPDU(
00836 H245_OpenLogicalChannel & openPDU
00837 ) const;
00838
00842 virtual void OnSendOpenAck(
00843 const H245_OpenLogicalChannel & open,
00844 H245_OpenLogicalChannelAck & ack
00845 ) const;
00846
00854 virtual PBoolean OnReceivedPDU(
00855 const H245_OpenLogicalChannel & pdu,
00856 unsigned & errorCode
00857 );
00858
00866 virtual PBoolean OnReceivedAckPDU(
00867 const H245_OpenLogicalChannelAck & pdu
00868 );
00870
00879 virtual PBoolean CreateListener();
00880
00888 virtual PBoolean CreateTransport();
00890
00891 protected:
00892 unsigned sessionID;
00893 H323Listener * listener;
00894 PBoolean autoDeleteListener;
00895 H323Transport * transport;
00896 PBoolean autoDeleteTransport;
00897 PBoolean separateReverseChannel;
00898 };
00899
00900
00901 #endif // OPAL_H323
00902
00903 #endif // OPAL_H323_CHANNELS_H
00904
00905