<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>TSP Media Driver</title>
  <link rel="alternate" href="http://developer.cisco.com/c/message_boards/find_thread?p_l_id=&amp;threadId=9108209" />
  <subtitle>TSP Media Driver</subtitle>
  <id>http://developer.cisco.com/c/message_boards/find_thread?p_l_id=&amp;threadId=9108209</id>
  <updated>2013-05-26T00:50:30Z</updated>
  <dc:date>2013-05-26T00:50:30Z</dc:date>
  <entry>
    <title>RE: TSP Media Driver</title>
    <link rel="alternate" href="http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=14795110" />
    <author>
      <name>Antonio Sedano</name>
    </author>
    <id>http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=14795110</id>
    <updated>2013-04-30T10:32:12Z</updated>
    <published>2013-04-30T10:32:12Z</published>
    <summary type="html">Hello again.
I found where the problem was. this is the right call that I have to do.
[color=#525252][DllImport(MEDIA_DRIVER_DLL,CallingConvention = CallingConvention.Cdecl, EntryPoint = "?EpOpenById@@YAPAXKW4eStreamDirection@@P6GXPAX1KPAEK1_N0@Z@Z")][/color]
[color=#525252]        public static extern System.Int32 EpOpenById(System.Int32 device,System.Int32 streamDir,IntPtr pRTPDataCallBack);[/color]</summary>
    <dc:creator>Antonio Sedano</dc:creator>
    <dc:date>2013-04-30T10:32:12Z</dc:date>
  </entry>
  <entry>
    <title>RE: TSP Media Driver</title>
    <link rel="alternate" href="http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=14764391" />
    <author>
      <name>Antonio Sedano</name>
    </author>
    <id>http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=14764391</id>
    <updated>2013-04-29T17:05:50Z</updated>
    <published>2013-04-29T17:05:50Z</published>
    <summary type="html">Hi Davide.
Like I told in my post, I did a little example in C++ and now everything is working fine. But now I want to use the ciscortplib.dll from C#, and I am having some problems.
 
I do not have any problem to do the init using this method:
[DllImport(MEDIA_DRIVER_DLL, CharSet = CharSet.Auto, SetLastError = true)]
        internal static extern bool _TspApiInitDefault(
            DLG_RTPTraceCallBack prtpLibTraceCallBack);
 
But if I try to use this other one: 
[DllImport(MEDIA_DRIVER_DLL, CharSet = CharSet.Auto, SetLastError = true)]
        internal static extern bool EpApiInitDefault(
            DLG_RTPTraceCallBack prtpLibTraceCallBack);
I have the exception that EpApiInitDefault does not exist in the dll.
 
In the same way EpOpenById does not exists, according to C#, but _EpOpenById exists, but here I have the problem that C# is telling me:
"A call to PInvoke function 'NeatTapi_Class!NeatTapi_Class.CTapi_MediaDriver::_EpOpenById' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature."
I have tried these option and I have always the same result.
[DllImport(MEDIA_DRIVER_DLL, EntryPoint = "_EpOpenById", CharSet = CharSet.Auto, SetLastError = true, CallingConvention = CallingConvention.StdCall)]
        internal static extern IntPtr _EpOpenById(
            uint deviceId,
            StreamDirection streamDir ,
            DLG_RTPEndPointCallBack pRTPDataCallBack);
[DllImport(MEDIA_DRIVER_DLL, EntryPoint = "_EpOpenById", CharSet = CharSet.Auto, SetLastError = true)]
        internal static extern IntPtr _EpOpenById(
            uint deviceId,
            StreamDirection streamDir ,
            DLG_RTPEndPointCallBack pRTPDataCallBack);
 
Definitions:
 - private const string MEDIA_DRIVER_DLL= "C:\\windows\\system32\\ciscortplib.dll";
 - public enum StreamDirection
        {
            Undef = 0x00,
            ToApp = 0x01,         //In,
            ToNwk = 0x02,         //Out
            Both = 0x03          //In/Out
         }
- public delegate void DLG_RTPEndPointCallBack(IntPtr hEp, IntPtr hStream, uint dwError, IntPtr pData, uint dwBytes, IntPtr pUser, bool isSilence, StreamDirection streamDir);
 
I hope you can help me. Thanks in advance.
 </summary>
    <dc:creator>Antonio Sedano</dc:creator>
    <dc:date>2013-04-29T17:05:50Z</dc:date>
  </entry>
  <entry>
    <title>RE: TSP Media Driver</title>
    <link rel="alternate" href="http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=14298967" />
    <author>
      <name>Antonio Sedano</name>
    </author>
    <id>http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=14298967</id>
    <updated>2013-04-16T09:11:06Z</updated>
    <published>2013-04-16T09:11:06Z</published>
    <summary type="html">Hi Davide.
Thank you for this sample of your code. 
At the end, we have discovered where our problem was. Our code was working fine, but we were doing the tests in the computer which had two IPs, the first belongs to the domain where the CUCM is, and second one, which does not belong to the domain. The audio was going out through the private IP. So we were doing the call and the media driver functions using the first IP but the audio went for the second one, so el CUCM could not reproduce the wave.
Thank you for your help.</summary>
    <dc:creator>Antonio Sedano</dc:creator>
    <dc:date>2013-04-16T09:11:06Z</dc:date>
  </entry>
  <entry>
    <title>RE: TSP Media Driver</title>
    <link rel="alternate" href="http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=14258053" />
    <author>
      <name>Davide Cocchi</name>
    </author>
    <id>http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=14258053</id>
    <updated>2013-04-15T09:02:43Z</updated>
    <published>2013-04-15T09:02:43Z</published>
    <summary type="html">Hi Antonio, 
 
I agree with you, probably cisco doesn't care too much on dll naming because they give a c++ lib, which contains directly the reference to the correct dll file.
 
For your second question, I didn't find any sample application, I have to do it by myself. I developed C# libraries as interops of the rtplib and tapi, and works well now... 
I have a c++ console app that works for debug purposes... I'll post here some sample code for minimum handling...
I have a CTapiLine class, this function enables handling of dev specific events...


BOOL CTapiLine::DevSpecEnableStreamData()
{
 int dwSize = sizeof (VARSTRING) + 1024;
 VARSTRING* pDeviceID = pDeviceID = (VARSTRING *) calloc (1, dwSize);
 pDeviceID-&gt;dwTotalSize = dwSize;
 //Fill in Structure
 long lResult = lineGetID (m_LineHandle, 0, NULL, LINECALLSELECT_LINE, pDeviceID, "ciscowave/out");
 
 if(lResult != NO_ERROR)
 CSmLogger::AddLogText(1, TAPI_LOG_HANDLE, "[CTapiLine::DevSpecEnableStreamData]\r\n"
 "\tName: %s\r\n"
 "\tlineGetID Error %s", GetName(), CTapiEnvironment::GetTAPIErrorString(lResult));
 else
 {
 m_EndPointDevId = (DWORD) *((DWORD *) ((LPSTR) pDeviceID + pDeviceID-&gt;dwStringOffset));
 
 CSmLogger::AddLogText(1, TAPI_LOG_HANDLE, "[CTapiLine::DevSpecEnableStreamData]\r\n"
 "\tName: %s\r\n"
 "\m_EndPointDevId: %d", GetName(), m_EndPointDevId);
 }
 
 CCiscoLineDevSpecificSetStatusMsgs _statusMsg;
 _statusMsg.m_DevSpecificStatusMsgsFlag = DEVSPECIFIC_MEDIA_STREAM;
 
 CSmLogger::AddLogText(1, TAPI_LOG_HANDLE, "[CTapiLine::DevSpecEnableStreamData]\r\n"
 "\tName: %s\r\n"
 "\_statusMsg.GetMsgType(): %d\r\n"
 "\_statusMsg.dwSize() %d", GetName(), _statusMsg.GetMsgType(), _statusMsg.dwSize());
 
 lResult = lineDevSpecific(m_LineHandle, 0, NULL, _statusMsg.lpParams(), _statusMsg.dwSize());
 if(lResult &gt; 0)
 {
 CSmLogger::AddLogText(1, TAPI_LOG_HANDLE, "[CTapiLine::DevSpecEnableStreamData]\r\n"
 "\tName: %s\r\n"
 "\tlineDevSpecific RequestId = 0x%08x (%d)", GetName(), lResult, lResult);
 AddRequest(lResult, NULL); 
 }
 else if(lResult != NO_ERROR)
 CSmLogger::AddLogText(1, TAPI_LOG_HANDLE, "[CTapiLine::DevSpecEnableStreamData]\r\n"
 "\tName: %s\r\n"
 "\tlineDevSpecific Error %s", GetName(), CTapiEnvironment::GetTAPIErrorString(lResult));
 
 return lResult &gt; 0;
}
 
This function instead manages events from devSpecific and plays data
void CTapiLine::OnDevSpecificMessage(LINEMESSAGE message)
{
 DWORD CiscoMessageType = message.dwParam1 &amp; 0x000000FF;
 CSmLogger::AddLogText(0, TAPI_LOG_HANDLE, "[CTapiLine::OnDevSpecificMessage] CiscoMessageType 0x%08x", CiscoMessageType);
 
 switch(CiscoMessageType)
 {
 case SLDSMT_START_TRANSMISION:
 {
 CSmLogger::AddLogText(0, TAPI_LOG_HANDLE, "[CTapiLine::OnDevSpecificMessage] Received START_TRANSMISION");
 if(m_hEndPoint == NULL)
 {
 m_hEndPoint = EpOpenById(m_EndPointDevId, Both, EndPointCBK);
 }
 
 HANDLE hStream = EpGetStreamHandle(m_hEndPoint, STREAM_TYPE_AUDIO, ToNwk);
 
 if(hStream != NULL)
 {
 if(EpStreamStart(hStream, EndPointCBK))
 {
 int lSize;
 PUCHAR buffer;
 
 FILE* pFile = fopen("d:\\downloads\\test.raw", "rb");
   size_t result;
 // obtain file size:
 fseek (pFile , 0 , SEEK_END);
 lSize = ftell (pFile);
 rewind (pFile);
 
 // allocate memory to contain the whole file:
 buffer = (PUCHAR) malloc (sizeof(PUCHAR)*lSize);
 
 // copy the file into the buffer:
 result = fread (buffer,1,lSize,pFile);
 if (result != lSize) {fputs ("Reading error",stderr); exit (3);}
 /* the whole file is now loaded in the memory buffer. */
   // terminate
 fclose (pFile);
  
 EpStreamWrite(hStream, buffer, lSize, new GUID(), EndPointCBK);
 }
 }
 }
 break;
 case SLDSMT_STOP_TRANSMISION:
 {
 CSmLogger::AddLogText(0, TAPI_LOG_HANDLE, "[CTapiLine::OnDevSpecificMessage] Received STOP_TRANSMISION");
 
 if(m_hEndPoint != NULL)
 {
 HANDLE hStream = EpGetStreamHandle(m_hEndPoint, STREAM_TYPE_AUDIO, ToNwk);
 
 if(hStream != NULL)
 {
 EpStreamStop(hStream);
 }
 EpClose(m_hEndPoint, Both);
 m_hEndPoint = NULL;
 }
 }
 break;
 case SLDSMT_START_RECEPTION:
 {
 CSmLogger::AddLogText(0, TAPI_LOG_HANDLE, "[CTapiLine::OnDevSpecificMessage] Received START_RECEPTION");
 if(m_hEndPoint == NULL)
 {
 m_hEndPoint = EpOpenById(m_EndPointDevId, Both, EndPointCBK);
 }
 }
 break;
 case SLDSMT_STOP_RECEPTION:
 {
 CSmLogger::AddLogText(0, TAPI_LOG_HANDLE, "[CTapiLine::OnDevSpecificMessage] Received STOP_RECEPTION");
 if(m_hEndPoint != NULL)
 {
 HANDLE hStream = EpGetStreamHandle(m_hEndPoint, STREAM_TYPE_AUDIO, ToApp);
 
 if(hStream != NULL)
 {
 EpStreamStop(hStream);
 }
 
 EpClose(m_hEndPoint, Both);
 m_hEndPoint = NULL;
 }
 }
 break;
 }
}
 </summary>
    <dc:creator>Davide Cocchi</dc:creator>
    <dc:date>2013-04-15T09:02:43Z</dc:date>
  </entry>
  <entry>
    <title>RE: TSP Media Driver</title>
    <link rel="alternate" href="http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=14253943" />
    <author>
      <name>Antonio Sedano</name>
    </author>
    <id>http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=14253943</id>
    <updated>2013-04-15T08:40:41Z</updated>
    <published>2013-04-15T08:40:41Z</published>
    <summary type="html">Hi Davide.
1. From my point of view, is an error in the documentation.
2. Did you find the cisco sample application that uses media driver?</summary>
    <dc:creator>Antonio Sedano</dc:creator>
    <dc:date>2013-04-15T08:40:41Z</dc:date>
  </entry>
  <entry>
    <title>RE: TSP Media Driver</title>
    <link rel="alternate" href="http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=10905632" />
    <author>
      <name>Davide Cocchi</name>
    </author>
    <id>http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=10905632</id>
    <updated>2013-01-20T15:10:50Z</updated>
    <published>2013-01-20T15:10:50Z</published>
    <summary type="html">No suggestions??</summary>
    <dc:creator>Davide Cocchi</dc:creator>
    <dc:date>2013-01-20T15:10:50Z</dc:date>
  </entry>
  <entry>
    <title>TSP Media Driver</title>
    <link rel="alternate" href="http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=9108208" />
    <author>
      <name>Davide Cocchi</name>
    </author>
    <id>http://developer.cisco.com/c/message_boards/find_message?p_l_id=&amp;messageId=9108208</id>
    <updated>2012-12-05T14:03:06Z</updated>
    <published>2012-12-05T14:03:06Z</published>
    <summary type="html">Hello to everybody,
i'm approaching the new TSP Media Driver, in order to be compatible with the new UCM 9.0.
I have 2 questions about this argument:
  1. I found a mismatch in documentation about library naming: in 64 bit os the library ciscortplib.dll changes name in ciscortplib64.dll. Is this an error that will be fixed (the library name will remain ciscortplib.dll also in 64 bit os) or not?
  2. Is there any cisco sample application that uses media driver, which explains in a more detailed way this new integration?
Thank you all,
Davide.</summary>
    <dc:creator>Davide Cocchi</dc:creator>
    <dc:date>2012-12-05T14:03:06Z</dc:date>
  </entry>
</feed>

