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 = false; }
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 bool SetSessionID(
00159 unsigned sessionID
00160 );
00161
00168 virtual PBoolean GetMediaTransportAddress(
00169 OpalTransportAddress & data,
00170 OpalTransportAddress & control
00171 ) const;
00172
00180 virtual PBoolean SetInitialBandwidth() = 0;
00181
00186 virtual PBoolean Open();
00187
00190 virtual PBoolean Start() = 0;
00191
00194 virtual void Close();
00195
00198 PBoolean IsOpen() const { return opened && m_terminating == 0; }
00199
00207 virtual OpalMediaStreamPtr GetMediaStream() const;
00208
00209
00212 virtual PBoolean OnSendingPDU(
00213 H245_OpenLogicalChannel & openPDU
00214 ) const = 0;
00215
00221 virtual void OnSendOpenAck(
00222 const H245_OpenLogicalChannel & open,
00223 H245_OpenLogicalChannelAck & ack
00224 ) const;
00225
00232 virtual PBoolean OnReceivedPDU(
00233 const H245_OpenLogicalChannel & pdu,
00234 unsigned & errorCode
00235 );
00236
00243 virtual PBoolean OnReceivedAckPDU(
00244 const H245_OpenLogicalChannelAck & pdu
00245 );
00246
00250 virtual void OnFlowControl(
00251 long bitRateRestriction
00252 );
00253
00257 virtual void OnMiscellaneousCommand(
00258 const H245_MiscellaneousCommand_type & type
00259 );
00260
00264 virtual void OnMiscellaneousIndication(
00265 const H245_MiscellaneousIndication_type & type
00266 );
00267
00271 virtual void OnJitterIndication(
00272 DWORD jitter,
00273 int skippedFrameCount,
00274 int additionalBuffer
00275 );
00277
00282 const H323ChannelNumber & GetNumber() const { return number; }
00283
00286 void SetNumber(const H323ChannelNumber & num) { number = num; }
00287
00290 const H323ChannelNumber & GetReverseChannel() const { return reverseChannel; }
00291
00294 void SetReverseChannel(const H323ChannelNumber & num) { reverseChannel = num; }
00295
00298 unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00299
00302 PBoolean SetBandwidthUsed(
00303 unsigned bandwidth
00304 );
00305
00308 const H323Capability & GetCapability() const { return *capability; }
00309
00318 PBoolean IsPaused() const { return paused; }
00319
00328 void SetPause(
00329 PBoolean pause
00330 ) { paused = pause; }
00332
00333 virtual void OnMediaCommand(OpalMediaCommand &);
00334
00335 protected:
00336 virtual void InternalClose();
00337
00338 H323EndPoint & endpoint;
00339 H323Connection & connection;
00340 H323Capability * capability;
00341 H323ChannelNumber number;
00342 H323ChannelNumber reverseChannel;
00343 bool opened;
00344 bool paused;
00345 PAtomicInteger m_terminating;
00346
00347 private:
00348 unsigned bandwidthUsed;
00349 };
00350
00351
00352 PLIST(H323LogicalChannelList, H323Channel);
00353
00354
00355
00362 class H323UnidirectionalChannel : public H323Channel
00363 {
00364 PCLASSINFO(H323UnidirectionalChannel, H323Channel);
00365
00366 public:
00371 H323UnidirectionalChannel(
00372 H323Connection & connection,
00373 const H323Capability & capability,
00374 Directions direction
00375 );
00376
00379 ~H323UnidirectionalChannel();
00381
00388 virtual Directions GetDirection() const;
00389
00397 virtual PBoolean SetInitialBandwidth();
00398
00401 virtual PBoolean Open();
00402
00407 virtual PBoolean Start();
00409
00415 virtual OpalMediaStreamPtr GetMediaStream() const;
00417
00418
00419 protected:
00420 virtual void InternalClose();
00421
00422 bool receiver;
00423 OpalMediaStreamPtr mediaStream;
00424 };
00425
00426
00433 class H323BidirectionalChannel : public H323Channel
00434 {
00435 PCLASSINFO(H323BidirectionalChannel, H323Channel);
00436
00437 public:
00442 H323BidirectionalChannel(
00443 H323Connection & connection,
00444 const H323Capability & capability
00445 );
00447
00454 virtual Directions GetDirection() const;
00455
00460 virtual PBoolean Start();
00462 };
00463
00464
00466
00469 class H323_RealTimeChannel : public H323UnidirectionalChannel
00470 {
00471 PCLASSINFO(H323_RealTimeChannel, H323UnidirectionalChannel);
00472
00473 public:
00478 H323_RealTimeChannel(
00479 H323Connection & connection,
00480 const H323Capability & capability,
00481 Directions direction
00482 );
00484
00489 virtual PBoolean OnSendingPDU(
00490 H245_OpenLogicalChannel & openPDU
00491 ) const;
00492
00496 virtual void OnSendOpenAck(
00497 const H245_OpenLogicalChannel & open,
00498 H245_OpenLogicalChannelAck & ack
00499 ) const;
00500
00508 virtual PBoolean OnReceivedPDU(
00509 const H245_OpenLogicalChannel & pdu,
00510 unsigned & errorCode
00511 );
00512
00520 virtual PBoolean OnReceivedAckPDU(
00521 const H245_OpenLogicalChannelAck & pdu
00522 );
00524
00529 virtual PBoolean OnSendingPDU(
00530 H245_H2250LogicalChannelParameters & param
00531 ) const;
00532
00536 virtual void OnSendOpenAck(
00537 H245_H2250LogicalChannelAckParameters & param
00538 ) const;
00539
00546 virtual PBoolean OnReceivedPDU(
00547 const H245_H2250LogicalChannelParameters & param,
00548 unsigned & errorCode
00549 );
00550
00557 virtual PBoolean OnReceivedAckPDU(
00558 const H245_H2250LogicalChannelAckParameters & param
00559 );
00560
00563 virtual PBoolean SetDynamicRTPPayloadType(
00564 int newType
00565 );
00566
00567 RTP_DataFrame::PayloadTypes GetDynamicRTPPayloadType() const { return rtpPayloadType; }
00569
00570 protected:
00571 RTP_DataFrame::PayloadTypes rtpPayloadType;
00572 };
00573
00574
00576
00579 class H323_RTPChannel : public H323_RealTimeChannel
00580 {
00581 PCLASSINFO(H323_RTPChannel, H323_RealTimeChannel);
00582
00583 public:
00588 H323_RTPChannel(
00589 H323Connection & connection,
00590 const H323Capability & capability,
00591 Directions direction,
00592 RTP_Session & rtp
00593 );
00594
00596 ~H323_RTPChannel();
00598
00605 virtual unsigned GetSessionID() const;
00606
00613 virtual bool SetSessionID(
00614 unsigned sessionID
00615 );
00617
00622 virtual PBoolean OnSendingPDU(
00623 H245_H2250LogicalChannelParameters & param
00624 ) const;
00625
00629 virtual void OnSendOpenAck(
00630 H245_H2250LogicalChannelAckParameters & param
00631 ) const;
00632
00639 virtual PBoolean OnReceivedPDU(
00640 const H245_H2250LogicalChannelParameters & param,
00641 unsigned & errorCode
00642 );
00643
00650 virtual PBoolean OnReceivedAckPDU(
00651 const H245_H2250LogicalChannelAckParameters & param
00652 );
00654
00655 protected:
00656 RTP_Session & rtpSession;
00657 H323_RTP_Session & rtpCallbacks;
00658 };
00659
00660
00662
00666 class H323_ExternalRTPChannel : public H323_RealTimeChannel
00667 {
00668 PCLASSINFO(H323_ExternalRTPChannel, H323_RealTimeChannel);
00669
00670 public:
00675 H323_ExternalRTPChannel(
00676 H323Connection & connection,
00677 const H323Capability & capability,
00678 Directions direction,
00679 unsigned sessionID
00680 );
00683 H323_ExternalRTPChannel(
00684 H323Connection & connection,
00685 const H323Capability & capability,
00686 Directions direction,
00687 unsigned sessionID,
00688 const H323TransportAddress & data,
00689 const H323TransportAddress & control
00690 );
00693 H323_ExternalRTPChannel(
00694 H323Connection & connection,
00695 const H323Capability & capability,
00696 Directions direction,
00697 unsigned sessionID,
00698 const PIPSocket::Address & ip,
00699 WORD dataPort
00700 );
00702
00709 virtual unsigned GetSessionID() const;
00710
00717 virtual PBoolean GetMediaTransportAddress(
00718 OpalTransportAddress & data,
00719 OpalTransportAddress & control
00720 ) const;
00721
00724 virtual PBoolean Start();
00725
00732 virtual void Receive();
00733
00740 virtual void Transmit();
00742
00747 virtual PBoolean OnSendingPDU(
00748 H245_H2250LogicalChannelParameters & param
00749 ) const;
00750
00754 virtual void OnSendOpenAck(
00755 H245_H2250LogicalChannelAckParameters & param
00756 ) const;
00757
00764 virtual PBoolean OnReceivedPDU(
00765 const H245_H2250LogicalChannelParameters & param,
00766 unsigned & errorCode
00767 );
00768
00775 virtual PBoolean OnReceivedAckPDU(
00776 const H245_H2250LogicalChannelAckParameters & param
00777 );
00779
00780 void SetExternalAddress(
00781 const H323TransportAddress & data,
00782 const H323TransportAddress & control
00783 );
00784
00785 const H323TransportAddress & GetRemoteMediaAddress() const { return remoteMediaAddress; }
00786 const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; }
00787
00788 PBoolean GetRemoteAddress(
00789 PIPSocket::Address & ip,
00790 WORD & dataPort
00791 ) const;
00792
00793 protected:
00794 void Construct(H323Connection & conn, unsigned id);
00795
00796 unsigned sessionID;
00797 H323TransportAddress externalMediaAddress;
00798 H323TransportAddress externalMediaControlAddress;
00799 H323TransportAddress remoteMediaAddress;
00800 H323TransportAddress remoteMediaControlAddress;
00801 };
00802
00803
00805
00812 class H323DataChannel : public H323UnidirectionalChannel
00813 {
00814 PCLASSINFO(H323DataChannel, H323UnidirectionalChannel);
00815
00816 public:
00821 H323DataChannel(
00822 H323Connection & connection,
00823 const H323Capability & capability,
00824 Directions direction,
00825 unsigned sessionID
00826 );
00827
00830 ~H323DataChannel();
00832
00839 virtual unsigned GetSessionID() const;
00840
00843 virtual PBoolean OnSendingPDU(
00844 H245_OpenLogicalChannel & openPDU
00845 ) const;
00846
00850 virtual void OnSendOpenAck(
00851 const H245_OpenLogicalChannel & open,
00852 H245_OpenLogicalChannelAck & ack
00853 ) const;
00854
00862 virtual PBoolean OnReceivedPDU(
00863 const H245_OpenLogicalChannel & pdu,
00864 unsigned & errorCode
00865 );
00866
00874 virtual PBoolean OnReceivedAckPDU(
00875 const H245_OpenLogicalChannelAck & pdu
00876 );
00878
00887 virtual PBoolean CreateListener();
00888
00896 virtual PBoolean CreateTransport();
00898
00899 protected:
00900 virtual void InternalClose();
00901
00902 unsigned sessionID;
00903 H323Listener * listener;
00904 PBoolean autoDeleteListener;
00905 H323Transport * transport;
00906 PBoolean autoDeleteTransport;
00907 PBoolean separateReverseChannel;
00908 };
00909
00910
00911 #endif // OPAL_H323
00912
00913 #endif // OPAL_H323_CHANNELS_H
00914
00915