Platform SDK: TAPI |
The following code snippet demonstrates selecting terminals onto streams associated with a call.
Before using this code snippet, you must perform the operations in Initialize TAPI and Select an Address.
Also, this snippet requires that the application already have a pointer to the ITBasicCallControl interface of either an incoming or outgoing call. See Make a Call or Receive a Call for code snippets on how to obtain this pointer.
Note This snippet does not have the error checking and releases appropriate for real code.
// pAddress is an ITAddress interface pointer. // pBasicCall is an ITBasicCallControl interface pointer. // Get the ITStreamControl interface. ITStreamControl * pStreamControl; pBasicCall->QueryInterface( IID_ITStreamControl, (void **) &pStreamControl ); // Enumerate the streams and select // terminals onto them. IEnumStream * pEnumStreams; ITStream * pStream; pStreamControl->EnumerateStreams(&pEnumStreams); while ( S_OK == pEnumStreams->Next(1, &pStream, NULL) ) { // Get the media type and direction of this stream. long lMediaType; TERMINAL_DIRECTION dir; pStream->get_MediaType( &lMediaType ); pStream->get_Direction( &dir ); // Create the default terminal for this media type // and direction. // If lMediaType == TAPIMEDIATYPE_VIDEO and // dir == TD_RENDER, a dynamic video render terminal // is required. Please see Incoming.cpp in // the samples section of the SDK. // For all other terminals, get the default // static terminal. ITTerminal * pTerminal; ITTerminalSupport * pTerminalSupport; pAddress->QueryInterface( IID_ITTerminalSupport, (void **)&pTerminalSupport ); pTerminalSupport->GetDefaultStaticTerminal( lMediaType, dir, pTerminal ); // Select the terminal on the stream. pStream->SelectTerminal(pTerminal); }
'query for ITBasicCallControl, the call control interface Dim objCallControl As ITBasicCallControl Set objCallControl = gobjReceivedCallInfo 'query ITTerminalSupport from Address object Dim objTerminalSupport As ITTerminalSupport Set objTerminalSupport = gobjAddress Dim objTerminal As ITTerminal Set objTerminal = objTerminalSupport.GetDefaultStaticTerminal _ lMediaType, dir) 'release not needed objects Set objTerminalSupport = Nothing 'Select the terminal before answering 'we'll need the ITStreamControl interface for doing this. Dim objStreamControl As ITStreamControl Set objStreamControl = objCallControl If Not (objStreamControl Is Nothing) Then Dim objITCollStreams As ITCollection Set objITCollStreams = objStreamControl.Streams Dim nIndex As Long, objCrtStream As ITStream For nIndex = 1 To objITCollStreams.Count Set objCrtStream = objITCollStreams.Item(nIndex) If objCrtStream.MediaType = lMediaType Then If objCrtStream.Direction = dir Then Call objCrtStream.SelectTerminal(objTerminal) End If End If Set objCrtStream = Nothing Next nIndex Set objITCollStreams = Nothing Set objStreamControl = Nothing End If
ITAddress, ITBasicCallControl, ITStreamControl, ITStream, IEnumStream, ITTerminal, ITTerminalSupport