MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
Data Structures | Enumerations | Functions | Variables
Mist Namespace Reference

Recording to file. More...

Data Structures

struct  booking
 
struct  DTSCPageData
 
struct  fragSet
 
class  HTTPOutput
 
class  InOutBase
 Class containing all basic input and output functions. More...
 
class  Input
 
class  inputAV
 
class  inputBuffer
 
class  inputDTSC
 
class  inputFLV
 
class  inputFolder
 
class  inputISMV
 
class  inputMP3
 
class  inputMP4
 
class  inputOGG
 
class  inputTS
 This class contains all functions needed to implement TS Input. More...
 
struct  keyPart
 
struct  mp4PartBpos
 
class  mp4PartTime
 
class  mp4TrackHeader
 
class  negotiationProxy
 
class  OutDashMP4
 
class  OutHDS
 
class  OutHLS
 
class  OutHSS
 
class  OutHTTP
 
class  OutHTTPMinimalServer
 
class  OutHTTPTS
 
class  OutJSON
 
class  OutProgressiveFLV
 
class  OutProgressiveMP3
 
class  OutProgressiveMP4
 
class  OutProgressiveOGG
 
class  OutProgressiveSRT
 
class  OutPush
 
class  Output
 The output class is intended to be inherited by MistOut process classes. More...
 
class  OutRaw
 
class  OutRTMP
 
class  OutRTSP
 
class  OutTS
 
class  OutTSPush
 
struct  position
 
struct  seekPos
 
class  segment
 
struct  segPart
 
struct  sortedPageInfo
 This struct keeps packet information sorted in playback order, so the Mist::Output class knows when to buffer which packet. More...
 
struct  sourceCompare
 Sorts the JSON::Value objects that hold source information by preference. More...
 
class  trackmeta
 Structure used to keep track of selected tracks. More...
 
class  TSOutput
 

Enumerations

enum  negotiationState { FILL_NEW, FILL_NEG, FILL_DEC, FILL_ACC }
 

Functions

void addSource (const std::string &rel, std::set< JSON::Value, sourceCompare > &sources, std::string &host, const std::string &port, JSON::Value &conncapa, unsigned int most_simul, unsigned int total_matches, const std::string &flvPlayerPrefix)
 
void addSources (std::string &streamname, const std::string &rel, std::set< JSON::Value, sourceCompare > &sources, std::string &host, const std::string &port, JSON::Value &conncapa, JSON::Value &strmMeta, const std::string httpHost)
 
static void builPipedPart (JSON::Value &p, char *argarr[], int &argnum, JSON::Value &argset)
 
int getDTSCLen (char *mapped, long long int offset)
 
unsigned long long getDTSCTime (char *mapped, long long int offset)
 
bool isMatch (const std::string &url, const std::string &m, std::string &streamname)
 
bool isPrefix (const std::string &url, const std::string &m, std::string &streamname)
 
void * memrchr (const void *s, int c, size_t n)
 
void sendTCP (void *socket, char *data, unsigned int len, unsigned int channel)
 Function used to send RTP packets over TCP. More...
 
void sendUDP (void *socket, char *data, unsigned int len, unsigned int channel)
 Function used to send RTP packets over UDP. More...
 

Variables

static const int bitRates [2][3][16]
 
static const int sampleCounts [2][3] = {{374, 1152, 1152}, {384, 1152, 576}}
 
static const double sampleRates [2][3] = {{44.1, 48.0, 32.0}, {22.05, 24.0, 16.0}}
 

Detailed Description

Recording to file.

Todo:
Whar be Opus support?
Todo:
Implement this trigger equivalent...

Currently MistServer has basic support for recording for which the functionality is spread over a couple of files. The general flow in mist (this is my understanding and I'm a newb to MistServer, roxlu), is like this:

The controller creates a couple of protocol handlers, e.g. for RTMP. When a new live connection is made, an output is created through this protocol handler. In the case of a live source, all received data is passed into a inputBuffer object (see input_buffer.cpp).

So, when the inputBuffer is created, the setup() function is called. In this function the config object is available that holds the configuration values for the specific stream. This is also where a recording gets initialized.

An recording is initialized by starting another output with a call to startRecording(). startRecording() forks the current process and then calls execvp() to take over the child process with e.g. MistOutFLV(). When execvp() starts the other process (that records the data), it passes the --outputFilename command line argument.

Each output checks if it's started with the --outputFilename flag; this is done in the constructor of Output. In Output, it opens the given filename and uses dup2() which makes sure that all stdout data is written into the recording file.

Though, because some or probably most outputs also write HTTP to stdout, I created the function HTTPOutput::sendResponse() which checks if the current output is creating a recording. When creating a recording it simply skips the HTTP output.

 +-------------------------+
 |  inputBuffer::setup()   |
 +-------+-----------------+  
         |
         o---- calls Util::startRecording() (stream.cpp)
         |
         v 
 +------------------------+
 | stream::startRecording | -> Kicks off output app with --outputFilename
 +-------+----------------+                
         |
         v
 +----------------+
 | MistOut[XXX]   | -> Checks if started with --outputFilename, 
 +----------------+    in Output::Output() and starts recording. 

The following files contain updates that were made for the recording:

Enumeration Type Documentation

Enumerator
FILL_NEW 

New track, just sent negotiation request.

FILL_NEG 

Negotiating this track, written metadata.

FILL_DEC 

Declined Track.

FILL_ACC 

Accepted Track.

Function Documentation

void Mist::addSource ( const std::string &  rel,
std::set< JSON::Value, sourceCompare > &  sources,
std::string &  host,
const std::string &  port,
JSON::Value conncapa,
unsigned int  most_simul,
unsigned int  total_matches,
const std::string &  flvPlayerPrefix 
)
void Mist::addSources ( std::string &  streamname,
const std::string &  rel,
std::set< JSON::Value, sourceCompare > &  sources,
std::string &  host,
const std::string &  port,
JSON::Value conncapa,
JSON::Value strmMeta,
const std::string  httpHost 
)
static void Mist::builPipedPart ( JSON::Value p,
char *  argarr[],
int &  argnum,
JSON::Value argset 
)
inlinestatic
int Mist::getDTSCLen ( char *  mapped,
long long int  offset 
)
unsigned long long Mist::getDTSCTime ( char *  mapped,
long long int  offset 
)
bool Mist::isMatch ( const std::string &  url,
const std::string &  m,
std::string &  streamname 
)
bool Mist::isPrefix ( const std::string &  url,
const std::string &  m,
std::string &  streamname 
)
void* Mist::memrchr ( const void *  s,
int  c,
size_t  n 
)
void Mist::sendTCP ( void *  socket,
char *  data,
unsigned int  len,
unsigned int  channel 
)

Function used to send RTP packets over TCP.

Parameters
socketA TCP Connection pointer, sent as a void*, to keep portability.
dataThe RTP Packet that needs to be sent
lenThe size of data
channelUsed to distinguish different data streams when sending RTP over TCP
void Mist::sendUDP ( void *  socket,
char *  data,
unsigned int  len,
unsigned int  channel 
)

Function used to send RTP packets over UDP.

Parameters
socketA UDP Connection pointer, sent as a void*, to keep portability.
dataThe RTP Packet that needs to be sent
lenThe size of data
channelNot used here, but is kept for compatibility with sendTCP

Variable Documentation

const int Mist::bitRates[2][3][16]
static
Initial value:
= {{{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, -1},
{0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, -1},
{0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -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}}}
const int Mist::sampleCounts[2][3] = {{374, 1152, 1152}, {384, 1152, 576}}
static
const double Mist::sampleRates[2][3] = {{44.1, 48.0, 32.0}, {22.05, 24.0, 16.0}}
static