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 bool OnMediaCommand(const 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
00561 RTP_DataFrame::PayloadTypes GetDynamicRTPPayloadType() const;
00563 };
00564
00565
00567
00570 class H323_RTPChannel : public H323_RealTimeChannel
00571 {
00572 PCLASSINFO(H323_RTPChannel, H323_RealTimeChannel);
00573
00574 public:
00579 H323_RTPChannel(
00580 H323Connection & connection,
00581 const H323Capability & capability,
00582 Directions direction,
00583 RTP_Session & rtp
00584 );
00585
00587 ~H323_RTPChannel();
00589
00596 virtual unsigned GetSessionID() const;
00597
00604 virtual bool SetSessionID(
00605 unsigned sessionID
00606 );
00608
00613 virtual PBoolean OnSendingPDU(
00614 H245_H2250LogicalChannelParameters & param
00615 ) const;
00616
00620 virtual void OnSendOpenAck(
00621 H245_H2250LogicalChannelAckParameters & param
00622 ) const;
00623
00630 virtual PBoolean OnReceivedPDU(
00631 const H245_H2250LogicalChannelParameters & param,
00632 unsigned & errorCode
00633 );
00634
00641 virtual PBoolean OnReceivedAckPDU(
00642 const H245_H2250LogicalChannelAckParameters & param
00643 );
00645
00646 protected:
00647 RTP_Session & rtpSession;
00648 H323_RTP_Session & rtpCallbacks;
00649 };
00650
00651
00653
00657 class H323_ExternalRTPChannel : public H323_RealTimeChannel
00658 {
00659 PCLASSINFO(H323_ExternalRTPChannel, H323_RealTimeChannel);
00660
00661 public:
00666 H323_ExternalRTPChannel(
00667 H323Connection & connection,
00668 const H323Capability & capability,
00669 Directions direction,
00670 unsigned sessionID
00671 );
00674 H323_ExternalRTPChannel(
00675 H323Connection & connection,
00676 const H323Capability & capability,
00677 Directions direction,
00678 unsigned sessionID,
00679 const H323TransportAddress & data,
00680 const H323TransportAddress & control
00681 );
00684 H323_ExternalRTPChannel(
00685 H323Connection & connection,
00686 const H323Capability & capability,
00687 Directions direction,
00688 unsigned sessionID,
00689 const PIPSocket::Address & ip,
00690 WORD dataPort
00691 );
00693
00700 virtual unsigned GetSessionID() const;
00701
00708 virtual PBoolean GetMediaTransportAddress(
00709 OpalTransportAddress & data,
00710 OpalTransportAddress & control
00711 ) const;
00712
00715 virtual PBoolean Start();
00716
00723 virtual void Receive();
00724
00731 virtual void Transmit();
00733
00738 virtual PBoolean OnSendingPDU(
00739 H245_H2250LogicalChannelParameters & param
00740 ) const;
00741
00745 virtual void OnSendOpenAck(
00746 H245_H2250LogicalChannelAckParameters & param
00747 ) const;
00748
00755 virtual PBoolean OnReceivedPDU(
00756 const H245_H2250LogicalChannelParameters & param,
00757 unsigned & errorCode
00758 );
00759
00766 virtual PBoolean OnReceivedAckPDU(
00767 const H245_H2250LogicalChannelAckParameters & param
00768 );
00770
00771 void SetExternalAddress(
00772 const H323TransportAddress & data,
00773 const H323TransportAddress & control
00774 );
00775
00776 const H323TransportAddress & GetRemoteMediaAddress() const { return remoteMediaAddress; }
00777 const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; }
00778
00779 PBoolean GetRemoteAddress(
00780 PIPSocket::Address & ip,
00781 WORD & dataPort
00782 ) const;
00783
00784 protected:
00785 void Construct(H323Connection & conn, unsigned id);
00786
00787 unsigned sessionID;
00788 H323TransportAddress externalMediaAddress;
00789 H323TransportAddress externalMediaControlAddress;
00790 H323TransportAddress remoteMediaAddress;
00791 H323TransportAddress remoteMediaControlAddress;
00792 };
00793
00794
00796
00803 class H323DataChannel : public H323UnidirectionalChannel
00804 {
00805 PCLASSINFO(H323DataChannel, H323UnidirectionalChannel);
00806
00807 public:
00812 H323DataChannel(
00813 H323Connection & connection,
00814 const H323Capability & capability,
00815 Directions direction,
00816 unsigned sessionID
00817 );
00818
00821 ~H323DataChannel();
00823
00830 virtual unsigned GetSessionID() const;
00831
00834 virtual PBoolean OnSendingPDU(
00835 H245_OpenLogicalChannel & openPDU
00836 ) const;
00837
00841 virtual void OnSendOpenAck(
00842 const H245_OpenLogicalChannel & open,
00843 H245_OpenLogicalChannelAck & ack
00844 ) const;
00845
00853 virtual PBoolean OnReceivedPDU(
00854 const H245_OpenLogicalChannel & pdu,
00855 unsigned & errorCode
00856 );
00857
00865 virtual PBoolean OnReceivedAckPDU(
00866 const H245_OpenLogicalChannelAck & pdu
00867 );
00869
00878 virtual PBoolean CreateListener();
00879
00887 virtual PBoolean CreateTransport();
00889
00890 protected:
00891 virtual void InternalClose();
00892
00893 unsigned sessionID;
00894 H323Listener * listener;
00895 PBoolean autoDeleteListener;
00896 H323Transport * transport;
00897 PBoolean autoDeleteTransport;
00898 PBoolean separateReverseChannel;
00899 };
00900
00901
00902 #endif // OPAL_H323
00903
00904 #endif // OPAL_H323_CHANNELS_H
00905
00906