Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

489 lines
15 KiB

  1. /*
  2. * Filename: RRCM_DLL.H
  3. *
  4. * Description: Declares imported/exported RRCM functions.
  5. *
  6. * $Workfile: rrcm_dll.h $
  7. * $Author: CMACIOCC $
  8. * $Date: 14 Feb 1997 11:59:52 $
  9. * $Revision: 1.20 $
  10. * $Archive: R:\rtp\src\include\rrcm_dll.h_v $
  11. *
  12. * INTEL Corporation Proprietary Information
  13. * This listing is supplied under the terms of a license agreement with
  14. * Intel Corporation and may not be copied nor disclosed except in
  15. * accordance with the terms of that agreement.
  16. * Copyright (c) 1995 Intel Corporation.
  17. *
  18. */
  19. #ifndef _RRCMDLL_H_
  20. #define _RRCMDLL_H_
  21. // force 8 byte structure packing
  22. #include <pshpack8.h>
  23. #if !defined (RRCMDLL)
  24. //#define RRCMAPI __declspec (dllimport)
  25. //#else
  26. //#define RRCMAPI __declspec (dllexport)
  27. #endif
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #define MAX_SDES_LEN 256
  32. #define MAX_ENCRYPT_KEY_SIZE 8
  33. #define NUM_COLLISION_ENTRIES 10
  34. #define MAX_ADDR_LEN 80
  35. // RTCP SDES type
  36. typedef enum {
  37. RTCP_SDES_END,
  38. RTCP_SDES_CNAME,
  39. RTCP_SDES_NAME,
  40. RTCP_SDES_EMAIL,
  41. RTCP_SDES_PHONE,
  42. RTCP_SDES_LOC,
  43. RTCP_SDES_TOOL,
  44. RTCP_SDES_TXT,
  45. RTCP_SDES_PRIV
  46. } RTCP_SDES_TYPE_T;
  47. // RRCM events
  48. typedef enum
  49. {
  50. RRCM_NO_EVENT,
  51. RRCM_NEW_SOURCE_EVENT, // New SSRC detected
  52. RRCM_RECV_RTCP_RECV_REPORT_EVENT, // RTCP RR received
  53. RRCM_RECV_RTCP_SNDR_REPORT_EVENT, // RTCP SR received
  54. RRCM_LOCAL_COLLISION_EVENT, // Collision detected
  55. RRCM_REMOTE_COLLISION_EVENT, // Remote collision detected
  56. RRCM_TIMEOUT_EVENT, // SSRC timed-out
  57. RRCM_BYE_EVENT, // RTCP Bye received
  58. RRCM_RTCP_WS_RCV_ERROR, // Winsock error on RTCP rcv
  59. RRCM_RTCP_WS_XMT_ERROR // Winsock error on RTCP xmt
  60. } RRCM_EVENT_T;
  61. // RRCM events callback
  62. typedef void (*PRRCM_EVENT_CALLBACK) (RRCM_EVENT_T, DWORD_PTR, DWORD_PTR, DWORD_PTR);
  63. // RRCM SSRC entry update
  64. typedef enum
  65. {
  66. RRCM_UPDATE_SDES,
  67. RRCM_UPDATE_CALLBACK,
  68. RRCM_UPDATE_STREAM_FREQUENCY,
  69. RRCM_UPDATE_RTCP_STREAM_MIN_BW
  70. } RRCM_UPDATE_SSRC_ENTRY;
  71. // RTP/RTCP session bits mask
  72. #define RTCP_DEST_LEARNED 0x00000001 // RTCP destination address known ?
  73. #define H323_CONFERENCE 0x00000002 // H.323 conference control
  74. #define ENCRYPT_SR_RR 0x00000004 // Encrypt SR/RR
  75. #define RTCP_ON 0x00000008
  76. #define NEW_RTCP_SESSION 0x00000010
  77. #define RTCP_OFF 0x00000020
  78. #define SHUTDOWN_IN_PROGRESS 0x80000000 // Shutdown in progress
  79. // RTCP control
  80. #define RRCM_CTRL_RTCP 0x00000000
  81. #define RTCP_XMT_OFF 0x7FFFFFFF
  82. #define RTCP_ONE_SEND_ONLY 0x80000000
  83. // RTCP SDES data
  84. typedef struct _SDES_DATA
  85. {
  86. DWORD dwSdesType; // SDES type: CNAME/NAME/...
  87. char sdesBfr[MAX_SDES_LEN];
  88. DWORD dwSdesLength; // SDES length
  89. DWORD dwSdesFrequency; // SDES frequency
  90. DWORD dwSdesEncrypted; // SDES encrypted Y/N ?
  91. } SDES_DATA, *PSDES_DATA;
  92. // Encryption data
  93. typedef struct _encryption_info
  94. {
  95. DWORD dwEncryptType; // DES/Triple DES/...
  96. DWORD dwKeyLen; // Encryption key length
  97. char keyVal[MAX_ENCRYPT_KEY_SIZE];
  98. } ENCRYPT_INFO, *PENCRYPT_INFO;
  99. // Received sequence numbers/cycles. Union allows access as combined
  100. // cycle/sequence number or as either field alone for optimizations
  101. typedef struct _RTP_SEQUENCE
  102. {
  103. WORD wSequenceNum;
  104. WORD wCycle;
  105. } RTP_SEQUENCE, *PRTP_SEQUENCE;
  106. typedef struct _RTP_SEQ_NUM
  107. {
  108. union {
  109. DWORD dwXtndedHighSeqNumRcvd; // Combined cycle/sequence number
  110. RTP_SEQUENCE RTPSequence; // Cycle/sequence number separate
  111. } seq_union;
  112. } RTP_SEQ_NUM, *PRTP_SEQ_NUM;
  113. // Link list elements
  114. typedef struct _LINK_LIST
  115. {
  116. struct _LINK_LIST *next; // Next in list / Head of list
  117. struct _LINK_LIST *prev; // Previous in list / Tail of list
  118. } LINK_LIST, *PLINK_LIST, HEAD_TAIL, *PHEAD_TAIL;
  119. // Application provided buffer for RTCP to copy the raw RTCP report into
  120. typedef struct _APP_RTCP_BFR
  121. {
  122. LINK_LIST bfrList; // Next/prev buffer in list
  123. char *bfr;
  124. DWORD dwBfrLen;
  125. DWORD dwBfrStatus; // RTCP Operation on this Bfr
  126. #define RTCP_SR_ONLY 0x00000001 // Only copy RTCP packet
  127. DWORD dwBytesRcvd;
  128. HANDLE hBfrEvent;
  129. } APP_RTCP_BFR, *PAPP_RTCP_BFR;
  130. // RTCP sender's feedback data structure
  131. typedef struct _RTCP_FEEDBACK
  132. {
  133. DWORD SSRC;
  134. DWORD fractionLost:8; // Fraction lost
  135. int cumNumPcktLost:24; // Cumulative num of pckts lost
  136. RTP_SEQ_NUM XtendedSeqNum; // Xtnded highest seq. num rcvd
  137. DWORD dwInterJitter; // Interarrival jitter
  138. DWORD dwLastSR; // Last sender report
  139. DWORD dwDelaySinceLastSR; // Delay since last SR
  140. DWORD dwLastRcvRpt; // Time of last Receive Report
  141. } RTCP_FEEDBACK, *PRTCP_FEEDBACK;
  142. // RTCPReportRequestEx bitmasks used to specify filter values
  143. typedef enum
  144. {
  145. FLTR_SSRC = 1, // Filters report on SSRC value
  146. FLTR_CNAME, // Filters report on CName
  147. FLTR_TIME_WITHIN // Filters report receive within a time period
  148. } RRCM_RPT_FILTER_OPTION;
  149. // RTCP report data structure
  150. typedef struct _RTCP_REPORT
  151. {
  152. // SSRC for this entry's information. Local SSRC if it's one of
  153. // are local stream, or a remote SSRC otherwise.
  154. DWORD ssrc;
  155. DWORD status;
  156. #define LOCAL_SSRC_RPT 0x1
  157. #define REMOTE_SSRC_RPT 0x2
  158. #define FEEDBACK_FOR_LOCAL_SSRC_PRESENT 0x4
  159. // LOCAL_SSRC_RPT identifies to the application that this entry is
  160. // one of our local stream.
  161. // Only 'dwSrcNumPcktRealTime & dwSrcNumByteRealTime' which
  162. // reflect the number of Pckt/byte transmitted are meaningful.
  163. // FEEDBACK_FOR_LOCAL_SSRC_PRESENT is set if the entry is for a
  164. // remote stream and if this remote stream has ever send us any
  165. // feedback about ourselve. Feedback send by the remote stream to
  166. // other SSRC are filtered out. Only feedback about ourselve is kept.
  167. // Number of Pckt/Byte send if this entry is for a local stream, or
  168. // number of Pckt/Byte received if this entry is for a remote stream
  169. // This counters are updated in real-time.
  170. DWORD dwSrcNumPcktRealTime;
  171. DWORD dwSrcNumByteRealTime;
  172. // This is the information we would be sending in a receiver report
  173. // for the stream identified by 'ssrc' if this 'ssrc' has been active
  174. // during the last report interval. This information is provided when the
  175. // API is queried, and will most likely be different than the one send
  176. // out by the receiver report. (RR will be send at some different time)
  177. DWORD SrcFraction:8;
  178. int SrcNumLost:24;
  179. DWORD dwSrcXtndNum;
  180. DWORD SrcJitter;
  181. DWORD dwSrcLsr;
  182. DWORD dwSrcDlsr;
  183. // This information has been received from 'ssrc' has part of an
  184. // RTCP sender report if 'ssrc' has been active, otherwise all 0s
  185. DWORD dwSrcNumPckt;
  186. DWORD dwSrcNumByte;
  187. DWORD dwSrcNtpMsw;
  188. DWORD dwSrcNtpLsw;
  189. DWORD dwSrcRtpTs;
  190. // This is the feedback information about us from the SSRC identified
  191. // in the 'feedback' data structure. Currently we only store feedback
  192. // information about ourselve and we filter out feedback information
  193. // about additional streams. We'll have feedback information only if
  194. // our stream has been active. If our stream goes from active to inactive
  195. // the feedback information will be set, but not updated.
  196. RTCP_FEEDBACK feedback;
  197. // Generic information for the SSRC entry
  198. // Payload type for this SSRC. If a sender, it is assume that the
  199. // application knows what it is sending, and the type will be set
  200. // to 0. If a receiver, this is the last value seen on an RTP data packet
  201. DWORD PayLoadType;
  202. DWORD dwStreamClock; // Sampling frequency
  203. DWORD dwLastReportRcvdTime; // Time of last report rcvd
  204. char fromAddr[MAX_ADDR_LEN];
  205. DWORD dwFromLen;
  206. CHAR cname[MAX_SDES_LEN];
  207. DWORD dwCnameLen;
  208. CHAR name[MAX_SDES_LEN];
  209. DWORD dwNameLen;
  210. } RTCP_REPORT, *PRTCP_REPORT;
  211. //----------------------------------------------------------------------------
  212. // ISDM Information
  213. //----------------------------------------------------------------------------
  214. #ifdef ENABLE_ISDM2
  215. // RTCP Xmt information
  216. typedef struct _XMIT_INFO_ISDM
  217. {
  218. DWORD dwNumPcktSent; // Number of packet sent
  219. DWORD dwNumBytesSent; // Number of bytes sent
  220. DWORD dwNTPmsw; // NTP most significant word
  221. DWORD dwNTPlsw; // NTP least significant word
  222. DWORD dwRTPts; // RTP timestamp
  223. DWORD dwCurXmtSeqNum; // Current Xmt sequence number
  224. DWORD dwPrvXmtSeqNum; // Previous Xmt sequence number
  225. DWORD sessionBW; // Session's bandwidth
  226. DWORD dwLastSR; // Last sender report
  227. DWORD dwLastSRLocalTime; // Last sender report local time
  228. DWORD dwLastSendRTPSystemTime; // Last RTP packet send time
  229. DWORD dwLastSendRTPTimeStamp; // RTP timestamp of the last packet
  230. } XMIT_INFO_ISDM, *PXMIT_INFO_ISDM;
  231. // RTCP receive information
  232. typedef struct _RECV_INFO_ISDM
  233. {
  234. DWORD dwNumPcktRcvd; // Number of packet received
  235. DWORD dwPrvNumPcktRcvd; // Previous number of pckt rcvd
  236. DWORD dwExpectedPrior; // Number previously expected
  237. DWORD dwNumBytesRcvd; // Number of bytes rcvd
  238. DWORD dwBaseRcvSeqNum; // Initial sequence number rcvd
  239. DWORD dwBadSeqNum; // Potential new valid seq num
  240. DWORD dwProbation; // # consec pkts for validation
  241. RTP_SEQ_NUM XtendedSeqNum; // Xtnded highest seq. num rcvd
  242. DWORD dwPropagationTime; // Last packet's transmit time
  243. DWORD interJitter; // Interarrival jitter
  244. } RECV_INFO_ISDM, *PRECV_INFO_ISDM;
  245. //----------------------------------------------------------------------------
  246. // RTP/RTCP: Registry information under:
  247. //----------------------------------------------------------------------------
  248. #define szRRCMISDM TEXT("RRCM_2")
  249. // Structure used by new ISDM features
  250. typedef struct _ISDM2_ENTRY
  251. {
  252. DWORD SSRC; // Source SSRC
  253. DWORD dwSSRCStatus; // Entry status
  254. #define XMITR 0x00000001
  255. #define RECVR 0x00000002
  256. DWORD PayLoadType; // Payload type for this SSRC
  257. // taken from the RTP header.
  258. // SSRC Transmit information
  259. // If on our transmit list, this is our SSRC information, and if on our
  260. // receive list, this is a SR feedback information.
  261. XMIT_INFO_ISDM xmitinfo;
  262. // SSRC Receive information
  263. // If on our transmit list, this is undefined information, and if on our
  264. // receive list, this is the SSRC's receive information, ie, this SSRC
  265. // is an active sender somewhere on the network. This information is
  266. // maintained by RTP, and used by RTCP to generate RR.
  267. RECV_INFO_ISDM rcvInfo;
  268. // Feedback information received about ourselve if we're an active source
  269. RTCP_FEEDBACK rrFeedback; // Feedback information
  270. DWORD dwLastReportRcvdTime; // Time of last report received
  271. // SSRC SDES information
  272. SDES_DATA cnameInfo; // CNAME information
  273. SDES_DATA nameInfo; // NAME information
  274. // SSRC network address information
  275. int fromLen; // From address length
  276. char from[MAX_ADDR_LEN]; // From address
  277. DWORD dwNumRptSent; // Number of RTCP report sent
  278. DWORD dwNumRptRcvd; // Number of RTCP report rcvd
  279. DWORD dwNumXmtIoPending; // Number of transmit I/O pending
  280. DWORD dwStreamClock; // Sampling frequency
  281. } ISDM2_ENTRY, *PISDM2_ENTRY;
  282. #endif // #ifdef ENABLE_ISDM2
  283. //----------------------------------------------------------------------------
  284. // RTP/RTCP Error Codes
  285. //----------------------------------------------------------------------------
  286. #define RRCM_NoError NO_ERROR
  287. #define RTP_ERROR_BASE 0x8100
  288. #define RTCP_ERROR_BASE 0x8200
  289. // Macro to create a custom HRESULT
  290. // S: Severity Code
  291. // C: Customer subsystem (TRUE)
  292. // F: Facility code
  293. // E: Error code
  294. #define MAKE_RRCM_HRESULT(S,C,F,E) \
  295. ((((DWORD)(S)<<31)|((DWORD)(C)<<29)|((DWORD)(F)<<16)|((DWORD)(E))))
  296. // Custom facility codes
  297. #define FACILITY_BASE 0x080
  298. #define FACILITY_RRCM (FACILITY_BASE+9)
  299. // Sample macro to support custom error reporting //
  300. #define MAKE_RRCM_ERROR(error) \
  301. MAKE_RRCM_HRESULT(SEVERITY_ERROR,TRUE,FACILITY_RRCM,error)
  302. // RTP Error Codes
  303. #define RRCMError_RTPReInit RTP_ERROR_BASE
  304. #define RRCMError_RTPResources (RTP_ERROR_BASE+1)
  305. #define RRCMError_RTPInvalidDelete (RTP_ERROR_BASE+2)
  306. #define RRCMError_RTPNoContext (RTP_ERROR_BASE+3)
  307. #define RRCMError_RTPSessResources (RTP_ERROR_BASE+4)
  308. #define RRCMError_RTPInvalid (RTP_ERROR_BASE+5)
  309. #define RRCMError_RTPInvSocket (RTP_ERROR_BASE+6)
  310. #define RRCMError_RTPSSRCNotFound (RTP_ERROR_BASE+7)
  311. #define RRCMError_RTCPCreateError (RTP_ERROR_BASE+8)
  312. #define RRCMError_RTPInvalidSession (RTP_ERROR_BASE+9)
  313. #define RRCMError_RTPStreamNotFound (RTP_ERROR_BASE+10)
  314. #define RRCMError_WinsockLibNotFound (RTP_ERROR_BASE+11)
  315. #define RRCMError_RTPNoSession (RTCP_ERROR_BASE+12)
  316. // RTCP Error Codes
  317. #define RRCMError_RTCPReInit RTCP_ERROR_BASE
  318. #define RRCMError_RTCPResources (RTCP_ERROR_BASE+1)
  319. #define RRCMError_RTCPInvalidDelete (RTCP_ERROR_BASE+2)
  320. #define RRCMError_RTCPNoContext (RTCP_ERROR_BASE+3)
  321. #define RRCMError_RTCPInvalidRequest (RTCP_ERROR_BASE+4)
  322. #define RRCMError_RTCPheapError (RTCP_ERROR_BASE+5)
  323. #define RRCMError_RTCPThreadCreation (RTCP_ERROR_BASE+6)
  324. #define RRCMError_RTCPInvalidSession (RTCP_ERROR_BASE+7)
  325. #define RRCMError_RTCPNotimer (RTCP_ERROR_BASE+8)
  326. #define RRCMError_RTCPMaxStreamPerSession (RTCP_ERROR_BASE+9)
  327. #define RRCMError_RTCPInvalidSSRCentry (RTCP_ERROR_BASE+10)
  328. #define RRCMError_RTCPNoXmtList (RTCP_ERROR_BASE+11)
  329. #define RRCMError_RTCPNoCname (RTCP_ERROR_BASE+12)
  330. #define RRCMError_RTCPNotImpl (RTCP_ERROR_BASE+13)
  331. // RRCM Exported API
  332. HANDLE WINAPI CreateRTPSession (SOCKET,
  333. SOCKET,
  334. LPVOID,
  335. DWORD,
  336. PSDES_DATA,
  337. DWORD,
  338. PENCRYPT_INFO,
  339. DWORD,
  340. PRRCM_EVENT_CALLBACK,
  341. DWORD_PTR,
  342. DWORD,
  343. DWORD,
  344. PDWORD);
  345. HRESULT WINAPI CloseRTPSession (HANDLE,
  346. PCHAR,
  347. DWORD);
  348. DWORD WINAPI RTPSendTo ( HANDLE,
  349. SOCKET,
  350. LPWSABUF,
  351. DWORD,
  352. LPDWORD,
  353. int,
  354. LPVOID,
  355. int,
  356. LPWSAOVERLAPPED,
  357. LPWSAOVERLAPPED_COMPLETION_ROUTINE);
  358. DWORD WINAPI RTPRecvFrom (SOCKET,
  359. LPWSABUF,
  360. DWORD,
  361. LPDWORD,
  362. LPDWORD,
  363. PSOCKADDR,
  364. LPINT,
  365. LPWSAOVERLAPPED,
  366. LPWSAOVERLAPPED_COMPLETION_ROUTINE);
  367. HRESULT WINAPI RTCPReportRequest (SOCKET,
  368. DWORD,
  369. PDWORD,
  370. PDWORD,
  371. DWORD,
  372. PRTCP_REPORT,
  373. DWORD,
  374. LPVOID,
  375. DWORD);
  376. HRESULT WINAPI getRtcpSessionList (PDWORD_PTR,
  377. DWORD,
  378. PDWORD);
  379. DWORD WINAPI updateRTCPDestinationAddress (HANDLE,
  380. PSOCKADDR,
  381. int);
  382. DWORD WINAPI getAnSSRC (void);
  383. DWORD WINAPI RTCPThreadCtrl (DWORD);
  384. HRESULT WINAPI RTCPSendSessionCtrl (DWORD_PTR,
  385. DWORD);
  386. HRESULT WINAPI updateSSRCentry ( HANDLE,
  387. SOCKET,
  388. DWORD,
  389. DWORD,
  390. DWORD);
  391. HRESULT WINAPI addApplicationRtcpBfr (DWORD_PTR,
  392. PAPP_RTCP_BFR);
  393. PAPP_RTCP_BFR WINAPI removeApplicationRtcpBfr (DWORD_PTR);
  394. #ifdef __cplusplus
  395. }
  396. #endif
  397. // restore structure packing
  398. #include <poppack.h>
  399. #endif /* #ifndef _RRCMDLL_H_ */
  400.