| 1 | /* |
| 2 | * Copyright (C) 2004-2005 by Objective Systems, Inc. |
| 3 | * |
| 4 | * This software is furnished under an open source license and may be |
| 5 | * used and copied only in accordance with the terms of this license. |
| 6 | * The text of the license may generally be found in the root |
| 7 | * directory of this installation in the COPYING file. It |
| 8 | * can also be viewed online at the following URL: |
| 9 | * |
| 10 | * http://www.obj-sys.com/open/license.html |
| 11 | * |
| 12 | * Any redistributions of this file including modified versions must |
| 13 | * maintain this copyright notice. |
| 14 | * |
| 15 | *****************************************************************************/ |
| 16 | /** |
| 17 | * @file ooLogChan.h |
| 18 | * This file contains structures and functions for maintaining information |
| 19 | * on logical channels within the stack. |
| 20 | */ |
| 21 | #ifndef _OOLOGCHAN_H_ |
| 22 | #define _OOLOGCHAN_H_ |
| 23 | |
| 24 | #include "ootypes.h" |
| 25 | #include "ooCapability.h" |
| 26 | #ifdef __cplusplus |
| 27 | extern "C" { |
| 28 | #endif |
| 29 | |
| 30 | /** |
| 31 | * @defgroup logchan H.245 logical channel management |
| 32 | * @{ |
| 33 | */ |
| 34 | struct ooH323EpCapability; |
| 35 | struct OOH323CallData; |
| 36 | |
| 37 | /** |
| 38 | * Logical channel states. |
| 39 | */ |
| 40 | typedef enum { |
| 41 | OO_LOGICAL_CHAN_UNKNOWN, |
| 42 | OO_LOGICALCHAN_IDLE, |
| 43 | OO_LOGICALCHAN_PROPOSED, |
| 44 | OO_LOGICALCHAN_ESTABLISHED, |
| 45 | OO_LOGICALCHAN_PROPOSEDFS, |
| 46 | OO_LOGICALCHAN_CLOSEPENDING |
| 47 | } OOLogicalChannelState; |
| 48 | |
| 49 | /** |
| 50 | * Structure to store information on logical channels for a call. |
| 51 | */ |
| 52 | typedef struct OOLogicalChannel { |
| 53 | int channelNo; |
| 54 | int sessionID; |
| 55 | enum OOCapType type; |
| 56 | char dir[10]; /* receive/transmit */ |
| 57 | char remoteIP[2+8*4+7]; |
| 58 | int remoteMediaPort; |
| 59 | int remoteMediaControlPort; |
| 60 | int localRtpPort; |
| 61 | int localRtcpPort; |
| 62 | char localIP[2+8*4+7]; |
| 63 | OOLogicalChannelState state; |
| 64 | struct ooH323EpCapability *chanCap; |
| 65 | struct OOLogicalChannel *next; |
| 66 | } OOLogicalChannel; |
| 67 | |
| 68 | #define ooLogicalChannel OOLogicalChannel |
| 69 | |
| 70 | /** |
| 71 | * This function is used to add a new logical channel entry into the list |
| 72 | * of currently active logical channels. |
| 73 | * @param call Pointer to the call for which new logical channel |
| 74 | * entry has to be created. |
| 75 | * @param channelNo Channel number for the new channel entry. |
| 76 | * @param sessionID Session identifier for the new channel. |
| 77 | * @param dir Direction of the channel(transmit/receive) |
| 78 | * @param epCap Capability to be used for the new channel. |
| 79 | * |
| 80 | * @return Pointer to logical channel, on success. NULL, on failure |
| 81 | */ |
| 82 | EXTERN ooLogicalChannel* ooAddNewLogicalChannel |
| 83 | (struct OOH323CallData *call, int channelNo, int sessionID, |
| 84 | char *dir, ooH323EpCapability *epCap); |
| 85 | |
| 86 | /** |
| 87 | * This function is used to find a logical channel using the logical |
| 88 | * channel number as a key. |
| 89 | * @param call Pointer to the call for which logical channel is |
| 90 | * required. |
| 91 | * @param channelNo Forward Logical Channel number for the logical channel |
| 92 | * |
| 93 | * @return Pointer to the logical channel if found, NULL |
| 94 | * otherwise. |
| 95 | */ |
| 96 | EXTERN ooLogicalChannel* ooFindLogicalChannelByLogicalChannelNo |
| 97 | (struct OOH323CallData *call, int channelNo); |
| 98 | |
| 99 | /** |
| 100 | * This function is called when a new logical channel is established. It is |
| 101 | * particularly useful in case of faststart. When the remote endpoint selects |
| 102 | * one of the proposed alternatives, other channels for the same session type |
| 103 | * need to be closed. This function is used for that. |
| 104 | * |
| 105 | * @param call Handle to the call which owns the logical channel. |
| 106 | * @param pChannel Handle to the newly established logical channel. |
| 107 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 108 | */ |
| 109 | EXTERN int ooOnLogicalChannelEstablished |
| 110 | (struct OOH323CallData *call, OOLogicalChannel * pChannel); |
| 111 | |
| 112 | /** |
| 113 | * This function is used to retrieve a logical channel with a particular |
| 114 | * sessionID. Note that there can be two entries of logical channel, one in |
| 115 | * each direction. This function will return the first channel which has the |
| 116 | * same session ID. |
| 117 | * @param call Handle to the call which owns the channels to be searched. |
| 118 | * @param sessionID Session id of the session which is to be searched for. |
| 119 | * @param dir Direction of the channel.(transmit/receive) |
| 120 | * |
| 121 | * @return Returns a pointer to the logical channel if found, NULL |
| 122 | * otherwise. |
| 123 | */ |
| 124 | EXTERN ooLogicalChannel* ooGetLogicalChannel |
| 125 | (struct OOH323CallData *call, int sessionID, char *dir); |
| 126 | |
| 127 | /** |
| 128 | * This function is used to remove a logical channel from the list of |
| 129 | * channels within the call structure. |
| 130 | * @param call Pointer to the call from which logical channel has |
| 131 | * to be removed. |
| 132 | * @param ChannelNo Forward logical channel number of the channel to be |
| 133 | * removed. |
| 134 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 135 | */ |
| 136 | EXTERN int ooRemoveLogicalChannel (struct OOH323CallData *call, int ChannelNo); |
| 137 | |
| 138 | /** |
| 139 | * This function is used to cleanup a logical channel. It first stops media if |
| 140 | * it is still active and then removes the channel from the list, freeing up |
| 141 | * all the associated memory. |
| 142 | * @param call Handle to the call which owns the logical channel. |
| 143 | * @param channelNo Channel number identifying the channel. |
| 144 | * |
| 145 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 146 | */ |
| 147 | EXTERN int ooClearLogicalChannel (struct OOH323CallData *call, int channelNo); |
| 148 | |
| 149 | /** |
| 150 | * This function is used to cleanup all the logical channels associated with |
| 151 | * the call. |
| 152 | * @param call Handle to the call which owns the channels. |
| 153 | * |
| 154 | * @return OO_OK, on success. OO_FAILED, on failure. |
| 155 | */ |
| 156 | EXTERN int ooClearAllLogicalChannels (struct OOH323CallData *call); |
| 157 | |
| 158 | /** |
| 159 | * This function is used to find a logical channel from a received |
| 160 | * H.245 Open Logical Channel (OLC) message. |
| 161 | * @param call Handle to the related call. |
| 162 | * @param olc Handle to the received OLC. |
| 163 | * |
| 164 | * @return Returns the corresponding logical channel if found, |
| 165 | * else returns NULL. |
| 166 | */ |
| 167 | EXTERN OOLogicalChannel * ooFindLogicalChannelByOLC |
| 168 | (struct OOH323CallData *call, H245OpenLogicalChannel *olc); |
| 169 | |
| 170 | /** |
| 171 | * This function is used to find a logical channel based on session Id, |
| 172 | * direction of channel and datatype. |
| 173 | * @param call Handle to the call |
| 174 | * @param sessionID Session ID for the channel to be searched. |
| 175 | * @param dir Direction of the channel wrt local endpoint. |
| 176 | * (transmit/receive) |
| 177 | * @param dataType Handle to the data type for the channel. |
| 178 | * |
| 179 | * @return Logical channel, if found, NULL otherwise. |
| 180 | */ |
| 181 | EXTERN OOLogicalChannel * ooFindLogicalChannel |
| 182 | (struct OOH323CallData* call, int sessionID, char *dir, H245DataType* dataType); |
| 183 | |
| 184 | EXTERN OOLogicalChannel* ooGetTransmitLogicalChannel(struct OOH323CallData *call); |
| 185 | EXTERN OOLogicalChannel* ooGetReceiveLogicalChannel(struct OOH323CallData *call); |
| 186 | |
| 187 | /** |
| 188 | * @} |
| 189 | */ |
| 190 | |
| 191 | #ifdef __cplusplus |
| 192 | } |
| 193 | #endif |
| 194 | |
| 195 | #endif |