|
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.
AstaSIP library provides possibilities to hook all media/RTP data for custom processing such as recording, encrypting etc. It is done through events exposed by (T)AstaSIPEndPoint class. Due to technical limitations this way is possible only for Delphi version and desktop .NET. To overcome these limitations the idea of user defined addiotional DSP library was used. This library constists the same events handler methods as for usual Delphi or desktop .NET application with media/RTP callbacks. However it is called by AstaSIP library directly without any proxyfing classes in the same context and thread as AstaSIP library acts. This reduces performance overheads also. 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 maximal performance, while application may be written in VB even.
Helper library MAY include the next exported functions(C/C++ syntax is used):
extern "C" void __stdcall OnMediaOpenRX(DWORD callToken, DWORD_PTR userData, DWORD_PTR userObject);
extern "C" void __stdcall OnMediaCloseRX(DWORD callToken, DWORD_PTR userData, DWORD_PTR userObject);
extern "C" void __stdcall OnMediaOpenTX(DWORD callToken, DWORD_PTR userData, DWORD_PTR userObject);
extern "C" void __stdcall OnMediaCloseTX(DWORD callToken, DWORD_PTR userData, DWORD_PTR userObject);
extern "C" void __stdcall OnAudioRXData(DWORD callToken, DWORD_PTR userData, DWORD_PTR userObject, void* data, int sizeInBytes);
extern "C" void __stdcall OnAudioTXData(DWORD callToken, DWORD_PTR userData, DWORD_PTR userObject, void* data, int sizeInBytes);
extern "C" void __stdcall OnVideoRXData(DWORD callToken, DWORD_PTR userData, DWORD_PTR userObject, void* data, int sizeInBytes);
extern "C" void __stdcall OnVideoTXData(DWORD callToken, DWORD_PTR userData, DWORD_PTR userObject, void* data, int sizeInBytes);
extern "C" void __stdcall OnRTPRXData(DWORD callToken, DWORD_PTR userData, DWORD_PTR userObject, int payloadType, int mediaType, void* data, int* sizeInBytes, int* isModified);
extern "C" void __stdcall OnRTPTXData(DWORD callToken, DWORD_PTR userData, DWORD_PTR userObject, int payloadType, int mediaType, void* data, int* sizeInBytes, int* isModified);
The signatures of these functions are equal to signatures of corresponding events in C#/Delphi versions. AstaSIP library distribution includes sample of such library with sources. .
|