diff --git a/src/output/output_ebml.cpp b/src/output/output_ebml.cpp index 36b62c8c..4dd845a4 100644 --- a/src/output/output_ebml.cpp +++ b/src/output/output_ebml.cpp @@ -12,6 +12,34 @@ namespace Mist{ cuesSize = 0; seekheadSize = 0; doctype = "matroska"; + if (config->getString("target").size()){ + if (config->getString("target").find(".webm") != std::string::npos){doctype = "webm";} + initialize(); + if (!streamName.size()){ + WARN_MSG("Recording unconnected EBML output to file! Cancelled."); + conn.close(); + return; + } + if (config->getString("target") == "-"){ + parseData = true; + wantRequest = false; + INFO_MSG("Outputting %s to stdout in EBML format", streamName.c_str()); + return; + } + if (!myMeta.tracks.size()){ + INFO_MSG("Stream not available - aborting"); + conn.close(); + return; + } + if (connectToFile(config->getString("target"))){ + parseData = true; + wantRequest = false; + INFO_MSG("Recording %s to %s in EBML format", streamName.c_str(), + config->getString("target").c_str()); + return; + } + conn.close(); + } } void OutEBML::init(Util::Config *cfg){ @@ -40,8 +68,19 @@ namespace Mist{ capa["methods"][0u]["handler"] = "http"; capa["methods"][0u]["type"] = "html5/video/webm"; capa["methods"][0u]["priority"] = 8ll; + capa["push_urls"].append("/*.mkv"); + capa["push_urls"].append("/*.webm"); + + JSON::Value opt; + opt["arg"] = "string"; + opt["default"] = ""; + opt["arg_num"] = 1ll; + opt["help"] = "Target filename to store EBML file as, or - for stdout."; + cfg->addOption("target", opt); } + bool OutEBML::isRecording(){return config->getString("target").size();} + /// Calculates the size of a Cluster (contents only) and returns it. /// Bases the calculation on the currently selected tracks and the given start/end time for the cluster. uint32_t OutEBML::clusterSize(uint64_t start, uint64_t end){ diff --git a/src/output/output_ebml.h b/src/output/output_ebml.h index 5e977be2..badd294e 100644 --- a/src/output/output_ebml.h +++ b/src/output/output_ebml.h @@ -11,6 +11,7 @@ namespace Mist{ uint32_t clusterSize(uint64_t start, uint64_t end); private: + bool isRecording(); std::string doctype; void sendElemTrackEntry(const DTSC::Track & Trk); uint32_t sizeElemTrackEntry(const DTSC::Track & Trk);