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.

263 lines
6.4 KiB

  1. /*++
  2. Copyright (c) 1995-1996 Microsoft Corporation
  3. Module Name:
  4. utils.h
  5. Abstract:
  6. Assorted support and debugging routines used by the Network Audio Controller.
  7. --*/
  8. #ifndef _UTILS_H_
  9. #define _UTILS_H_
  10. #include <pshpack8.h> /* Assume 8 byte packing throughout */
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif // __cplusplus
  14. typedef struct tagDefWaveFormat
  15. {
  16. WORD wFormatTag; /* format type */
  17. WORD nChannels; /* number of channels (i.e. mono, stereo...) */
  18. DWORD nSamplesPerSec; /* sample rate */
  19. DWORD nAvgBytesPerSec; /* for buffer estimation */
  20. WORD nBlockAlign; /* block size of data */
  21. WORD wBitsPerSample; /* Number of bits per sample of mono data */
  22. WORD cbSize; /* The count in bytes of the size of extra information (after cbSize) */
  23. WORD awExtra[32]; /* room for ADPCM coeff...*/
  24. }
  25. DEFWAVEFORMAT;
  26. enum
  27. {
  28. // NAME_SamplesPerSec_BitsPerSample
  29. DWF_VOX_8K_16,
  30. DWF_PCM_8K_8,
  31. DWF_PCM_5510_8,
  32. DWF_ADPCM_8K_4,
  33. DWF_ADPCM_5510_4,
  34. DWF_GSM610_8K,
  35. DWF_ALAW_8K_8,
  36. DWF_PCM_11025_8,
  37. DWF_PCM_8K_16,
  38. DWF_NumOfWaveFormats
  39. };
  40. extern DEFWAVEFORMAT g_wfDefList[];
  41. WAVEFORMATEX * GetDefWaveFormat ( int idx );
  42. ULONG GetWaveFormatSize ( PVOID pwf );
  43. BOOL IsSameWaveFormat ( PVOID pwf1, PVOID pwf2 );
  44. void FillSilenceBuf ( WAVEFORMATEX *pwf, PBYTE pb, ULONG cb );
  45. void MakeDTMFBeep(WAVEFORMATEX *pwf, PBYTE pb, ULONG cb);
  46. char CompareMemory1 ( char * p1, char * p2, UINT u );
  47. short CompareMemory2 ( short * p1, short * p2, UINT u );
  48. long CompareMemory4 ( long * p1, long * p2, UINT u );
  49. #ifndef SIZEOF_WAVEFORMATEX
  50. #define SIZEOF_WAVEFORMATEX(pwfx) ((WAVE_FORMAT_PCM==(pwfx)->wFormatTag)?sizeof(PCMWAVEFORMAT):(sizeof(WAVEFORMATEX)+(pwfx)->cbSize))
  51. #endif
  52. #ifdef _DEBUG
  53. # ifndef DEBUG
  54. # define DEBUG
  55. # endif // !DEBUG
  56. #endif // _DEBUG
  57. #ifdef DEBUG // { DEBUG
  58. int WINAPI NacDbgPrintf ( LPTSTR lpszFormat, ... );
  59. extern HDBGZONE ghDbgZoneNac;
  60. #define ZONE_INIT (GETMASK(ghDbgZoneNac) & 0x0001)
  61. #define ZONE_CONN (GETMASK(ghDbgZoneNac) & 0x0002)
  62. #define ZONE_COMMCHAN (GETMASK(ghDbgZoneNac) & 0x0004)
  63. #define ZONE_CAPS (GETMASK(ghDbgZoneNac) & 0x0008)
  64. #define ZONE_DP (GETMASK(ghDbgZoneNac) & 0x0010)
  65. #define ZONE_ACM (GETMASK(ghDbgZoneNac) & 0x0020)
  66. #define ZONE_VCM (GETMASK(ghDbgZoneNac) & 0x0040)
  67. #define ZONE_VERBOSE (GETMASK(ghDbgZoneNac) & 0x0080)
  68. #define ZONE_INSTCODEC (GETMASK(ghDbgZoneNac) & 0x0100)
  69. #define ZONE_PROFILE (GETMASK(ghDbgZoneNac) & 0x0200)
  70. #define ZONE_QOS (GETMASK(ghDbgZoneNac) & 0x0400)
  71. #define ZONE_IFRAME (GETMASK(ghDbgZoneNac) & 0x0800)
  72. extern HDBGZONE ghDbgZoneNMCap;
  73. #define ZONE_NMCAP_CDTOR (GETMASK(ghDbgZoneNMCap) & 0x0001)
  74. #define ZONE_NMCAP_REFCOUNT (GETMASK(ghDbgZoneNMCap) & 0x0002)
  75. #define ZONE_NMCAP_STREAMING (GETMASK(ghDbgZoneNMCap) & 0x0004)
  76. #ifndef DEBUGMSG // { DEBUGMSG
  77. #define DEBUGMSG(z,s) ( (z) ? (NacDbgPrintf s ) : 0)
  78. #endif // } DEBUGMSG
  79. #ifndef FX_ENTRY // { FX_ENTRY
  80. #define FX_ENTRY(s) static TCHAR _this_fx_ [] = (s);
  81. #define _fx_ ((LPTSTR) _this_fx_)
  82. #endif // } FX_ENTRY
  83. #define ERRORMESSAGE(m) (NacDbgPrintf m)
  84. #else // }{ DEBUG
  85. #ifndef FX_ENTRY // { FX_ENTRY
  86. #define FX_ENTRY(s)
  87. #endif // } FX_ENTRY
  88. #ifndef DEBUGMSG // { DEBUGMSG
  89. #define DEBUGMSG(z,s)
  90. #define ERRORMESSAGE(m)
  91. #endif // } DEBUGMSG
  92. #define _fx_
  93. #define ERRORMESSAGE(m)
  94. #endif // } DEBUG
  95. // Message ids.
  96. // Ensure ids correspond to message strings in LogStringTable[]
  97. enum LogMsgs {
  98. LOGMSG_SENT = 1,
  99. LOGMSG_NET_RECVD,
  100. LOGMSG_AUD_SEND,
  101. LOGMSG_SILENT,
  102. LOGMSG_RECORD,
  103. LOGMSG_AUD_RECV,
  104. LOGMSG_RX_RESET,
  105. LOGMSG_RX_RESET2,
  106. LOGMSG_ENCODED,
  107. LOGMSG_DECODED,
  108. LOGMSG_PLAY,
  109. LOGMSG_PLAY_SILENT,
  110. LOGMSG_OPEN_AUDIO,
  111. LOGMSG_PLAY_YIELD,
  112. LOGMSG_REC_YIELD,
  113. LOGMSG_AUD_RECYCLE,
  114. LOGMSG_AUTO_SILENCE,
  115. LOGMSG_PRESEND,
  116. LOGMSG_RX_SKIP,
  117. LOGMSG_TX_RESET,
  118. LOGMSG_JITTER,
  119. LOGMSG_PLAY_INTERPOLATED,
  120. LOGMSG_INTERPOLATED,
  121. LOGMSG_VID_SEND,
  122. LOGMSG_VID_RECV,
  123. LOGMSG_VID_RECYCLE,
  124. LOGMSG_VID_RECORD,
  125. LOGMSG_VID_PLAY,
  126. LOGMSG_VID_PLAY_SILENT,
  127. LOGMSG_VID_PLAY_INTERPOLATED,
  128. LOGMSG_VID_INTERPOLATED,
  129. LOGMSG_VID_ENCODED,
  130. LOGMSG_VID_DECODED,
  131. LOGMSG_OPEN_VIDEO,
  132. LOGMSG_GET_SEND_FRAME,
  133. LOGMSG_GET_RECV_FRAME,
  134. LOGMSG_RELEASE_SEND_FRAME,
  135. LOGMSG_RELEASE_RECV_FRAME,
  136. LOGMSG_TESTSYNC,
  137. LOGMSG_ONREAD1,
  138. LOGMSG_ONREAD2,
  139. LOGMSG_ONREADDONE1,
  140. LOGMSG_ONREADDONE2,
  141. LOGMSG_RECVFROM1,
  142. LOGMSG_RECVFROM2,
  143. LOGMSG_READWOULDBLOCK,
  144. LOGMSG_VIDSEND_VID_QUEUING,
  145. LOGMSG_VIDSEND_AUD_QUEUING,
  146. LOGMSG_VIDSEND_VID_SEND,
  147. LOGMSG_VIDSEND_AUD_SEND,
  148. LOGMSG_VIDSEND_VID_NOT_SEND,
  149. LOGMSG_VIDSEND_AUD_NOT_SEND,
  150. LOGMSG_VIDSEND_IO_PENDING,
  151. LOGMSG_VIDSEND_AUDIO_QUEUE_EMPTY,
  152. LOGMSG_VIDSEND_VIDEO_QUEUE_EMPTY,
  153. LOGMSG_AUDSEND_VID_QUEUING,
  154. LOGMSG_AUDSEND_AUD_QUEUING,
  155. LOGMSG_AUDSEND_VID_SEND,
  156. LOGMSG_AUDSEND_AUD_SEND,
  157. LOGMSG_AUDSEND_VID_NOT_SEND,
  158. LOGMSG_AUDSEND_AUD_NOT_SEND,
  159. LOGMSG_AUDSEND_IO_PENDING,
  160. LOGMSG_AUDSEND_AUDIO_QUEUE_EMPTY,
  161. LOGMSG_AUDSEND_VIDEO_QUEUE_EMPTY,
  162. LOGMSG_SEND_BLOCKED,
  163. LOGMSG_DSPLAY,
  164. LOGMSG_DSEMPTY,
  165. LOGMSG_DSTIMEOUT,
  166. LOGMSG_DSMOVPOS,
  167. LOGMSG_DSCREATE,
  168. LOGMSG_DSRELEASE,
  169. LOGMSG_DSDROPOOS, // out of sequence
  170. LOGMSG_DSENTRY,
  171. LOGMSG_DSTIME,
  172. LOGMSG_DSSTATUS,
  173. LOGMSG_DSDROPOVERFLOW, // overflow
  174. LOGMSG_DSOFCONDITION,
  175. LOGMSG_TIME_SEND_AUDIO_CONFIGURE,
  176. LOGMSG_TIME_SEND_AUDIO_UNCONFIGURE,
  177. LOGMSG_TIME_SEND_VIDEO_CONFIGURE,
  178. LOGMSG_TIME_SEND_VIDEO_UNCONFIGURE,
  179. LOGMSG_TIME_RECV_AUDIO_CONFIGURE,
  180. LOGMSG_TIME_RECV_AUDIO_UNCONFIGURE,
  181. LOGMSG_TIME_RECV_VIDEO_CONFIGURE,
  182. LOGMSG_TIME_RECV_VIDEO_UNCONFIGURE,
  183. LOGMSG_DSC_TIMESTAMP,
  184. LOGMSG_DSC_GETCURRENTPOS,
  185. LOGMSG_DSC_LOG_TIMEOUT,
  186. LOGMSG_DSC_LAGGING,
  187. LOGMSG_DSC_SENDING,
  188. LOGMSG_DSC_STATS,
  189. LOGMSG_DSC_EARLY
  190. };
  191. #ifdef DEBUG
  192. #define LOGGING 1
  193. #else
  194. #ifdef TEST
  195. #define LOGGING 1
  196. #endif
  197. #endif
  198. #ifdef LOGGING
  199. #define MAX_STRING_SIZE 64
  200. void Log (UINT n, UINT arg1=0, UINT arg2=0, UINT arg3=0);
  201. LogInit();
  202. LogClose();
  203. #define LOG(x) Log x
  204. #else
  205. #define LOG(x)
  206. #define LogInit()
  207. #define LogClose()
  208. #endif // LOGGING
  209. HRESULT InitAudioFlowspec(FLOWSPEC *pFlowSpec, WAVEFORMATEX *pwf, DWORD dwPacketSize);
  210. HRESULT InitVideoFlowspec(FLOWSPEC *pFlowspec, DWORD dwMaxBitrate, DWORD dwMaxFrag, DWORD dwAvgPacketSize);
  211. #ifdef __cplusplus
  212. } // extern "C"
  213. #endif // __cplusplus
  214. #include <poppack.h> /* End byte packing */
  215. #endif // _UTILS_H_