OPAL  Version 3.12.5
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: 28351 $
30  * $Author: rjongbloed $
31  * $Date: 2012-09-13 19:58:35 -0500 (Thu, 13 Sep 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_ArrayOf_GenericInformation;
57 class H245_MiscellaneousCommand_type;
58 class H245_MiscellaneousIndication_type;
59 
60 class H323EndPoint;
61 class H323Connection;
62 class H323Capability;
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(
110  const H323Capability & capability
111  );
112 
117  ~H323Channel();
119 
122  virtual void PrintOn(
123  ostream & strm
124  ) const;
126 
129  enum Directions {
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 
188  virtual bool PreOpen();
189 
194  virtual PBoolean Open();
195 
198  virtual void Close();
199 
202  PBoolean IsOpen() const { return opened && m_terminating == 0; }
203 
211  virtual OpalMediaStreamPtr GetMediaStream() const;
212 
216  virtual void SetMediaStream(OpalMediaStreamPtr mediaStream);
217 
218 
221  virtual PBoolean OnSendingPDU(
222  H245_OpenLogicalChannel & openPDU
223  ) const = 0;
224 
230  virtual void OnSendOpenAck(
231  const H245_OpenLogicalChannel & open,
232  H245_OpenLogicalChannelAck & ack
233  ) const;
234 
241  virtual PBoolean OnReceivedPDU(
242  const H245_OpenLogicalChannel & pdu,
243  unsigned & errorCode
244  );
245 
252  virtual PBoolean OnReceivedAckPDU(
253  const H245_OpenLogicalChannelAck & pdu
254  );
255 
259  virtual void OnFlowControl(
260  long bitRateRestriction
261  );
262 
266  virtual void OnMiscellaneousCommand(
267  const H245_MiscellaneousCommand_type & type
268  );
269 
273  virtual void OnMiscellaneousIndication(
274  const H245_MiscellaneousIndication_type & type
275  );
276 
280  virtual void OnJitterIndication(
281  DWORD jitter,
282  int skippedFrameCount,
283  int additionalBuffer
284  );
286 
291  const H323ChannelNumber & GetNumber() const { return number; }
292 
295  void SetNumber(const H323ChannelNumber & num) { number = num; }
296 
300 
304 
307  OpalBandwidth GetBandwidthUsed() const { return m_bandwidthUsed; }
308 
311  bool SetBandwidthUsed(
312  OpalBandwidth bandwidth
313  );
314 
317  const H323Capability & GetCapability() const { return *capability; }
319 
320  protected:
321  virtual void InternalClose();
322 
328  bool opened;
329  PAtomicInteger m_terminating;
330 
331  private:
332  OpalBandwidth m_bandwidthUsed;
333 };
334 
335 
336 PLIST(H323LogicalChannelList, H323Channel);
337 
338 
339 
347 {
349 
350  public:
357  const H323Capability & capability,
358  Directions direction
359  );
360 
365 
372  virtual Directions GetDirection() const;
373 
381  virtual PBoolean SetInitialBandwidth();
382 
389  virtual bool PreOpen();
390 
393  virtual PBoolean Open();
395 
399 
403  virtual OpalMediaStreamPtr GetMediaStream() const;
404 
408  virtual void SetMediaStream(OpalMediaStreamPtr mediaStream);
410 
411 
412  protected:
413  virtual void InternalClose();
414 
415  bool receiver;
418 };
419 
420 
428 {
430 
431  public:
438  const H323Capability & capability
439  );
441 
448  virtual Directions GetDirection() const;
450 };
451 
452 
454 
458 {
460 
461  public:
468  const H323Capability & capability,
469  Directions direction
470  );
472 
477  virtual PBoolean OnSendingPDU(
478  H245_OpenLogicalChannel & openPDU
479  ) const;
480 
484  virtual void OnSendOpenAck(
485  const H245_OpenLogicalChannel & open,
486  H245_OpenLogicalChannelAck & ack
487  ) const;
488 
489  virtual void OnSendOpenAck(
490  H245_H2250LogicalChannelAckParameters & param
491  ) const;
492 
493 
501  virtual PBoolean OnReceivedPDU(
502  const H245_OpenLogicalChannel & pdu,
503  unsigned & errorCode
504  );
505 
513  virtual PBoolean OnReceivedAckPDU(
514  const H245_OpenLogicalChannelAck & pdu
515  );
517 
522  virtual PBoolean OnSendingPDU(
523  H245_H2250LogicalChannelParameters & param
524  ) const;
525 
528  virtual PBoolean OnSendingAltPDU(
529  H245_ArrayOf_GenericInformation & alternate
530  ) const = 0;
531 
542  virtual PBoolean OnReceivedPDU(
543  const H245_H2250LogicalChannelParameters & param,
544  unsigned & errorCode
545  );
546 
553  virtual PBoolean OnReceivedAckPDU(
554  const H245_H2250LogicalChannelAckParameters & param
555  );
556 
559  virtual PBoolean OnReceivedAckAltPDU(
560  const H245_ArrayOf_GenericInformation & alternate
561  ) = 0;
562 
565 };
566 
567 
569 
577 {
579 
580  public:
587  const H323Capability & capability,
588  Directions direction,
589  unsigned sessionID
590  );
591 
596 
601  virtual unsigned GetSessionID() const;
602 
605  virtual PBoolean OnSendingPDU(
606  H245_OpenLogicalChannel & openPDU
607  ) const;
608 
612  virtual void OnSendOpenAck(
613  const H245_OpenLogicalChannel & open,
614  H245_OpenLogicalChannelAck & ack
615  ) const;
616 
624  virtual PBoolean OnReceivedPDU(
625  const H245_OpenLogicalChannel & pdu,
626  unsigned & errorCode
627  );
628 
636  virtual PBoolean OnReceivedAckPDU(
637  const H245_OpenLogicalChannelAck & pdu
638  );
640 
649  virtual PBoolean CreateListener();
650 
658  virtual PBoolean CreateTransport();
660 
661  protected:
662  virtual void InternalClose();
663 
664  unsigned sessionID;
670 };
671 
672 
673 #endif // OPAL_H323
674 
675 #endif // OPAL_H323_CHANNELS_H
676 
677