metrics.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* metrics.h external interface to metric processing */
  2. #ifndef _METRICS_H
  3. #define _METRICS_H
  4. #include "unicode/uniString.h"
  5. class protocol_shoutcastClient;
  6. class streamData;
  7. class config;
  8. #if 1
  9. #define METRICS_AUDIENCE_URL "https://metrics.shoutcast.com/metrics"
  10. #define METRICS_ADVERTS_URL "https://ads.shoutcast.com/dnas"
  11. #define TARGETSPOT_URL "https://ads.shoutcast.com/dnas"
  12. #define METRICS_YP_URL "https://dnas-services.shoutcast.com/yp/"
  13. #else
  14. #define METRICS_AUDIENCE_URL "http://localhost:9001"
  15. #define METRICS_ADVERTS_URL "http://localhost:9001/dnas"
  16. #define TARGETSPOT_URL "http://localhost/~karl/mapping1.php"
  17. #endif
  18. #define METRICS_RESET_URL "https://metrics.radionomy.com/connections/closednas"
  19. namespace metrics
  20. {
  21. typedef size_t streamID_t;
  22. typedef enum {
  23. METRIC_AUDIENCE = 1,
  24. METRIC_ADVERT = 2,
  25. METRIC_NOTIFICATION = 4,
  26. METRIC_LICENCE = 8,
  27. METRIC_YP = 16
  28. } service_t;
  29. struct adSummary
  30. {
  31. streamID_t sid;
  32. bool sendRest;
  33. bool failed;
  34. bool missing;
  35. uniString::utf8 path;
  36. time_t tstamp;
  37. const char *name;
  38. int count;
  39. std::string id;
  40. size_t group;
  41. streamData *sd;
  42. adSummary() : sid(1), tstamp(0), name(0), count(0), group(0) { sd = NULL; sendRest = failed = missing = false; }
  43. };
  44. struct metaInfo
  45. {
  46. streamID_t m_sid;
  47. bool m_private;
  48. unsigned int m_audience;
  49. unsigned int m_maxListeners;
  50. unsigned int m_bitrate;
  51. unsigned int m_samplerate;
  52. uniString::utf8 m_version;
  53. uniString::utf8 m_song;
  54. uniString::utf8 m_format;
  55. uniString::utf8 m_agent;
  56. uniString::utf8 m_publicIP;
  57. uniString::utf8 m_sourceIP;
  58. };
  59. void metrics_init();
  60. void metrics_stop();
  61. void metrics_apply(config &conf);
  62. // new listener triggers
  63. void metrics_listener_new(const protocol_shoutcastClient &client);
  64. // exiting listener triggers
  65. void metrics_listener_drop(const protocol_shoutcastClient &client);
  66. void metrics_adListener (const protocol_shoutcastClient &client, const adSummary &summary);
  67. void metrics_advert_started (const adSummary &summary);
  68. void metrics_advert_stats(const adSummary &summary);
  69. typedef unsigned yp2SessionKey;
  70. void metrics_stream_down (const streamID_t sid, const uniString::utf8& radionomyID,
  71. const uniString::utf8& serverID, const uniString::utf8& publicip, time_t tm);
  72. void metrics_stream_up (const streamID_t sid, const uniString::utf8& radionomyID,
  73. const uniString::utf8& serverID, const uniString::utf8& publicip, time_t tm);
  74. // periodic wakeup for any stalled metrics
  75. void metrics_wakeup(bool force = false);
  76. void updateMeta (const metaInfo &meta);
  77. uniString::utf8 metrics_verifyDestIP(config &conf, bool full = true, uniString::utf8 url = "");
  78. }
  79. #endif /* _METRICS_H */