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 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();
00408
00412 virtual void OnMiscellaneousCommand(
00413 const H245_MiscellaneousCommand_type & type
00414 );
00416
00422 virtual OpalMediaStreamPtr GetMediaStream() const;
00424
00425 void OnMediaCommand(OpalMediaCommand & command);
00426
00427 protected:
00428 virtual void InternalClose();
00429
00430 bool receiver;
00431 OpalMediaStreamPtr mediaStream;
00432 };
00433
00434
00441 class H323BidirectionalChannel : public H323Channel
00442 {
00443 PCLASSINFO(H323BidirectionalChannel, H323Channel);
00444
00445 public:
00450 H323BidirectionalChannel(
00451 H323Connection & connection,
00452 const H323Capability & capability
00453 );
00455
00462 virtual Directions GetDirection() const;
00463
00468 virtual PBoolean Start();
00470 };
00471
00472
00474
00477 class H323_RealTimeChannel : public H323UnidirectionalChannel
00478 {
00479 PCLASSINFO(H323_RealTimeChannel, H323UnidirectionalChannel);
00480
00481 public:
00486 H323_RealTimeChannel(
00487 H323Connection & connection,
00488 const H323Capability & capability,
00489 Directions direction
00490 );
00492
00497 virtual PBoolean OnSendingPDU(
00498 H245_OpenLogicalChannel & openPDU
00499 ) const;
00500
00504 virtual void OnSendOpenAck(
00505 const H245_OpenLogicalChannel & open,
00506 H245_OpenLogicalChannelAck & ack
00507 ) const;
00508
00516 virtual PBoolean OnReceivedPDU(
00517 const H245_OpenLogicalChannel & pdu,
00518 unsigned & errorCode
00519 );
00520
00528 virtual PBoolean OnReceivedAckPDU(
00529 const H245_OpenLogicalChannelAck & pdu
00530 );
00532
00537 virtual PBoolean OnSendingPDU(
00538 H245_H2250LogicalChannelParameters & param
00539 ) const;
00540
00544 virtual void OnSendOpenAck(
00545 H245_H2250LogicalChannelAckParameters & param
00546 ) const;
00547
00554 virtual PBoolean OnReceivedPDU(
00555 const H245_H2250LogicalChannelParameters & param,
00556 unsigned & errorCode
00557 );
00558
00565 virtual PBoolean OnReceivedAckPDU(
00566 const H245_H2250LogicalChannelAckParameters & param
00567 );
00568
00571 virtual PBoolean SetDynamicRTPPayloadType(
00572 int newType
00573 );
00574
00575 RTP_DataFrame::PayloadTypes GetDynamicRTPPayloadType() const { return rtpPayloadType; }
00577
00578 protected:
00579 RTP_DataFrame::PayloadTypes rtpPayloadType;
00580 };
00581
00582
00584
00587 class H323_RTPChannel : public H323_RealTimeChannel
00588 {
00589 PCLASSINFO(H323_RTPChannel, H323_RealTimeChannel);
00590
00591 public:
00596 H323_RTPChannel(
00597 H323Connection & connection,
00598 const H323Capability & capability,
00599 Directions direction,
00600 RTP_Session & rtp
00601 );
00602
00604 ~H323_RTPChannel();
00606
00613 virtual unsigned GetSessionID() const;
00614
00621 virtual bool SetSessionID(
00622 unsigned sessionID
00623 );
00625
00630 virtual PBoolean OnSendingPDU(
00631 H245_H2250LogicalChannelParameters & param
00632 ) const;
00633
00637 virtual void OnSendOpenAck(
00638 H245_H2250LogicalChannelAckParameters & param
00639 ) const;
00640
00647 virtual PBoolean OnReceivedPDU(
00648 const H245_H2250LogicalChannelParameters & param,
00649 unsigned & errorCode
00650 );
00651
00658 virtual PBoolean OnReceivedAckPDU(
00659 const H245_H2250LogicalChannelAckParameters & param
00660 );
00662
00663 protected:
00664 RTP_Session & rtpSession;
00665 H323_RTP_Session & rtpCallbacks;
00666 };
00667
00668
00670
00674 class H323_ExternalRTPChannel : public H323_RealTimeChannel
00675 {
00676 PCLASSINFO(H323_ExternalRTPChannel, H323_RealTimeChannel);
00677
00678 public:
00683 H323_ExternalRTPChannel(
00684 H323Connection & connection,
00685 const H323Capability & capability,
00686 Directions direction,
00687 unsigned sessionID
00688 );
00691 H323_ExternalRTPChannel(
00692 H323Connection & connection,
00693 const H323Capability & capability,
00694 Directions direction,
00695 unsigned sessionID,
00696 const H323TransportAddress & data,
00697 const H323TransportAddress & control
00698 );
00701 H323_ExternalRTPChannel(
00702 H323Connection & connection,
00703 const H323Capability & capability,
00704 Directions direction,
00705 unsigned sessionID,
00706 const PIPSocket::Address & ip,
00707 WORD dataPort
00708 );
00710
00717 virtual unsigned GetSessionID() const;
00718
00725 virtual PBoolean GetMediaTransportAddress(
00726 OpalTransportAddress & data,
00727 OpalTransportAddress & control
00728 ) const;
00729
00732 virtual PBoolean Start();
00733
00740 virtual void Receive();
00741
00748 virtual void Transmit();
00750
00755 virtual PBoolean OnSendingPDU(
00756 H245_H2250LogicalChannelParameters & param
00757 ) const;
00758
00762 virtual void OnSendOpenAck(
00763 H245_H2250LogicalChannelAckParameters & param
00764 ) const;
00765
00772 virtual PBoolean OnReceivedPDU(
00773 const H245_H2250LogicalChannelParameters & param,
00774 unsigned & errorCode
00775 );
00776
00783 virtual PBoolean OnReceivedAckPDU(
00784 const H245_H2250LogicalChannelAckParameters & param
00785 );
00787
00788 void SetExternalAddress(
00789 const H323TransportAddress & data,
00790 const H323TransportAddress & control
00791 );
00792
00793 const H323TransportAddress & GetRemoteMediaAddress() const { return remoteMediaAddress; }
00794 const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; }
00795
00796 PBoolean GetRemoteAddress(
00797 PIPSocket::Address & ip,
00798 WORD & dataPort
00799 ) const;
00800
00801 protected:
00802 void Construct(H323Connection & conn, unsigned id);
00803
00804 unsigned sessionID;
00805 H323TransportAddress externalMediaAddress;
00806 H323TransportAddress externalMediaControlAddress;
00807 H323TransportAddress remoteMediaAddress;
00808 H323TransportAddress remoteMediaControlAddress;
00809 };
00810
00811
00813
00820 class H323DataChannel : public H323UnidirectionalChannel
00821 {
00822 PCLASSINFO(H323DataChannel, H323UnidirectionalChannel);
00823
00824 public:
00829 H323DataChannel(
00830 H323Connection & connection,
00831 const H323Capability & capability,
00832 Directions direction,
00833 unsigned sessionID
00834 );
00835
00838 ~H323DataChannel();
00840
00847 virtual unsigned GetSessionID() const;
00848
00851 virtual PBoolean OnSendingPDU(
00852 H245_OpenLogicalChannel & openPDU
00853 ) const;
00854
00858 virtual void OnSendOpenAck(
00859 const H245_OpenLogicalChannel & open,
00860 H245_OpenLogicalChannelAck & ack
00861 ) const;
00862
00870 virtual PBoolean OnReceivedPDU(
00871 const H245_OpenLogicalChannel & pdu,
00872 unsigned & errorCode
00873 );
00874
00882 virtual PBoolean OnReceivedAckPDU(
00883 const H245_OpenLogicalChannelAck & pdu
00884 );
00886
00895 virtual PBoolean CreateListener();
00896
00904 virtual PBoolean CreateTransport();
00906
00907 protected:
00908 virtual void InternalClose();
00909
00910 unsigned sessionID;
00911 H323Listener * listener;
00912 PBoolean autoDeleteListener;
00913 H323Transport * transport;
00914 PBoolean autoDeleteTransport;
00915 PBoolean separateReverseChannel;
00916 };
00917
00918
00919 #endif // OPAL_H323
00920
00921 #endif // OPAL_H323_CHANNELS_H
00922
00923