ipm_StartMedia( )
Termination Events | Cautions | Errors | Example | See Also
Name: int ipm_StartMedia(nDeviceHandle, *pMediaInfo, eDirection, usMode) Inputs:
Returns: 0 on success -1 on failure Includes: srllib.h ipmlib.h Category: Mode: Platform: Description
The ipm_StartMedia( ) function sets media properties and starts the session. This function allows the application to set the remote and local connectivity selections. ipm_StartMedia( ) also starts RTP streaming. The remote RTP/ RTCP port information and coder information is provided in the IPM_MEDIA_INFO structure.
nDeviceHandle handle of the IP Media device pMediaInfo pointer to structure; see IPM_MEDIA_INFO for details. Applications can define the following: eDirection media operation enumeration The eIPM_DATA_DIRECTION data type is an enumeration which defines the following values: usMode operation mode. Set to EV_ASYNC for asynchronous execution or to EV_SYNC for synchronous execution. Termination Events
- IPMEV_START_MEDIA
- indicates successful completion, that is, media information was set and the session has been started. Use SRL functions to retrieve IPM_MEDIA_INFO structure fields.
- IPMEV_ERROR
- indicates the function failed.
Cautions
The application must wait until this function completes before calling ipm_Listen( ).
Errors
If the function returns -1 to indicate failure, call ATDV_LASTERR( ) and ATDV_ERRMSGP( ) to return one of the following errors:
- EIPM_BADPARM
- Invalid parameter
- EIPM_BUSY
- Channel is busy
- EIPM_INTERNAL
- Internal error
- EIPM_INV_MODE
- Invalid mode
- EIPM_INV_STATE
- Invalid state. Initial command did not complete before another function call was made.
- EIPM_SYSTEM
- System error
Example
#include <stdio.h> #include <string> #include <srllib.h> #include <ipmlib.h> typedef long int(*HDLR)(unsigned long); void CheckEvent(); void main() { int nDeviceHandle; // Register event handler function with srl sr_enbhdlr( EV_ANYDEV ,EV_ANYEVT ,(HDLR)CheckEvent); /* . . Main Processing . . . */ /* Set the media properties for a remote party using IP device handle, nDeviceHandle. ASSUMPTION: A valid nDeviceHandle was obtained from prior call to ipm_Open(). */ IPM_MEDIA_INFO MediaInfo; MediaInfo.unCount = 4; MediaInfo.MediaData[0].eMediaType = MEDIATYPE_REMOTE_RTP_INFO; MediaInfo.MediaData[0].mediaInfo.PortInfo.unPortId = 2328; strcpy(MediaInfo.MediaData[0].mediaInfo.PortInfo.cIPAddress,"111.21.0.9\n"); MediaInfo.MediaData[1].eMediaType = MEDIATYPE_REMOTE_RTCP_INFO; MediaInfo.MediaData[1].mediaInfo.PortInfo.unPortId = 2329; strcpy(MediaInfo.MediaData[1].mediaInfo.PortInfo.cIPAddress,"111.41.0.9\n"); MediaInfo.MediaData[2].eMediaType = MEDIATYPE_REMOTE_CODER_INFO; MediaInfo.MediaData[2].mediaInfo.CoderInfo.eCoderType = CODER_TYPE_G711ULAW64K; MediaInfo.MediaData[2].mediaInfo.CoderInfo.eFrameSize = (eIPM_CODER_FRAMESIZE) 30; MediaInfo.MediaData[2].mediaInfo.CoderInfo.unFramesPerPkt = 1; MediaInfo.MediaData[2].mediaInfo.CoderInfo.eVadEnable = CODER_VAD_DISABLE; MediaInfo.MediaData[2].mediaInfo.CoderInfo.unCoderPayloadType = 0; MediaInfo.MediaData[2].mediaInfo.CoderInfo.unRedPayloadType = 0; MediaInfo.MediaData[3].eMediaType = MEDIATYPE_LOCAL_CODER_INFO; MediaInfo.MediaData[3].mediaInfo.CoderInfo.eCoderType = CODER_TYPE_G711ULAW64K; MediaInfo.MediaData[3].mediaInfo.CoderInfo.eFrameSize = (eIPM_CODER_FRAMESIZE) 30; MediaInfo.MediaData[3].mediaInfo.CoderInfo.unFramesPerPkt = 1; MediaInfo.MediaData[3].mediaInfo.CoderInfo.eVadEnable =CODER_VAD_DISABLE; MediaInfo.MediaData[3].mediaInfo.CoderInfo.unCoderPayloadType = 0; MediaInfo.MediaData[3].mediaInfo.CoderInfo.unRedPayloadType = 0; if(ipm_StartMedia(nDeviceHandle, &MediaInfo,DATA_IP_TDM_BIDIRECTIONAL, EV_ASYNC) == -1) { printf("ipm_StartMediaInfo failed for device name = %s with error = %d\n", ATDV_NAMEP(nDeviceHandle), ATDV_LASTERR(nDeviceHandle)); /* . . Perform Error Processing . . */ } /* . . Continue processing . */ } void CheckEvent() { int nDeviceID = sr_getevtdev(); int nEventType = sr_getevttype(); switch(nEventType) { /* . . . Other events . . */ /* Expected reply to ipm_StartMedia */ case IPMEV_STARTMEDIA: printf("Received IPMEV_START_MEDIA for device = %s\n", ATDV_NAMEP(nDeviceID)); break; default: printf("Received unknown event = %d for device = %s\n", nEventType, ATDV_NAMEP(nDeviceID)); break; } }See Also
Click here to contact Telecom Support Resources
Copyright 2002, Intel Corporation