|
DSP Library |
Top Previous Next |
|
Media hooks in DSP library.
The custom processing of audio data is a frequent task for VoIP development.
Example tasks could include
Providing solutions for all possible scenarios in an API is a daunting task and would take a great number of additional API methods. Additionally, attempting to extend the API to support every scenario could greatly limit the developer who's goal was not specifically predicted by the API.
To overcome these issues the ASTA SIP Toolkit provides media hooks methods. These methods as a proxy between the SDK and multimedia devices.
Developer can readily modify data coming to or from multimedia devices using these methods.
Initially these methods were available in Delphi and the desktop .NET ASTA SIP SDK editions only.
For COM version and Compact Framework .NET v.1 they were not available. The reason is the technical impossibility to call these handlers directly from the SDK core avoiding long marshaling steps.
Marshalling could cause delays in media processing and greatly degrade audio (or in the future video quality).
This is one of the reasons why these methods were moved to a separate DLL. Developer should code this DLL and tell the SDK where this library can be found.
Example:
SIPEndPoint.SetDSPLibrary(“MyDSP.dll”, 0);
SDK will load MyDSP.dll and will call the media hooks from it directly – without inter threading marshaling.
Lets look on the declaration of one of the media hook calls:
extern "C" void __stdcall OnMediaOpenRX(LPCTSTR callToken, DWORD_PTR userData, DWORD_PTR userObject);
You should note userData and userObject parameters.
The userData value is specified in MakeCall/AcceptCall methods calls. You can use it for associating your data structures with the call.
userObject is not used yet – it is reserved for future use.
Note – the media hook functions should be exported from the DLL.
For C++ it means that their name must be listed in the .def file.
Helper DSP library documentation.
The AstaSIP library makes it possible to hook all of the media/RTP data for custom processing such as recording, encrypting etc.via then event mechanisms events exposed by the (T)AstaSIPEndPoint class.
Due to technical limitations, these events are only available using the Delphi version or the desktop .NET version. To overcome these limitations the idea of a user defined additional DSP library was created.
This library consists of the same event handler methods available in the Delphi or desktop .NET application with media/RTP callbacks. However it is called by the AstaSIP library directly without any proxying classes in the same context and thread as AstaSIP library executes. This reduces any possible performance penalty . This way is useful for all AstaSIP versions – COM, desktop .NET, PocketPC .NET, Delphi, static C++ library.
Also the DLL may be written in C/C++ to provide maximum performance, while application may be written, for example, in Visual Basic.
Helper library MAY include the following exported functions(C/C++ syntax is used):
extern "C" void __stdcall OnMediaOpenRX(LPCTSTR callToken, DWORD_PTR userData, DWORD_PTR userObject);
extern "C" void __stdcall OnMediaCloseRX(LPCTSTR callToken, DWORD_PTR userData, DWORD_PTR userObject);
extern "C" void __stdcall OnMediaOpenTX(LPCTSTR callToken, DWORD_PTR userData, DWORD_PTR userObject);
extern "C" void __stdcall OnMediaCloseTX(LPCTSTR callToken, DWORD_PTR userData, DWORD_PTR userObject);
extern "C" void __stdcall OnMediaRXData(LPCTSTR callToken, DWORD_PTR userData, DWORD_PTR userObject, void* data, int sizeInBytes);
extern "C" void __stdcall OnMediaTXData(LPCTSTR callToken, DWORD_PTR userData, DWORD_PTR userObject, void* data, int sizeInBytes);
extern "C" void __stdcall OnVideoRXData(LPCTSTR callToken, DWORD_PTR userData, DWORD_PTR userObject, void* data, int sizeInBytes);
extern "C" void __stdcall OnVideoTXData(LPCTSTR callToken, DWORD_PTR userData, DWORD_PTR userObject, void* data, int sizeInBytes);
extern "C" void __stdcall OnRTPRXData(LPCTSTR callToken, DWORD_PTR userData, DWORD_PTR userObject, int payloadType, int mediaType, void* data, int sizeInBytes);
extern "C" void __stdcall OnRTPTXData(LPCTSTR callToken, DWORD_PTR userData, DWORD_PTR userObject, int payloadType, int mediaType, void* data, int sizeInBytes);
The signatures of these functions are equal to the signatures of corresponding events in C#/Delphi versions. AstaSIP library distribution includes sample of such library with sources.
|