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.

144 lines
6.3 KiB

  1. // COUNTERS.CPP
  2. //
  3. // Global performance counters for the nac
  4. //
  5. // Created 13-Nov-96 [JonT]
  6. #include "precomp.h"
  7. // Global ICounterMgr. We just use as an CLSID_Counter class factory
  8. ICounterMgr* g_pCtrMgr;
  9. // Define all counters here
  10. ICounter* g_pctrVideoSend;
  11. ICounter* g_pctrVideoReceive;
  12. ICounter* g_pctrVideoSendBytes;
  13. ICounter* g_pctrVideoReceiveBytes;
  14. ICounter* g_pctrVideoSendLost;
  15. ICounter* g_pctrVideoCPUuse;
  16. ICounter* g_pctrVideoBWuse;
  17. ICounter* g_pctrAudioSendBytes;
  18. ICounter* g_pctrAudioReceiveBytes;
  19. ICounter* g_pctrAudioSendLost;
  20. ICounter* g_pctrAudioJBDelay;
  21. // Define all reports here
  22. IReport* g_prptCallParameters;
  23. IReport* g_prptSystemSettings;
  24. // Put these in a .LIB file someday
  25. const IID IID_ICounterMgr = {0x9CB7FE5B,0x3444,0x11D0,{0xB1,0x43,0x00,0xC0,0x4F,0xC2,0xA1,0x18}};
  26. const CLSID CLSID_CounterMgr = {0x65DDC229,0x38FE,0x11d0,{0xB1,0x43,0x00,0xC0,0x4F,0xC2,0xA1,0x18}};
  27. // InitCountersAndReports
  28. // Initializes all counters and reports that we want to use
  29. extern "C" BOOL WINAPI InitCountersAndReports(void)
  30. {
  31. // Get a pointer to the statistics counter interface if it's around
  32. if (CoCreateInstance(CLSID_CounterMgr, NULL, CLSCTX_INPROC_SERVER, IID_ICounterMgr, (void**)&g_pCtrMgr) != S_OK)
  33. return FALSE;
  34. // Create counters here
  35. DEFINE_COUNTER(&g_pctrVideoSend, "Video Send Frames Per Second", COUNTER_FLAG_ACCUMULATE);
  36. DEFINE_COUNTER(&g_pctrVideoReceive, "Video Receive Frames Per Second", COUNTER_FLAG_ACCUMULATE);
  37. DEFINE_COUNTER(&g_pctrVideoSendBytes, "Video Send Bits Per Second", COUNTER_FLAG_ACCUMULATE);
  38. DEFINE_COUNTER(&g_pctrVideoReceiveBytes, "Video Receive Bits Per Second", COUNTER_FLAG_ACCUMULATE);
  39. DEFINE_COUNTER(&g_pctrAudioSendBytes, "Audio Send Bits Per Second", COUNTER_FLAG_ACCUMULATE);
  40. DEFINE_COUNTER(&g_pctrAudioReceiveBytes, "Audio Receive Bits Per Second", COUNTER_FLAG_ACCUMULATE);
  41. DEFINE_COUNTER(&g_pctrAudioSendLost, "Audio Send Packets Lost", 0);
  42. DEFINE_COUNTER(&g_pctrVideoSendLost, "Video Send Packets Lost", 0);
  43. DEFINE_COUNTER(&g_pctrAudioJBDelay, "Audio Jitter Buffer Delay", 0);
  44. DEFINE_COUNTER(&g_pctrVideoCPUuse, "Video CPU use calculation", COUNTER_CLEAR);
  45. DEFINE_COUNTER(&g_pctrVideoBWuse, "Video Bit rate calculation", COUNTER_CLEAR);
  46. // Create reports here
  47. DEFINE_REPORT(&g_prptCallParameters, "Call Parameters", 0);
  48. DEFINE_REPORT(&g_prptSystemSettings, "System Settings", 0);
  49. // Create call parameters report entries here
  50. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Audio Send Format", REP_SEND_AUDIO_FORMAT);
  51. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Audio Send Sampling Rate (Hz)", REP_SEND_AUDIO_SAMPLING);
  52. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Audio Send Bitrate (w/o network overhead - bps)", REP_SEND_AUDIO_BITRATE);
  53. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Audio Send Packetization (ms / packet)", REP_SEND_AUDIO_PACKET);
  54. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Audio Recv Format", REP_RECV_AUDIO_FORMAT);
  55. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Audio Recv Sampling Rate (Hz)", REP_RECV_AUDIO_SAMPLING);
  56. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Audio Recv Bitrate (w/o network overhead - bps)", REP_RECV_AUDIO_BITRATE);
  57. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Audio Recv Packetization (ms / packet)", REP_RECV_AUDIO_PACKET);
  58. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Video Send Format", REP_SEND_VIDEO_FORMAT);
  59. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Video Send Max Frame Rate (negotiated - fps)", REP_SEND_VIDEO_MAXFPS);
  60. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Video Send Max Bitrate (negotiated - bps)", REP_SEND_VIDEO_BITRATE);
  61. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Video Recv Format", REP_RECV_VIDEO_FORMAT);
  62. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Video Recv Max Frame Rate (negotiated - fps)", REP_RECV_VIDEO_MAXFPS);
  63. DEFINE_REPORT_ENTRY(g_prptCallParameters, "Video Recv Max Bitrate (negotiated - bps)", REP_RECV_VIDEO_BITRATE);
  64. // Create system settings report entries here
  65. DEFINE_REPORT_ENTRY(g_prptSystemSettings, "Bandwidth (user setting)", REP_SYS_BANDWIDTH);
  66. DEFINE_REPORT_ENTRY(g_prptSystemSettings, "Audio Subsystem", REP_SYS_AUDIO_DSOUND);
  67. DEFINE_REPORT_ENTRY(g_prptSystemSettings, "Audio Record", REP_SYS_AUDIO_RECORD);
  68. DEFINE_REPORT_ENTRY(g_prptSystemSettings, "Audio Playback", REP_SYS_AUDIO_PLAYBACK);
  69. DEFINE_REPORT_ENTRY(g_prptSystemSettings, "Audio Duplex Type", REP_SYS_AUDIO_DUPLEX);
  70. DEFINE_REPORT_ENTRY(g_prptSystemSettings, "Capture", REP_SYS_VIDEO_DEVICE);
  71. DEFINE_REPORT_ENTRY(g_prptSystemSettings, "Device Image Size", REP_DEVICE_IMAGE_SIZE);
  72. // Provide defaults for some entries
  73. UPDATE_REPORT_ENTRY(g_prptSystemSettings, 4, REP_SYS_BANDWIDTH);
  74. UPDATE_REPORT_ENTRY(g_prptSystemSettings, 0, REP_SYS_AUDIO_DSOUND);
  75. UPDATE_REPORT_ENTRY(g_prptSystemSettings, 0, REP_SYS_AUDIO_RECORD);
  76. UPDATE_REPORT_ENTRY(g_prptSystemSettings, 0, REP_SYS_AUDIO_PLAYBACK);
  77. UPDATE_REPORT_ENTRY(g_prptSystemSettings, 0, REP_SYS_VIDEO_DEVICE);
  78. UPDATE_REPORT_ENTRY(g_prptSystemSettings, 0, REP_DEVICE_IMAGE_SIZE);
  79. UPDATE_COUNTER(g_pctrAudioJBDelay, 0);
  80. UPDATE_COUNTER(g_pctrAudioSendLost,0);
  81. UPDATE_COUNTER(g_pctrVideoSendLost,0);
  82. INIT_COUNTER_MAX(g_pctrAudioJBDelay, 500); // jitter delay above 500ms is bad
  83. return TRUE;
  84. }
  85. // DoneCountersAndReports
  86. // Cleans up after all counters and reports we wanted to use
  87. extern "C" void WINAPI DoneCountersAndReports(void)
  88. {
  89. ICounterMgr* pctrmgr;
  90. // Release the statistics stuff if it's around
  91. if (!g_pCtrMgr)
  92. return;
  93. // Zero out the interface pointer so we don't accidentally use it elsewhere
  94. pctrmgr = g_pCtrMgr;
  95. g_pCtrMgr = NULL;
  96. // Remove counters here
  97. DELETE_COUNTER(&g_pctrVideoSend);
  98. DELETE_COUNTER(&g_pctrVideoReceive);
  99. DELETE_COUNTER(&g_pctrVideoSendBytes);
  100. DELETE_COUNTER(&g_pctrVideoReceiveBytes);
  101. DELETE_COUNTER(&g_pctrVideoSendLost);
  102. DELETE_COUNTER(&g_pctrAudioSendBytes);
  103. DELETE_COUNTER(&g_pctrAudioReceiveBytes);
  104. DELETE_COUNTER(&g_pctrAudioSendLost);
  105. DELETE_COUNTER(&g_pctrVideoCPUuse);
  106. DELETE_COUNTER(&g_pctrVideoBWuse);
  107. DELETE_COUNTER(&g_pctrAudioJBDelay);
  108. // Remove reports here
  109. DELETE_REPORT(&g_prptCallParameters);
  110. DELETE_REPORT(&g_prptSystemSettings);
  111. // Done with ICounterMgr
  112. pctrmgr->Release();
  113. }