OPAL  Version 3.10.10
channels.h
Go to the documentation of this file.
1 /*
2  * channels.h
3  *
4  * H.323 protocol handler
5  *
6  * Open H323 Library
7  *
8  * Copyright (c) 1998-2001 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open H323 Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions of this code were written with the assisance of funding from
25  * Vovida Networks, Inc. http://www.vovida.com.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 27619 $
30  * $Author: rjongbloed $
31  * $Date: 2012-05-13 20:16:44 -0500 (Sun, 13 May 2012) $
32  */
33 
34 #ifndef OPAL_H323_CHANNELS_H
35 #define OPAL_H323_CHANNELS_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 #include <opal/buildopts.h>
42 
43 #if OPAL_H323
44 
45 #include <rtp/rtp.h>
46 #include <h323/transaddr.h>
47 #include <opal/mediastrm.h>
48 
49 
50 class H245_OpenLogicalChannel;
51 class H245_OpenLogicalChannelAck;
52 class H245_OpenLogicalChannel_forwardLogicalChannelParameters;
53 class H245_OpenLogicalChannel_reverseLogicalChannelParameters;
54 class H245_H2250LogicalChannelParameters;
55 class H245_H2250LogicalChannelAckParameters;
56 class H245_MiscellaneousCommand_type;
57 class H245_MiscellaneousIndication_type;
58 
59 class H323EndPoint;
60 class H323Connection;
61 class H323Capability;
62 class H323_RTP_Session;
63 
64 
66 
70 class H323ChannelNumber : public PObject
71 {
72  PCLASSINFO(H323ChannelNumber, PObject);
73 
74  public:
75  H323ChannelNumber() { number = 0; fromRemote = false; }
76  H323ChannelNumber(unsigned number, PBoolean fromRemote);
77 
78  virtual PObject * Clone() const;
79  virtual PINDEX HashFunction() const;
80  virtual void PrintOn(ostream & strm) const;
81  virtual Comparison Compare(const PObject & obj) const;
82 
84  operator unsigned() const { return number; }
85  PBoolean IsFromRemote() const { return fromRemote; }
86 
87  protected:
88  unsigned number;
89  PBoolean fromRemote;
90 };
91 
92 
99 class H323Channel : public PObject
100 {
101  PCLASSINFO(H323Channel, PObject);
102 
103  public:
108  H323Channel(
109  H323Connection & connection,
110  const H323Capability & capability
111  );
112 
117  ~H323Channel();
119 
122  virtual void PrintOn(
123  ostream & strm
124  ) const;
126 
129  enum Directions {
133  NumDirections
134  };
135 #if PTRACING
136  friend ostream & operator<<(ostream & out, Directions dir);
137 #endif
138 
143  virtual Directions GetDirection() const = 0;
144 
150  virtual unsigned GetSessionID() const;
151 
158  virtual bool SetSessionID(
159  unsigned sessionID
160  );
161 
168  virtual PBoolean GetMediaTransportAddress(
169  OpalTransportAddress & data,
170  OpalTransportAddress & control
171  ) const;
172 
180  virtual PBoolean SetInitialBandwidth() = 0;
181 
186  virtual PBoolean Open();
187 
190  virtual PBoolean Start() = 0;
191 
194  virtual void Close();
195 
198  PBoolean IsOpen() const { return opened && m_terminating == 0; }
199 
207  virtual OpalMediaStreamPtr GetMediaStream() const;
208 
209 
212  virtual PBoolean OnSendingPDU(
213  H245_OpenLogicalChannel & openPDU
214  ) const = 0;
215 
221  virtual void OnSendOpenAck(
222  const H245_OpenLogicalChannel & open,
223  H245_OpenLogicalChannelAck & ack
224  ) const;
225 
232  virtual PBoolean OnReceivedPDU(
233  const H245_OpenLogicalChannel & pdu,
234  unsigned & errorCode
235  );
236 
243  virtual PBoolean OnReceivedAckPDU(
244  const H245_OpenLogicalChannelAck & pdu
245  );
246 
250  virtual void OnFlowControl(
251  long bitRateRestriction
252  );
253 
257  virtual void OnMiscellaneousCommand(
258  const H245_MiscellaneousCommand_type & type
259  );
260 
264  virtual void OnMiscellaneousIndication(
265  const H245_MiscellaneousIndication_type & type
266  );
267 
271  virtual void OnJitterIndication(
272  DWORD jitter,
273  int skippedFrameCount,
274  int additionalBuffer
275  );
277 
282  const H323ChannelNumber & GetNumber() const { return number; }
283 
286  void SetNumber(const H323ChannelNumber & num) { number = num; }
287 
290  const H323ChannelNumber & GetReverseChannel() const { return reverseChannel; }
291 
294  void SetReverseChannel(const H323ChannelNumber & num) { reverseChannel = num; }
295 
298  unsigned GetBandwidthUsed() const { return bandwidthUsed; }
299 
302  PBoolean SetBandwidthUsed(
303  unsigned bandwidth
304  );
305 
308  const H323Capability & GetCapability() const { return *capability; }
309 
318  PBoolean IsPaused() const { return paused; }
319 
328  void SetPause(
329  PBoolean pause
330  ) { paused = pause; }
332 
333  virtual bool OnMediaCommand(const OpalMediaCommand &);
334 
335  protected:
336  virtual void InternalClose();
337 
343  bool opened;
344  bool paused;
345  PAtomicInteger m_terminating;
346 
347  private:
348  unsigned bandwidthUsed;
349 };
350 
351 
352 PLIST(H323LogicalChannelList, H323Channel);
353 
354 
355 
363 {
365 
366  public:
372  H323Connection & connection,
373  const H323Capability & capability,
374  Directions direction
375  );
376 
381 
388  virtual Directions GetDirection() const;
389 
397  virtual PBoolean SetInitialBandwidth();
398 
401  virtual PBoolean Open();
402 
407  virtual PBoolean Start();
409 
415  virtual OpalMediaStreamPtr GetMediaStream() const;
417 
418 
419  protected:
420  virtual void InternalClose();
421 
422  bool receiver;
424 };
425 
426 
434 {
436 
437  public:
443  H323Connection & connection,
444  const H323Capability & capability
445  );
447 
454  virtual Directions GetDirection() const;
455 
460  virtual PBoolean Start();
462 };
463 
464 
466 
470 {
472 
473  public:
479  H323Connection & connection,
480  const H323Capability & capability,
481  Directions direction
482  );
484 
489  virtual PBoolean OnSendingPDU(
490  H245_OpenLogicalChannel & openPDU
491  ) const;
492 
496  virtual void OnSendOpenAck(
497  const H245_OpenLogicalChannel & open,
498  H245_OpenLogicalChannelAck & ack
499  ) const;
500 
508  virtual PBoolean OnReceivedPDU(
509  const H245_OpenLogicalChannel & pdu,
510  unsigned & errorCode
511  );
512 
520  virtual PBoolean OnReceivedAckPDU(
521  const H245_OpenLogicalChannelAck & pdu
522  );
524 
529  virtual PBoolean OnSendingPDU(
530  H245_H2250LogicalChannelParameters & param
531  ) const;
532 
536  virtual void OnSendOpenAck(
537  H245_H2250LogicalChannelAckParameters & param
538  ) const;
539 
546  virtual PBoolean OnReceivedPDU(
547  const H245_H2250LogicalChannelParameters & param,
548  unsigned & errorCode
549  );
550 
557  virtual PBoolean OnReceivedAckPDU(
558  const H245_H2250LogicalChannelAckParameters & param
559  );
560 
561  RTP_DataFrame::PayloadTypes GetDynamicRTPPayloadType() const;
563 };
564 
565 
567 
571 {
573 
574  public:
580  H323Connection & connection,
581  const H323Capability & capability,
582  Directions direction,
583  RTP_Session & rtp
584  );
585 
587  ~H323_RTPChannel();
589 
596  virtual unsigned GetSessionID() const;
597 
604  virtual bool SetSessionID(
605  unsigned sessionID
606  );
608 
613  virtual PBoolean OnSendingPDU(
614  H245_H2250LogicalChannelParameters & param
615  ) const;
616 
620  virtual void OnSendOpenAck(
621  H245_H2250LogicalChannelAckParameters & param
622  ) const;
623 
630  virtual PBoolean OnReceivedPDU(
631  const H245_H2250LogicalChannelParameters & param,
632  unsigned & errorCode
633  );
634 
641  virtual PBoolean OnReceivedAckPDU(
642  const H245_H2250LogicalChannelAckParameters & param
643  );
645 
646  protected:
649 };
650 
651 
653 
658 {
660 
661  public:
667  H323Connection & connection,
668  const H323Capability & capability,
669  Directions direction,
670  unsigned sessionID
671  );
675  H323Connection & connection,
676  const H323Capability & capability,
677  Directions direction,
678  unsigned sessionID,
679  const H323TransportAddress & data,
680  const H323TransportAddress & control
681  );
685  H323Connection & connection,
686  const H323Capability & capability,
687  Directions direction,
688  unsigned sessionID,
689  const PIPSocket::Address & ip,
690  WORD dataPort
691  );
693 
700  virtual unsigned GetSessionID() const;
701 
708  virtual PBoolean GetMediaTransportAddress(
709  OpalTransportAddress & data,
710  OpalTransportAddress & control
711  ) const;
712 
715  virtual PBoolean Start();
716 
723  virtual void Receive();
724 
731  virtual void Transmit();
733 
738  virtual PBoolean OnSendingPDU(
739  H245_H2250LogicalChannelParameters & param
740  ) const;
741 
745  virtual void OnSendOpenAck(
746  H245_H2250LogicalChannelAckParameters & param
747  ) const;
748 
755  virtual PBoolean OnReceivedPDU(
756  const H245_H2250LogicalChannelParameters & param,
757  unsigned & errorCode
758  );
759 
766  virtual PBoolean OnReceivedAckPDU(
767  const H245_H2250LogicalChannelAckParameters & param
768  );
770 
771  void SetExternalAddress(
772  const H323TransportAddress & data,
773  const H323TransportAddress & control
774  );
775 
776  const H323TransportAddress & GetRemoteMediaAddress() const { return remoteMediaAddress; }
777  const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; }
778 
779  PBoolean GetRemoteAddress(
780  PIPSocket::Address & ip,
781  WORD & dataPort
782  ) const;
783 
784  protected:
785  void Construct(H323Connection & conn, unsigned id);
786 
787  unsigned sessionID;
792 };
793 
794 
796 
804 {
806 
807  public:
813  H323Connection & connection,
814  const H323Capability & capability,
815  Directions direction,
816  unsigned sessionID
817  );
818 
821  ~H323DataChannel();
823 
830  virtual unsigned GetSessionID() const;
831 
834  virtual PBoolean OnSendingPDU(
835  H245_OpenLogicalChannel & openPDU
836  ) const;
837 
841  virtual void OnSendOpenAck(
842  const H245_OpenLogicalChannel & open,
843  H245_OpenLogicalChannelAck & ack
844  ) const;
845 
853  virtual PBoolean OnReceivedPDU(
854  const H245_OpenLogicalChannel & pdu,
855  unsigned & errorCode
856  );
857 
865  virtual PBoolean OnReceivedAckPDU(
866  const H245_OpenLogicalChannelAck & pdu
867  );
869 
878  virtual PBoolean CreateListener();
879 
887  virtual PBoolean CreateTransport();
889 
890  protected:
891  virtual void InternalClose();
892 
893  unsigned sessionID;
899 };
900 
901 
902 #endif // OPAL_H323
903 
904 #endif // OPAL_H323_CHANNELS_H
905 
906 
const H323ChannelNumber & GetNumber() const
Definition: channels.h:282
H323Connection & connection
Definition: channels.h:339
unsigned sessionID
Definition: channels.h:893
const H323ChannelNumber & GetReverseChannel() const
Definition: channels.h:290
Definition: rtp.h:502
PBoolean autoDeleteTransport
Definition: channels.h:897
Definition: channels.h:469
const H323TransportAddress & GetRemoteMediaAddress() const
Definition: channels.h:776
const H323Capability & GetCapability() const
Definition: channels.h:308
Definition: mediacmd.h:43
H323TransportAddress externalMediaAddress
Definition: channels.h:788
Definition: h323caps.h:89
PBoolean autoDeleteListener
Definition: channels.h:895
H323TransportAddress externalMediaControlAddress
Definition: channels.h:789
Directions
Definition: channels.h:129
Definition: transports.h:703
PSafePtr< OpalMediaStream > OpalMediaStreamPtr
Definition: mediastrm.h:442
H323ChannelNumber number
Definition: channels.h:341
Definition: channels.h:570
H323TransportAddress remoteMediaControlAddress
Definition: channels.h:791
H323TransportAddress remoteMediaAddress
Definition: channels.h:790
PBoolean IsPaused() const
Definition: channels.h:318
const H323TransportAddress & GetRemoteMediaControlAddress() const
Definition: channels.h:777
Definition: transports.h:351
PayloadTypes
Definition: rtp.h:86
virtual PINDEX HashFunction() const
H323Capability * capability
Definition: channels.h:340
H323Listener * listener
Definition: channels.h:894
Definition: channels.h:99
H323_RTP_Session & rtpCallbacks
Definition: channels.h:648
Definition: channels.h:803
PAtomicInteger m_terminating
Definition: channels.h:345
void SetPause(PBoolean pause)
Definition: channels.h:328
unsigned GetBandwidthUsed() const
Definition: channels.h:298
virtual Comparison Compare(const PObject &obj) const
OpalMediaStreamPtr mediaStream
Definition: channels.h:423
Definition: channels.h:131
PLIST(H323LogicalChannelList, H323Channel)
Definition: h323con.h:130
virtual PObject * Clone() const
PBoolean IsOpen() const
Definition: channels.h:198
ostream & operator<<(ostream &strm, OpalSilenceDetector::Mode mode)
H323EndPoint & endpoint
Definition: channels.h:338
unsigned number
Definition: channels.h:88
bool paused
Definition: channels.h:344
bool opened
Definition: channels.h:343
unsigned sessionID
Definition: channels.h:787
Definition: channels.h:362
Definition: h323rtp.h:62
Definition: channels.h:433
Definition: channels.h:132
Definition: channels.h:70
PBoolean fromRemote
Definition: channels.h:89
H323ChannelNumber reverseChannel
Definition: channels.h:342
bool receiver
Definition: channels.h:422
void SetNumber(const H323ChannelNumber &num)
Definition: channels.h:286
PBoolean separateReverseChannel
Definition: channels.h:898
Definition: channels.h:130
Definition: transports.h:149
void SetReverseChannel(const H323ChannelNumber &num)
Definition: channels.h:294
Definition: channels.h:657
Definition: h323ep.h:85
H323ChannelNumber()
Definition: channels.h:75
RTP_Session & rtpSession
Definition: channels.h:647
Definition: transaddr.h:66
H323Transport * transport
Definition: channels.h:896
virtual void PrintOn(ostream &strm) const
H323ChannelNumber & operator++(int)
PBoolean IsFromRemote() const
Definition: channels.h:85