Merge branch 'development' into LTS_development

# Conflicts:
#	lib/stream.cpp
#	src/output/output_http_internal.cpp
This commit is contained in:
Thulinma 2015-07-21 23:51:46 +02:00
commit 569ef07f29
7 changed files with 97 additions and 49 deletions

View file

@ -107,14 +107,26 @@ namespace Mist {
if (streamName.size() < 1){
return; //abort - no stream to initialize...
}
isInitialized = true;
reconnect();
selectDefaultTracks();
sought = false;
}
/// 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 metaPages, then sets metaPages[0], statsPage and userClient to (hopefully) valid handles.
/// Finally, calls updateMeta()
void Output::reconnect(){
if (!Util::startInput(streamName)){
DEBUG_MSG(DLVL_FAIL, "Opening stream disallowed - aborting initalization");
DEBUG_MSG(DLVL_FAIL, "Opening stream failed - aborting initalization");
onFail();
return;
}
isInitialized = true;
char pageId[NAME_BUFFER_SIZE];
snprintf(pageId, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, streamName.c_str());
metaPages.clear();
metaPages[0].init(pageId, DEFAULT_META_PAGE_SIZE);
if (!metaPages[0].mapped){
DEBUG_MSG(DLVL_FAIL, "Could not connect to server for %s\n", streamName.c_str());
@ -124,14 +136,10 @@ namespace Mist {
statsPage = IPC::sharedClient(SHM_STATISTICS, STAT_EX_SIZE, true);
char userPageName[NAME_BUFFER_SIZE];
snprintf(userPageName, NAME_BUFFER_SIZE, SHM_USERS, streamName.c_str());
if (!userClient.getData()){
userClient = IPC::sharedClient(userPageName, PLAY_EX_SIZE, true);
}
userClient = IPC::sharedClient(userPageName, PLAY_EX_SIZE, true);
updateMeta();
selectDefaultTracks();
sought = false;
}
void Output::selectDefaultTracks(){
if (!isInitialized){
initialize();
@ -293,7 +301,13 @@ namespace Mist {
if (!timeout){
DEBUG_MSG(DLVL_HIGH, "Requesting page with key %lu:%lld", trackId, keyNum);
}
if (timeout++ > 100){
++timeout;
//if we've been waiting for this page for 3 seconds, reconnect to the stream - something might be going wrong...
if (timeout == 30){
DEVEL_MSG("Loading is taking longer than usual, reconnecting to stream %s...", streamName.c_str());
reconnect();
}
if (timeout > 100){
DEBUG_MSG(DLVL_FAIL, "Timeout while waiting for requested page %lld for track %lu. Aborting.", keyNum, trackId);
curPage.erase(trackId);
currKeyOpen.erase(trackId);

View file

@ -70,6 +70,7 @@ namespace Mist {
virtual bool onFinish() {
return false;
}
void reconnect();
virtual void initialize();
virtual void sendHeader();
virtual void onFail();

View file

@ -249,7 +249,7 @@ namespace Mist {
H.Clean();
H.SetHeader("Content-Type", "application/smil");
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION "/" + Util::Config::libver);
H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
H.setCORSHeaders();
H.SetBody("<smil>\n <head>\n <meta base='rtmp://" + host + ":" + port + url_rel + "' />\n </head>\n <body>\n <switch>\n"+trackSources+" </switch>\n </body>\n</smil>");
H.SendResponse("200", "OK", myConn);
@ -264,7 +264,7 @@ namespace Mist {
host.resize(host.find(':'));
}
H.Clean();
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
H.setCORSHeaders();
if (rURL.substr(0, 6) != "/json_"){
H.SetHeader("Content-Type", "application/javascript");
@ -287,9 +287,9 @@ namespace Mist {
configLock.post();
//Stream metadata not found - attempt to start it
if (Util::startInput(streamName)){
char streamPageName[NAME_BUFFER_SIZE];
snprintf(streamPageName, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, streamName.c_str());
streamIndex.init(streamPageName, DEFAULT_META_PAGE_SIZE);
char pageId[NAME_BUFFER_SIZE];
snprintf(pageId, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, streamName.c_str());
streamIndex.init(pageId, DEFAULT_META_PAGE_SIZE);
if (streamIndex.mapped){
metaLock = true;
metaLocker.wait();