refactor: capitalize Input classes, rename srt to subrip in source as well

Co-authored-by: Thulinma <jaron@vietors.com>
This commit is contained in:
Eli Mallon 2024-05-15 23:46:13 +00:00 committed by Thulinma
parent dbafa808b8
commit e324c2ee58
40 changed files with 249 additions and 249 deletions

View file

@ -483,7 +483,7 @@ makeInput(Folder folder)#LTS
makeInput(Playlist playlist)#LTS makeInput(Playlist playlist)#LTS
makeInput(Balancer balancer)#LTS makeInput(Balancer balancer)#LTS
makeInput(RTSP rtsp)#LTS makeInput(RTSP rtsp)#LTS
makeInput(SubRip srt)#LTS makeInput(SubRip subrip)#LTS
makeInput(SDP sdp) makeInput(SDP sdp)
if(SRT_LIB) if(SRT_LIB)

View file

@ -59,7 +59,7 @@
#include "input_aac.h" #include "input_aac.h"
namespace Mist{ namespace Mist{
inputAAC::inputAAC(Util::Config *cfg) : Input(cfg){ InputAAC::InputAAC(Util::Config *cfg) : Input(cfg){
capa["name"] = "AAC"; capa["name"] = "AAC";
capa["desc"] = "Allows loading AAC files"; capa["desc"] = "Allows loading AAC files";
capa["source_match"] = "/*.aac"; capa["source_match"] = "/*.aac";
@ -75,9 +75,9 @@ namespace Mist{
audioTrack = INVALID_TRACK_ID; audioTrack = INVALID_TRACK_ID;
} }
inputAAC::~inputAAC(){} InputAAC::~InputAAC(){}
bool inputAAC::checkArguments(){ bool InputAAC::checkArguments(){
if (!config->getString("streamname").size()){ if (!config->getString("streamname").size()){
if (config->getString("output") == "-"){ if (config->getString("output") == "-"){
Util::logExitReason(ER_FORMAT_SPECIFIC, "Output to stdout not yet supported"); Util::logExitReason(ER_FORMAT_SPECIFIC, "Output to stdout not yet supported");
@ -92,7 +92,7 @@ namespace Mist{
return true; return true;
} }
bool inputAAC::preRun(){ bool InputAAC::preRun(){
inFile.open(config->getString("input")); inFile.open(config->getString("input"));
if (!inFile || inFile.isEOF()){ if (!inFile || inFile.isEOF()){
Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str()); Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str());
@ -111,7 +111,7 @@ namespace Mist{
// Overrides the default keepRunning function to shut down // Overrides the default keepRunning function to shut down
// if the file disappears or changes, by polling the file's mtime. // if the file disappears or changes, by polling the file's mtime.
// If neither applies, calls the original function. // If neither applies, calls the original function.
bool inputAAC::keepRunning(){ bool InputAAC::keepRunning(){
struct stat statData; struct stat statData;
if (stat(config->getString("input").c_str(), &statData) == -1){ if (stat(config->getString("input").c_str(), &statData) == -1){
INFO_MSG("Shutting down because input file disappeared"); INFO_MSG("Shutting down because input file disappeared");
@ -127,7 +127,7 @@ namespace Mist{
// Reads the first frame to init track // Reads the first frame to init track
// Then calls getNext untill all other frames have been added to the DTSH file // Then calls getNext untill all other frames have been added to the DTSH file
bool inputAAC::readHeader(){ bool InputAAC::readHeader(){
char *aacData; char *aacData;
char *aacFrame; char *aacFrame;
uint64_t frameSize = 0; uint64_t frameSize = 0;
@ -209,7 +209,7 @@ namespace Mist{
// Reads the ADTS frame at the current position then updates thisPacket // Reads the ADTS frame at the current position then updates thisPacket
// @param <idx> contains the trackID to which we want to add the ADTS payload // @param <idx> contains the trackID to which we want to add the ADTS payload
void inputAAC::getNext(size_t idx){ void InputAAC::getNext(size_t idx){
//packets should be initialised to null to ensure termination //packets should be initialised to null to ensure termination
thisPacket.null(); thisPacket.null();
@ -294,7 +294,7 @@ namespace Mist{
// Seeks to the filePos // Seeks to the filePos
// @param <seekTime> timestamp of the DTSH entry containing required file pos info // @param <seekTime> timestamp of the DTSH entry containing required file pos info
// @param <idx> trackID of the AAC track // @param <idx> trackID of the AAC track
void inputAAC::seek(uint64_t seekTime, size_t idx){ void InputAAC::seek(uint64_t seekTime, size_t idx){
if (audioTrack == INVALID_TRACK_ID){ if (audioTrack == INVALID_TRACK_ID){
std::set<size_t> trks = meta.getValidTracks(); std::set<size_t> trks = meta.getValidTracks();
if (trks.size()){ if (trks.size()){

View file

@ -4,10 +4,10 @@
#include <mist/urireader.h> #include <mist/urireader.h>
namespace Mist{ namespace Mist{
class inputAAC : public Input{ class InputAAC : public Input{
public: public:
inputAAC(Util::Config *cfg); InputAAC(Util::Config *cfg);
~inputAAC(); ~InputAAC();
protected: protected:
// Private Functions // Private Functions
@ -24,4 +24,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputAAC mistIn; typedef Mist::InputAAC mistIn;

View file

@ -11,7 +11,7 @@
#include "input_av.h" #include "input_av.h"
namespace Mist{ namespace Mist{
inputAV::inputAV(Util::Config *cfg) : Input(cfg){ InputAV::InputAV(Util::Config *cfg) : Input(cfg){
pFormatCtx = 0; pFormatCtx = 0;
capa["name"] = "AV"; capa["name"] = "AV";
capa["desc"] = capa["desc"] =
@ -37,11 +37,11 @@ namespace Mist{
} }
} }
inputAV::~inputAV(){ InputAV::~InputAV(){
if (pFormatCtx){avformat_close_input(&pFormatCtx);} if (pFormatCtx){avformat_close_input(&pFormatCtx);}
} }
bool inputAV::checkArguments(){ bool InputAV::checkArguments(){
if (config->getString("input") == "-"){ if (config->getString("input") == "-"){
Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported"); Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported");
return false; return false;
@ -60,7 +60,7 @@ namespace Mist{
return true; return true;
} }
bool inputAV::preRun(){ bool InputAV::preRun(){
// make sure all av inputs are registered properly, just in case // make sure all av inputs are registered properly, just in case
// the constructor already does this, but under windows it doesn't remember that it has. // the constructor already does this, but under windows it doesn't remember that it has.
// Very sad, that. We may need to get windows some medication for it. // Very sad, that. We may need to get windows some medication for it.
@ -94,7 +94,7 @@ namespace Mist{
return true; return true;
} }
bool inputAV::readHeader(){ bool InputAV::readHeader(){
if (!meta || (needsLock() && isSingular())){ if (!meta || (needsLock() && isSingular())){
meta.reInit(isSingular() ? streamName : ""); meta.reInit(isSingular() ? streamName : "");
} }
@ -167,7 +167,7 @@ namespace Mist{
return true; return true;
} }
void inputAV::getNext(size_t wantIdx){ void InputAV::getNext(size_t wantIdx){
AVPacket packet; AVPacket packet;
while (av_read_frame(pFormatCtx, &packet) >= 0){ while (av_read_frame(pFormatCtx, &packet) >= 0){
// filter tracks we don't care about // filter tracks we don't care about
@ -198,7 +198,7 @@ namespace Mist{
Util::logExitReason(ER_UNKNOWN, "getNext failed"); Util::logExitReason(ER_UNKNOWN, "getNext failed");
} }
void inputAV::seek(uint64_t seekTime, size_t idx){ void InputAV::seek(uint64_t seekTime, size_t idx){
int stream_index = av_find_default_stream_index(pFormatCtx); int stream_index = av_find_default_stream_index(pFormatCtx);
// Convert ts to frame // Convert ts to frame
unsigned long long reseekTime = unsigned long long reseekTime =

View file

@ -13,10 +13,10 @@ extern "C"{
} }
namespace Mist{ namespace Mist{
class inputAV : public Input{ class InputAV : public Input{
public: public:
inputAV(Util::Config *cfg); InputAV(Util::Config *cfg);
~inputAV(); ~InputAV();
protected: protected:
// Private Functions // Private Functions
@ -31,4 +31,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputAV mistIn; typedef Mist::InputAV mistIn;

View file

@ -6,7 +6,7 @@
#include <mist/url.h> #include <mist/url.h>
namespace Mist{ namespace Mist{
inputBalancer::inputBalancer(Util::Config *cfg) : Input(cfg){ InputBalancer::InputBalancer(Util::Config *cfg) : Input(cfg){
capa["name"] = "Balancer"; capa["name"] = "Balancer";
capa["desc"] = capa["desc"] =
"The load balancer input restarts itself as the input a load balancer tells it it should " "The load balancer input restarts itself as the input a load balancer tells it it should "
@ -82,7 +82,7 @@ namespace Mist{
capa["optional"]["segmentsize"]["default"] = 5000; capa["optional"]["segmentsize"]["default"] = 5000;
} }
int inputBalancer::boot(int argc, char *argv[]){ int InputBalancer::boot(int argc, char *argv[]){
if (!config->parseArgs(argc, argv)){return 1;} if (!config->parseArgs(argc, argv)){return 1;}
if (config->getBool("json")){return Input::boot(argc, argv);} if (config->getBool("json")){return Input::boot(argc, argv);}

View file

@ -2,9 +2,9 @@
#include <mist/dtsc.h> #include <mist/dtsc.h>
namespace Mist{ namespace Mist{
class inputBalancer : public Input{ class InputBalancer : public Input{
public: public:
inputBalancer(Util::Config *cfg); InputBalancer(Util::Config *cfg);
int boot(int argc, char *argv[]); int boot(int argc, char *argv[]);
protected: protected:
@ -13,4 +13,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputBalancer mistIn; typedef Mist::InputBalancer mistIn;

View file

@ -25,7 +25,7 @@
/*LTS-END*/ /*LTS-END*/
namespace Mist{ namespace Mist{
inputBuffer::inputBuffer(Util::Config *cfg) : Input(cfg){ InputBuffer::InputBuffer(Util::Config *cfg) : Input(cfg){
firstProcTime = 0; firstProcTime = 0;
lastProcTime = 0; lastProcTime = 0;
allProcsRunning = false; allProcsRunning = false;
@ -136,7 +136,7 @@ namespace Mist{
resumeMode = false; resumeMode = false;
} }
inputBuffer::~inputBuffer(){ InputBuffer::~InputBuffer(){
config->is_active = false; config->is_active = false;
if (liveMeta){ if (liveMeta){
liveMeta->unlink(); liveMeta->unlink();
@ -146,7 +146,7 @@ namespace Mist{
} }
/// Cleans up any left-over data for the current stream /// Cleans up any left-over data for the current stream
void inputBuffer::onCrash(){ void InputBuffer::onCrash(){
WARN_MSG("Buffer crashed. Cleaning."); WARN_MSG("Buffer crashed. Cleaning.");
streamName = config->getString("streamname"); streamName = config->getString("streamname");
@ -185,7 +185,7 @@ namespace Mist{
/// FULL, EMPTY, DRY or RECOVER (depending on current state) /// FULL, EMPTY, DRY or RECOVER (depending on current state)
/// Detected issues in string format, or empty string if no issues /// Detected issues in string format, or empty string if no issues
/// ~~~~~~~~~~~~~~~ /// ~~~~~~~~~~~~~~~
void inputBuffer::updateMeta(){ void InputBuffer::updateMeta(){
if (!M){ if (!M){
Util::logExitReason(ER_SHM_LOST, "Lost connection to metadata"); Util::logExitReason(ER_SHM_LOST, "Lost connection to metadata");
return; return;
@ -262,7 +262,7 @@ namespace Mist{
/// * first fragment hasn't been at least lastms-firstms ms in buffer /// * first fragment hasn't been at least lastms-firstms ms in buffer
/// * less than 8 times the biggest fragment duration is buffered /// * less than 8 times the biggest fragment duration is buffered
/// If a key was deleted and the first buffered data page is no longer used, it is deleted also. /// If a key was deleted and the first buffered data page is no longer used, it is deleted also.
bool inputBuffer::removeKey(size_t tid){ bool InputBuffer::removeKey(size_t tid){
DTSC::Keys keys(M.keys(tid)); DTSC::Keys keys(M.keys(tid));
// If this track is empty, abort // If this track is empty, abort
if (!keys.getValidCount()){return false;} if (!keys.getValidCount()){return false;}
@ -290,7 +290,7 @@ namespace Mist{
return meta.removeFirstKey(tid); return meta.removeFirstKey(tid);
} }
void inputBuffer::finish(){ void InputBuffer::finish(){
if (M.getValidTracks().size()){ if (M.getValidTracks().size()){
/*LTS-START*/ /*LTS-START*/
if (M.getBufferWindow()){ if (M.getBufferWindow()){
@ -306,7 +306,7 @@ namespace Mist{
updateMeta(); updateMeta();
} }
void inputBuffer::removeTrack(size_t tid){ void InputBuffer::removeTrack(size_t tid){
size_t lastUser = users.recordCount(); size_t lastUser = users.recordCount();
for (size_t i = 0; i < lastUser; ++i){ for (size_t i = 0; i < lastUser; ++i){
if (users.getStatus(i) == COMM_STATUS_INVALID){continue;} if (users.getStatus(i) == COMM_STATUS_INVALID){continue;}
@ -330,7 +330,7 @@ namespace Mist{
/*LTS-END*/ /*LTS-END*/
} }
void inputBuffer::removeUnused(){ void InputBuffer::removeUnused(){
meta.reloadReplacedPagesIfNeeded(); meta.reloadReplacedPagesIfNeeded();
if (!meta){ if (!meta){
return; return;
@ -433,7 +433,7 @@ namespace Mist{
updateMeta(); updateMeta();
} }
void inputBuffer::userLeadIn(){ void InputBuffer::userLeadIn(){
meta.reloadReplacedPagesIfNeeded(); meta.reloadReplacedPagesIfNeeded();
/*LTS-START*/ /*LTS-START*/
// Reload the configuration to make sure we stay up to date with changes through the api // Reload the configuration to make sure we stay up to date with changes through the api
@ -475,7 +475,7 @@ namespace Mist{
} }
hasPush = false; hasPush = false;
} }
void inputBuffer::userOnActive(size_t id){ void InputBuffer::userOnActive(size_t id){
///\todo Add tracing of earliest watched keys, to prevent data going out of memory for ///\todo Add tracing of earliest watched keys, to prevent data going out of memory for
/// still-watching viewers /// still-watching viewers
if (!(users.getStatus(id) & COMM_STATUS_DISCONNECT) && (users.getStatus(id) & COMM_STATUS_SOURCE)){ if (!(users.getStatus(id) & COMM_STATUS_DISCONNECT) && (users.getStatus(id) & COMM_STATUS_SOURCE)){
@ -486,7 +486,7 @@ namespace Mist{
if (!(users.getStatus(id) & COMM_STATUS_DONOTTRACK)){++connectedUsers;} if (!(users.getStatus(id) & COMM_STATUS_DONOTTRACK)){++connectedUsers;}
} }
void inputBuffer::userOnDisconnect(size_t id){ void InputBuffer::userOnDisconnect(size_t id){
if (sourcePids.count(id)){ if (sourcePids.count(id)){
if (!resumeMode){ if (!resumeMode){
INFO_MSG("Disconnected track %zu", sourcePids[id]); INFO_MSG("Disconnected track %zu", sourcePids[id]);
@ -498,7 +498,7 @@ namespace Mist{
sourcePids.erase(id); sourcePids.erase(id);
} }
} }
void inputBuffer::userLeadOut(){ void InputBuffer::userLeadOut(){
if (config->is_active && streamStatus){ if (config->is_active && streamStatus){
streamStatus.mapped[0] = (hasPush && allProcsRunning) ? STRMSTAT_READY : STRMSTAT_WAIT; streamStatus.mapped[0] = (hasPush && allProcsRunning) ? STRMSTAT_READY : STRMSTAT_WAIT;
} }
@ -526,7 +526,7 @@ namespace Mist{
/*LTS-END*/ /*LTS-END*/
} }
uint64_t inputBuffer::retrieveSetting(DTSC::Scan &streamCfg, const std::string &setting, uint64_t InputBuffer::retrieveSetting(DTSC::Scan &streamCfg, const std::string &setting,
const std::string &option){ const std::string &option){
std::string opt = (option == "" ? setting : option); std::string opt = (option == "" ? setting : option);
// If stream is not configured, use commandline option // If stream is not configured, use commandline option
@ -537,7 +537,7 @@ namespace Mist{
return config->getOption(opt, true)[0u].asInt(); return config->getOption(opt, true)[0u].asInt();
} }
bool inputBuffer::preRun(){ bool InputBuffer::preRun(){
// This function gets run periodically to make sure runtime updates of the config get parsed. // This function gets run periodically to make sure runtime updates of the config get parsed.
Util::Procs::kill_timeout = 5; Util::Procs::kill_timeout = 5;
std::string strName = config->getString("streamname"); std::string strName = config->getString("streamname");
@ -602,7 +602,7 @@ namespace Mist{
return true; return true;
} }
uint64_t inputBuffer::findTrack(const std::string &trackVal){ uint64_t InputBuffer::findTrack(const std::string &trackVal){
std::set<size_t> validTracks = M.getValidTracks(); std::set<size_t> validTracks = M.getValidTracks();
if (!validTracks.size()){ if (!validTracks.size()){
return INVALID_TRACK_ID; return INVALID_TRACK_ID;
@ -646,7 +646,7 @@ namespace Mist{
/*LTS-START*/ /*LTS-START*/
/// Checks if all processes are running, starts them if needed, stops them if needed /// Checks if all processes are running, starts them if needed, stops them if needed
void inputBuffer::checkProcesses(const JSON::Value &procs){ void InputBuffer::checkProcesses(const JSON::Value &procs){
allProcsRunning = true; allProcsRunning = true;
if (!M.getValidTracks().size()){return;} if (!M.getValidTracks().size()){return;}
std::set<std::string> newProcs; std::set<std::string> newProcs;

View file

@ -4,10 +4,10 @@
#include <mist/shared_memory.h> #include <mist/shared_memory.h>
namespace Mist{ namespace Mist{
class inputBuffer : public Input{ class InputBuffer : public Input{
public: public:
inputBuffer(Util::Config *cfg); InputBuffer(Util::Config *cfg);
~inputBuffer(); ~InputBuffer();
void onCrash(); void onCrash();
private: private:
@ -59,4 +59,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputBuffer mistIn; typedef Mist::InputBuffer mistIn;

View file

@ -13,7 +13,7 @@
#include "input_dtsc.h" #include "input_dtsc.h"
namespace Mist{ namespace Mist{
inputDTSC::inputDTSC(Util::Config *cfg) : Input(cfg){ InputDTSC::InputDTSC(Util::Config *cfg) : Input(cfg){
capa["name"] = "DTSC"; capa["name"] = "DTSC";
capa["desc"] = "Load DTSC files as Video on Demand sources, or dtsc:// URLs from other " capa["desc"] = "Load DTSC files as Video on Demand sources, or dtsc:// URLs from other "
"instances for live sources. This is the optimal method to pull live " "instances for live sources. This is the optimal method to pull live "
@ -66,7 +66,7 @@ namespace Mist{
lockNeeded = false; lockNeeded = false;
} }
bool inputDTSC::needsLock(){ bool InputDTSC::needsLock(){
if (!lockCache){ if (!lockCache){
lockNeeded = lockNeeded =
config->getString("input").substr(0, 7) != "dtsc://" && config->getString("input") != "-"; config->getString("input").substr(0, 7) != "dtsc://" && config->getString("input") != "-";
@ -135,7 +135,7 @@ namespace Mist{
} }
} }
void inputDTSC::parseStreamHeader(){ void InputDTSC::parseStreamHeader(){
while (srcConn.connected() && config->is_active){ while (srcConn.connected() && config->is_active){
srcConn.spool(); srcConn.spool();
if (!srcConn.Received().available(8)){ if (!srcConn.Received().available(8)){
@ -176,7 +176,7 @@ namespace Mist{
} }
} }
bool inputDTSC::openStreamSource(){ bool InputDTSC::openStreamSource(){
std::string source = config->getString("input"); std::string source = config->getString("input");
if (source == "-"){ if (source == "-"){
srcConn.open(fileno(stdout), fileno(stdin)); srcConn.open(fileno(stdout), fileno(stdin));
@ -204,9 +204,9 @@ namespace Mist{
return true; return true;
} }
void inputDTSC::closeStreamSource(){srcConn.close();} void InputDTSC::closeStreamSource(){srcConn.close();}
bool inputDTSC::checkArguments(){ bool InputDTSC::checkArguments(){
if (!needsLock()){return true;} if (!needsLock()){return true;}
if (!config->getString("streamname").size()){ if (!config->getString("streamname").size()){
if (config->getString("output") == "-"){ if (config->getString("output") == "-"){
@ -230,12 +230,12 @@ namespace Mist{
return true; return true;
} }
bool inputDTSC::needHeader(){ bool InputDTSC::needHeader(){
if (!needsLock()){return false;} if (!needsLock()){return false;}
return Input::needHeader(); return Input::needHeader();
} }
bool inputDTSC::readHeader(){ bool InputDTSC::readHeader(){
if (!F){ if (!F){
Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str()); Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str());
return false; return false;
@ -272,7 +272,7 @@ namespace Mist{
return meta; return meta;
} }
void inputDTSC::getNext(size_t idx){ void InputDTSC::getNext(size_t idx){
if (!needsLock()){ if (!needsLock()){
getNextFromStream(idx); getNextFromStream(idx);
return; return;
@ -336,7 +336,7 @@ namespace Mist{
fseek(F, thisPos.bytePos, SEEK_SET); fseek(F, thisPos.bytePos, SEEK_SET);
} }
void inputDTSC::getNextFromStream(size_t idx){ void InputDTSC::getNextFromStream(size_t idx){
thisPacket.reInit(srcConn); thisPacket.reInit(srcConn);
while (config->is_active){ while (config->is_active){
if (thisPacket.getVersion() == DTSC::DTCM){ if (thisPacket.getVersion() == DTSC::DTCM){
@ -415,7 +415,7 @@ namespace Mist{
} }
} }
void inputDTSC::seek(uint64_t seekTime, size_t idx){ void InputDTSC::seek(uint64_t seekTime, size_t idx){
currentPositions.clear(); currentPositions.clear();
if (idx != INVALID_TRACK_ID){ if (idx != INVALID_TRACK_ID){
seekNext(seekTime, idx, true); seekNext(seekTime, idx, true);
@ -427,7 +427,7 @@ namespace Mist{
} }
} }
void inputDTSC::seekNext(uint64_t ms, size_t trackIdx, bool forceSeek){ void InputDTSC::seekNext(uint64_t ms, size_t trackIdx, bool forceSeek){
seekPos tmpPos; seekPos tmpPos;
tmpPos.trackID = trackIdx; tmpPos.trackID = trackIdx;
if (!forceSeek && thisPacket && ms >= thisPacket.getTime() && trackIdx >= thisPacket.getTrackId()){ if (!forceSeek && thisPacket && ms >= thisPacket.getTime() && trackIdx >= thisPacket.getTrackId()){

View file

@ -22,9 +22,9 @@ namespace Mist{
///< associated with. ///< associated with.
}; };
class inputDTSC : public Input{ class InputDTSC : public Input{
public: public:
inputDTSC(Util::Config *cfg); InputDTSC(Util::Config *cfg);
bool needsLock(); bool needsLock();
virtual std::string getConnectedBinHost(){ virtual std::string getConnectedBinHost(){
@ -61,4 +61,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputDTSC mistIn; typedef Mist::InputDTSC mistIn;

View file

@ -14,7 +14,7 @@
#include <ctime> #include <ctime>
namespace Mist{ namespace Mist{
inputDTSC::inputDTSC(Util::Config *cfg) : Input(cfg){ InputDTSC::InputDTSC(Util::Config *cfg) : Input(cfg){
capa["name"] = "DTSC"; capa["name"] = "DTSC";
capa["desc"] = "Enables DTSC Input"; capa["desc"] = "Enables DTSC Input";
capa["priority"] = 9; capa["priority"] = 9;
@ -52,7 +52,7 @@ namespace Mist{
srand(time(NULL)); srand(time(NULL));
} }
bool inputDTSC::checkArguments(){ bool InputDTSC::checkArguments(){
key = Encodings::Base64::decode(config->getString("key")); key = Encodings::Base64::decode(config->getString("key"));
if (key == ""){ if (key == ""){
if (config->getString("keyseed") == "" || config->getString("keyid") == ""){ if (config->getString("keyseed") == "" || config->getString("keyid") == ""){
@ -90,7 +90,7 @@ namespace Mist{
return true; return true;
} }
bool inputDTSC::readHeader(){ bool InputDTSC::readHeader(){
if (!inFile){ if (!inFile){
Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str()); Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str());
return false; return false;
@ -110,7 +110,7 @@ namespace Mist{
return true; return true;
} }
void inputDTSC::getNext(bool smart){ void InputDTSC::getNext(bool smart){
if (smart){ if (smart){
inFile.seekNext(); inFile.seekNext();
}else{ }else{
@ -135,13 +135,13 @@ namespace Mist{
Encryption::encryptPlayReady(thisPacket, myMeta.tracks[tid].codec, iVec, key.data()); Encryption::encryptPlayReady(thisPacket, myMeta.tracks[tid].codec, iVec, key.data());
} }
void inputDTSC::seek(int seekTime){ void InputDTSC::seek(int seekTime){
inFile.seek_time(seekTime); inFile.seek_time(seekTime);
initialTime = 0; initialTime = 0;
playUntil = 0; playUntil = 0;
} }
void inputDTSC::trackSelect(std::string trackSpec){ void InputDTSC::trackSelect(std::string trackSpec){
selectedTracks.clear(); selectedTracks.clear();
long long unsigned int index; long long unsigned int index;
while (trackSpec != ""){ while (trackSpec != ""){

View file

@ -2,9 +2,9 @@
#include <mist/dtsc.h> #include <mist/dtsc.h>
namespace Mist{ namespace Mist{
class inputDTSC : public Input{ class InputDTSC : public Input{
public: public:
inputDTSC(Util::Config *cfg); InputDTSC(Util::Config *cfg);
protected: protected:
// Private Functions // Private Functions
@ -21,4 +21,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputDTSC mistIn; typedef Mist::InputDTSC mistIn;

View file

@ -16,7 +16,7 @@
#include <mist/flac.h> #include <mist/flac.h>
namespace Mist{ namespace Mist{
inputFLAC::inputFLAC(Util::Config *cfg) : Input(cfg){ InputFLAC::InputFLAC(Util::Config *cfg) : Input(cfg){
capa["name"] = "FLAC"; capa["name"] = "FLAC";
capa["desc"] = "Allows loading FLAC files for Audio on Demand."; capa["desc"] = "Allows loading FLAC files for Audio on Demand.";
capa["source_match"] = "/*.flac"; capa["source_match"] = "/*.flac";
@ -36,9 +36,9 @@ namespace Mist{
tNum = INVALID_TRACK_ID; tNum = INVALID_TRACK_ID;
} }
inputFLAC::~inputFLAC(){} InputFLAC::~InputFLAC(){}
bool inputFLAC::checkArguments(){ bool InputFLAC::checkArguments(){
if (config->getString("input") == "-"){ if (config->getString("input") == "-"){
Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported"); Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported");
return false; return false;
@ -57,7 +57,7 @@ namespace Mist{
return true; return true;
} }
bool inputFLAC::preRun(){ bool InputFLAC::preRun(){
inFile = fopen(config->getString("input").c_str(), "r"); inFile = fopen(config->getString("input").c_str(), "r");
if (!inFile){ if (!inFile){
Util::logExitReason(ER_READ_START_FAILURE, "Opening input '%s' failed", config->getString("input").c_str()); Util::logExitReason(ER_READ_START_FAILURE, "Opening input '%s' failed", config->getString("input").c_str());
@ -66,7 +66,7 @@ namespace Mist{
return true; return true;
} }
void inputFLAC::stripID3tag(){ void InputFLAC::stripID3tag(){
char header[10]; char header[10];
fread(header, 10, 1, inFile); // Read a 10 byte header fread(header, 10, 1, inFile); // Read a 10 byte header
if (header[0] == 'I' || header[1] == 'D' || header[2] == '3'){ if (header[0] == 'I' || header[1] == 'D' || header[2] == '3'){
@ -81,7 +81,7 @@ namespace Mist{
} }
} }
bool inputFLAC::readMagicPacket(){ bool InputFLAC::readMagicPacket(){
char magic[4]; char magic[4];
if (fread(magic, 4, 1, inFile) != 1){ if (fread(magic, 4, 1, inFile) != 1){
Util::logExitReason(ER_FORMAT_SPECIFIC, "Could not read magic word - aborting!"); Util::logExitReason(ER_FORMAT_SPECIFIC, "Could not read magic word - aborting!");
@ -97,7 +97,7 @@ namespace Mist{
return false; return false;
} }
bool inputFLAC::readHeader(){ bool InputFLAC::readHeader(){
if (!inFile){ if (!inFile){
Util::logExitReason(ER_READ_START_FAILURE, "Opening input '%s' failed", config->getString("input").c_str()); Util::logExitReason(ER_READ_START_FAILURE, "Opening input '%s' failed", config->getString("input").c_str());
return false; return false;
@ -206,7 +206,7 @@ namespace Mist{
return true; return true;
} }
bool inputFLAC::fillBuffer(size_t size){ bool InputFLAC::fillBuffer(size_t size){
if (feof(inFile)){ if (feof(inFile)){
INFO_MSG("EOF"); INFO_MSG("EOF");
return flacBuffer.size(); return flacBuffer.size();
@ -229,7 +229,7 @@ namespace Mist{
return flacBuffer.size(); return flacBuffer.size();
} }
void inputFLAC::getNext(size_t idx){ void InputFLAC::getNext(size_t idx){
while (!stopProcessing){ while (!stopProcessing){
blockSize = M.inputLocalVars["blockSize"].asInt(); blockSize = M.inputLocalVars["blockSize"].asInt();
@ -323,7 +323,7 @@ namespace Mist{
return; return;
} }
void inputFLAC::seek(uint64_t seekTime, size_t idx){ void InputFLAC::seek(uint64_t seekTime, size_t idx){
uint64_t mainTrack = M.mainTrack(); uint64_t mainTrack = M.mainTrack();
blockSize = M.inputLocalVars["blockSize"].asInt(); blockSize = M.inputLocalVars["blockSize"].asInt();
sampleRate = meta.getRate(mainTrack); sampleRate = meta.getRate(mainTrack);

View file

@ -3,10 +3,10 @@
#include <mist/dtsc.h> #include <mist/dtsc.h>
namespace Mist{ namespace Mist{
class inputFLAC : public Input{ class InputFLAC : public Input{
public: public:
inputFLAC(Util::Config *cfg); InputFLAC(Util::Config *cfg);
~inputFLAC(); ~InputFLAC();
protected: protected:
bool checkArguments(); bool checkArguments();
@ -45,4 +45,4 @@ namespace Mist{
}// namespace Mist }// namespace Mist
typedef Mist::inputFLAC mistIn; typedef Mist::InputFLAC mistIn;

View file

@ -15,7 +15,7 @@
#include "input_flv.h" #include "input_flv.h"
namespace Mist{ namespace Mist{
inputFLV::inputFLV(Util::Config *cfg) : Input(cfg){ InputFLV::InputFLV(Util::Config *cfg) : Input(cfg){
capa["name"] = "FLV"; capa["name"] = "FLV";
capa["desc"] = "Allows loading FLV files for Video on Demand."; capa["desc"] = "Allows loading FLV files for Video on Demand.";
capa["source_match"] = "/*.flv"; capa["source_match"] = "/*.flv";
@ -28,9 +28,9 @@ namespace Mist{
capa["codecs"]["audio"].append("MP3"); capa["codecs"]["audio"].append("MP3");
} }
inputFLV::~inputFLV(){} InputFLV::~InputFLV(){}
bool inputFLV::checkArguments(){ bool InputFLV::checkArguments(){
if (config->getString("input") == "-"){ if (config->getString("input") == "-"){
Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported"); Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported");
return false; return false;
@ -49,7 +49,7 @@ namespace Mist{
return true; return true;
} }
bool inputFLV::preRun(){ bool InputFLV::preRun(){
// open File // open File
inFile = fopen(config->getString("input").c_str(), "r"); inFile = fopen(config->getString("input").c_str(), "r");
if (!inFile){ if (!inFile){
@ -67,7 +67,7 @@ namespace Mist{
/// Overrides the default keepRunning function to shut down /// Overrides the default keepRunning function to shut down
/// if the file disappears or changes, by polling the file's mtime. /// if the file disappears or changes, by polling the file's mtime.
/// If neither applies, calls the original function. /// If neither applies, calls the original function.
bool inputFLV::keepRunning(){ bool InputFLV::keepRunning(){
struct stat statData; struct stat statData;
if (stat(config->getString("input").c_str(), &statData) == -1){ if (stat(config->getString("input").c_str(), &statData) == -1){
INFO_MSG("Shutting down because input file disappeared"); INFO_MSG("Shutting down because input file disappeared");
@ -80,7 +80,7 @@ namespace Mist{
return Input::keepRunning(); return Input::keepRunning();
} }
bool inputFLV::readHeader(){ bool InputFLV::readHeader(){
if (!inFile){ if (!inFile){
Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str()); Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str());
return false; return false;
@ -116,7 +116,7 @@ namespace Mist{
return true; return true;
} }
void inputFLV::getNext(size_t idx){ void InputFLV::getNext(size_t idx){
uint64_t lastBytePos = Util::ftell(inFile); uint64_t lastBytePos = Util::ftell(inFile);
if (idx != INVALID_TRACK_ID){ if (idx != INVALID_TRACK_ID){
uint8_t targetTag = 0x08; uint8_t targetTag = 0x08;
@ -165,7 +165,7 @@ namespace Mist{
} }
} }
void inputFLV::seek(uint64_t seekTime, size_t idx){ void InputFLV::seek(uint64_t seekTime, size_t idx){
// We will seek to the corresponding keyframe of the video track if selected, otherwise audio // We will seek to the corresponding keyframe of the video track if selected, otherwise audio
// keyframe. Flv files are never multi-track, so track 1 is video, track 2 is audio. // keyframe. Flv files are never multi-track, so track 1 is video, track 2 is audio.
size_t seekTrack = (idx == INVALID_TRACK_ID ? M.mainTrack() : idx); size_t seekTrack = (idx == INVALID_TRACK_ID ? M.mainTrack() : idx);

View file

@ -3,10 +3,10 @@
#include <mist/flv_tag.h> #include <mist/flv_tag.h>
namespace Mist{ namespace Mist{
class inputFLV : public Input{ class InputFLV : public Input{
public: public:
inputFLV(Util::Config *cfg); InputFLV(Util::Config *cfg);
~inputFLV(); ~InputFLV();
protected: protected:
// Private Functions // Private Functions
@ -22,4 +22,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputFLV mistIn; typedef Mist::InputFLV mistIn;

View file

@ -7,7 +7,7 @@
#include "input_folder.h" #include "input_folder.h"
namespace Mist{ namespace Mist{
inputFolder::inputFolder(Util::Config *cfg) : Input(cfg){ InputFolder::InputFolder(Util::Config *cfg) : Input(cfg){
capa["name"] = "Folder"; capa["name"] = "Folder";
capa["desc"] = capa["desc"] =
"The folder input will make available all supported files in the given folder as streams " "The folder input will make available all supported files in the given folder as streams "
@ -21,7 +21,7 @@ namespace Mist{
capa["morphic"] = 1; capa["morphic"] = 1;
} }
int inputFolder::boot(int argc, char *argv[]){ int InputFolder::boot(int argc, char *argv[]){
if (!config->parseArgs(argc, argv)){return 1;} if (!config->parseArgs(argc, argv)){return 1;}
if (config->getBool("json")){return Input::boot(argc, argv);} if (config->getBool("json")){return Input::boot(argc, argv);}

View file

@ -2,9 +2,9 @@
#include <mist/dtsc.h> #include <mist/dtsc.h>
namespace Mist{ namespace Mist{
class inputFolder : public Input{ class InputFolder : public Input{
public: public:
inputFolder(Util::Config *cfg); InputFolder(Util::Config *cfg);
int boot(int argc, char *argv[]); int boot(int argc, char *argv[]);
protected: protected:
@ -15,4 +15,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputFolder mistIn; typedef Mist::InputFolder mistIn;

View file

@ -140,11 +140,11 @@ namespace Mist{
// These are used in the HTTP::Downloader callback, to prevent timeouts when downloading // These are used in the HTTP::Downloader callback, to prevent timeouts when downloading
// segments/playlists. // segments/playlists.
inputHLS *self = 0; InputHLS *self = 0;
bool callbackFunc(uint8_t){return self->callback();} bool callbackFunc(uint8_t){return self->callback();}
/// Called by the global callbackFunc, to prevent timeouts /// Called by the global callbackFunc, to prevent timeouts
bool inputHLS::callback(){ bool InputHLS::callback(){
keepAlive(); keepAlive();
return config->is_active; return config->is_active;
} }
@ -723,7 +723,7 @@ namespace Mist{
} }
/// Constructor of HLS Input /// Constructor of HLS Input
inputHLS::inputHLS(Util::Config *cfg) : Input(cfg){ InputHLS::InputHLS(Util::Config *cfg) : Input(cfg){
zUTC = nUTC = 0; zUTC = nUTC = 0;
self = this; self = this;
streamIsLive = true; //< default to sliding window playlist streamIsLive = true; //< default to sliding window playlist
@ -783,11 +783,11 @@ namespace Mist{
inFile = NULL; inFile = NULL;
} }
inputHLS::~inputHLS(){ InputHLS::~InputHLS(){
if (inFile){fclose(inFile);} if (inFile){fclose(inFile);}
} }
bool inputHLS::checkArguments(){ bool InputHLS::checkArguments(){
config->is_active = true; config->is_active = true;
if (config->getString("input") == "-"){ if (config->getString("input") == "-"){
return false; return false;
@ -806,7 +806,7 @@ namespace Mist{
return true; return true;
} }
bool inputHLS::readExistingHeader(){ bool InputHLS::readExistingHeader(){
if (!Input::readExistingHeader()){ if (!Input::readExistingHeader()){
INFO_MSG("Could not read existing header, regenerating"); INFO_MSG("Could not read existing header, regenerating");
return false; return false;
@ -900,12 +900,12 @@ namespace Mist{
return true; return true;
} }
void inputHLS::parseStreamHeader(){ void InputHLS::parseStreamHeader(){
streamIsVOD = false; streamIsVOD = false;
readHeader(); readHeader();
} }
bool inputHLS::readHeader(){ bool InputHLS::readHeader(){
// to analyse and extract data // to analyse and extract data
TS::Packet packet; TS::Packet packet;
char *data; char *data;
@ -1038,7 +1038,7 @@ namespace Mist{
} }
/// Sets inputLocalVars based on data ingested /// Sets inputLocalVars based on data ingested
void inputHLS::injectLocalVars(){ void InputHLS::injectLocalVars(){
meta.inputLocalVars.null(); meta.inputLocalVars.null();
meta.inputLocalVars["version"] = 4; meta.inputLocalVars["version"] = 4;
@ -1080,7 +1080,7 @@ namespace Mist{
/// \brief Parses new segments added to playlist files as live data /// \brief Parses new segments added to playlist files as live data
/// \param segmentIndex: the index of the segment in the current playlist /// \param segmentIndex: the index of the segment in the current playlist
/// \return True if the segment has been buffered successfully /// \return True if the segment has been buffered successfully
bool inputHLS::parseSegmentAsLive(uint64_t segmentIndex){ bool InputHLS::parseSegmentAsLive(uint64_t segmentIndex){
bool hasOffset = false; bool hasOffset = false;
bool hasPacket = false; bool hasPacket = false;
uint64_t bufferTime = config->getInteger("pagetimeout"); uint64_t bufferTime = config->getInteger("pagetimeout");
@ -1187,12 +1187,12 @@ namespace Mist{
return true; return true;
} }
void inputHLS::streamMainLoop(){ void InputHLS::streamMainLoop(){
parseLivePoint(); parseLivePoint();
} }
// Removes any metadata which is no longer and the playlist or buffered in memory // Removes any metadata which is no longer and the playlist or buffered in memory
void inputHLS::updateMeta(){ void InputHLS::updateMeta(){
// EVENT and VOD type playlists should never segments disappear from the start // EVENT and VOD type playlists should never segments disappear from the start
// Only LIVE (sliding-window) type playlists should execute updateMeta() // Only LIVE (sliding-window) type playlists should execute updateMeta()
if (streamIsVOD || !streamIsLive){ if (streamIsVOD || !streamIsLive){
@ -1224,7 +1224,7 @@ namespace Mist{
} }
} }
void inputHLS::parseLivePoint(){ void InputHLS::parseLivePoint(){
uint64_t maxTime = Util::bootMS() + 500; uint64_t maxTime = Util::bootMS() + 500;
// Update all playlists to make sure listEntries contains all live segments // Update all playlists to make sure listEntries contains all live segments
for (std::map<uint64_t, Playlist>::iterator pListIt = playlistMapping.begin(); for (std::map<uint64_t, Playlist>::iterator pListIt = playlistMapping.begin();
@ -1279,16 +1279,16 @@ namespace Mist{
} }
/// \brief Override userLeadOut to buffer new data as live packets /// \brief Override userLeadOut to buffer new data as live packets
void inputHLS::userLeadOut(){ void InputHLS::userLeadOut(){
Input::userLeadOut(); Input::userLeadOut();
if (streamIsLive){ if (streamIsLive){
parseLivePoint(); parseLivePoint();
} }
} }
bool inputHLS::openStreamSource(){return true;} bool InputHLS::openStreamSource(){return true;}
void inputHLS::getNext(size_t idx){ void InputHLS::getNext(size_t idx){
INSANE_MSG("Getting next"); INSANE_MSG("Getting next");
uint32_t tid = 0; uint32_t tid = 0;
bool finished = false; bool finished = false;
@ -1390,7 +1390,7 @@ namespace Mist{
} }
// Note: bpos is overloaded here for playlist entry! // Note: bpos is overloaded here for playlist entry!
void inputHLS::seek(uint64_t seekTime, size_t idx){ void InputHLS::seek(uint64_t seekTime, size_t idx){
if (idx == INVALID_TRACK_ID){return;} if (idx == INVALID_TRACK_ID){return;}
plsTimeOffset.clear(); plsTimeOffset.clear();
plsLastTime.clear(); plsLastTime.clear();
@ -1456,7 +1456,7 @@ namespace Mist{
/// \param currentPlaylist: the ID of the playlist we are currently trying to parse /// \param currentPlaylist: the ID of the playlist we are currently trying to parse
/// \param nUTC: Defaults to 0. If larger than 0, sync the timestamp based on this value and zUTC /// \param nUTC: Defaults to 0. If larger than 0, sync the timestamp based on this value and zUTC
/// \return the (modified) packetTime, used for meta.updates and buffering packets /// \return the (modified) packetTime, used for meta.updates and buffering packets
uint64_t inputHLS::getPacketTime(uint64_t packetTime, uint64_t tid, uint64_t currentPlaylist, uint64_t nUTC){ uint64_t InputHLS::getPacketTime(uint64_t packetTime, uint64_t tid, uint64_t currentPlaylist, uint64_t nUTC){
INSANE_MSG("Calculating adjusted packet time for track %" PRIu64 " on playlist %" PRIu64 " with current timestamp %" PRIu64 ". UTC timestamp is %" PRIu64, tid, currentPlaylist, packetTime, nUTC); INSANE_MSG("Calculating adjusted packet time for track %" PRIu64 " on playlist %" PRIu64 " with current timestamp %" PRIu64 ". UTC timestamp is %" PRIu64, tid, currentPlaylist, packetTime, nUTC);
uint64_t newTime = packetTime; uint64_t newTime = packetTime;
@ -1519,7 +1519,7 @@ namespace Mist{
/// \brief Returns the packet ID corresponding to this playlist and track /// \brief Returns the packet ID corresponding to this playlist and track
/// \param trackId: the trackid corresponding to this track and playlist /// \param trackId: the trackid corresponding to this track and playlist
/// \param currentPlaylist: the ID of the playlist we are currently trying to parse /// \param currentPlaylist: the ID of the playlist we are currently trying to parse
uint64_t inputHLS::getPacketID(uint64_t currentPlaylist, uint64_t trackId){ uint64_t InputHLS::getPacketID(uint64_t currentPlaylist, uint64_t trackId){
uint64_t packetId = pidMapping[(((uint64_t)currentPlaylist) << 32) + trackId]; uint64_t packetId = pidMapping[(((uint64_t)currentPlaylist) << 32) + trackId];
if (packetId == 0){ if (packetId == 0){
pidMapping[(((uint64_t)currentPlaylist) << 32) + trackId] = pidCounter; pidMapping[(((uint64_t)currentPlaylist) << 32) + trackId] = pidCounter;
@ -1530,11 +1530,11 @@ namespace Mist{
return packetId; return packetId;
} }
uint64_t inputHLS::getOriginalTrackId(uint32_t playlistId, uint32_t id){ uint64_t InputHLS::getOriginalTrackId(uint32_t playlistId, uint32_t id){
return pidMapping[(((uint64_t)playlistId) << 32) + id]; return pidMapping[(((uint64_t)playlistId) << 32) + id];
} }
uint32_t inputHLS::getMappedTrackId(uint64_t id){ uint32_t InputHLS::getMappedTrackId(uint64_t id){
static uint64_t lastIn = id; static uint64_t lastIn = id;
static uint32_t lastOut = (pidMappingR[id] & 0xFFFFFFFFull); static uint32_t lastOut = (pidMappingR[id] & 0xFFFFFFFFull);
if (lastIn != id){ if (lastIn != id){
@ -1544,7 +1544,7 @@ namespace Mist{
return lastOut; return lastOut;
} }
uint32_t inputHLS::getMappedTrackPlaylist(uint64_t id){ uint32_t InputHLS::getMappedTrackPlaylist(uint64_t id){
if (!pidMappingR.count(id)){ if (!pidMappingR.count(id)){
FAIL_MSG("No mapping found for track ID %" PRIu64, id); FAIL_MSG("No mapping found for track ID %" PRIu64, id);
return 0; return 0;
@ -1559,7 +1559,7 @@ namespace Mist{
} }
/// Parses the main playlist, possibly containing variants. /// Parses the main playlist, possibly containing variants.
bool inputHLS::initPlaylist(const std::string &uri, bool fullInit){ bool InputHLS::initPlaylist(const std::string &uri, bool fullInit){
// Used to set zUTC, in case the first EXT-X-PROGRAM-DATE-TIME does not appear before the first segment // Used to set zUTC, in case the first EXT-X-PROGRAM-DATE-TIME does not appear before the first segment
float timestampSum = 0; float timestampSum = 0;
bool isRegularPls = false; bool isRegularPls = false;
@ -1741,7 +1741,7 @@ namespace Mist{
} }
/// Function for reading every playlist. /// Function for reading every playlist.
bool inputHLS::readPlaylist(const HTTP::URL &uri, const std::string & relurl, bool fullInit){ bool InputHLS::readPlaylist(const HTTP::URL &uri, const std::string & relurl, bool fullInit){
std::string urlBuffer; std::string urlBuffer;
// Wildcard streams can have a ' ' in the name, which getUrl converts to a '+' // Wildcard streams can have a ' ' in the name, which getUrl converts to a '+'
if (uri.isLocalPath()){ if (uri.isLocalPath()){
@ -1761,7 +1761,7 @@ namespace Mist{
/// Read next .ts file from the playlist. (from the list of entries which needs /// Read next .ts file from the playlist. (from the list of entries which needs
/// to be processed) /// to be processed)
bool inputHLS::readNextFile(){ bool InputHLS::readNextFile(){
tsStream.clear(); tsStream.clear();
playListEntries ntry; playListEntries ntry;
@ -1808,7 +1808,7 @@ namespace Mist{
/// return the playlist id from which we need to read the first upcoming segment /// return the playlist id from which we need to read the first upcoming segment
/// by timestamp. /// by timestamp.
/// this will keep the playlists in sync while reading segments. /// this will keep the playlists in sync while reading segments.
size_t inputHLS::firstSegment(){ size_t InputHLS::firstSegment(){
// Only one selected? Immediately return the right playlist. // Only one selected? Immediately return the right playlist.
if (!streamIsLive){return getMappedTrackPlaylist(M.getID(userSelect.begin()->first));} if (!streamIsLive){return getMappedTrackPlaylist(M.getID(userSelect.begin()->first));}
uint64_t firstTimeStamp = 0; uint64_t firstTimeStamp = 0;
@ -1831,7 +1831,7 @@ namespace Mist{
return tmpId; return tmpId;
} }
void inputHLS::finish(){ void InputHLS::finish(){
if (streamIsLive){ //< Already generated from readHeader if (streamIsLive){ //< Already generated from readHeader
INFO_MSG("Writing updated header to disk"); INFO_MSG("Writing updated header to disk");
injectLocalVars(); injectLocalVars();
@ -1840,7 +1840,7 @@ namespace Mist{
Input::finish(); Input::finish();
} }
void inputHLS::checkHeaderTimes(const HTTP::URL & streamFile){ void InputHLS::checkHeaderTimes(const HTTP::URL & streamFile){
if (streamIsLive){return;} //< Since the playlist will likely be newer than the DTSH for live-dvr if (streamIsLive){return;} //< Since the playlist will likely be newer than the DTSH for live-dvr
Input::checkHeaderTimes(streamFile); Input::checkHeaderTimes(streamFile);
} }

View file

@ -106,10 +106,10 @@ namespace Mist{
void playlistRunner(void *ptr); void playlistRunner(void *ptr);
class inputHLS : public Input{ class InputHLS : public Input{
public: public:
inputHLS(Util::Config *cfg); InputHLS(Util::Config *cfg);
~inputHLS(); ~InputHLS();
bool needsLock(){return !config->getBool("realtime");} bool needsLock(){return !config->getBool("realtime");}
bool openStreamSource(); bool openStreamSource();
bool callback(); bool callback();
@ -187,4 +187,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputHLS mistIn; typedef Mist::InputHLS mistIn;

View file

@ -11,7 +11,7 @@
#include "input_ismv.h" #include "input_ismv.h"
namespace Mist{ namespace Mist{
inputISMV::inputISMV(Util::Config *cfg) : Input(cfg){ InputISMV::InputISMV(Util::Config *cfg) : Input(cfg){
capa["name"] = "ISMV"; capa["name"] = "ISMV";
capa["desc"] = "This input allows you to stream ISMV Video on Demand files."; capa["desc"] = "This input allows you to stream ISMV Video on Demand files.";
capa["source_match"] = "/*.ismv"; capa["source_match"] = "/*.ismv";
@ -22,7 +22,7 @@ namespace Mist{
inFile = 0; inFile = 0;
} }
bool inputISMV::checkArguments(){ bool InputISMV::checkArguments(){
if (config->getString("input") == "-"){ if (config->getString("input") == "-"){
Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported"); Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported");
return false; return false;
@ -41,7 +41,7 @@ namespace Mist{
return true; return true;
} }
bool inputISMV::preRun(){ bool InputISMV::preRun(){
inFile = fopen(config->getString("input").c_str(), "r"); inFile = fopen(config->getString("input").c_str(), "r");
if (!inFile){ if (!inFile){
Util::logExitReason(ER_READ_START_FAILURE, "Opening input '%s' failed", config->getString("input").c_str()); Util::logExitReason(ER_READ_START_FAILURE, "Opening input '%s' failed", config->getString("input").c_str());
@ -50,7 +50,7 @@ namespace Mist{
return true; return true;
} }
bool inputISMV::readHeader(){ bool InputISMV::readHeader(){
if (!inFile){ if (!inFile){
Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str()); Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str());
return false; return false;
@ -97,7 +97,7 @@ namespace Mist{
return true; return true;
} }
void inputISMV::getNext(size_t idx){ void InputISMV::getNext(size_t idx){
thisPacket.null(); thisPacket.null();
if (!buffered.size()){return;} if (!buffered.size()){return;}
@ -128,7 +128,7 @@ namespace Mist{
if (idx != INVALID_TRACK_ID && thisPacket.getTrackId() != M.getID(idx)){getNext(idx);} if (idx != INVALID_TRACK_ID && thisPacket.getTrackId() != M.getID(idx)){getNext(idx);}
} }
void inputISMV::seek(uint64_t seekTime, size_t idx){ void InputISMV::seek(uint64_t seekTime, size_t idx){
buffered.clear(); buffered.clear();
lastKeyNum.clear(); lastKeyNum.clear();
@ -152,7 +152,7 @@ namespace Mist{
} }
} }
void inputISMV::parseMoov(MP4::MOOV &moovBox){ void InputISMV::parseMoov(MP4::MOOV &moovBox){
std::deque<MP4::TRAK> trak = moovBox.getChildren<MP4::TRAK>(); std::deque<MP4::TRAK> trak = moovBox.getChildren<MP4::TRAK>();
for (std::deque<MP4::TRAK>::iterator it = trak.begin(); it != trak.end(); it++){ for (std::deque<MP4::TRAK>::iterator it = trak.begin(); it != trak.end(); it++){
size_t tNumber = meta.addTrack(); size_t tNumber = meta.addTrack();
@ -189,7 +189,7 @@ namespace Mist{
} }
} }
bool inputISMV::readMoofSkipMdat(size_t &tId, std::vector<MP4::trunSampleInformation> &trunSamples){ bool InputISMV::readMoofSkipMdat(size_t &tId, std::vector<MP4::trunSampleInformation> &trunSamples){
tId = INVALID_TRACK_ID; tId = INVALID_TRACK_ID;
trunSamples.clear(); trunSamples.clear();
@ -222,7 +222,7 @@ namespace Mist{
return true; return true;
} }
void inputISMV::bufferFragmentData(size_t trackId, uint32_t keyNum){ void InputISMV::bufferFragmentData(size_t trackId, uint32_t keyNum){
INFO_MSG("Bpos seek for %zu/%" PRIu32, trackId, keyNum); INFO_MSG("Bpos seek for %zu/%" PRIu32, trackId, keyNum);
if (trackId == INVALID_TRACK_ID){return;} if (trackId == INVALID_TRACK_ID){return;}
DTSC::Keys keys(M.keys(trackId)); DTSC::Keys keys(M.keys(trackId));

View file

@ -22,9 +22,9 @@ namespace Mist{
std::string iVec; std::string iVec;
}; };
class inputISMV : public Input{ class InputISMV : public Input{
public: public:
inputISMV(Util::Config *cfg); InputISMV(Util::Config *cfg);
protected: protected:
// Private Functions // Private Functions
@ -47,4 +47,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputISMV mistIn; typedef Mist::InputISMV mistIn;

View file

@ -13,7 +13,7 @@
#include "input_mp3.h" #include "input_mp3.h"
namespace Mist{ namespace Mist{
inputMP3::inputMP3(Util::Config *cfg) : Input(cfg){ InputMP3::InputMP3(Util::Config *cfg) : Input(cfg){
capa["name"] = "MP3"; capa["name"] = "MP3";
capa["desc"] = "This input allows you to stream MP3 Video on Demand files."; capa["desc"] = "This input allows you to stream MP3 Video on Demand files.";
capa["source_match"] = "/*.mp3"; capa["source_match"] = "/*.mp3";
@ -23,7 +23,7 @@ namespace Mist{
timestamp = 0; timestamp = 0;
} }
bool inputMP3::checkArguments(){ bool InputMP3::checkArguments(){
if (config->getString("input") == "-"){ if (config->getString("input") == "-"){
Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported"); Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported");
return false; return false;
@ -42,7 +42,7 @@ namespace Mist{
return true; return true;
} }
bool inputMP3::preRun(){ bool InputMP3::preRun(){
// open File // open File
inFile = fopen(config->getString("input").c_str(), "r"); inFile = fopen(config->getString("input").c_str(), "r");
if (!inFile){ if (!inFile){
@ -52,7 +52,7 @@ namespace Mist{
return true; return true;
} }
bool inputMP3::readHeader(){ bool InputMP3::readHeader(){
if (!inFile){ if (!inFile){
Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str()); Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str());
return false; return false;
@ -94,7 +94,7 @@ namespace Mist{
return true; return true;
} }
void inputMP3::getNext(size_t idx){ void InputMP3::getNext(size_t idx){
thisPacket.null(); thisPacket.null();
static char packHeader[3000]; static char packHeader[3000];
size_t filePos = ftell(inFile); size_t filePos = ftell(inFile);
@ -158,7 +158,7 @@ namespace Mist{
timestamp += (sampleCount / (sampleRate / 1000)); timestamp += (sampleCount / (sampleRate / 1000));
} }
void inputMP3::seek(uint64_t seekTime, size_t idx){ void InputMP3::seek(uint64_t seekTime, size_t idx){
idx = 0; idx = 0;
DTSC::Keys keys(M.keys(idx)); DTSC::Keys keys(M.keys(idx));
uint32_t keyNum = M.getKeyNumForTime(idx, seekTime); uint32_t keyNum = M.getKeyNumForTime(idx, seekTime);

View file

@ -12,9 +12,9 @@ namespace Mist{
{{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, -1}, {{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, -1},
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1}, {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1},
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1}}}; {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1}}};
class inputMP3 : public Input{ class InputMP3 : public Input{
public: public:
inputMP3(Util::Config *cfg); InputMP3(Util::Config *cfg);
protected: protected:
// Private Functions // Private Functions
@ -30,4 +30,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputMP3 mistIn; typedef Mist::InputMP3 mistIn;

View file

@ -96,7 +96,7 @@ namespace Mist{
initialised = true; initialised = true;
} }
mp4TrackHeader &inputMP4::headerData(size_t trackID){ mp4TrackHeader &InputMP4::headerData(size_t trackID){
static mp4TrackHeader none; static mp4TrackHeader none;
for (std::deque<mp4TrackHeader>::iterator it = trackHeaders.begin(); it != trackHeaders.end(); it++){ for (std::deque<mp4TrackHeader>::iterator it = trackHeaders.begin(); it != trackHeaders.end(); it++){
if (it->trackId == trackID){return *it;} if (it->trackId == trackID){return *it;}
@ -104,7 +104,7 @@ namespace Mist{
return none; return none;
} }
inputMP4::inputMP4(Util::Config *cfg) : Input(cfg){ InputMP4::InputMP4(Util::Config *cfg) : Input(cfg){
capa["name"] = "MP4"; capa["name"] = "MP4";
capa["desc"] = "This input allows streaming of MP4 files as Video on Demand."; capa["desc"] = "This input allows streaming of MP4 files as Video on Demand.";
capa["source_match"].append("/*.mp4"); capa["source_match"].append("/*.mp4");
@ -125,7 +125,7 @@ namespace Mist{
readPos = 0; readPos = 0;
} }
bool inputMP4::checkArguments(){ bool InputMP4::checkArguments(){
if (config->getString("input") == "-"){ if (config->getString("input") == "-"){
Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported"); Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported");
return false; return false;
@ -145,7 +145,7 @@ namespace Mist{
return true; return true;
} }
bool inputMP4::preRun(){ bool InputMP4::preRun(){
// open File // open File
inFile.open(config->getString("input")); inFile.open(config->getString("input"));
if (!inFile){ if (!inFile){
@ -159,17 +159,17 @@ namespace Mist{
return true; return true;
} }
void inputMP4::dataCallback(const char *ptr, size_t size){readBuffer.append(ptr, size);} void InputMP4::dataCallback(const char *ptr, size_t size){readBuffer.append(ptr, size);}
size_t inputMP4::getDataCallbackPos() const{return readPos + readBuffer.size();} size_t InputMP4::getDataCallbackPos() const{return readPos + readBuffer.size();}
bool inputMP4::needHeader(){ bool InputMP4::needHeader(){
//Attempt to read cache, but force calling of the readHeader function anyway //Attempt to read cache, but force calling of the readHeader function anyway
bool r = Input::needHeader(); bool r = Input::needHeader();
if (!r){r = !readHeader();} if (!r){r = !readHeader();}
return r; return r;
} }
bool inputMP4::readHeader(){ bool InputMP4::readHeader(){
if (!inFile){ if (!inFile){
Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str()); Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str());
return false; return false;
@ -493,7 +493,7 @@ namespace Mist{
return true; return true;
} }
void inputMP4::getNext(size_t idx){// get next part from track in stream void InputMP4::getNext(size_t idx){// get next part from track in stream
if (curPositions.empty()){ if (curPositions.empty()){
thisPacket.null(); thisPacket.null();
return; return;
@ -587,7 +587,7 @@ namespace Mist{
} }
} }
void inputMP4::seek(uint64_t seekTime, size_t idx){// seek to a point void InputMP4::seek(uint64_t seekTime, size_t idx){// seek to a point
nextKeyframe.clear(); nextKeyframe.clear();
curPositions.clear(); curPositions.clear();
if (idx != INVALID_TRACK_ID){ if (idx != INVALID_TRACK_ID){
@ -600,7 +600,7 @@ namespace Mist{
} }
} }
void inputMP4::handleSeek(uint64_t seekTime, size_t idx){ void InputMP4::handleSeek(uint64_t seekTime, size_t idx){
nextKeyframe[idx] = 0; nextKeyframe[idx] = 0;
mp4PartTime addPart; mp4PartTime addPart;
addPart.trackID = idx; addPart.trackID = idx;

View file

@ -70,9 +70,9 @@ namespace Mist{
bool stco64; bool stco64;
}; };
class inputMP4 : public Input, public Util::DataCallback { class InputMP4 : public Input, public Util::DataCallback {
public: public:
inputMP4(Util::Config *cfg); InputMP4(Util::Config *cfg);
virtual void dataCallback(const char *ptr, size_t size); virtual void dataCallback(const char *ptr, size_t size);
virtual size_t getDataCallbackPos() const; virtual size_t getDataCallbackPos() const;
@ -101,4 +101,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputMP4 mistIn; typedef Mist::InputMP4 mistIn;

View file

@ -33,7 +33,7 @@ namespace Mist{
return retval; return retval;
} }
inputOGG::inputOGG(Util::Config *cfg) : Input(cfg){ InputOGG::InputOGG(Util::Config *cfg) : Input(cfg){
capa["name"] = "OGG"; capa["name"] = "OGG";
capa["desc"] = "This input allows streaming of OGG files as Video on Demand."; capa["desc"] = "This input allows streaming of OGG files as Video on Demand.";
capa["source_match"] = "/*.ogg"; capa["source_match"] = "/*.ogg";
@ -43,7 +43,7 @@ namespace Mist{
capa["codecs"]["audio"].append("opus"); capa["codecs"]["audio"].append("opus");
} }
bool inputOGG::checkArguments(){ bool InputOGG::checkArguments(){
if (config->getString("input") == "-"){ if (config->getString("input") == "-"){
std::cerr << "Input from stream not yet supported" << std::endl; std::cerr << "Input from stream not yet supported" << std::endl;
return false; return false;
@ -51,7 +51,7 @@ namespace Mist{
return true; return true;
} }
bool inputOGG::preRun(){ bool InputOGG::preRun(){
// open File // open File
inFile = fopen(config->getString("input").c_str(), "r"); inFile = fopen(config->getString("input").c_str(), "r");
if (!inFile){ if (!inFile){
@ -62,7 +62,7 @@ namespace Mist{
} }
///\todo check if all trackID (tid) instances are replaced with bitstream serial numbers ///\todo check if all trackID (tid) instances are replaced with bitstream serial numbers
void inputOGG::parseBeginOfStream(OGG::Page &bosPage){ void InputOGG::parseBeginOfStream(OGG::Page &bosPage){
// long long int tid = snum2tid.size() + 1; // long long int tid = snum2tid.size() + 1;
size_t tid = bosPage.getBitstreamSerialNumber(); size_t tid = bosPage.getBitstreamSerialNumber();
size_t idx = M.trackIDToIndex(tid, getpid()); size_t idx = M.trackIDToIndex(tid, getpid());
@ -117,7 +117,7 @@ namespace Mist{
} }
} }
bool inputOGG::readHeader(){ bool InputOGG::readHeader(){
meta.reInit(config->getString("streamname"), true); meta.reInit(config->getString("streamname"), true);
OGG::Page myPage; OGG::Page myPage;
fseek(inFile, 0, SEEK_SET); fseek(inFile, 0, SEEK_SET);
@ -228,7 +228,7 @@ namespace Mist{
return true; return true;
} }
position inputOGG::seekFirstData(size_t idx){ position InputOGG::seekFirstData(size_t idx){
fseek(inFile, 0, SEEK_SET); fseek(inFile, 0, SEEK_SET);
position res; position res;
res.time = 0; res.time = 0;
@ -272,7 +272,7 @@ namespace Mist{
return res; return res;
} }
void inputOGG::getNext(size_t idx){ void InputOGG::getNext(size_t idx){
if (!currentPositions.size()){ if (!currentPositions.size()){
thisPacket.null(); thisPacket.null();
return; return;
@ -362,7 +362,7 @@ namespace Mist{
if (readFullPacket){currentPositions.insert(curPos);} if (readFullPacket){currentPositions.insert(curPos);}
}// getnext() }// getnext()
uint64_t inputOGG::calcGranuleTime(size_t tid, uint64_t granule){ uint64_t InputOGG::calcGranuleTime(size_t tid, uint64_t granule){
size_t idx = M.trackIDToIndex(tid, getpid()); size_t idx = M.trackIDToIndex(tid, getpid());
switch (oggTracks[idx].codec){ switch (oggTracks[idx].codec){
case OGG::VORBIS: case OGG::VORBIS:
@ -395,7 +395,7 @@ namespace Mist{
} }
#endif #endif
void inputOGG::seek(uint64_t seekTime, size_t idx){ void InputOGG::seek(uint64_t seekTime, size_t idx){
currentPositions.clear(); currentPositions.clear();
MEDIUM_MSG("Seeking to %" PRIu64 "ms", seekTime); MEDIUM_MSG("Seeking to %" PRIu64 "ms", seekTime);

View file

@ -35,9 +35,9 @@ namespace Mist{
uint64_t segmentNo; uint64_t segmentNo;
}; };
class inputOGG : public Input{ class InputOGG : public Input{
public: public:
inputOGG(Util::Config *cfg); InputOGG(Util::Config *cfg);
protected: protected:
// Private Functions // Private Functions
@ -58,4 +58,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputOGG mistIn; typedef Mist::InputOGG mistIn;

View file

@ -8,7 +8,7 @@
#include <sys/types.h> #include <sys/types.h>
namespace Mist{ namespace Mist{
inputPlaylist::inputPlaylist(Util::Config *cfg) : Input(cfg){ InputPlaylist::InputPlaylist(Util::Config *cfg) : Input(cfg){
capa["name"] = "Playlist"; capa["name"] = "Playlist";
capa["desc"] = "Enables Playlist Input"; capa["desc"] = "Enables Playlist Input";
capa["source_match"].append("/*.pls"); capa["source_match"].append("/*.pls");
@ -20,7 +20,7 @@ namespace Mist{
playlistIndex = 0xFFFFFFFEull; // Not FFFFFFFF on purpose! playlistIndex = 0xFFFFFFFEull; // Not FFFFFFFF on purpose!
} }
bool inputPlaylist::checkArguments(){ bool InputPlaylist::checkArguments(){
if (config->getString("input") == "-"){ if (config->getString("input") == "-"){
Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported"); Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported");
return false; return false;
@ -39,7 +39,7 @@ namespace Mist{
return true; return true;
} }
void inputPlaylist::streamMainLoop(){ void InputPlaylist::streamMainLoop(){
bool seenValidEntry = true; bool seenValidEntry = true;
Comms::Users killSwitch; Comms::Users killSwitch;
killSwitch.reload(streamName, (size_t)INVALID_TRACK_ID, (uint8_t)(COMM_STATUS_ACTIVE | COMM_STATUS_DONOTTRACK)); killSwitch.reload(streamName, (size_t)INVALID_TRACK_ID, (uint8_t)(COMM_STATUS_ACTIVE | COMM_STATUS_DONOTTRACK));
@ -134,7 +134,7 @@ namespace Mist{
} }
} }
void inputPlaylist::reloadPlaylist(){ void InputPlaylist::reloadPlaylist(){
minIndex = std::string::npos; minIndex = std::string::npos;
maxIndex = std::string::npos; maxIndex = std::string::npos;
std::string playlistFile; std::string playlistFile;

View file

@ -3,9 +3,9 @@
#include <mist/dtsc.h> #include <mist/dtsc.h>
namespace Mist{ namespace Mist{
class inputPlaylist : public Input{ class InputPlaylist : public Input{
public: public:
inputPlaylist(Util::Config *cfg); InputPlaylist(Util::Config *cfg);
bool needsLock(){return false;} bool needsLock(){return false;}
protected: protected:
@ -28,4 +28,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputPlaylist mistIn; typedef Mist::InputPlaylist mistIn;

View file

@ -1,8 +1,8 @@
#include "input_srt.h" #include "input_subrip.h"
namespace Mist{ namespace Mist{
InputSrt::InputSrt(Util::Config *cfg) : Input(cfg){ InputSubRip::InputSubRip(Util::Config *cfg) : Input(cfg){
vtt = false; vtt = false;
capa["name"] = "SubRip"; capa["name"] = "SubRip";
capa["decs"] = capa["decs"] =
@ -13,7 +13,7 @@ namespace Mist{
capa["codecs"]["subtitle"].append("subtitle"); capa["codecs"]["subtitle"].append("subtitle");
} }
bool InputSrt::preRun(){ bool InputSubRip::preRun(){
fileSource.close(); fileSource.close();
fileSource.open(config->getString("input").c_str()); fileSource.open(config->getString("input").c_str());
if (!fileSource.is_open()){ if (!fileSource.is_open()){
@ -23,7 +23,7 @@ namespace Mist{
return true; return true;
} }
bool InputSrt::checkArguments(){ bool InputSubRip::checkArguments(){
if (config->getString("input") == "-"){ if (config->getString("input") == "-"){
Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported"); Util::logExitReason(ER_FORMAT_SPECIFIC, "Input from stdin not yet supported");
return false; return false;
@ -45,7 +45,7 @@ namespace Mist{
return true; return true;
} }
bool InputSrt::readHeader(){ bool InputSubRip::readHeader(){
if (!fileSource.good()){ if (!fileSource.good()){
Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str()); Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str());
return false; return false;
@ -63,7 +63,7 @@ namespace Mist{
return true; return true;
} }
void InputSrt::getNext(size_t idx){ void InputSubRip::getNext(size_t idx){
thisPacket.null(); thisPacket.null();
std::string line; std::string line;
@ -131,6 +131,6 @@ namespace Mist{
thisPacket.null(); thisPacket.null();
} }
void InputSrt::seek(uint64_t seekTime, size_t idx){fileSource.seekg(0, fileSource.beg);} void InputSubRip::seek(uint64_t seekTime, size_t idx){fileSource.seekg(0, fileSource.beg);}
}// namespace Mist }// namespace Mist

View file

@ -6,9 +6,9 @@
namespace Mist{ namespace Mist{
class InputSrt : public Input{ class InputSubRip : public Input{
public: public:
InputSrt(Util::Config *cfg); InputSubRip(Util::Config *cfg);
protected: protected:
std::ifstream fileSource; std::ifstream fileSource;
@ -25,4 +25,4 @@ namespace Mist{
}// namespace Mist }// namespace Mist
typedef Mist::InputSrt mistIn; typedef Mist::InputSubRip mistIn;

View file

@ -35,7 +35,7 @@ int64_t timeStampOffset = 0;
void parseThread(void *mistIn){ void parseThread(void *mistIn){
uint64_t lastTimeStamp = 0; uint64_t lastTimeStamp = 0;
Mist::inputTS *input = reinterpret_cast<Mist::inputTS *>(mistIn); Mist::InputTS *input = reinterpret_cast<Mist::InputTS *>(mistIn);
size_t tid = 0; size_t tid = 0;
{ {
@ -160,7 +160,7 @@ namespace Mist{
/// Constructor of TS Input /// Constructor of TS Input
/// \arg cfg Util::Config that contains all current configurations. /// \arg cfg Util::Config that contains all current configurations.
inputTS::inputTS(Util::Config *cfg) : Input(cfg){ InputTS::InputTS(Util::Config *cfg) : Input(cfg){
rawMode = false; rawMode = false;
udpMode = false; udpMode = false;
rawIdx = INVALID_TRACK_ID; rawIdx = INVALID_TRACK_ID;
@ -279,7 +279,7 @@ namespace Mist{
config->addOption("raw", option); config->addOption("raw", option);
} }
inputTS::~inputTS(){ InputTS::~InputTS(){
if (!standAlone){ if (!standAlone){
tthread::lock_guard<tthread::mutex> guard(threadClaimMutex); tthread::lock_guard<tthread::mutex> guard(threadClaimMutex);
threadTimer.clear(); threadTimer.clear();
@ -289,7 +289,7 @@ namespace Mist{
bool skipPipes = false; bool skipPipes = false;
bool inputTS::checkArguments(){ bool InputTS::checkArguments(){
if (config->getString("input").substr(0, 6) == "srt://"){ if (config->getString("input").substr(0, 6) == "srt://"){
std::string source = config->getString("input"); std::string source = config->getString("input");
HTTP::URL srtUrl(source); HTTP::URL srtUrl(source);
@ -313,7 +313,7 @@ namespace Mist{
} }
/// Live Setup of TS Input /// Live Setup of TS Input
bool inputTS::preRun(){ bool InputTS::preRun(){
std::string const inCfg = config->getString("input"); std::string const inCfg = config->getString("input");
udpMode = false; udpMode = false;
rawMode = config->getBool("raw"); rawMode = config->getBool("raw");
@ -396,7 +396,7 @@ namespace Mist{
return true; return true;
} }
void inputTS::dataCallback(const char *ptr, size_t size){ void InputTS::dataCallback(const char *ptr, size_t size){
if (standAlone){ if (standAlone){
unitStartSeen |= assembler.assemble(tsStream, ptr, size, true, readPos); unitStartSeen |= assembler.assemble(tsStream, ptr, size, true, readPos);
}else{ }else{
@ -404,11 +404,11 @@ namespace Mist{
} }
readPos += size; readPos += size;
} }
size_t inputTS::getDataCallbackPos() const{ size_t InputTS::getDataCallbackPos() const{
return readPos; return readPos;
} }
bool inputTS::needHeader(){ bool InputTS::needHeader(){
if (!standAlone){return false;} if (!standAlone){return false;}
return Input::needHeader(); return Input::needHeader();
} }
@ -418,7 +418,7 @@ namespace Mist{
/// It encounters a new PES start, it writes the currently found PES data /// It encounters a new PES start, it writes the currently found PES data
/// for a specific track to metadata. After the entire stream has been read, /// for a specific track to metadata. After the entire stream has been read,
/// it writes the remaining metadata. /// it writes the remaining metadata.
bool inputTS::readHeader(){ bool InputTS::readHeader(){
if (!reader){ if (!reader){
Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str()); Util::logExitReason(ER_READ_START_FAILURE, "Reading header for '%s' failed: Could not open input stream", config->getString("input").c_str());
return false; return false;
@ -476,7 +476,7 @@ namespace Mist{
/// At the moment, the logic of sending the last packet that was finished has been implemented, /// At the moment, the logic of sending the last packet that was finished has been implemented,
/// but the seeking and finding data is not yet ready. /// but the seeking and finding data is not yet ready.
///\todo Finish the implementation ///\todo Finish the implementation
void inputTS::getNext(size_t idx){ void InputTS::getNext(size_t idx){
size_t pid = (idx == INVALID_TRACK_ID ? 0 : M.getID(idx)); size_t pid = (idx == INVALID_TRACK_ID ? 0 : M.getID(idx));
INSANE_MSG("Getting next on track %zu", idx); INSANE_MSG("Getting next on track %zu", idx);
thisPacket.null(); thisPacket.null();
@ -516,7 +516,7 @@ namespace Mist{
} }
/// Guarantees the PMT is read and we know about all tracks. /// Guarantees the PMT is read and we know about all tracks.
void inputTS::postHeader(){ void InputTS::postHeader(){
if (!standAlone){return;} if (!standAlone){return;}
tsStream.clear(); tsStream.clear();
assembler.clear(); assembler.clear();
@ -531,7 +531,7 @@ namespace Mist{
} }
/// Seeks to a specific time /// Seeks to a specific time
void inputTS::seek(uint64_t seekTime, size_t idx){ void InputTS::seek(uint64_t seekTime, size_t idx){
uint64_t seekPos = 0xFFFFFFFFull; uint64_t seekPos = 0xFFFFFFFFull;
if (idx != INVALID_TRACK_ID){ if (idx != INVALID_TRACK_ID){
uint32_t keyNum = M.getKeyNumForTime(idx, seekTime); uint32_t keyNum = M.getKeyNumForTime(idx, seekTime);
@ -553,7 +553,7 @@ namespace Mist{
readPos = reader.getPos(); readPos = reader.getPos();
} }
bool inputTS::openStreamSource(){ bool InputTS::openStreamSource(){
//Non-UDP mode inputs were already opened in preRun() //Non-UDP mode inputs were already opened in preRun()
if (!udpMode){return reader;} if (!udpMode){return reader;}
HTTP::URL input_url(config->getString("input")); HTTP::URL input_url(config->getString("input"));
@ -564,7 +564,7 @@ namespace Mist{
return (udpCon.getSock() != -1); return (udpCon.getSock() != -1);
} }
void inputTS::streamMainLoop(){ void InputTS::streamMainLoop(){
Comms::Connections statComm; Comms::Connections statComm;
uint64_t startTime = Util::bootSecs(); uint64_t startTime = Util::bootSecs();
uint64_t noDataSince = Util::bootSecs(); uint64_t noDataSince = Util::bootSecs();
@ -730,7 +730,7 @@ namespace Mist{
} }
} }
void inputTS::finish(){ void InputTS::finish(){
if (standAlone){ if (standAlone){
Input::finish(); Input::finish();
return; return;

View file

@ -9,10 +9,10 @@
namespace Mist{ namespace Mist{
/// This class contains all functions needed to implement TS Input /// This class contains all functions needed to implement TS Input
class inputTS : public Input, public Util::DataCallback{ class InputTS : public Input, public Util::DataCallback{
public: public:
inputTS(Util::Config *cfg); InputTS(Util::Config *cfg);
~inputTS(); ~InputTS();
// This function can simply check standAlone because we ensure it's set in checkArguments, // This function can simply check standAlone because we ensure it's set in checkArguments,
// which is always called before the first call to needsLock // which is always called before the first call to needsLock
@ -56,4 +56,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputTS mistIn; typedef Mist::InputTS mistIn;

View file

@ -21,7 +21,7 @@
#include <mist/tinythread.h> #include <mist/tinythread.h>
#include <sys/stat.h> #include <sys/stat.h>
Mist::inputTSRIST *connPtr = 0; Mist::InputTSRIST *connPtr = 0;
Util::Config *cnfPtr = 0; Util::Config *cnfPtr = 0;
@ -65,7 +65,7 @@ static int cb_recv(void *arg, struct rist_data_block *b){
namespace Mist{ namespace Mist{
/// Constructor of TS Input /// Constructor of TS Input
/// \arg cfg Util::Config that contains all current configurations. /// \arg cfg Util::Config that contains all current configurations.
inputTSRIST::inputTSRIST(Util::Config *cfg) : Input(cfg){ InputTSRIST::InputTSRIST(Util::Config *cfg) : Input(cfg){
rawMode = false; rawMode = false;
rawIdx = INVALID_TRACK_ID; rawIdx = INVALID_TRACK_ID;
lastRawPacket = 0; lastRawPacket = 0;
@ -170,12 +170,12 @@ namespace Mist{
receiver_ctx = 0; receiver_ctx = 0;
} }
inputTSRIST::~inputTSRIST(){ InputTSRIST::~InputTSRIST(){
cnfPtr = 0; cnfPtr = 0;
rist_destroy(receiver_ctx); rist_destroy(receiver_ctx);
} }
bool inputTSRIST::checkArguments(){ bool InputTSRIST::checkArguments(){
if (config->getString("datatrack") == "json"){ if (config->getString("datatrack") == "json"){
tsStream.setRawDataParser(TS::JSON); tsStream.setRawDataParser(TS::JSON);
} }
@ -183,7 +183,7 @@ namespace Mist{
} }
/// Live Setup of SRT Input. Runs only if we are the "main" thread /// Live Setup of SRT Input. Runs only if we are the "main" thread
bool inputTSRIST::preRun(){ bool InputTSRIST::preRun(){
rawMode = config->getBool("raw"); rawMode = config->getBool("raw");
if (rawMode){INFO_MSG("Entering raw mode");} if (rawMode){INFO_MSG("Entering raw mode");}
@ -200,7 +200,7 @@ namespace Mist{
} }
// Retrieve the next packet to be played from the srt connection. // Retrieve the next packet to be played from the srt connection.
void inputTSRIST::getNext(size_t idx){ void InputTSRIST::getNext(size_t idx){
thisPacket.null(); thisPacket.null();
if (rawMode){ if (rawMode){
//Set to false so the other thread knows its safe to fill //Set to false so the other thread knows its safe to fill
@ -246,12 +246,12 @@ namespace Mist{
thisPacket.setTime(adjustTime); thisPacket.setTime(adjustTime);
} }
void inputTSRIST::onFail(const std::string & msg){ void InputTSRIST::onFail(const std::string & msg){
FAIL_MSG("%s", msg.c_str()); FAIL_MSG("%s", msg.c_str());
Util::logExitReason(ER_FORMAT_SPECIFIC, msg.c_str()); Util::logExitReason(ER_FORMAT_SPECIFIC, msg.c_str());
} }
bool inputTSRIST::openStreamSource(){ bool InputTSRIST::openStreamSource(){
if (rist_receiver_create(&receiver_ctx, (rist_profile)config->getInteger("profile"), &log_settings) != 0){ if (rist_receiver_create(&receiver_ctx, (rist_profile)config->getInteger("profile"), &log_settings) != 0){
onFail("Failed to create RIST receiver context"); onFail("Failed to create RIST receiver context");
return false; return false;
@ -282,7 +282,7 @@ namespace Mist{
return true; return true;
} }
void inputTSRIST::addData(const char * ptr, size_t len){ void InputTSRIST::addData(const char * ptr, size_t len){
for (size_t o = 0; o+188 <= len; o += 188){ for (size_t o = 0; o+188 <= len; o += 188){
if (rawMode){ if (rawMode){
rawBuffer.append(ptr+o, 188); rawBuffer.append(ptr+o, 188);
@ -308,7 +308,7 @@ namespace Mist{
} }
void inputTSRIST::connStats(Comms::Connections &statComm){ void InputTSRIST::connStats(Comms::Connections &statComm){
statComm.setUp(0); statComm.setUp(0);
statComm.setDown(downBytes); statComm.setDown(downBytes);
statComm.setHost(getConnectedBinHost()); statComm.setHost(getConnectedBinHost());

View file

@ -5,10 +5,10 @@
namespace Mist{ namespace Mist{
class inputTSRIST : public Input{ class InputTSRIST : public Input{
public: public:
inputTSRIST(Util::Config *cfg); InputTSRIST(Util::Config *cfg);
~inputTSRIST(); ~InputTSRIST();
virtual bool needsLock(){return false;} virtual bool needsLock(){return false;}
virtual bool publishesTracks(){return false;} virtual bool publishesTracks(){return false;}
virtual std::string getConnectedBinHost(){ virtual std::string getConnectedBinHost(){
@ -42,4 +42,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputTSRIST mistIn; typedef Mist::InputTSRIST mistIn;

View file

@ -40,7 +40,7 @@ void signal_handler(int signum, siginfo_t *sigInfo, void *ignore){
// We use threads here for multiple input pushes, because of the internals of the SRT Library // We use threads here for multiple input pushes, because of the internals of the SRT Library
static void callThreadCallbackSRT(void *socknum){ static void callThreadCallbackSRT(void *socknum){
// use the accepted socket as the second parameter // use the accepted socket as the second parameter
Mist::inputTSSRT inp(cfgPointer, *(Socket::SRTConnection *)socknum); Mist::InputTSSRT inp(cfgPointer, *(Socket::SRTConnection *)socknum);
inp.setSingular(false); inp.setSingular(false);
inp.run(); inp.run();
} }
@ -48,7 +48,7 @@ static void callThreadCallbackSRT(void *socknum){
namespace Mist{ namespace Mist{
/// Constructor of TS Input /// Constructor of TS Input
/// \arg cfg Util::Config that contains all current configurations. /// \arg cfg Util::Config that contains all current configurations.
inputTSSRT::inputTSSRT(Util::Config *cfg, Socket::SRTConnection s) : Input(cfg){ InputTSSRT::InputTSSRT(Util::Config *cfg, Socket::SRTConnection s) : Input(cfg){
rawIdx = INVALID_TRACK_ID; rawIdx = INVALID_TRACK_ID;
lastRawPacket = 0; lastRawPacket = 0;
bootMSOffsetCalculated = false; bootMSOffsetCalculated = false;
@ -158,9 +158,9 @@ namespace Mist{
singularFlag = true; singularFlag = true;
} }
inputTSSRT::~inputTSSRT(){} InputTSSRT::~InputTSSRT(){}
bool inputTSSRT::checkArguments(){ bool InputTSSRT::checkArguments(){
if (config->getString("datatrack") == "json"){ if (config->getString("datatrack") == "json"){
tsStream.setRawDataParser(TS::JSON); tsStream.setRawDataParser(TS::JSON);
} }
@ -168,7 +168,7 @@ namespace Mist{
} }
/// Live Setup of SRT Input. Runs only if we are the "main" thread /// Live Setup of SRT Input. Runs only if we are the "main" thread
bool inputTSSRT::preRun(){ bool InputTSSRT::preRun(){
rawMode = config->getBool("raw"); rawMode = config->getBool("raw");
if (rawMode){INFO_MSG("Entering raw mode");} if (rawMode){INFO_MSG("Entering raw mode");}
if (srtConn.getSocket() == -1){ if (srtConn.getSocket() == -1){
@ -216,7 +216,7 @@ namespace Mist{
} }
// Retrieve the next packet to be played from the srt connection. // Retrieve the next packet to be played from the srt connection.
void inputTSSRT::getNext(size_t idx){ void InputTSSRT::getNext(size_t idx){
thisPacket.null(); thisPacket.null();
bool hasPacket = tsStream.hasPacket(); bool hasPacket = tsStream.hasPacket();
while (!hasPacket && srtConn && config->is_active){ while (!hasPacket && srtConn && config->is_active){
@ -284,9 +284,9 @@ namespace Mist{
thisTime = pktTimeWithOffset; thisTime = pktTimeWithOffset;
} }
bool inputTSSRT::openStreamSource(){return true;} bool InputTSSRT::openStreamSource(){return true;}
void inputTSSRT::streamMainLoop(){ void InputTSSRT::streamMainLoop(){
// If we do not have a srtConn here, we are the main thread and should start accepting pushes. // If we do not have a srtConn here, we are the main thread and should start accepting pushes.
if (srtConn.getSocket() == -1){ if (srtConn.getSocket() == -1){
cfgPointer = config; cfgPointer = config;
@ -308,11 +308,11 @@ namespace Mist{
srtConn.close(); srtConn.close();
} }
bool inputTSSRT::needsLock(){return false;} bool InputTSSRT::needsLock(){return false;}
void inputTSSRT::setSingular(bool newSingular){singularFlag = newSingular;} void InputTSSRT::setSingular(bool newSingular){singularFlag = newSingular;}
void inputTSSRT::connStats(Comms::Connections &statComm){ void InputTSSRT::connStats(Comms::Connections &statComm){
statComm.setUp(srtConn.dataUp()); statComm.setUp(srtConn.dataUp());
statComm.setDown(srtConn.dataDown()); statComm.setDown(srtConn.dataDown());
statComm.setPacketCount(srtConn.packetCount()); statComm.setPacketCount(srtConn.packetCount());

View file

@ -9,10 +9,10 @@
namespace Mist{ namespace Mist{
class inputTSSRT : public Input{ class InputTSSRT : public Input{
public: public:
inputTSSRT(Util::Config *cfg, Socket::SRTConnection s = Socket::SRTConnection()); InputTSSRT(Util::Config *cfg, Socket::SRTConnection s = Socket::SRTConnection());
~inputTSSRT(); ~InputTSSRT();
void setSingular(bool newSingular); void setSingular(bool newSingular);
virtual bool needsLock(); virtual bool needsLock();
virtual std::string getConnectedBinHost(){ virtual std::string getConnectedBinHost(){
@ -49,4 +49,4 @@ namespace Mist{
}; };
}// namespace Mist }// namespace Mist
typedef Mist::inputTSSRT mistIn; typedef Mist::InputTSSRT mistIn;

View file

@ -14,7 +14,7 @@ inputs = [
{'name' : 'Playlist', 'format' : 'playlist'}, {'name' : 'Playlist', 'format' : 'playlist'},
{'name' : 'Balancer', 'format' : 'balancer'}, {'name' : 'Balancer', 'format' : 'balancer'},
{'name' : 'RTSP', 'format' : 'rtsp'}, {'name' : 'RTSP', 'format' : 'rtsp'},
{'name' : 'SubRip', 'format' : 'srt'}, {'name' : 'SubRip', 'format' : 'subrip'},
{'name' : 'SDP', 'format' : 'sdp'}, {'name' : 'SDP', 'format' : 'sdp'},
{'name' : 'AAC', 'format' : 'aac'}, {'name' : 'AAC', 'format' : 'aac'},
{'name' : 'FLAC', 'format' : 'flac'}, {'name' : 'FLAC', 'format' : 'flac'},