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_BPS_DOWN 128
|
||||
#define STAT_CLI_BPS_UP 256
|
||||
#define STAT_CLI_CRC 512
|
||||
#define STAT_CLI_ALL 0xFFFF
|
||||
// These are used to store "totals" field requests in a bitfield for speedup.
|
||||
#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.
|
||||
void Controller::SharedMemStats(void * config){
|
||||
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){
|
||||
//parse current users
|
||||
statServer.parseEach(parseStatistics);
|
||||
|
@ -63,6 +64,7 @@ void Controller::statStorage::update(IPC::statExchange & data) {
|
|||
if (!connector.size()){
|
||||
connector = data.connector();
|
||||
}
|
||||
crc = data.crc();
|
||||
statLog tmp;
|
||||
tmp.time = data.time();
|
||||
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_BPS_DOWN){rep["fields"].append("downbps");}
|
||||
if (fields & STAT_CLI_BPS_UP){rep["fields"].append("upbps");}
|
||||
if (fields & STAT_CLI_CRC){rep["fields"].append("crc");}
|
||||
//output the data itself
|
||||
rep["data"].null();
|
||||
//start with current connections
|
||||
|
@ -233,6 +236,7 @@ void Controller::fillClients(JSON::Value & req, JSON::Value & rep){
|
|||
d.append(statRef->second.up);
|
||||
}
|
||||
}
|
||||
if (fields & STAT_CLI_CRC){d.append((long long)it->second.crc);}
|
||||
rep["data"].append(d);
|
||||
}
|
||||
}
|
||||
|
@ -272,6 +276,7 @@ void Controller::fillClients(JSON::Value & req, JSON::Value & rep){
|
|||
d.append(statRef->second.up);
|
||||
}
|
||||
}
|
||||
if (fields & STAT_CLI_CRC){d.append((long long)it->second.crc);}
|
||||
rep["data"].append(d);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Controller {
|
|||
public:
|
||||
void update(IPC::statExchange & data);
|
||||
std::string host;
|
||||
unsigned int crc;
|
||||
std::string streamName;
|
||||
std::string connector;
|
||||
std::map<unsigned long long, statLog> log;
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace Mist {
|
|||
|
||||
Output::Output(Socket::Connection & conn) : myConn(conn) {
|
||||
firstTime = 0;
|
||||
crc = 0;
|
||||
parseData = false;
|
||||
wantRequest = true;
|
||||
sought = false;
|
||||
|
@ -238,7 +239,7 @@ namespace Mist {
|
|||
onFail();
|
||||
return;
|
||||
}
|
||||
statsPage = IPC::sharedClient("statistics", 88, true);
|
||||
statsPage = IPC::sharedClient("statistics", STAT_EX_SIZE, true);
|
||||
playerConn = IPC::sharedClient(streamName + "_users", 30, true);
|
||||
|
||||
updateMeta();
|
||||
|
@ -652,6 +653,7 @@ namespace Mist {
|
|||
tmpEx.host(myConn.getBinHost());
|
||||
setHost = false;
|
||||
}
|
||||
tmpEx.crc(crc);
|
||||
tmpEx.streamName(streamName);
|
||||
tmpEx.connector(capa["name"].asString());
|
||||
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
|
||||
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
|
||||
unsigned int crc;///< Checksum, if any, for usage in the stats.
|
||||
unsigned int getKeyForTime(long unsigned int trackId, long long timeStamp);
|
||||
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.
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <mist/http_parser.h>
|
||||
#include <mist/stream.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mist/amf.h>
|
||||
#include <mist/mp4_adobe.h>
|
||||
|
||||
|
@ -191,6 +190,8 @@ namespace Mist {
|
|||
void OutHDS::onRequest(){
|
||||
HTTP_R.Clean();
|
||||
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());
|
||||
if (HTTP_R.url.find(".abst") != std::string::npos){
|
||||
initialize();
|
||||
|
|
|
@ -286,6 +286,8 @@ namespace Mist {
|
|||
|
||||
void OutHLS::onRequest(){
|
||||
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());
|
||||
if (HTTP_R.url == "/crossdomain.xml"){
|
||||
HTTP_S.Clean();
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <mist/base64.h>
|
||||
#include <mist/http_parser.h>
|
||||
#include <mist/stream.h>
|
||||
#include <mist/checksum.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
@ -449,6 +450,8 @@ namespace Mist {
|
|||
sentHeader = false;
|
||||
while (HTTP_R.Read(myConn)) {
|
||||
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) {
|
||||
//Manifest, direct reply
|
||||
HTTP_S.Clean();
|
||||
|
|
|
@ -154,6 +154,8 @@ namespace Mist {
|
|||
|
||||
void OutHTTPTS::onRequest(){
|
||||
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());
|
||||
initialize();
|
||||
HTTP_S.Clean();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "output_json.h"
|
||||
#include <mist/http_parser.h>
|
||||
#include <mist/defines.h>
|
||||
#include <mist/checksum.h>
|
||||
#include <iomanip>
|
||||
|
||||
namespace Mist {
|
||||
|
@ -61,6 +62,8 @@ namespace Mist {
|
|||
void OutJSON::onRequest(){
|
||||
HTTP::Parser HTTP_R;
|
||||
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());
|
||||
first = true;
|
||||
jsonp = "";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "output_progressive_flv.h"
|
||||
#include <mist/checksum.h>
|
||||
#include <mist/http_parser.h>
|
||||
#include <mist/defines.h>
|
||||
|
||||
|
@ -86,6 +87,8 @@ namespace Mist {
|
|||
void OutProgressiveFLV::onRequest(){
|
||||
HTTP::Parser HTTP_R;
|
||||
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());
|
||||
if (HTTP_R.GetVar("audio") != ""){
|
||||
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("audio")).asInt());
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "output_progressive_mp3.h"
|
||||
#include <mist/http_parser.h>
|
||||
#include <mist/defines.h>
|
||||
#include <mist/checksum.h>
|
||||
|
||||
namespace Mist {
|
||||
OutProgressiveMP3::OutProgressiveMP3(Socket::Connection & conn) : Output(conn) {
|
||||
|
@ -54,6 +55,8 @@ namespace Mist {
|
|||
void OutProgressiveMP3::onRequest(){
|
||||
HTTP::Parser HTTP_R;
|
||||
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());
|
||||
if (HTTP_R.GetVar("audio") != ""){
|
||||
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("audio")).asInt());
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <mist/defines.h>
|
||||
#include <mist/mp4.h>
|
||||
#include <mist/mp4_generic.h>
|
||||
#include <mist/checksum.h>
|
||||
|
||||
namespace Mist {
|
||||
OutProgressiveMP4::OutProgressiveMP4(Socket::Connection & conn) : Output(conn) {
|
||||
|
@ -421,6 +422,8 @@ namespace Mist {
|
|||
|
||||
void OutProgressiveMP4::onRequest(){
|
||||
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());
|
||||
if (HTTP_R.GetVar("audio") != ""){
|
||||
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("audio")).asInt());
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "output_srt.h"
|
||||
#include <mist/http_parser.h>
|
||||
#include <mist/defines.h>
|
||||
#include <mist/checksum.h>
|
||||
#include <iomanip>
|
||||
|
||||
namespace Mist {
|
||||
|
@ -75,6 +76,8 @@ namespace Mist {
|
|||
void OutProgressiveSRT::onRequest(){
|
||||
HTTP::Parser HTTP_R;
|
||||
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());
|
||||
lastNum = 0;
|
||||
webVTT = (HTTP_R.url.find(".webvtt") != std::string::npos);
|
||||
|
|
Loading…
Add table
Reference in a new issue