Edits for live multibitrate

This commit is contained in:
Erik Zandvliet 2013-06-19 11:06:56 +02:00 committed by Thulinma
parent ae0da6955c
commit 8ddc1ab884
2 changed files with 71 additions and 121 deletions

View file

@ -135,6 +135,18 @@ namespace DTSC {
/// A simple structure used for ordering byte seek positions.
struct livePos {
livePos(){
seekTime = 0;
trackID = 0;
}
livePos(const livePos & rhs){
seekTime = rhs.seekTime;
trackID = rhs.trackID;
}
void operator = (const livePos& rhs) {
seekTime = rhs.seekTime;
trackID = rhs.trackID;
}
bool operator < (const livePos& rhs) const {
if (seekTime < rhs.seekTime){
return true;
@ -147,16 +159,16 @@ namespace DTSC {
}
return false;
}
long long unsigned int seekTime;
unsigned int trackID;
volatile long long unsigned int seekTime;
volatile unsigned int trackID;
};
/// A part from the DTSC::Stream ringbuffer.
/// Holds information about a buffer that will stay consistent
class Ring{
public:
Ring(unsigned int v);
volatile livePos b;
Ring(livePos v);
livePos b;
//volatile unsigned int b; ///< Holds current number of buffer. May and is intended to change unexpectedly!
volatile bool waiting; ///< If true, this Ring is currently waiting for a buffer fill.
volatile bool starved; ///< If true, this Ring can no longer receive valid data.
@ -173,6 +185,7 @@ namespace DTSC {
~Stream();
Stream(unsigned int buffers, unsigned int bufferTime = 0);
JSON::Value metadata;
JSON::Value & getPacket();
JSON::Value & getPacket(livePos num);
JSON::Value & getTrackById(int trackNo);
datatype lastType();
@ -181,6 +194,7 @@ namespace DTSC {
bool hasAudio();
bool parsePacket(std::string & buffer);
bool parsePacket(Socket::Buffer & buffer);
std::string & outPacket();
std::string & outPacket(livePos num);
std::string & outHeader();
Ring * getRing();
@ -188,15 +202,11 @@ namespace DTSC {
void dropRing(Ring * ptr);
void updateHeaders();
int canSeekms(unsigned int ms);
int canSeekFrame(unsigned int frameno);
unsigned int msSeek(unsigned int ms);
unsigned int frameSeek(unsigned int frameno);
livePos msSeek(unsigned int ms, std::set<int> allowedTracks);
void setBufferTime(unsigned int ms);
private:
std::map<livePos,JSON::Value> buffers;
std::map<int,std::set<livePos> > keyframes;
void advanceRings();
void updateRingHeaders();
void addPacket(JSON::Value & newPack);
std::string * datapointer;
datatype datapointertype;