WinRTP Programmer's Guide 翻译
WinRTP
Programmer’s Guide
MWG_arden 翻译
免责申明:此文档来自vovida.org 并遵守GPL 我翻译是为了自己熟悉,要是错了别找我茬。
纵览Overview of this Document 1
介绍Introduction. 1
更新What's New.. 1
功能Features. 2
组件及安装Components and Installation. 2
源码发布Source Code Distribution. 2
二进制发布Binary Distribution. 3
安装Installation. 3
测试程序Test Program.. 3
接口描述/程序员指南Interface Description/Programmer’s Guide. 3
WINRTP COM 接口WINRTP COM Interface. 3
WINRTP接口详解(ICCNMedia)Details of WINRTP Interface (Interface ICCNMediaTerm) 4
COM的GUID COM GUIDs, etc. 9
可选参数 Configurable Parameters. 12
静态/动态 抖动缓冲器 Static/Dynamic Jitter Buffer 12
抖动缓冲区大小Jitter Buffer Length. 12
接收的RTP音频流放大等级 Level of Auto-Amplification of incoming RTP audio streams 12
发送的RTP包的TOS值Type of Service Value (DiffServ Byte) of Outgoing RTP Packets 12
指定UDP传输端口Fixed Transmit Port for UDP Packets. 12
发送音频的预加重Pre-emphasis of transmitted audio. 13
接受音频的后加重Post-emphasis of received audio. 13
音量限制Volume Limiting. 13
示例代码Sample Code. 13
未来的改进Future Improvements. 14
纵览Overview of this Document
此文档以程序员的视角描述了用于Cisco IP电话软件的WINRTP。它论述了WINRTP的COM接口、安装以及各组件的配置。
Introduction介绍
WINRTP最基础的工作是发起和接收网络上的音频流。如果一个应用软件需要实时语音的支持(特别是当它集成了Cisco的AVVID),它可以使用WINRTP组件。
What's New 更新
Here are the improvements since the last version
这里是新版本的改进:
- Completely standalone package – Compatible with all flavors of desktop Windows starting from Windows 95. Uses standard .DLL files that come with all Windows flavors 完全独立的包—兼容所有从windows95以来的版本,使用标准DLL适用所有windows。
- Simple distribution: just two DLL's, no more .ax files. Also, the whole software is less than 300 Kbytes 简单的发布:只有两个DLL,再无.ax文件,整个软件小于300K字节
- Support for multiple sound cards 支持多声卡
- Dynamic jitter buffer algorithm option: it is very simple, but it works most of the time 动态抖动缓冲设置:简单而有效
- Audio quality enhancements: including pre-emphasis and post-emphasis of audio to make it sound sharper, automatic amplification of the incoming RTP audio stream 声音质量改善:添加音频预增强和后增强,使声音清晰 。自动增大RTP音频流。
- Others: Volume limiter algorithm in case you want to use it. 其它:需要时可以音量限制
- Comes with pre-built binaries for your convenience 带有预先编译好的二进制文件,便于用户使用
- Ability to play any wav file. Previous format restrictions removed. Also, now you can play as many files at the same time as you want 取消先前格式限制支持播放任何wav 文件。并且,可以同时播放多个文件。
Features 功能
支持多个音频设备: 此版本WinRTP支持多音频设备。这样,如果你的PC上有多个音频设备,你可以自由地选择使用那个设备去发送和接收。
流数量:现在只支持一个输入音频流和一个输出音频流。这是因为WINRTP声卡,同时只有一个应用程序可以使用系统扬声器或麦克风。
混音支持: WINRTP允许输入或输出音频流混合其它来自WAV文件的音频流。
音量调节支持:WINRTP支持设置麦克风、扬声器以及被混音的音频流的音量。
静音抑制:WINRTP支持输出流的静音抑制(声音活动性检查VAD)。这就是说,如果发现静音(用户没说话),它可以停止输出RTP包,以节省网络带宽。
Qos支持:WINRTP支持在输出RTP包中标示DiffServ 。
- RTP Implementation: Encoding and decoding of RTP packets.
- WINRTP does not support RTCP, but it does sink RTCP packets sent by the other end to prevent ICMP messages due to discarded packets.
RTP 实现:编码和解码RTP包。
WINRTP不支持RTCP,但是它可以接收其它端发来的RTCP包,以免ICMP消息导致的丢包。
- Independence of transmit/receive sides: The transmit and receive sides are independent, and that means
- Different codecs may be used for transmit and receive
- User can choose to do only one of the two operations
发送和接收端的独立性:发送和接收端是独立的,这就是说:
发送和接收可以使用不同的codecs(多媒体数字信号编解码器)。
用户可以选择只做其中某项操作。
- Operating Systems Supported: All flavors of windows Windows95 and later, including Windows NT (Service Pack 3 onwards), Windows ME and Windows 2000/XP
操作系统支持:支持Windows95以后的版本,包括WindowsNT,WindowsME 及Windows2000/XP
- Configurable/Dynamic Jitter Buffer: The depth of the jitter buffer can be specified, or a dynamic jitter buffer can also be used
可配置动态的抖动缓冲:可以设置抖动缓冲的深度值,也可以使用动态抖动。
- DSP algorithms: like pre-emphasis and post-emphasis to make the audio sound sharper. Volume limiting to control the max volume, and auto-amplification of incoming RTP audio streams
DSP算法: 如预加重及后加重使声音更清晰,音量限制控制最大音量,自动放大输入的RTP音频流。
Components and Installation 组件及安装
发行版同时包含了源代码及二进制文件。解开ZIP文件,可以得到所有文件。
Source Code Distribution 源代码发布
Build Order 编译 顺序
- TracerServer
- Tracer
- CCNMediaTerm
This will create TraceServer.dll and CCNSMT.dll. Build these projects either in Debug or Release mode.
这将建立TraceServer.dll 和CCNSMT.dll 两个文件,请在Debug和Release两个模式下都编译。
Binary Distribution 二进制发布
WINRTP binary distribution consists of two DLL files under the WinRTP directory. The main COM DLL (CCNSMT.dll) that exposes the WINRTP interface is about 200Kbytes while the other (TraceServer.dll) DLL (used for tracing) is 28Kbytes
WINRTP的二进制发布在WinRTP目录下包含了两个DLL文件。主要的COM 动态链接库(CCNSMT.dll)提供给我们WINRTOP的接口,大概200K字节大小。TraceServer.dll 28K字节。
Installation安装
Third Party Dependencies 第三方依赖
Location of Distributed Files 文件位置:
CCNSMT.dll: 这是一个COM组件,当它被系统注册以后它的位置已经不重要。推荐将它保存在一个单独的目录中或使用WINRTP的应用程序目录。
Final Install Steps 最后一步:
所有COM对象在使用前必须进行注册,对于WINRTP,我们可以使用windows自带的regsvr32程序完成,命令如下:
Test Program 测试程序
Interface Description/Programmer’s Guide 接口描述及程序员指南
WinRTP主要的DLL是CCNSMT.dll,它提供了我们一个COM接口用于调用WINRTP。
WINRTP COM Interface WINRTP COM 接口
The interface of WINRTP (ICCNMediaTerm) consists of the following functions
- HRESULT Initialize()
- HRESULT UnInitialize()
- HRESULT StartMicrophone() - not implemented/needed in this version.
- HRESULT StopMicrophone() - not implemented/needed in this version.
- HRESULT StartAudioReceive() - not implemented/needed in this version.
- HRESULT StopAudioReceive() - not implemented/needed in this version.
- HRESULT SetAudioCodecRX(
[in] long CompressionType,
[in] long MillisecPacketSize,
[in] long EchoCancellationValue,
[in] long G723BitRate
) - HRESULT SetAudioCodecTX(
[in] long CompressionType,
[in] long MillisecPacketSize,
[in] long PrecedenceValue,
[in] long SilenceSuppression,
[in] unsigned short MaxFramesPerPacket,
[in] long G723BitRate
) - HRESULT SetAudioDestination(
[in] BSTR strHostName,
[in] long nUDPortNumber
) - HRESULT SetAudioReceivePort(
[in] long nUDPPortNumber
) - HRESULT StartPlayingFileTX(
[in] BSTR Filename,
[in] unsigned long Mode,
[in] unsigned long StartPosition,
[in] unsigned long StopPosition,
[in, out] long * Cookie
) - HRESULT StartPlayingFileRX(
[in] BSTR Filename,
[in] unsigned long Mode,
[in] unsigned long StartPosition,
[in] unsigned long StopPosition,
[in] unsigned long waveoutDeviceID,
[in, out] long * Cookie
) - HRESULT StopPlayingFileTX(
[in] unsigned long Cookie
) - HRESULT StopPlayingFileRX(
[in] unsigned long Cookie
) - HRESULT StartTX(unsigned long waveinDeviceID)
- HRESULT StopTX()
- HRESULT StartRX(unsigned long waveoutDeviceID)
- HRESULT StopRX()
- HRESULT SetSpeakerVolume(
[in] unsigned long volume
) - HRESULT SetMicrophoneVolume(
[in] unsigned long volume
) - HRESULT SetFilePlayVolume(
[in] unsigned long cookie,
[in] unsigned long volume
)
Events From WINRTP
The events interface (ICCNMediaTermEvents) is as follows
· HRESULT EndOfFileEventRX(
[in] long Cookie
)
· HRESULT EndOfFileEventTX(
[in] long Cookie
)
Details of WINRTP Interface (Interface ICCNMediaTerm) WINRTP接口详解
HRESULT Initialize()
Description:
Initializes the WINRTP. Instantiates all components. Also sets up default codecs using the following calls
初始化WINRTP,初始化所有组件,并且使用下面调用设置默认codecs:
- SetAudioCodecTX(Codec = G711 Ulaw 64kbps, 20, 0, 0, 1, 0)
- SetAudioCodecRX(Codec = G711 Ulaw 64kbps, 20, 0, 0)
This function must be called before any other calls to WINRTP
调用所有其它WINRTP函数前必须调用该函数。
Parameters:
None 无参数
HRESULT UnInitialize()
Description:
Uninitializes the WINRTP and releases all allocated resources. This must be the last call made to the WINRTP
销毁WINRTP,释放所有分配的资源。这必须是WINRTP的最后一个调用。
Parameters:
None 无参数
HRESULT StartMicrophone()
Description:
No implemented/needed in this version
没有在此版本中实现
Parameters:
None
HRESULT StopMicrophone()
Description:
No implemented/needed in this version
没有在此版本中实现
Parameters:
None
HRESULT StartAudioReceive()
Description:
No implemented/needed in this version
没有在此版本中实现
Parameters:
None
HRESULT StopAudioReceive()
Description:
No implemented/needed in this version
没有在此版本中实现
Parameters:
None
HRESULT SetAudioCodecRX
Description:
Call this function to inform WINRTP of the audio codec used to encode the incoming RTP stream. This function may be called before StartRX is called. (so you may need to call StopRX before making this call). If called before StartRX is called, it sets the codec for the next invocation of StartRX. If it is called while receiving audio (i.e. after StartRX) it may return an error.
调用这个函数通知WINRTP对输入RTP流使用那个编码。此函数可能在StartRX之前调用(所以,你可能需要此函数前调用StopRX)。如果StartRX已经调用了,它将设置下一个StartRX,如果调用时正在接收数据,它返回一个错误。
Parameters:
[in] long CompressionType: The following values are supported
· 2 : G.711 Alaw 64kbps
· 4 : G.711 Ulaw 64kbps
[in] long MillisecPacketSize: Specifies the length of audio in each incoming RTP audio packets
[in] long EchoCancellationValue: Ignored. Put any value here. Echo cancellation is not supported in the WINRTP
[in] long G723BitRate: Ignored
HRESULT SetAudioCodecTX
Description:
Sets the audio codec for the transmit stream (outgoing stream). Should be called while NOT streaming (i.e. before StartTX/after StopTX)
设置输出流的codecs,需要在没有流传输时调用(如,StartTX之前,StopTX之后)
Parameters:
[in] long CompressionType: See SetAudioCodecRX
[in] long MillisecPacketSize: See SetAudioCodecRX
[in] long PrecedenceValue: Ignored
[in] long SilenceSuppression: Specifies whether to do silence suppression in the transmit stream
0 : Silence suppression is turned OFF
1 : Silence suppression is turned ON
[in] unsigned short MaxFramesPerPacket: Ignored
[in] long G723BitRate: See SetAudioCodecRX
HRESULT SetAudioDestination
Description:
Sets the destination [IP Address, UDPPort] where the send side audio stream should be transmitted. Must be called while not streaming (i.e. Before StartTX/after StopTX).
设置发送端传输音频流的目的地[IP地址,UDP端口] 。必须在无流传输时调用(如,StartTX之前,StopTX之后)。
Parameters:
[in] BSTR strHostName: IP address of the destination. E.g. “171.69.12.34”
[in] long nUDPortNumber: UDP port number where to send the stream
HRESULT SetAudioReceivePort
Description:
Informs the WINRTP of the UDP port number where it should listen for the incoming RTP audio stream. Note: StartAudioReceive must be called before any audio from the incoming stream is played to the speaker.
告知WINRTP用于监听输入RTP音频流的UDP地址。注:StartAudioReceive必须在输入流已经播放之前。
Parameters:
[in] long nUDPPortNumber: UDP port number
HRESULT StartPlayingFileTX
Description:
This method should be used when a WAV file needs to be transmitted. The audio from the file is mixed in with the outgoing audio stream (user’s voice). The WINRTP fires an event to let the caller know when the file has finished playing, so that another file may be played. If the file finished playing, the WINRTP automatically calls StopPlayingFileTX so the caller need not call it. Only one file may be playing at a time. If this function is called while another file is playing already, an error is returned and the original file keeps playing. The function returns an unique identifier (cookie) that may be used in later calls related to this file play (to set the volume, or stop it from playing any more). This method can also play the file in a loop continuously without stopping. By default, files start playing at 25% volume.
此方法用于WAV文件需要传输时。文件的音频将同输出流混音。WINRTP发送一个事件让调用者知道文件已经播放完毕,这时其它文件可以播放。当文件播放完毕,WINRTP自动调用StopPlayingFileTX ,调用者不必再调用。同一时刻只能播放一个文件。如果此函数调用时已经有文件在播放,此调用将返回一个错误,原来的文件将继续播放。函数返回一个唯一标示,可以被用于之后的函数调用(设置音量、停止播放等)。此方法也可以无间断地重复播放一个文件。默认情况下,文件以25%的音量大小播放。
Parameters:
[in] BSTR Filename: the location (path) of the file to be played 待播放文件的位置(路径)
[in] unsigned long Mode: specifies whether to play the file once or in a loop 制定播放一次或循环
· 0 : play the file continuously in a loop
· 1 : play the file once
[in] unsigned long StartPosition: unimplemented/ignored
[in] unsigned long StopPosition: unimplemented/ignored
[in, out] long * Cookie: WINRTP returns a unique ID for this instance of the file being played. This cookie should be used in later calls pertaining to the instance of the file playing
HRESULT StartPlayingFileRX
Description:
This function starts mixing audio from the specified file to the received audio stream, so that the user hears audio from both the incoming audio stream and the file. The only difference is that we can have two files playing simultaneously in the receive side instead of one. By default, files start playing at 25% volume.
此函数开始对接收音频流和制定的文件进行混音。用户将同时听到输入音频流和文件音频,唯一的不同点是我们可以在接收端同时播放两个文件。默认音量为25%。
Parameters:
Exactly the same as StartPlayingFileTX, but with another extra parameter
[in] unsigned long waveoutDeviceID: specifies which speaker device to play the file to. WinRTP now allows you to play the file using the wave/speaker device opened for audio (with StartRX) or to another wave/speaker device. sometimes it may be useful to play a file locally to another audio device (for e.g. if you are using a USB headset for speech, you may want to play ring tones for incoming calls through the speakers connected to the sound card so that it is heard loudly). See StartRX for a discussion on waveoutDeviceID
HRESULT StartTX
Description:
Starts streaming on the transmit side. This method must be called before StartPlayingFileTX is called. Calling this method starts transmitting the user’s voice
在传输端开始流。此函数必须在StartPlayingFileTX函数调用前。调用此方法开发传输用户语音。
Parameters:
unsigned long waveinDeviceID: specifies which audio device to use for audio capture/recording. device ID's are numbered 0...(#of recording audio devices-1), and -1 means use default audio device for windows. Check out waveInOpen() and waveInGetDevCaps() in the windows API. If you are confused, -1 actually means (unsigned long) –1.
HRESULT StartRX
Description:
Sets up WINRTP to start the receive side. It also starts playing the received audio to the speaker.
设置接收端开始WINRTP,它也开始播放接收到的音频。
Parameters:
unsigned long waveoutDeviceID: specifies which audio device to use for playback/speaker. These device ID's are numbered 0 ... (# of playback devices - 1), and -1 means use the default playback device. Check out waveOutOpen() and waveOutGetDevCaps() functions in the windows API.. If you are confused, -1 actually means (unsigned long) –1.
HRESULT StopTX
Description:
Stops transmitting audio. Stops transmitting the user’s voice and files.
停止传输语音。停止传输用户语音及文件。
Parameters:
None
HRESULT StopRX
Description:
Stops receiving and playing audio. Stops playing the received audio stream and the files
停止接收和播放音频。停止播放接收的音频流及文件。
Parameters:
None
HRESULT SetSpeakerVolume
Description:
Sets the speaker volume on the PC. This setting sets the WAVEOUT volume of the system (not the master volume).
设置PC扬声器音量。此调用设置系统的WAVEOUT音量(不是主音量)。
Parameters:
[in] unsigned long volume: value between 0 and 100 where 0 = silence, and 100 = max volume. The scale is linear, so 50 = half volume
HRESULT SetMicrophoneVolume
Description:
Sets the microphone volume. This setting changes the PC’s microphone volume or audio capture volume.
设置麦克风音量。此调用改变麦克风音量或音频捕捉音量。
Parameters:
[in] unsigned long volume: value between 0 and 100 where 0 = silence, and 100 = max volume. The scale is linear, so 50 = half volume
HRESULT SetFilePlayVolume
Description:
Sets the volume of a file being played by the WINRTP.
设置WINRTP正在播放的文件的音量
Parameters:
[in] unsigned long cookie: the cookie that pertains to this instance of the file play. The cookie is obtained when StartPlayingFileTX(or RX) is called
[in] unsigned long volume: Volume setting. Starts from 0 (silence) to 100 (max volume)
HRESULT StopPlayingFileTX
Description:
Stops a file being played in the transmit side
在传输端停止当前文件播放
Parameters:
[in] unsigned long Cookie: Cookie that was returned when the file started playing.
HRESULT StopPlayingFileRX
Description:
Stops a file being played in the receive side
在接收端停止当前文件播放。
Parameters:
[in] unsigned long Cookie: Cookie that was returned when the file started playing.
COM GUIDs, etc
The important GUIDs are 最主要的GUID为:
- WinRTP COM object (CCNMediaTerm class) : 94221C4E-00F1-11D4-9D59-0060B0FC246C
- WinRTP COM Inteface (ICCNMediaTerm) : 94221C4D-00F1-11D4-9D59-0060B0FC246C
- WinRTP Events Interface (_ICCNMediaTermEvents) : 94221C4F-00F1-11D4-9D59-0060B0FC246C
The following code snippet may be useful for more information 下面的小代码断可能会提供更多信息:
WINRTP Interface
// CCNSMT.idl : IDL source for CCNSMT.dll
//
// This file will be processed by the MIDL tool to
// produce the type library (CCNSMT.tlb) and marshalling code.
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(94221C4D-00F1-11D4-9D59-0060B0FC246C),
helpstring("ICCNMediaTerm Interface"),
pointer_default(unique)
]
interface ICCNMediaTerm : IUnknown
{
[helpstring("method Initialize")]
HRESULT Initialize();
[helpstring("method UnInitialize")]
HRESULT UnInitialize();
[helpstring("method StartMicrophone")]
HRESULT StartMicrophone();
[helpstring("method StopMicrophone")]
HRESULT StopMicrophone();
[helpstring("method StartAudioReceive")]
HRESULT StartAudioReceive();
[helpstring("method StopAudioReceive")]
HRESULT StopAudioReceive();
[helpstring("method StopDtmfTone")]
HRESULT StopDtmfTone();
[helpstring("method SetAudioCodecRX")]
HRESULT SetAudioCodecRX([in] long CompressionType, [in] long MillisecPacketSize, [in] long EchoCancellationValue, [in] long G723BitRate);
[helpstring("method SetAudioCodecTX")]
HRESULT SetAudioCodecTX([in] long CompressionType, [in] long MillisecPacketSize, [in] long PrecedenceValue, [in] long SilenceSuppression, [in] unsigned short MaxFramesPerPacket, [in] long G723BitRate);
[helpstring("method SetAudioDestination")]
HRESULT SetAudioDestination([in] BSTR strHostName, [in] long nUDPortNumber);
[helpstring("method SetAudioReceivePort")]
HRESULT SetAudioReceivePort([in] long nUDPPortNumber);
[helpstring("method StartDtmfTone")]
HRESULT StartDtmfTone([in] long cToneAsChar, [in] long OnTime, [in] long OffTime);
[helpstring("method StartPlayingFileTX")]
HRESULT StartPlayingFileTX([in] BSTR Filename, [in] unsigned long Mode, [in, out] long * Cookie);
[helpstring("method StartPlayingFileRX")]
HRESULT StartPlayingFileRX([in] BSTR Filename, [in] unsigned long Mode, [in] unsigned long waveoutDeviceID, [in, out] long * Cookie);
[helpstring("method StopPlayingFileTX")]
HRESULT StopPlayingFileTX([in] unsigned long Cookie);
[helpstring("method StopPlayingFileRX")]
HRESULT StopPlayingFileRX([in] unsigned long Cookie);
[helpstring("method StartTX")]
HRESULT StartTX([in] unsigned long waveinDeviceID);
[helpstring("method StopTX")]
HRESULT StopTX();
[helpstring("method StartRX")]
HRESULT StartRX([in] unsigned long waveoutDeviceID);
[helpstring("method StopRX")]
HRESULT StopRX();
[helpstring("method SetSpeakerVolume")]
HRESULT SetSpeakerVolume([in] unsigned long deviceID, [in] unsigned long volume);
[helpstring("method SetMicrophoneVolume")]
HRESULT SetMicrophoneVolume([in] unsigned long deviceID, [in] unsigned long volume);
[helpstring("method SetFilePlayVolume")]
HRESULT SetFilePlayVolume([in] unsigned long cookie, [in] unsigned long volume);
[helpstring("method NetworkMonitor")]
HRESULT NetworkMonitor([in] unsigned long Enable, [in] unsigned long DurationMillisec);
};
[
uuid(94221C4F-00F1-11D4-9D59-0060B0FC246C),
helpstring("_ICCNMediaTermEvents Interface")
]
interface _ICCNMediaTermEvents : IUnknown
{
[helpstring("method EndOfFileEventRX")]
HRESULT EndOfFileEventRX([in] long Cookie);
[helpstring("method EndOfFileEventTX")]
HRESULT EndOfFileEventTX([in] long Cookie);
[helpstring("method NetworkMonitorEventRX")]
HRESULT NetworkMonitorEventRX([in] double RXMean, [in] double RXVariance);
[helpstring("method NetworkMonitorEventTX")]
HRESULT NetworkMonitorEventTX([in] double TXMean, [in] double TXVariance);
};
[
uuid(94221C40-00F1-11D4-9D59-0060B0FC246C),
version(1.0),
helpstring("CCNSMT 1.0 Type Library")
]
library CCNSMTLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(94221C4E-00F1-11D4-9D59-0060B0FC246C),
helpstring("CCNMediaTerm Class")
]
coclass CCNMediaTerm
{
[default] interface ICCNMediaTerm;
[default, source] interface _ICCNMediaTermEvents;
};
};
Type Library
[
uuid(94221C40-00F1-11D4-9D59-0060B0FC246C),
version(1.0),
helpstring("CCNSMT 1.0 Type Library")
]
library CCNSMTLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(94221C4E-00F1-11D4-9D59-0060B0FC246C),
helpstring("CCNMediaTerm Class")
]
coclass CCNMediaTerm
{
[default] interface ICCNMediaTerm;
[default, source] interface _ICCNMediaTermEvents;
};
};
Sample C++ Code 示例C++代码:
Using the type library generated while compiling WinRTP (CCNSMT.tlb) one can easily use WinRTP in code. Visual C++ 6.0 allows importing a type library in the #import command, as the following sample code shows. Note that you cannot import WinRTP as a COM object into your project because it is NOT and ActiveX control nor does it support IDispatch.
使用编译WINRTP时得到的类型库文件,可以在编码时很容易的使用WinRTP。就像下面代码显示的那样,VC 6.0 允许使用#import 命令导入一个类型库。注意,你不可以把WINRTP当作一个COM 对象导入你的工程,因为它不是。而且ActiveX 控件也不支持IDispatch。
#import "../CCNMediaTerm/CCNSMT/CCNSMT.tlb" no_namespace, raw_interfaces_only
int main()
{
HRESULT hr;
// Initialize COM
hr = CoInitialize(NULL);
// Get Interface ICCNMediaTerm from the WinRTP COM Object using smart pointer defined by the #import command above.
// Automatically calls IUnknown::AddRef();
ICCNMediaTermPtr pICCNMediaTerm(__uuidof(CCNMediaTerm));
// Initialize WinRTP. Must be the first call
pICCNMediaTerm->Initialize();
// Set parameters for receive side
pICCNMediaTerm->SetAudioCodecRX(4, 20, 0, 0);
pICCNMediaTerm->SetAudioReceivePort(8500);
// Set parameters for transmit side
pICCNMediaTerm->SetAudioCodecTX(4, 20, 0, 0, 0, 0);
pICCNMediaTerm->SetAudioDestination(L"127.0.0.1", 8500);
// Start reception side. we will use the default (-1) playback device
pICCNMediaTerm->StartRX(-1);
// Start transmit side. we will use the default (-1) recording device
pICCNMediaTerm->StartTX(-1);
// Set the speaker volume to 50%
pICCNMediaTerm->SetSpeakerVolume(-1, 50);
// Set the microphone volume to 50%
pICCNMediaTerm->SetMicrophoneVolume(-1, 50);
// Hear yourself for 5 seconds
Sleep(5000);
// Stop reception & transmission
pICCNMediaTerm->StopRX();
pICCNMediaTerm->StopTX();
// Unitialize WinRTP. Must be the last call
pICCNMediaTerm->UnInitialize();
// Let go of the reference to the ICCNMediaTerm interface. Automatically calls IUnknown::Release()
pICCNMediaTerm = 0;
// Uninitialize COM
CoUninitialize();
return 0;
}
Configurable Parameters 可选参数
Static/Dynamic Jitter Buffer 静态/动态 抖动缓冲
设置 UseDynamicJitterBuffer 条目为 “true” 则在音频接收时使用动态抖动缓冲算法。设置为“false” 则使用静态抖动缓冲(就像上的版本一样)
Jitter Buffer Length 抖动缓冲长度
Try the following (Windows 2000/XP : 60ms, WinNT 4.0 : 120ms, Win 95/98/ME : 180ms
按照操作系统不同,可尝试下面的设置:Windows 2000/XP : 60ms, WinNT 4.0 : 120ms, Win 95/98/ME : 180ms
Level of Auto-Amplification of incoming RTP audio streams 接收的RTP音频流自动放大等级
VolumeMaximizeMaxGain (floating point number >= 1.0 e.g. 8.0 )
VolumeMaximizePercentile (floating point number between 0.0 and 100.0 )
Type of Service Value (DiffServ Byte) of Outgoing RTP Packets 输出RTP包的TOS
Fixed Transmit Port for UDP Packets 指定UDP 传输端口
Pre-emphasis of transmitted audio 发送音频的预加重
Post-emphasis of received audio 接收音频的后加重
Volume Limiting 音量限制
Sample Code 示例代码
下面的段落叙述了一个使用Media Term组件的例子。下面是步骤:
- Initialize COM (CoInitializeEx) 初始化COM,使用(CoInitializeEx)
- Instantiate the Media Term Component and get the ICCNMediaTerm COM interface (Say the variable is CCNMediaTerm) using CoCreateInstance
初始化Media Term 组件,使用CoCreateInstance得到ICCNMediaTerm接口 (CCNMediaTerm)
o SetAudioCodecTX(4, 30, 0, 0, 1, 0);
o SetAudioDestination(“127.0.0.1”, 21243);
· Start transmission using the default audio capture device 开始发送音频流
o StartPlayingFileTX(“foo.wav”, 1, 0, 0, &sendFileCookie)
· Set the volume of the “foo.wav” file to 50% 设置音量为50%
o SetFilePlayVolume(sendFileCookie, 50)
o SetAudioCodecTX(9, 30, 0, 1, 1, 0)
· Stop Transmitting (everything, including voice and files) 停止传输
o SetAudioCodecRX(4, 30, 0, 0);
· Start receive side using the default audio playback device 使用默认的回放设备开始接收
o StartPlayingFileRX(“foo.wav”, 0, 0, 0, -1, &receiveFileCookie1);
o StartPlayingFileRX(“foobar.wav”, 1, 0, 0. –1, &receiveFileCookie2);
· Set the volume of the “foobar.wav” file to 25% 设置音量25%
o SetFilePlayVolume(receiveFileCookie2, 25)
· Stop playing the “foo.wav” file that was playing in a loop 停止“foo.wav”播放
o StopPlayingFileRX(receiveFileCookie1);
o SetAudioCodecRX(11, 30, 0, 0)
· Stop receiving (everything, including voice and files). This method releases the speaker停止接收
- Uninitialize the WINRTP and release all resources 销毁WINRTP ,释放所有资源
- Uninitialize()
- Uninitialize COM if needed using CoUninitialize 销毁COM
I plan to release some sample C++ code to show how to use this component soon
我计划不久后发布一些C++代码来展示如何使用这些组件。
Future Improvements 未来的改进
Some of the future improvements that are being considered are 一些未来需要做的改进:
WinRTP Programmer's Guide 翻译相关推荐
- Java Card Technology for Smart Card's Architecture and Programmer's Guide (Zhiqun Chen)翻译版(PART 0)
这是一本Java Card开发者的Bible,本人在Amazon上花了45大刀还不算运费才搞到的,翻译过来给大家共享.如果您觉得书不错,或者我翻译的烂,请支持正版. Java Card Technol ...
- NEON Programmer’s Guide
NEON Programmer's Guide NEON Programmer's Guide Version: 1.0 https://static.docs.arm.com/den0018/a/D ...
- ZooKeeper Programmer's Guide(3.4.6)英文快读
为什么80%的码农都做不了架构师?>>> Introduction This document is a guide for developers wishing to cre ...
- spring boot guide 翻译
Spring官方Guides 随着微服务的流行,Spring Boot/Cloud的崛起,Spring Source几乎再一次要成为Java的代名词.那么我们如何才能快速的学习和入门Spring呢?除 ...
- [泰然翻译] cocos2d programming guide翻译(10)
效果是一些动作,通过修改方格属性来代替不透明.位置.旋转等动作对普通属性的修改. 网格属性像矩阵,由一系列矩形组成的. 这些特别的动作可以用任意的CCNode(CCLayer,CCScene,CCSp ...
- Zookeeper Tutorial 2 -- Programmer's Guide
数据模型 ZooKeeper跟分布式文件系统一样, 有一系列的命名空间. 唯一不同的地方是命名空间中的每个节点都有数据和他相关联. 它类似于一个允许文件同时是一个目录的文件系统. 节点的路径永远是以斜 ...
- 程序员延寿指南 | A programmer's guide to live longer
说明 程序员延寿指南是个开源项目,因为作者之前和一些技术群分享过,大家好评很多,于是作者索性把这些年攒的方法开源了,目前已有3.1k的Star. 考虑到一些童鞋打不开Github,也放了Gitee的链 ...
- DPDK Programmer’s Guide(3)环境抽象层(EAL)
官方文档查看地址: http://doc.dpdk.org/guides/prog_guide/env_abstraction_layer.html PDF下载地址: https://www.inte ...
- Cisco IP电话软件的WINRTP
纵览Overview of this Document 介绍Introduction 更新What's New 功能Features 组件及安装Components and Installation ...
最新文章
- nio的优势_NIO研究所 | 最有AI的EC6故事
- 如何实现软件的国际化
- cf飞刀制作源码_(飞刀)KDJ+W%R发出分析家源码
- hashtable——散列表
- 单链表进阶学习 三段
- object references an unsaved transient instance - save the transient instance before flushing
- Hive表中加载数据的5中方式
- Unity3d资源包的使用心得
- mybatis3-中文文档
- 淘宝模拟登录2解决滑动验证问题
- python中文文本信息提取_PyMuPDF提取文本信息
- 60020:not allow to access from your ip
- linux c++ 线程支持 多核应用,linux C++多线程服务端开发
- 你不得不掌握的前端提交规范(git cz)
- 可扩展java游戏框架实践之java飞机大战
- 网页报错404原因及解决方法
- Java培训机构哪家好,不靠谱的有哪些
- 【渝粤题库】陕西师范大学100121 政治经济学作业 (高起专、高起本)
- 云呐|房地产企业固定资产管理系统优势
- 转:15条优化电脑系统开机速度方法
热门文章
- 无垠PE组合工具2017.09.03 维护版网络版
- 微软面试题【飞机加油问题】题解
- JAVA—— HTML
- ccie入门学习day1
- COleDateTime和COleDateTimeSpan类详细分析
- 荣耀7x刷android10,华为荣耀畅玩7X官方固件rom包_荣耀畅玩7X完整系统升级包
- 小白看物联网论文——EchoTag: Accurate Infrastructure-Free Indoor Location Tagging with Smartphones
- Unity3D脚本中文教程(八)
- 无服务计算应用场景探讨及 FaaS 应用实战
- Linux系统使用LAMP架构部署Discuz论坛系统,简洁明了