#pragma once #include #include #include #include #include #include #include #include #include #include /*LTS-START*/ #ifdef GEOIP #include #endif /*LTS-END*/ #include "../io.h" namespace Mist { /// This struct keeps packet information sorted in playback order, so the /// Mist::Output class knows when to buffer which packet. struct sortedPageInfo { bool operator < (const sortedPageInfo & rhs) const { if (time < rhs.time) { return true; } return (time == rhs.time && tid < rhs.tid); } unsigned int tid; long long unsigned int time; unsigned int offset; }; /// The output class is intended to be inherited by MistOut process classes. /// It contains all generic code and logic, while the child classes implement /// anything specific to particular protocols or containers. /// It contains several virtual functions, that may be overridden to "hook" into /// the streaming process at those particular points, simplifying child class /// logic and implementation details. class Output : public InOutBase { public: //constructor and destructor Output(Socket::Connection & conn); virtual ~Output(); //static members for initialization and capabilities static void init(Util::Config * cfg); static JSON::Value capa; /*LTS-START*/ #ifdef GEOIP static GeoIP * geoIP4; static GeoIP * geoIP6; #endif std::string reqUrl; /*LTS-END*/ //non-virtual generic functions int run(); void stats(); void seek(unsigned long long pos); bool seek(unsigned int tid, unsigned long long pos, bool getNextKey = false); void stop(); void setBlocking(bool blocking); long unsigned int getMainSelectedTrack(); void updateMeta(); void selectDefaultTracks(); /*begin-roxlu*/ bool openOutputFileForRecording(); // Opens the output file and uses dup2() to make sure that all stdout is written into a file. bool closeOutputFileForRecording(); // Closes the output file into which we're writing and resets the file descriptor. /*end-roxlu*/ static bool listenMode(){return true;} //virtuals. The optional virtuals have default implementations that do as little as possible. virtual void sendNext() {}//REQUIRED! Others are optional. virtual void prepareNext(); virtual void onRequest(); virtual bool onFinish() { return false; } void reconnect(); virtual void initialize(); virtual void sendHeader(); virtual void onFail(); virtual void requestHandler(); virtual void onRecord(){ wantRequest = false; parseData = true; realTime = 1000; seek(0); } private://these *should* not be messed with in child classes. /*LTS-START*/ void Log(std::string type, std::string message); bool checkLimits(); bool isBlacklisted(std::string host, std::string streamName, int timeConnected); std::string hostLookup(std::string ip); bool onList(std::string ip, std::string list); std::string getCountry(std::string ip); /*LTS-END*/ std::map currKeyOpen; void loadPageForKey(long unsigned int trackId, long long int keyNum); int pageNumForKey(long unsigned int trackId, long long int keyNum); unsigned int lastStats;///