OPAL Version 3.10.4

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

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: 26728 $
30 * $Author: rjongbloed $
31 * $Date: 2011-12-01 22:59:14 -0600 (Thu, 01 Dec 2011) $
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
83 H323ChannelNumber & operator++(int);
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 {
130 IsBidirectional,
131 IsTransmitter,
132 IsReceiver,
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
338 H323EndPoint & endpoint;
339 H323Connection & connection;
340 H323Capability * capability;
341 H323ChannelNumber number;
342 H323ChannelNumber reverseChannel;
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
362 class H323UnidirectionalChannel : public H323Channel
363 {
364 PCLASSINFO(H323UnidirectionalChannel, H323Channel);
365
366 public:
371 H323UnidirectionalChannel(
372 H323Connection & connection,
373 const H323Capability & capability,
374 Directions direction
375 );
376
379 ~H323UnidirectionalChannel();
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;
423 OpalMediaStreamPtr mediaStream;
424 };
425
426
433 class H323BidirectionalChannel : public H323Channel
434 {
435 PCLASSINFO(H323BidirectionalChannel, H323Channel);
436
437 public:
442 H323BidirectionalChannel(
443 H323Connection & connection,
444 const H323Capability & capability
445 );
447
454 virtual Directions GetDirection() const;
455
460 virtual PBoolean Start();
462 };
463
464
466
469 class H323_RealTimeChannel : public H323UnidirectionalChannel
470 {
471 PCLASSINFO(H323_RealTimeChannel, H323UnidirectionalChannel);
472
473 public:
478 H323_RealTimeChannel(
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
563 virtual PBoolean SetDynamicRTPPayloadType(
564 int newType
565 );
566
567 RTP_DataFrame::PayloadTypes GetDynamicRTPPayloadType() const { return rtpPayloadType; }
569
570 protected:
571 RTP_DataFrame::PayloadTypes rtpPayloadType;
572 };
573
574
576
579 class H323_RTPChannel : public H323_RealTimeChannel
580 {
581 PCLASSINFO(H323_RTPChannel, H323_RealTimeChannel);
582
583 public:
588 H323_RTPChannel(
589 H323Connection & connection,
590 const H323Capability & capability,
591 Directions direction,
592 RTP_Session & rtp
593 );
594
596 ~H323_RTPChannel();
598
605 virtual unsigned GetSessionID() const;
606
613 virtual bool SetSessionID(
614 unsigned sessionID
615 );
617
622 virtual PBoolean OnSendingPDU(
623 H245_H2250LogicalChannelParameters & param
624 ) const;
625
629 virtual void OnSendOpenAck(
630 H245_H2250LogicalChannelAckParameters & param
631 ) const;
632
639 virtual PBoolean OnReceivedPDU(
640 const H245_H2250LogicalChannelParameters & param,
641 unsigned & errorCode
642 );
643
650 virtual PBoolean OnReceivedAckPDU(
651 const H245_H2250LogicalChannelAckParameters & param
652 );
654
655 protected:
656 RTP_Session & rtpSession;
657 H323_RTP_Session & rtpCallbacks;
658 };
659
660
662
666 class H323_ExternalRTPChannel : public H323_RealTimeChannel
667 {
668 PCLASSINFO(H323_ExternalRTPChannel, H323_RealTimeChannel);
669
670 public:
675 H323_ExternalRTPChannel(
676 H323Connection & connection,
677 const H323Capability & capability,
678 Directions direction,
679 unsigned sessionID
680 );
683 H323_ExternalRTPChannel(
684 H323Connection & connection,
685 const H323Capability & capability,
686 Directions direction,
687 unsigned sessionID,
688 const H323TransportAddress & data,
689 const H323TransportAddress & control
690 );
693 H323_ExternalRTPChannel(
694 H323Connection & connection,
695 const H323Capability & capability,
696 Directions direction,
697 unsigned sessionID,
698 const PIPSocket::Address & ip,
699 WORD dataPort
700 );
702
709 virtual unsigned GetSessionID() const;
710
717 virtual PBoolean GetMediaTransportAddress(
718 OpalTransportAddress & data,
719 OpalTransportAddress & control
720 ) const;
721
724 virtual PBoolean Start();
725
732 virtual void Receive();
733
740 virtual void Transmit();
742
747 virtual PBoolean OnSendingPDU(
748 H245_H2250LogicalChannelParameters & param
749 ) const;
750
754 virtual void OnSendOpenAck(
755 H245_H2250LogicalChannelAckParameters & param
756 ) const;
757
764 virtual PBoolean OnReceivedPDU(
765 const H245_H2250LogicalChannelParameters & param,
766 unsigned & errorCode
767 );
768
775 virtual PBoolean OnReceivedAckPDU(
776 const H245_H2250LogicalChannelAckParameters & param
777 );
779
780 void SetExternalAddress(
781 const H323TransportAddress & data,
782 const H323TransportAddress & control
783 );
784
785 const H323TransportAddress & GetRemoteMediaAddress() const { return remoteMediaAddress; }
786 const H323TransportAddress & GetRemoteMediaControlAddress() const { return remoteMediaControlAddress; }
787
788 PBoolean GetRemoteAddress(
789 PIPSocket::Address & ip,
790 WORD & dataPort
791 ) const;
792
793 protected:
794 void Construct(H323Connection & conn, unsigned id);
795
796 unsigned sessionID;
797 H323TransportAddress externalMediaAddress;
798 H323TransportAddress externalMediaControlAddress;
799 H323TransportAddress remoteMediaAddress;
800 H323TransportAddress remoteMediaControlAddress;
801 };
802
803
805
812 class H323DataChannel : public H323UnidirectionalChannel
813 {
814 PCLASSINFO(H323DataChannel, H323UnidirectionalChannel);
815
816 public:
821 H323DataChannel(
822 H323Connection & connection,
823 const H323Capability & capability,
824 Directions direction,
825 unsigned sessionID
826 );
827
830 ~H323DataChannel();
832
839 virtual unsigned GetSessionID() const;
840
843 virtual PBoolean OnSendingPDU(
844 H245_OpenLogicalChannel & openPDU
845 ) const;
846
850 virtual void OnSendOpenAck(
851 const H245_OpenLogicalChannel & open,
852 H245_OpenLogicalChannelAck & ack
853 ) const;
854
862 virtual PBoolean OnReceivedPDU(
863 const H245_OpenLogicalChannel & pdu,
864 unsigned & errorCode
865 );
866
874 virtual PBoolean OnReceivedAckPDU(
875 const H245_OpenLogicalChannelAck & pdu
876 );
878
887 virtual PBoolean CreateListener();
888
896 virtual PBoolean CreateTransport();
898
899 protected:
900 virtual void InternalClose();
901
902 unsigned sessionID;
903 H323Listener * listener;
904 PBoolean autoDeleteListener;
905 H323Transport * transport;
906 PBoolean autoDeleteTransport;
907 PBoolean separateReverseChannel;
908 };
909
910
911 #endif // OPAL_H323
912
913 #endif // OPAL_H323_CHANNELS_H
914
915