Added checksum to stats of HTTP based outputs for later merging of connections.

This commit is contained in:
Thulinma 2014-10-23 15:12:33 +02:00
parent c26661b690
commit b325ca96ee
13 changed files with 35 additions and 3 deletions

View file

@ -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());

View file

@ -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.

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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 = "";

View file

@ -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());

View file

@ -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());

View file

@ -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());

View file

@ -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);