MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes
Mist::OutProgressiveMP4 Class Reference

#include <output_progressive_mp4.h>

Inheritance diagram for Mist::OutProgressiveMP4:
Mist::HTTPOutput Mist::Output Mist::InOutBase

Public Member Functions

 OutProgressiveMP4 (Socket::Connection &conn)
 
 ~OutProgressiveMP4 ()
 
void bufferFinalize (unsigned long tid)
 Wraps up the buffering of a shared memory data page. More...
 
void bufferLivePacket (JSON::Value &packet)
 Buffers a live packet to a page. More...
 
void bufferLivePacket (DTSC::Packet &packet)
 Buffers a live packet to a page. More...
 
void bufferNext (DTSC::Packet &pack)
 Buffers the next packet on the currently opened page. More...
 
void bufferNext (JSON::Value &pack)
 Buffers the next packet on the currently opened page. More...
 
void bufferRemove (unsigned long tid, unsigned long pageNumber)
 Removes a fully buffered page. More...
 
bool bufferStart (unsigned long tid, unsigned long pageNumber)
 
void buildFragment (int fragNum)
 Builds up a datastructure that allows for access in the fragment send header function using the fragment number FOR THIS USER, NOT ACTUAL FRAGMENT NUMBER, HAS NOTHING TO DO WITH ACTUAL FRAGMENTS EVEN We take the corresponding keyframe and interframes of the main video track and take concurrent frames from its secondary (audio) tracks. More...
 
bool closeOutputFileForRecording ()
 
std::string DTSCMeta2MP4Header (long long &size, int fragmented=0)
 
void findSeekPoint (long long byteStart, long long &seekPoint, unsigned int headerSize)
 Calculate a seekPoint, based on byteStart, metadata, tracks and headerSize. More...
 
std::string getHandler ()
 
long unsigned int getMainSelectedTrack ()
 Returns the ID of the main selected track, or 0 if no tracks are selected. More...
 
virtual void initialize ()
 
void initiateMeta ()
 Opens a shared memory page for the stream metadata. More...
 
virtual void onFail ()
 Called when stream initialization has failed. More...
 
virtual bool onFinish ()
 
void onHTTP ()
 
virtual void onRecord ()
 
void onRequest ()
 
bool openOutputFileForRecording ()
 
void parseRange (std::string header, long long &byteStart, long long &byteEnd, long long &seekPoint, unsigned int headerSize)
 Parses a "Range: " header, setting byteStart, byteEnd and seekPoint using data from metadata and tracks to do the calculations. More...
 
virtual void prepareNext ()
 
void reconnect ()
 Connects or reconnects to the stream. More...
 
void reConnector (std::string &connector)
 Handles requests by starting a corresponding output process. More...
 
virtual void requestHandler ()
 
int run ()
 
void seek (unsigned long long pos)
 Prepares all tracks from selectedTracks for seeking to the specified ms position. More...
 
bool seek (unsigned int tid, unsigned long long pos, bool getNextKey=false)
 
void selectDefaultTracks ()
 
void sendFragmentHeader (int fragNum)
 
void sendHeader ()
 
void sendNext ()
 
void sendResponse (std::string message, std::string code="200")
 
void setBlocking (bool blocking)
 
void stats ()
 
void stop ()
 Clears the buffer, sets parseData to false, and generally makes not very much happen at all. More...
 
void updateMeta ()
 

Static Public Member Functions

static void init (Util::Config *cfg)
 
static bool listenMode ()
 

Data Fields

std::string reqUrl
 

Static Public Attributes

static JSON::Value capa = JSON::Value()
 

Protected Member Functions

void buildTrafPart ()
 
void continueNegotiate (unsigned long tid)
 
long long unsigned estimateFileSize ()
 
std::string getConnectedBinHost ()
 
std::string getConnectedHost ()
 
unsigned int getKeyForTime (long unsigned int trackId, long long timeStamp)
 
bool isTrustedProxy (const std::string &ip)
 
bool recording ()
 
void setvidTrack ()
 

Protected Attributes

std::map< int, DTSCPageDatabookKeeping
 
long long byteEnd
 
long long byteStart
 
bool completeKeysOnly
 Bool if we send whole keys only, so the metadata is complete and the output knows in advance what will be sent. More...
 
unsigned int crc
 Checksum, if any, for usage in the stats. More...
 
std::map< long unsigned int, fragSetcurrentPartSet
 
long long currPos
 
long long fileSize
 
long int fragKeyNumberShift
 
int fragSeqNum
 
HTTP::Parser H
 
bool isBlocking
 If true, indicates that myConn is blocking. More...
 
bool isInitialized
 If false, triggers initialization if parseData is true. More...
 
long long leftOver
 
unsigned int maxSkipAhead
 Maximum ms that we will go ahead of the intended timestamps. More...
 
unsigned int minSkipAhead
 Minimum ms that we will go ahead of the intended timestamps. More...
 
Socket::ConnectionmyConn
 Connection to the client. More...
 
DTSC::Meta myMeta
 Stores either the input or output metadata. More...
 
negotiationProxy nProxy
 
int outputFileDescriptor
 
bool parseData
 If true, triggers initalization if not already done, sending of header, sending of packets. More...
 
long unsigned int partListLength
 
long unsigned int partListSent
 
long long unsigned int realBaseOffset
 
unsigned int realTime
 Playback speed in ms of data per second. eg: 0 is infinite, 1000 real-time, 5000 is 0.2X speed, 500 = 2X speed. More...
 
long long seekPoint
 
std::set< unsigned long > selectedTracks
 Stores the track id's that are either selected for playback or input. More...
 
bool sending3GP
 
bool sentHeader
 If false, triggers sendHeader if parseData is true. More...
 
std::set< keyPartsortSet
 
bool standAlone
 
IPC::sharedClient statsPage
 Shared memory used for statistics reporting. More...
 
std::string streamName
 
DTSC::Packet thisPacket
 
long unsigned int vidTrack
 
bool wantRequest
 If true, waits for a request. More...
 

Static Protected Attributes

static Util::Configconfig = NULL
 

Constructor & Destructor Documentation

Mist::OutProgressiveMP4::OutProgressiveMP4 ( Socket::Connection conn)
Mist::OutProgressiveMP4::~OutProgressiveMP4 ( )

Member Function Documentation

void Mist::InOutBase::bufferFinalize ( unsigned long  tid)
inherited

Wraps up the buffering of a shared memory data page.

Registers the data page on the track index page as well

Parameters
tidThe trackid of the page to finalize
void Mist::InOutBase::bufferLivePacket ( JSON::Value packet)
inherited

Buffers a live packet to a page.

Handles both buffering and creation of new pages

Initiates/continues negotiation with the buffer as well

Parameters
packetThe packet to buffer
void Mist::InOutBase::bufferLivePacket ( DTSC::Packet packet)
inherited

Buffers a live packet to a page.

Handles both buffering and creation of new pages

Initiates/continues negotiation with the buffer as well

Parameters
packetThe packet to buffer
void Mist::InOutBase::bufferNext ( DTSC::Packet pack)
inherited

Buffers the next packet on the currently opened page.

Parameters
packThe packet to buffer
void Mist::InOutBase::bufferNext ( JSON::Value pack)
inherited

Buffers the next packet on the currently opened page.

Parameters
packThe packet to buffer
Note
Internally calls bufferNext(DTSC::Packet & pack)
void Mist::InOutBase::bufferRemove ( unsigned long  tid,
unsigned long  pageNumber 
)
inherited

Removes a fully buffered page.

Does not do anything if the process is not standalone, in this case the master process will have an overloaded version of this function.

Parameters
tidThe trackid to remove the page from
pageNumberThe number of the page to remove
bool Mist::InOutBase::bufferStart ( unsigned long  tid,
unsigned long  pageNumber 
)
inherited
void Mist::OutProgressiveMP4::buildFragment ( int  fragNum)

Builds up a datastructure that allows for access in the fragment send header function using the fragment number FOR THIS USER, NOT ACTUAL FRAGMENT NUMBER, HAS NOTHING TO DO WITH ACTUAL FRAGMENTS EVEN We take the corresponding keyframe and interframes of the main video track and take concurrent frames from its secondary (audio) tracks.

Todo:
See if we can use something more elegant than a member variable...
void Mist::OutProgressiveMP4::buildTrafPart ( )
protected
bool Mist::Output::closeOutputFileForRecording ( )
inherited
void Mist::InOutBase::continueNegotiate ( unsigned long  tid)
protectedinherited
std::string Mist::OutProgressiveMP4::DTSCMeta2MP4Header ( long long &  size,
int  fragmented = 0 
)
Todo:
This function does not indicate errors anywhere... maybe fix this...
Todo:
Figure out if this box is really needed for anything.
Todo:
rewrite for sanity
Todo:
PLEASE rewrite this for sanity.... SHOULD be: index FIRST, value SECOND
Todo:
rewrite for sanity
Todo:
Again, rewrite for sanity. index FIRST, value SECOND
Todo:
Update this thing for boxes >4G?
long long unsigned Mist::OutProgressiveMP4::estimateFileSize ( )
protected
void Mist::OutProgressiveMP4::findSeekPoint ( long long  byteStart,
long long &  seekPoint,
unsigned int  headerSize 
)

Calculate a seekPoint, based on byteStart, metadata, tracks and headerSize.

The seekPoint will be set to the timestamp of the first packet to send.

std::string Mist::HTTPOutput::getConnectedBinHost ( )
protectedvirtualinherited

Reimplemented from Mist::Output.

std::string Mist::HTTPOutput::getConnectedHost ( )
protectedvirtualinherited

Reimplemented from Mist::Output.

std::string Mist::HTTPOutput::getHandler ( )
inherited
  • anything else: The request should be dispatched to a connector on the named socket.
unsigned int Mist::Output::getKeyForTime ( long unsigned int  trackId,
long long  timeStamp 
)
protectedinherited
long unsigned int Mist::Output::getMainSelectedTrack ( )
inherited

Returns the ID of the main selected track, or 0 if no tracks are selected.

The main track is the first video track, if any, and otherwise the first other track.

void Mist::OutProgressiveMP4::init ( Util::Config cfg)
static
Todo:
uncomment when we actually start implementing mp4 recording
void Mist::Output::initialize ( )
virtualinherited
Trigger:
The "CONN_PLAY" trigger is stream-specific, and is ran when an active connection first opens a stream.

Its payload is:

streamname
connected client host
output handler name
request URL (if any)

The "USER_NEW" trigger is stream-specific, and is ran when a new user first opens a stream. Segmented protcols are unduplicated over the duration of the statistics log (~10 minutes), true streaming protocols (RTMP, RTSP) are not deduplicated as no duplication ever takes place. Its payload is:

streamname
connected client host
User agent checksum (CRC32 of User-agent string)
output handler name
request URL (if any)

Reimplemented in Mist::OutDashMP4.

void Mist::InOutBase::initiateMeta ( )
inherited

Opens a shared memory page for the stream metadata.

Assumes myMeta contains the metadata to write.

bool Mist::HTTPOutput::isTrustedProxy ( const std::string &  ip)
protectedinherited

< Open server config

static bool Mist::HTTPOutput::listenMode ( )
inlinestaticinherited
void Mist::HTTPOutput::onFail ( )
virtualinherited

Called when stream initialization has failed.

The standard implementation will set isInitialized to false and close the client connection, thus causing the process to exit cleanly.

Reimplemented from Mist::Output.

Reimplemented in Mist::OutHTTP.

virtual bool Mist::Output::onFinish ( )
inlinevirtualinherited

Reimplemented in Mist::OutProgressiveOGG, and Mist::OutJSON.

void Mist::OutProgressiveMP4::onHTTP ( )
virtual
Todo:
Should this happen here?
Todo:
Do we really need this though?
Todo:
Note: Not necessary, but we might want to think of a method that does not use seeking
Todo:
Switch to chunked?
Todo:
Switch to chunked?
Todo:
Switch to chunked?

Reimplemented from Mist::HTTPOutput.

virtual void Mist::HTTPOutput::onRecord ( )
inlinevirtualinherited

Reimplemented from Mist::Output.

void Mist::HTTPOutput::onRequest ( )
virtualinherited

Reimplemented from Mist::Output.

Reimplemented in Mist::OutProgressiveOGG.

bool Mist::Output::openOutputFileForRecording ( )
inherited
void Mist::OutProgressiveMP4::parseRange ( std::string  header,
long long &  byteStart,
long long &  byteEnd,
long long &  seekPoint,
unsigned int  headerSize 
)

Parses a "Range: " header, setting byteStart, byteEnd and seekPoint using data from metadata and tracks to do the calculations.

On error, byteEnd is set to zero.

void Mist::Output::prepareNext ( )
virtualinherited
void Mist::Output::reconnect ( )
inherited

Connects or reconnects to the stream.

Assumes streamName class member has been set already. Will start input if not currently active, calls onFail() if this does not succeed. After assuring stream is online, clears nProxy.metaPages, then sets nProxy.metaPages[0], statsPage and nProxy.userClient to (hopefully) valid handles. Finally, calls updateMeta()

void Mist::HTTPOutput::reConnector ( std::string &  connector)
inherited

Handles requests by starting a corresponding output process.

Parameters
HThe request to be handled
connThe connection to the client that issued the request.
connectorThe type of connector to be invoked.

start new/better process

bool Mist::Output::recording ( )
protectedinherited
void Mist::HTTPOutput::requestHandler ( )
virtualinherited

Reimplemented from Mist::Output.

int Mist::Output::run ( )
inherited
Trigger:
The "CONN_OPEN" trigger is stream-specific, and is ran when a connection is made or passed to a new handler.

Its payload is:

streamname
connected client host
output handler name
request URL (if any)

The "CONN_CLOSE" trigger is stream-specific, and is ran when a connection closes. Its payload is:

streamname
connected client host
output handler name
request URL (if any)
Todo:
generate payload
void Mist::Output::seek ( unsigned long long  pos)
inherited

Prepares all tracks from selectedTracks for seeking to the specified ms position.

bool Mist::Output::seek ( unsigned int  tid,
unsigned long long  pos,
bool  getNextKey = false 
)
inherited
void Mist::Output::selectDefaultTracks ( )
inherited
void Mist::OutProgressiveMP4::sendFragmentHeader ( int  fragNum)
void Mist::OutProgressiveMP4::sendHeader ( )
virtual

Reimplemented from Mist::Output.

void Mist::OutProgressiveMP4::sendNext ( )
virtual

Reimplemented from Mist::Output.

void Mist::HTTPOutput::sendResponse ( std::string  message,
std::string  code = "200" 
)
inherited
void Mist::Output::setBlocking ( bool  blocking)
inherited
void Mist::OutProgressiveMP4::setvidTrack ( )
protected
void Mist::Output::stats ( )
inherited
void Mist::Output::stop ( )
inherited

Clears the buffer, sets parseData to false, and generally makes not very much happen at all.

void Mist::Output::updateMeta ( )
inherited

Field Documentation

std::map<int,DTSCPageData> Mist::Output::bookKeeping
protectedinherited
long long Mist::OutProgressiveMP4::byteEnd
protected
long long Mist::OutProgressiveMP4::byteStart
protected
JSON::Value Mist::Output::capa = JSON::Value()
staticinherited
bool Mist::Output::completeKeysOnly
protectedinherited

Bool if we send whole keys only, so the metadata is complete and the output knows in advance what will be sent.

Util::Config * Mist::InOutBase::config = NULL
staticprotectedinherited
unsigned int Mist::Output::crc
protectedinherited

Checksum, if any, for usage in the stats.

std::map<long unsigned int, fragSet> Mist::OutProgressiveMP4::currentPartSet
protected
long long Mist::OutProgressiveMP4::currPos
protected
long long Mist::OutProgressiveMP4::fileSize
protected
long int Mist::OutProgressiveMP4::fragKeyNumberShift
protected
int Mist::OutProgressiveMP4::fragSeqNum
protected
HTTP::Parser Mist::HTTPOutput::H
protectedinherited
bool Mist::Output::isBlocking
protectedinherited

If true, indicates that myConn is blocking.

bool Mist::Output::isInitialized
protectedinherited

If false, triggers initialization if parseData is true.

long long Mist::OutProgressiveMP4::leftOver
protected
unsigned int Mist::Output::maxSkipAhead
protectedinherited

Maximum ms that we will go ahead of the intended timestamps.

unsigned int Mist::Output::minSkipAhead
protectedinherited

Minimum ms that we will go ahead of the intended timestamps.

Socket::Connection& Mist::Output::myConn
protectedinherited

Connection to the client.

DTSC::Meta Mist::InOutBase::myMeta
protectedinherited

Stores either the input or output metadata.

negotiationProxy Mist::InOutBase::nProxy
protectedinherited
int Mist::Output::outputFileDescriptor
protectedinherited
bool Mist::Output::parseData
protectedinherited

If true, triggers initalization if not already done, sending of header, sending of packets.

long unsigned int Mist::OutProgressiveMP4::partListLength
protected
long unsigned int Mist::OutProgressiveMP4::partListSent
protected
long long unsigned int Mist::OutProgressiveMP4::realBaseOffset
protected
unsigned int Mist::Output::realTime
protectedinherited

Playback speed in ms of data per second. eg: 0 is infinite, 1000 real-time, 5000 is 0.2X speed, 500 = 2X speed.

std::string Mist::Output::reqUrl
inherited
long long Mist::OutProgressiveMP4::seekPoint
protected
std::set<unsigned long> Mist::InOutBase::selectedTracks
protectedinherited

Stores the track id's that are either selected for playback or input.

bool Mist::OutProgressiveMP4::sending3GP
protected
bool Mist::Output::sentHeader
protectedinherited

If false, triggers sendHeader if parseData is true.

std::set<keyPart> Mist::OutProgressiveMP4::sortSet
protected
bool Mist::InOutBase::standAlone
protectedinherited
IPC::sharedClient Mist::Output::statsPage
protectedinherited

Shared memory used for statistics reporting.

std::string Mist::InOutBase::streamName
protectedinherited
DTSC::Packet Mist::InOutBase::thisPacket
protectedinherited
long unsigned int Mist::OutProgressiveMP4::vidTrack
protected
bool Mist::Output::wantRequest
protectedinherited

If true, waits for a request.


The documentation for this class was generated from the following files: