Added checksum to stats of HTTP based outputs for later merging of connections.
This commit is contained in:
parent
c26661b690
commit
b325ca96ee
13 changed files with 35 additions and 3 deletions
|
@ -15,6 +15,7 @@
|
||||||
#define STAT_CLI_UP 64
|
#define STAT_CLI_UP 64
|
||||||
#define STAT_CLI_BPS_DOWN 128
|
#define STAT_CLI_BPS_DOWN 128
|
||||||
#define STAT_CLI_BPS_UP 256
|
#define STAT_CLI_BPS_UP 256
|
||||||
|
#define STAT_CLI_CRC 512
|
||||||
#define STAT_CLI_ALL 0xFFFF
|
#define STAT_CLI_ALL 0xFFFF
|
||||||
// These are used to store "totals" field requests in a bitfield for speedup.
|
// These are used to store "totals" field requests in a bitfield for speedup.
|
||||||
#define STAT_TOT_CLIENTS 1
|
#define STAT_TOT_CLIENTS 1
|
||||||
|
@ -31,7 +32,7 @@ std::map<unsigned long, Controller::statStorage> Controller::curConns;///<Connec
|
||||||
/// old statistics that have disconnected over 10 minutes ago.
|
/// old statistics that have disconnected over 10 minutes ago.
|
||||||
void Controller::SharedMemStats(void * config){
|
void Controller::SharedMemStats(void * config){
|
||||||
DEBUG_MSG(DLVL_HIGH, "Starting stats thread");
|
DEBUG_MSG(DLVL_HIGH, "Starting stats thread");
|
||||||
IPC::sharedServer statServer("statistics", 88, true);
|
IPC::sharedServer statServer("statistics", STAT_EX_SIZE, true);
|
||||||
while(((Util::Config*)config)->is_active){
|
while(((Util::Config*)config)->is_active){
|
||||||
//parse current users
|
//parse current users
|
||||||
statServer.parseEach(parseStatistics);
|
statServer.parseEach(parseStatistics);
|
||||||
|
@ -63,6 +64,7 @@ void Controller::statStorage::update(IPC::statExchange & data) {
|
||||||
if (!connector.size()){
|
if (!connector.size()){
|
||||||
connector = data.connector();
|
connector = data.connector();
|
||||||
}
|
}
|
||||||
|
crc = data.crc();
|
||||||
statLog tmp;
|
statLog tmp;
|
||||||
tmp.time = data.time();
|
tmp.time = data.time();
|
||||||
tmp.lastSecond = data.lastSecond();
|
tmp.lastSecond = data.lastSecond();
|
||||||
|
@ -193,6 +195,7 @@ void Controller::fillClients(JSON::Value & req, JSON::Value & rep){
|
||||||
if (fields & STAT_CLI_UP){rep["fields"].append("up");}
|
if (fields & STAT_CLI_UP){rep["fields"].append("up");}
|
||||||
if (fields & STAT_CLI_BPS_DOWN){rep["fields"].append("downbps");}
|
if (fields & STAT_CLI_BPS_DOWN){rep["fields"].append("downbps");}
|
||||||
if (fields & STAT_CLI_BPS_UP){rep["fields"].append("upbps");}
|
if (fields & STAT_CLI_BPS_UP){rep["fields"].append("upbps");}
|
||||||
|
if (fields & STAT_CLI_CRC){rep["fields"].append("crc");}
|
||||||
//output the data itself
|
//output the data itself
|
||||||
rep["data"].null();
|
rep["data"].null();
|
||||||
//start with current connections
|
//start with current connections
|
||||||
|
@ -233,6 +236,7 @@ void Controller::fillClients(JSON::Value & req, JSON::Value & rep){
|
||||||
d.append(statRef->second.up);
|
d.append(statRef->second.up);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fields & STAT_CLI_CRC){d.append((long long)it->second.crc);}
|
||||||
rep["data"].append(d);
|
rep["data"].append(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,6 +276,7 @@ void Controller::fillClients(JSON::Value & req, JSON::Value & rep){
|
||||||
d.append(statRef->second.up);
|
d.append(statRef->second.up);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fields & STAT_CLI_CRC){d.append((long long)it->second.crc);}
|
||||||
rep["data"].append(d);
|
rep["data"].append(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace Controller {
|
||||||
public:
|
public:
|
||||||
void update(IPC::statExchange & data);
|
void update(IPC::statExchange & data);
|
||||||
std::string host;
|
std::string host;
|
||||||
|
unsigned int crc;
|
||||||
std::string streamName;
|
std::string streamName;
|
||||||
std::string connector;
|
std::string connector;
|
||||||
std::map<unsigned long long, statLog> log;
|
std::map<unsigned long long, statLog> log;
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace Mist {
|
||||||
|
|
||||||
Output::Output(Socket::Connection & conn) : myConn(conn) {
|
Output::Output(Socket::Connection & conn) : myConn(conn) {
|
||||||
firstTime = 0;
|
firstTime = 0;
|
||||||
|
crc = 0;
|
||||||
parseData = false;
|
parseData = false;
|
||||||
wantRequest = true;
|
wantRequest = true;
|
||||||
sought = false;
|
sought = false;
|
||||||
|
@ -238,7 +239,7 @@ namespace Mist {
|
||||||
onFail();
|
onFail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
statsPage = IPC::sharedClient("statistics", 88, true);
|
statsPage = IPC::sharedClient("statistics", STAT_EX_SIZE, true);
|
||||||
playerConn = IPC::sharedClient(streamName + "_users", 30, true);
|
playerConn = IPC::sharedClient(streamName + "_users", 30, true);
|
||||||
|
|
||||||
updateMeta();
|
updateMeta();
|
||||||
|
@ -652,6 +653,7 @@ namespace Mist {
|
||||||
tmpEx.host(myConn.getBinHost());
|
tmpEx.host(myConn.getBinHost());
|
||||||
setHost = false;
|
setHost = false;
|
||||||
}
|
}
|
||||||
|
tmpEx.crc(crc);
|
||||||
tmpEx.streamName(streamName);
|
tmpEx.streamName(streamName);
|
||||||
tmpEx.connector(capa["name"].asString());
|
tmpEx.connector(capa["name"].asString());
|
||||||
tmpEx.up(myConn.dataUp());
|
tmpEx.up(myConn.dataUp());
|
||||||
|
|
|
@ -78,6 +78,7 @@ namespace Mist {
|
||||||
std::map<unsigned long, unsigned long> lastKeyTime;///< Stores the time of the last keyframe, for preventing duplicates
|
std::map<unsigned long, unsigned long> lastKeyTime;///< Stores the time of the last keyframe, for preventing duplicates
|
||||||
bool sought;///<If a seek has been done, this is set to true. Used for seeking on prepareNext().
|
bool sought;///<If a seek has been done, this is set to true. Used for seeking on prepareNext().
|
||||||
protected://these are to be messed with by child classes
|
protected://these are to be messed with by child classes
|
||||||
|
unsigned int crc;///< Checksum, if any, for usage in the stats.
|
||||||
unsigned int getKeyForTime(long unsigned int trackId, long long timeStamp);
|
unsigned int getKeyForTime(long unsigned int trackId, long long timeStamp);
|
||||||
IPC::sharedPage streamIndex;///< Shared memory used for metadata
|
IPC::sharedPage streamIndex;///< Shared memory used for metadata
|
||||||
std::map<int,IPC::sharedPage> indexPages;///< Maintains index pages of each track, holding information about available pages with DTSC packets.
|
std::map<int,IPC::sharedPage> indexPages;///< Maintains index pages of each track, holding information about available pages with DTSC packets.
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <mist/http_parser.h>
|
#include <mist/http_parser.h>
|
||||||
#include <mist/stream.h>
|
#include <mist/stream.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <mist/amf.h>
|
#include <mist/amf.h>
|
||||||
#include <mist/mp4_adobe.h>
|
#include <mist/mp4_adobe.h>
|
||||||
|
|
||||||
|
@ -191,6 +190,8 @@ namespace Mist {
|
||||||
void OutHDS::onRequest(){
|
void OutHDS::onRequest(){
|
||||||
HTTP_R.Clean();
|
HTTP_R.Clean();
|
||||||
while (HTTP_R.Read(myConn)){
|
while (HTTP_R.Read(myConn)){
|
||||||
|
std::string ua = HTTP_R.GetHeader("User-Agent");
|
||||||
|
crc = checksum::crc32(0, ua.data(), ua.size());
|
||||||
DEBUG_MSG(DLVL_DEVEL, "Received request: %s", HTTP_R.getUrl().c_str());
|
DEBUG_MSG(DLVL_DEVEL, "Received request: %s", HTTP_R.getUrl().c_str());
|
||||||
if (HTTP_R.url.find(".abst") != std::string::npos){
|
if (HTTP_R.url.find(".abst") != std::string::npos){
|
||||||
initialize();
|
initialize();
|
||||||
|
|
|
@ -286,6 +286,8 @@ namespace Mist {
|
||||||
|
|
||||||
void OutHLS::onRequest(){
|
void OutHLS::onRequest(){
|
||||||
while (HTTP_R.Read(myConn)){
|
while (HTTP_R.Read(myConn)){
|
||||||
|
std::string ua = HTTP_R.GetHeader("User-Agent");
|
||||||
|
crc = checksum::crc32(0, ua.data(), ua.size());
|
||||||
DEBUG_MSG(DLVL_MEDIUM, "Received request: %s", HTTP_R.getUrl().c_str());
|
DEBUG_MSG(DLVL_MEDIUM, "Received request: %s", HTTP_R.getUrl().c_str());
|
||||||
if (HTTP_R.url == "/crossdomain.xml"){
|
if (HTTP_R.url == "/crossdomain.xml"){
|
||||||
HTTP_S.Clean();
|
HTTP_S.Clean();
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <mist/base64.h>
|
#include <mist/base64.h>
|
||||||
#include <mist/http_parser.h>
|
#include <mist/http_parser.h>
|
||||||
#include <mist/stream.h>
|
#include <mist/stream.h>
|
||||||
|
#include <mist/checksum.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -449,6 +450,8 @@ namespace Mist {
|
||||||
sentHeader = false;
|
sentHeader = false;
|
||||||
while (HTTP_R.Read(myConn)) {
|
while (HTTP_R.Read(myConn)) {
|
||||||
initialize();
|
initialize();
|
||||||
|
std::string ua = HTTP_R.GetHeader("User-Agent");
|
||||||
|
crc = checksum::crc32(0, ua.data(), ua.size());
|
||||||
if (HTTP_R.url.find("Manifest") != std::string::npos) {
|
if (HTTP_R.url.find("Manifest") != std::string::npos) {
|
||||||
//Manifest, direct reply
|
//Manifest, direct reply
|
||||||
HTTP_S.Clean();
|
HTTP_S.Clean();
|
||||||
|
|
|
@ -154,6 +154,8 @@ namespace Mist {
|
||||||
|
|
||||||
void OutHTTPTS::onRequest(){
|
void OutHTTPTS::onRequest(){
|
||||||
while (HTTP_R.Read(myConn)){
|
while (HTTP_R.Read(myConn)){
|
||||||
|
std::string ua = HTTP_R.GetHeader("User-Agent");
|
||||||
|
crc = checksum::crc32(0, ua.data(), ua.size());
|
||||||
DEBUG_MSG(DLVL_MEDIUM, "Received request: %s", HTTP_R.getUrl().c_str());
|
DEBUG_MSG(DLVL_MEDIUM, "Received request: %s", HTTP_R.getUrl().c_str());
|
||||||
initialize();
|
initialize();
|
||||||
HTTP_S.Clean();
|
HTTP_S.Clean();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "output_json.h"
|
#include "output_json.h"
|
||||||
#include <mist/http_parser.h>
|
#include <mist/http_parser.h>
|
||||||
#include <mist/defines.h>
|
#include <mist/defines.h>
|
||||||
|
#include <mist/checksum.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
namespace Mist {
|
namespace Mist {
|
||||||
|
@ -61,6 +62,8 @@ namespace Mist {
|
||||||
void OutJSON::onRequest(){
|
void OutJSON::onRequest(){
|
||||||
HTTP::Parser HTTP_R;
|
HTTP::Parser HTTP_R;
|
||||||
while (HTTP_R.Read(myConn)){
|
while (HTTP_R.Read(myConn)){
|
||||||
|
std::string ua = HTTP_R.GetHeader("User-Agent");
|
||||||
|
crc = checksum::crc32(0, ua.data(), ua.size());
|
||||||
DEBUG_MSG(DLVL_DEVEL, "Received request %s", HTTP_R.getUrl().c_str());
|
DEBUG_MSG(DLVL_DEVEL, "Received request %s", HTTP_R.getUrl().c_str());
|
||||||
first = true;
|
first = true;
|
||||||
jsonp = "";
|
jsonp = "";
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "output_progressive_flv.h"
|
#include "output_progressive_flv.h"
|
||||||
|
#include <mist/checksum.h>
|
||||||
#include <mist/http_parser.h>
|
#include <mist/http_parser.h>
|
||||||
#include <mist/defines.h>
|
#include <mist/defines.h>
|
||||||
|
|
||||||
|
@ -86,6 +87,8 @@ namespace Mist {
|
||||||
void OutProgressiveFLV::onRequest(){
|
void OutProgressiveFLV::onRequest(){
|
||||||
HTTP::Parser HTTP_R;
|
HTTP::Parser HTTP_R;
|
||||||
while (HTTP_R.Read(myConn)){
|
while (HTTP_R.Read(myConn)){
|
||||||
|
std::string ua = HTTP_R.GetHeader("User-Agent");
|
||||||
|
crc = checksum::crc32(0, ua.data(), ua.size());
|
||||||
DEBUG_MSG(DLVL_DEVEL, "Received request %s", HTTP_R.getUrl().c_str());
|
DEBUG_MSG(DLVL_DEVEL, "Received request %s", HTTP_R.getUrl().c_str());
|
||||||
if (HTTP_R.GetVar("audio") != ""){
|
if (HTTP_R.GetVar("audio") != ""){
|
||||||
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("audio")).asInt());
|
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("audio")).asInt());
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "output_progressive_mp3.h"
|
#include "output_progressive_mp3.h"
|
||||||
#include <mist/http_parser.h>
|
#include <mist/http_parser.h>
|
||||||
#include <mist/defines.h>
|
#include <mist/defines.h>
|
||||||
|
#include <mist/checksum.h>
|
||||||
|
|
||||||
namespace Mist {
|
namespace Mist {
|
||||||
OutProgressiveMP3::OutProgressiveMP3(Socket::Connection & conn) : Output(conn) {
|
OutProgressiveMP3::OutProgressiveMP3(Socket::Connection & conn) : Output(conn) {
|
||||||
|
@ -54,6 +55,8 @@ namespace Mist {
|
||||||
void OutProgressiveMP3::onRequest(){
|
void OutProgressiveMP3::onRequest(){
|
||||||
HTTP::Parser HTTP_R;
|
HTTP::Parser HTTP_R;
|
||||||
while (HTTP_R.Read(myConn)){
|
while (HTTP_R.Read(myConn)){
|
||||||
|
std::string ua = HTTP_R.GetHeader("User-Agent");
|
||||||
|
crc = checksum::crc32(0, ua.data(), ua.size());
|
||||||
DEBUG_MSG(DLVL_DEVEL, "Received request %s", HTTP_R.getUrl().c_str());
|
DEBUG_MSG(DLVL_DEVEL, "Received request %s", HTTP_R.getUrl().c_str());
|
||||||
if (HTTP_R.GetVar("audio") != ""){
|
if (HTTP_R.GetVar("audio") != ""){
|
||||||
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("audio")).asInt());
|
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("audio")).asInt());
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <mist/defines.h>
|
#include <mist/defines.h>
|
||||||
#include <mist/mp4.h>
|
#include <mist/mp4.h>
|
||||||
#include <mist/mp4_generic.h>
|
#include <mist/mp4_generic.h>
|
||||||
|
#include <mist/checksum.h>
|
||||||
|
|
||||||
namespace Mist {
|
namespace Mist {
|
||||||
OutProgressiveMP4::OutProgressiveMP4(Socket::Connection & conn) : Output(conn) {
|
OutProgressiveMP4::OutProgressiveMP4(Socket::Connection & conn) : Output(conn) {
|
||||||
|
@ -421,6 +422,8 @@ namespace Mist {
|
||||||
|
|
||||||
void OutProgressiveMP4::onRequest(){
|
void OutProgressiveMP4::onRequest(){
|
||||||
if (HTTP_R.Read(myConn)){
|
if (HTTP_R.Read(myConn)){
|
||||||
|
std::string ua = HTTP_R.GetHeader("User-Agent");
|
||||||
|
crc = checksum::crc32(0, ua.data(), ua.size());
|
||||||
DEBUG_MSG(DLVL_MEDIUM, "Received request: %s", HTTP_R.getUrl().c_str());
|
DEBUG_MSG(DLVL_MEDIUM, "Received request: %s", HTTP_R.getUrl().c_str());
|
||||||
if (HTTP_R.GetVar("audio") != ""){
|
if (HTTP_R.GetVar("audio") != ""){
|
||||||
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("audio")).asInt());
|
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("audio")).asInt());
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "output_srt.h"
|
#include "output_srt.h"
|
||||||
#include <mist/http_parser.h>
|
#include <mist/http_parser.h>
|
||||||
#include <mist/defines.h>
|
#include <mist/defines.h>
|
||||||
|
#include <mist/checksum.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
namespace Mist {
|
namespace Mist {
|
||||||
|
@ -75,6 +76,8 @@ namespace Mist {
|
||||||
void OutProgressiveSRT::onRequest(){
|
void OutProgressiveSRT::onRequest(){
|
||||||
HTTP::Parser HTTP_R;
|
HTTP::Parser HTTP_R;
|
||||||
while (HTTP_R.Read(myConn)){
|
while (HTTP_R.Read(myConn)){
|
||||||
|
std::string ua = HTTP_R.GetHeader("User-Agent");
|
||||||
|
crc = checksum::crc32(0, ua.data(), ua.size());
|
||||||
DEBUG_MSG(DLVL_DEVEL, "Received request %s", HTTP_R.getUrl().c_str());
|
DEBUG_MSG(DLVL_DEVEL, "Received request %s", HTTP_R.getUrl().c_str());
|
||||||
lastNum = 0;
|
lastNum = 0;
|
||||||
webVTT = (HTTP_R.url.find(".webvtt") != std::string::npos);
|
webVTT = (HTTP_R.url.find(".webvtt") != std::string::npos);
|
||||||
|
|
Loading…
Add table
Reference in a new issue