Improved input start behavior for live pushed streams
This commit is contained in:
parent
72ce4fb852
commit
967bc5729c
2 changed files with 34 additions and 7 deletions
|
@ -143,7 +143,7 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir
|
||||||
//Note: this uses the _whole_ stream name, including + (if any).
|
//Note: this uses the _whole_ stream name, including + (if any).
|
||||||
//This means "test+a" and "test+b" have separate locks and do not interact with each other.
|
//This means "test+a" and "test+b" have separate locks and do not interact with each other.
|
||||||
uint8_t streamStat = getStreamStatus(streamname);
|
uint8_t streamStat = getStreamStatus(streamname);
|
||||||
while (streamStat != STRMSTAT_OFF && streamStat != STRMSTAT_READY){
|
while (streamStat != STRMSTAT_OFF && streamStat != STRMSTAT_READY && (!isProvider || streamStat != STRMSTAT_WAIT)){
|
||||||
if (streamStat == STRMSTAT_BOOT && overrides.count("throughboot")){
|
if (streamStat == STRMSTAT_BOOT && overrides.count("throughboot")){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,8 @@ namespace Mist{
|
||||||
|
|
||||||
bool Output::isReadyForPlay(){
|
bool Output::isReadyForPlay(){
|
||||||
if (isPushing()){return true;}
|
if (isPushing()){return true;}
|
||||||
|
if (!isInitialized){initialize();}
|
||||||
|
if (!myMeta.tracks.size()){updateMeta();}
|
||||||
if (myMeta.tracks.size()){
|
if (myMeta.tracks.size()){
|
||||||
if (!selectedTracks.size()){
|
if (!selectedTracks.size()){
|
||||||
selectDefaultTracks();
|
selectDefaultTracks();
|
||||||
|
@ -1154,8 +1156,6 @@ namespace Mist{
|
||||||
std::string strmSource;
|
std::string strmSource;
|
||||||
|
|
||||||
// Initialize the stream source if needed, connect to it
|
// Initialize the stream source if needed, connect to it
|
||||||
initialize();
|
|
||||||
|
|
||||||
waitForStreamPushReady();
|
waitForStreamPushReady();
|
||||||
//pull the source setting from metadata
|
//pull the source setting from metadata
|
||||||
strmSource = myMeta.sourceURI;
|
strmSource = myMeta.sourceURI;
|
||||||
|
@ -1190,10 +1190,7 @@ namespace Mist{
|
||||||
MEDIUM_MSG("Current status for %s buffer is %u", streamName.c_str(), streamStatus);
|
MEDIUM_MSG("Current status for %s buffer is %u", streamName.c_str(), streamStatus);
|
||||||
while (streamStatus != STRMSTAT_WAIT && streamStatus != STRMSTAT_READY && keepGoing()){
|
while (streamStatus != STRMSTAT_WAIT && streamStatus != STRMSTAT_READY && keepGoing()){
|
||||||
INFO_MSG("Waiting for %s buffer to be ready... (%u)", streamName.c_str(), streamStatus);
|
INFO_MSG("Waiting for %s buffer to be ready... (%u)", streamName.c_str(), streamStatus);
|
||||||
if (nProxy.userClient.getData()){
|
disconnect();
|
||||||
nProxy.userClient.finish();
|
|
||||||
nProxy.userClient = IPC::sharedClient();
|
|
||||||
}
|
|
||||||
Util::wait(1000);
|
Util::wait(1000);
|
||||||
streamStatus = Util::getStreamStatus(streamName);
|
streamStatus = Util::getStreamStatus(streamName);
|
||||||
if (streamStatus == STRMSTAT_OFF || streamStatus == STRMSTAT_WAIT || streamStatus == STRMSTAT_READY){
|
if (streamStatus == STRMSTAT_OFF || streamStatus == STRMSTAT_WAIT || streamStatus == STRMSTAT_READY){
|
||||||
|
@ -1201,6 +1198,36 @@ namespace Mist{
|
||||||
streamStatus = Util::getStreamStatus(streamName);
|
streamStatus = Util::getStreamStatus(streamName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (streamStatus == STRMSTAT_WAIT || streamStatus == STRMSTAT_READY){
|
||||||
|
if (!myMeta.sourceURI.size()){
|
||||||
|
char pageId[NAME_BUFFER_SIZE];
|
||||||
|
snprintf(pageId, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, streamName.c_str());
|
||||||
|
nProxy.metaPages[0].init(pageId, DEFAULT_STRM_PAGE_SIZE);
|
||||||
|
if (nProxy.metaPages[0].mapped){
|
||||||
|
IPC::semaphore * liveSem = 0;
|
||||||
|
static char liveSemName[NAME_BUFFER_SIZE];
|
||||||
|
snprintf(liveSemName, NAME_BUFFER_SIZE, SEM_LIVE, streamName.c_str());
|
||||||
|
liveSem = new IPC::semaphore(liveSemName, O_RDWR, ACCESSPERMS, 1, !myMeta.live);
|
||||||
|
if (*liveSem){
|
||||||
|
liveSem->wait();
|
||||||
|
}else{
|
||||||
|
delete liveSem;
|
||||||
|
liveSem = 0;
|
||||||
|
}
|
||||||
|
DTSC::Packet tmpMeta(nProxy.metaPages[0].mapped, nProxy.metaPages[0].len, true);
|
||||||
|
if (tmpMeta.getVersion()){
|
||||||
|
DTSC::Meta reMeta;
|
||||||
|
reMeta.reinit(tmpMeta);
|
||||||
|
myMeta.sourceURI = reMeta.sourceURI;
|
||||||
|
}
|
||||||
|
if (liveSem){
|
||||||
|
liveSem->post();
|
||||||
|
delete liveSem;
|
||||||
|
liveSem = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue