OPAL  Version 3.14.3
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: 30908 $
30  * $Author: rjongbloed $
31  * $Date: 2013-11-14 18:03:17 +1100 (Thu, 14 Nov 2013) $
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_config.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;
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; }
318 
321 
323  virtual bool UpdateMediaFormat(const OpalMediaFormat & mediaFormat);
325 
326  protected:
327  virtual void InternalClose();
328 
334  bool opened;
335  PAtomicInteger m_terminating;
336 
337  private:
338  OpalBandwidth m_bandwidthUsed;
339 };
340 
341 
342 PLIST(H323LogicalChannelList, H323Channel);
343 
344 
345 
353 {
355 
356  public:
363  const H323Capability & capability,
364  Directions direction
365  );
366 
371 
378  virtual Directions GetDirection() const;
379 
387  virtual PBoolean SetInitialBandwidth();
388 
395  virtual bool PreOpen();
396 
399  virtual PBoolean Open();
400 
402  virtual bool UpdateMediaFormat(const OpalMediaFormat & mediaFormat);
404 
410  virtual OpalMediaStreamPtr GetMediaStream() const;
411 
415  virtual void SetMediaStream(OpalMediaStreamPtr mediaStream);
417 
418 
419  protected:
420  virtual void InternalClose();
421 
422  bool receiver;
424 };
425 
426 
434 {
436 
437  public:
444  const H323Capability & capability
445  );
447 
454  virtual Directions GetDirection() const;
456 };
457 
458 
460 
464 {
466 
467  public:
474  const H323Capability & capability,
475  Directions direction
476  );
478 
483  virtual PBoolean OnSendingPDU(
484  H245_OpenLogicalChannel & openPDU
485  ) const;
486 
490  virtual void OnSendOpenAck(
491  const H245_OpenLogicalChannel & open,
492  H245_OpenLogicalChannelAck & ack
493  ) const;
494 
495  virtual void OnSendOpenAck(
496  H245_H2250LogicalChannelAckParameters & param
497  ) const;
498 
499 
507  virtual PBoolean OnReceivedPDU(
508  const H245_OpenLogicalChannel & pdu,
509  unsigned & errorCode
510  );
511 
519  virtual PBoolean OnReceivedAckPDU(
520  const H245_OpenLogicalChannelAck & pdu
521  );
523 
528  virtual PBoolean OnSendingPDU(
529  H245_H2250LogicalChannelParameters & param
530  ) const;
531 
534  virtual PBoolean OnSendingAltPDU(
535  H245_ArrayOf_GenericInformation & alternate
536  ) const = 0;
537 
548  virtual PBoolean OnReceivedPDU(
549  const H245_H2250LogicalChannelParameters & param,
550  unsigned & errorCode
551  );
552 
559  virtual PBoolean OnReceivedAckPDU(
560  const H245_H2250LogicalChannelAckParameters & param
561  );
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