Stability improvements for live buffers / fixed issues with file extensions in RTMP stream names.

This commit is contained in:
Thulinma 2015-01-29 01:28:46 +01:00
parent 9bdf5ee19b
commit 39a386ab18
3 changed files with 20 additions and 10 deletions

View file

@ -183,7 +183,7 @@ namespace Mist {
char tempMetaName[100];
sprintf(tempMetaName, "liveStream_%s%d", config->getString("streamname").c_str(), tmpTid);
metaPages[tmpTid].init(tempMetaName, 8388608, true);
metaPages[tmpTid].init(tempMetaName, DEFAULT_META_PAGE_SIZE, true);
}
if (negotiateTracks.count(value)){
//Track is currently under negotiation, check whether the metadata has been submitted
@ -261,7 +261,7 @@ namespace Mist {
((long long int *)indexPages[finalMap].mapped)[0] = htonl(1000);
sprintf(firstPage, "%s%d_%d", config->getString("streamname").c_str(), finalMap, keyNum);
///\todo Make size dynamic / other solution. 25mb is too much.
dataPages[finalMap][0].init(firstPage, 26214400, true);
dataPages[finalMap][0].init(firstPage, DEFAULT_DATA_PAGE_SIZE, true);
}
}
}
@ -276,12 +276,12 @@ namespace Mist {
//update current page
int currentPage = dataPages[value].rbegin()->first;
updateMetaFromPage(value, currentPage);
if (inputLoc[value][currentPage].curOffset > 8388608) {
if (inputLoc[value][currentPage].curOffset > FLIP_DATA_PAGE_SIZE) {
int nextPage = currentPage + inputLoc[value][currentPage].keyNum;
char nextPageName[100];
sprintf(nextPageName, "%s%lu_%d", config->getString("streamname").c_str(), value, nextPage);
dataPages[value][nextPage].init(nextPageName, 20971520, true);
DEVEL_MSG("Created page %s", nextPageName);
dataPages[value][nextPage].init(nextPageName, DEFAULT_DATA_PAGE_SIZE, true);
DEVEL_MSG("Created page %s, from pos %llu", nextPageName, inputLoc[value][currentPage].curOffset);
bool createdNew = false;
for (int i = 0; i < 8192; i += 8){
unsigned int thisKeyNum = ((((long long int *)(indexPages[value].mapped + i))[0]) >> 32) & 0xFFFFFFFF;

View file

@ -197,17 +197,21 @@ namespace Mist {
}
int pageNum = bookKeeping[tNum].pageNum;
std::string tmp = pack.toNetPacked();
if (bookKeeping[tNum].curOffset > 8388608 && pack.isMember("keyframe") && pack["keyframe"]){
Util::sleep(500);
if (bookKeeping[tNum].curOffset > FLIP_DATA_PAGE_SIZE && pack.isMember("keyframe") && pack["keyframe"]){
//open new page
char nextPage[100];
sprintf(nextPage, "%s%llu_%d", streamName.c_str(), tNum, bookKeeping[tNum].pageNum + bookKeeping[tNum].keyNum);
INFO_MSG("Continuing track %llu on page %d", tNum, bookKeeping[tNum].pageNum + bookKeeping[tNum].keyNum);
INFO_MSG("Continuing track %llu on page %d, from pos %llu", tNum, bookKeeping[tNum].pageNum + bookKeeping[tNum].keyNum, bookKeeping[tNum].curOffset);
curPages[tNum].init(nextPage, DEFAULT_DATA_PAGE_SIZE);
bookKeeping[tNum].pageNum += bookKeeping[tNum].keyNum;
bookKeeping[tNum].keyNum = 0;
bookKeeping[tNum].curOffset = 0;
}
if (!curPages[tNum].mapped){
//prevent page init failures from crashing everything.
myConn.close();//closes the connection to trigger a clean shutdown
return;
}
if (bookKeeping[tNum].curOffset + tmp.size() < (unsigned long long)curPages[tNum].len){
bookKeeping[tNum].keyNum += (pack.isMember("keyframe") && pack["keyframe"]);
memcpy(curPages[tNum].mapped + bookKeeping[tNum].curOffset, tmp.data(), tmp.size());

View file

@ -518,10 +518,16 @@ namespace Mist {
//handle variables
if (streamName.find('?') != std::string::npos){
std::string tmpVars = streamName.substr(streamName.find('?') + 1);
streamName = streamName.substr(0, streamName.find('?'));
parseVars(tmpVars);
Util::sanitizeName(streamName);
}
size_t colonPos = streamName.find(':');
if (colonPos != std::string::npos && colonPos < 6){
std::string oldName = streamName;
streamName = oldName.substr(colonPos + 1) + std::string(".") + oldName.substr(0, colonPos);
}
Util::sanitizeName(streamName);
initialize();
//send a status reply