Merge branch 'development' into LTS_development
# Conflicts: # src/output/output.h
This commit is contained in:
commit
dc8bae8dd3
10 changed files with 80 additions and 30 deletions
|
@ -348,7 +348,7 @@ namespace DTSC {
|
||||||
return vod || live;
|
return vod || live;
|
||||||
}
|
}
|
||||||
void reinit(const DTSC::Packet & source);
|
void reinit(const DTSC::Packet & source);
|
||||||
void update(DTSC::Packet & pack, unsigned long segment_size = 5000);
|
void update(const DTSC::Packet & pack, unsigned long segment_size = 5000);
|
||||||
void updatePosOverride(DTSC::Packet & pack, uint64_t bpos);
|
void updatePosOverride(DTSC::Packet & pack, uint64_t bpos);
|
||||||
void update(JSON::Value & pack, unsigned long segment_size = 5000);
|
void update(JSON::Value & pack, unsigned long segment_size = 5000);
|
||||||
/*LTS
|
/*LTS
|
||||||
|
|
|
@ -1495,7 +1495,7 @@ namespace DTSC {
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Updates a meta object given a DTSC::Packet
|
///\brief Updates a meta object given a DTSC::Packet
|
||||||
void Meta::update(DTSC::Packet & pack, unsigned long segment_size) {
|
void Meta::update(const DTSC::Packet & pack, unsigned long segment_size) {
|
||||||
char * data;
|
char * data;
|
||||||
unsigned int dataLen;
|
unsigned int dataLen;
|
||||||
pack.getString("data", data, dataLen);
|
pack.getString("data", data, dataLen);
|
||||||
|
|
41
lib/util.cpp
41
lib/util.cpp
|
@ -12,6 +12,7 @@
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <direct.h> // _mkdir
|
#include <direct.h> // _mkdir
|
||||||
#endif
|
#endif
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define RECORD_POINTER p + getOffset() + (getRecordPosition(recordNo) * getRSize()) + fd.offset
|
#define RECORD_POINTER p + getOffset() + (getRecordPosition(recordNo) * getRSize()) + fd.offset
|
||||||
#define RAXHDR_FIELDOFFSET p[1]
|
#define RAXHDR_FIELDOFFSET p[1]
|
||||||
|
@ -148,6 +149,46 @@ namespace Util{
|
||||||
return fseeko(stream, offset, whence);
|
return fseeko(stream, offset, whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResizeablePointer::ResizeablePointer(){
|
||||||
|
currSize = 0;
|
||||||
|
ptr = 0;
|
||||||
|
maxSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResizeablePointer::~ResizeablePointer(){
|
||||||
|
if (ptr){free(ptr);}
|
||||||
|
currSize = 0;
|
||||||
|
ptr = 0;
|
||||||
|
maxSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ResizeablePointer::assign(void * p, uint32_t l){
|
||||||
|
if (!allocate(l)){return false;}
|
||||||
|
memcpy(ptr, p, l);
|
||||||
|
currSize = l;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ResizeablePointer::append(void * p, uint32_t l){
|
||||||
|
if (!allocate(l+currSize)){return false;}
|
||||||
|
memcpy(((char*)ptr)+currSize, p, l);
|
||||||
|
currSize += l;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ResizeablePointer::allocate(uint32_t l){
|
||||||
|
if (l > maxSize){
|
||||||
|
void *tmp = realloc(ptr, l);
|
||||||
|
if (!tmp){
|
||||||
|
FAIL_MSG("Could not allocate %lu bytes of memory", l);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ptr = tmp;
|
||||||
|
maxSize = l;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// If waitReady is true (default), waits for isReady() to return true in 50ms sleep increments.
|
/// If waitReady is true (default), waits for isReady() to return true in 50ms sleep increments.
|
||||||
RelAccX::RelAccX(char *data, bool waitReady){
|
RelAccX::RelAccX(char *data, bool waitReady){
|
||||||
if (!data){
|
if (!data){
|
||||||
|
|
18
lib/util.h
18
lib/util.h
|
@ -12,6 +12,24 @@ namespace Util{
|
||||||
uint64_t ftell(FILE *stream);
|
uint64_t ftell(FILE *stream);
|
||||||
uint64_t fseek(FILE *stream, uint64_t offset, int whence);
|
uint64_t fseek(FILE *stream, uint64_t offset, int whence);
|
||||||
|
|
||||||
|
/// Helper class that maintains a resizeable pointer and will free it upon deletion of the class.
|
||||||
|
class ResizeablePointer{
|
||||||
|
public:
|
||||||
|
ResizeablePointer();
|
||||||
|
~ResizeablePointer();
|
||||||
|
inline uint32_t& size(){return currSize;}
|
||||||
|
bool assign(void * p, uint32_t l);
|
||||||
|
bool append(void * p, uint32_t l);
|
||||||
|
bool allocate(uint32_t l);
|
||||||
|
inline operator char*(){return (char*)ptr;}
|
||||||
|
inline operator void*(){return ptr;}
|
||||||
|
private:
|
||||||
|
void * ptr;
|
||||||
|
uint32_t currSize;
|
||||||
|
uint32_t maxSize;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/// Holds type, size and offset for RelAccX class internal data fields.
|
/// Holds type, size and offset for RelAccX class internal data fields.
|
||||||
class RelAccXFieldData{
|
class RelAccXFieldData{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -672,7 +672,7 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
bufferFinalize(track);
|
bufferFinalize(track);
|
||||||
bufferTimer = Util::bootMS() - bufferTimer;
|
bufferTimer = Util::bootMS() - bufferTimer;
|
||||||
DEBUG_MSG(DLVL_DEVEL, "Done buffering page %d (%llu packets, %llu bytes) for track %d in %llums", keyNum, packCounter, byteCounter, track, bufferTimer);
|
DEBUG_MSG(DLVL_DEVEL, "Done buffering page %d (%llu packets, %llu bytes) for track %d (%s) in %llums", keyNum, packCounter, byteCounter, track, myMeta.tracks[track].codec.c_str(), bufferTimer);
|
||||||
pageCounter[track][keyNum] = 15;
|
pageCounter[track][keyNum] = 15;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
10
src/io.cpp
10
src/io.cpp
|
@ -296,11 +296,11 @@ namespace Mist {
|
||||||
|
|
||||||
///Buffers the next packet on the currently opened page
|
///Buffers the next packet on the currently opened page
|
||||||
///\param pack The packet to buffer
|
///\param pack The packet to buffer
|
||||||
void InOutBase::bufferNext(DTSC::Packet & pack) {
|
void InOutBase::bufferNext(const DTSC::Packet & pack) {
|
||||||
nProxy.bufferNext(pack, myMeta);
|
nProxy.bufferNext(pack, myMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void negotiationProxy::bufferNext(DTSC::Packet & pack, DTSC::Meta & myMeta) {
|
void negotiationProxy::bufferNext(const DTSC::Packet & pack, DTSC::Meta & myMeta) {
|
||||||
static bool multiWrong = false;
|
static bool multiWrong = false;
|
||||||
//Save the trackid of the track for easier access
|
//Save the trackid of the track for easier access
|
||||||
unsigned long tid = pack.getTrackId();
|
unsigned long tid = pack.getTrackId();
|
||||||
|
@ -453,11 +453,11 @@ namespace Mist {
|
||||||
///
|
///
|
||||||
///Initiates/continues negotiation with the buffer as well
|
///Initiates/continues negotiation with the buffer as well
|
||||||
///\param packet The packet to buffer
|
///\param packet The packet to buffer
|
||||||
void InOutBase::bufferLivePacket(DTSC::Packet & packet){
|
void InOutBase::bufferLivePacket(const DTSC::Packet & packet){
|
||||||
nProxy.bufferLivePacket(packet, myMeta);
|
nProxy.bufferLivePacket(packet, myMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void negotiationProxy::bufferLivePacket(DTSC::Packet & packet, DTSC::Meta & myMeta){
|
void negotiationProxy::bufferLivePacket(const DTSC::Packet & packet, DTSC::Meta & myMeta){
|
||||||
myMeta.vod = false;
|
myMeta.vod = false;
|
||||||
myMeta.live = true;
|
myMeta.live = true;
|
||||||
//Store the trackid for easier access
|
//Store the trackid for easier access
|
||||||
|
@ -491,7 +491,7 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void negotiationProxy::bufferSinglePacket(DTSC::Packet & packet, DTSC::Meta & myMeta){
|
void negotiationProxy::bufferSinglePacket(const DTSC::Packet & packet, DTSC::Meta & myMeta){
|
||||||
//Store the trackid for easier access
|
//Store the trackid for easier access
|
||||||
unsigned long tid = packet.getTrackId();
|
unsigned long tid = packet.getTrackId();
|
||||||
//This update needs to happen whether the track is accepted or not.
|
//This update needs to happen whether the track is accepted or not.
|
||||||
|
|
10
src/io.h
10
src/io.h
|
@ -32,10 +32,10 @@ namespace Mist {
|
||||||
void clear();
|
void clear();
|
||||||
void initiateEncryption();//LTS
|
void initiateEncryption();//LTS
|
||||||
bool bufferStart(unsigned long tid, unsigned long pageNumber, DTSC::Meta & myMeta);
|
bool bufferStart(unsigned long tid, unsigned long pageNumber, DTSC::Meta & myMeta);
|
||||||
void bufferNext(DTSC::Packet & pack, DTSC::Meta & myMeta);
|
void bufferNext(const DTSC::Packet & pack, DTSC::Meta & myMeta);
|
||||||
void bufferFinalize(unsigned long tid, DTSC::Meta &myMeta);
|
void bufferFinalize(unsigned long tid, DTSC::Meta &myMeta);
|
||||||
void bufferLivePacket(DTSC::Packet & packet, DTSC::Meta & myMeta);
|
void bufferLivePacket(const DTSC::Packet & packet, DTSC::Meta & myMeta);
|
||||||
void bufferSinglePacket(DTSC::Packet & packet, DTSC::Meta & myMeta);
|
void bufferSinglePacket(const DTSC::Packet & packet, DTSC::Meta & myMeta);
|
||||||
bool isBuffered(unsigned long tid, unsigned long keyNum);
|
bool isBuffered(unsigned long tid, unsigned long keyNum);
|
||||||
unsigned long bufferedOnPage(unsigned long tid, unsigned long keyNum);
|
unsigned long bufferedOnPage(unsigned long tid, unsigned long keyNum);
|
||||||
|
|
||||||
|
@ -73,10 +73,10 @@ namespace Mist {
|
||||||
public:
|
public:
|
||||||
void initiateMeta();
|
void initiateMeta();
|
||||||
bool bufferStart(unsigned long tid, unsigned long pageNumber);
|
bool bufferStart(unsigned long tid, unsigned long pageNumber);
|
||||||
void bufferNext(DTSC::Packet & pack);
|
void bufferNext(const DTSC::Packet & pack);
|
||||||
void bufferFinalize(unsigned long tid);
|
void bufferFinalize(unsigned long tid);
|
||||||
void bufferRemove(unsigned long tid, unsigned long pageNumber);
|
void bufferRemove(unsigned long tid, unsigned long pageNumber);
|
||||||
virtual void bufferLivePacket(DTSC::Packet & packet);
|
virtual void bufferLivePacket(const DTSC::Packet & packet);
|
||||||
protected:
|
protected:
|
||||||
void continueNegotiate(unsigned long tid, bool quickNegotiate = false);
|
void continueNegotiate(unsigned long tid, bool quickNegotiate = false);
|
||||||
void continueNegotiate();
|
void continueNegotiate();
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace Mist{
|
||||||
cfg->addOption("noinput", option);
|
cfg->addOption("noinput", option);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Output::bufferLivePacket(DTSC::Packet & packet){
|
void Output::bufferLivePacket(const DTSC::Packet & packet){
|
||||||
if (!pushIsOngoing){
|
if (!pushIsOngoing){
|
||||||
waitForStreamPushReady();
|
waitForStreamPushReady();
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ namespace Mist {
|
||||||
bool allowPush(const std::string & passwd);
|
bool allowPush(const std::string & passwd);
|
||||||
void waitForStreamPushReady();
|
void waitForStreamPushReady();
|
||||||
bool pushIsOngoing;
|
bool pushIsOngoing;
|
||||||
void bufferLivePacket(DTSC::Packet & packet);
|
void bufferLivePacket(const DTSC::Packet & packet);
|
||||||
uint64_t firstPacketTime;
|
uint64_t firstPacketTime;
|
||||||
uint64_t lastPacketTime;
|
uint64_t lastPacketTime;
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <mist/stream.h>
|
#include <mist/stream.h>
|
||||||
#include <mist/triggers.h>
|
#include <mist/triggers.h>
|
||||||
#include <mist/encode.h>
|
#include <mist/encode.h>
|
||||||
|
#include <mist/util.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -293,8 +294,7 @@ namespace Mist{
|
||||||
0, 0, 0, 0}; //bytes 12-15 = extended timestamp
|
0, 0, 0, 0}; //bytes 12-15 = extended timestamp
|
||||||
char dataheader[] ={0, 0, 0, 0, 0};
|
char dataheader[] ={0, 0, 0, 0, 0};
|
||||||
unsigned int dheader_len = 1;
|
unsigned int dheader_len = 1;
|
||||||
static char * swappyPointer = 0;
|
static Util::ResizeablePointer swappy;
|
||||||
static uint32_t swappySize = 0;
|
|
||||||
char * tmpData = 0;//pointer to raw media data
|
char * tmpData = 0;//pointer to raw media data
|
||||||
unsigned int data_len = 0;//length of processed media data
|
unsigned int data_len = 0;//length of processed media data
|
||||||
thisPacket.getString("data", tmpData, data_len);
|
thisPacket.getString("data", tmpData, data_len);
|
||||||
|
@ -346,21 +346,12 @@ namespace Mist{
|
||||||
dataheader[0] |= 0x10;
|
dataheader[0] |= 0x10;
|
||||||
}
|
}
|
||||||
if (track.codec == "PCM"){
|
if (track.codec == "PCM"){
|
||||||
if (track.size == 16){
|
if (track.size == 16 && swappy.allocate(data_len)){
|
||||||
if (swappySize < data_len){
|
|
||||||
char * tmp = (char*)realloc(swappyPointer, data_len);
|
|
||||||
if (!tmp){
|
|
||||||
FAIL_MSG("Could not allocate data for PCM endianness swap!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
swappyPointer = tmp;
|
|
||||||
swappySize = data_len;
|
|
||||||
}
|
|
||||||
for (uint32_t i = 0; i < data_len; i+=2){
|
for (uint32_t i = 0; i < data_len; i+=2){
|
||||||
swappyPointer[i] = tmpData[i+1];
|
swappy[i] = tmpData[i+1];
|
||||||
swappyPointer[i+1] = tmpData[i];
|
swappy[i+1] = tmpData[i];
|
||||||
}
|
}
|
||||||
tmpData = swappyPointer;
|
tmpData = swappy;
|
||||||
}
|
}
|
||||||
dataheader[0] |= 0x30;
|
dataheader[0] |= 0x30;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue