Merge branch 'development' into LTS_development
# Conflicts: # lib/stream.cpp # lib/stream.h # src/input/input.cpp # src/output/output_http_internal.cpp
This commit is contained in:
commit
bef46f969c
8 changed files with 74 additions and 97 deletions
|
@ -293,6 +293,7 @@ namespace Mist {
|
|||
}
|
||||
finish();
|
||||
DEBUG_MSG(DLVL_DEVEL, "Input for stream %s closing clean", streamName.c_str());
|
||||
userPage.finishEach();
|
||||
//end player functionality
|
||||
}
|
||||
|
||||
|
@ -358,7 +359,7 @@ namespace Mist {
|
|||
WARN_MSG("Stream already online, cancelling");
|
||||
return;
|
||||
}
|
||||
if (!Util::startInput(streamName, "push://INTERNAL_ONLY:"+config->getString("input"))) {//manually override stream url to start the buffer
|
||||
if (!Util::startInput(streamName, "push://INTERNAL_ONLY:"+config->getString("input"), true, true)) {//manually override stream url to start the buffer
|
||||
pullLock.post();
|
||||
pullLock.close();
|
||||
pullLock.unlink();
|
||||
|
|
|
@ -85,6 +85,7 @@ namespace Mist {
|
|||
/*LTS-end*/
|
||||
|
||||
capa["source_match"] = "push://*";
|
||||
capa["non-provider"] = true;//Indicates we don't provide data, only collect it
|
||||
capa["priority"] = 9ll;
|
||||
capa["desc"] = "Provides buffered live input";
|
||||
capa["codecs"][0u][0u].append("*");
|
||||
|
|
|
@ -307,7 +307,7 @@ namespace Mist{
|
|||
return;
|
||||
}
|
||||
}else{
|
||||
if (!Util::startInput(streamName)){
|
||||
if (!Util::startInput(streamName, "", true, isPushing())){
|
||||
FAIL_MSG("Opening stream %s failed - aborting initialization", streamName.c_str());
|
||||
onFail();
|
||||
return;
|
||||
|
@ -346,8 +346,8 @@ namespace Mist{
|
|||
updateMeta();
|
||||
selectDefaultTracks();
|
||||
if (!myMeta.vod && !isReadyForPlay()){
|
||||
unsigned long long waitUntil = Util::epoch() + 15;
|
||||
while (!myMeta.vod && !isReadyForPlay()){
|
||||
unsigned long long waitUntil = Util::epoch() + 30;
|
||||
while (!myMeta.vod && !isReadyForPlay() && nProxy.userClient.isAlive()){
|
||||
if (Util::epoch() > waitUntil + 45 || (!selectedTracks.size() && Util::epoch() > waitUntil)){
|
||||
INFO_MSG("Giving up waiting for playable tracks. Stream: %s, IP: %s", streamName.c_str(), getConnectedHost().c_str());
|
||||
break;
|
||||
|
|
|
@ -230,32 +230,34 @@ namespace Mist {
|
|||
}
|
||||
|
||||
INFO_MSG("Received request %s", H.getUrl().c_str());
|
||||
selectedTracks.clear();
|
||||
if (H.GetVar("audio") != ""){
|
||||
selectedTracks.insert(JSON::Value(H.GetVar("audio")).asInt());
|
||||
}
|
||||
if (H.GetVar("video") != ""){
|
||||
selectedTracks.insert(JSON::Value(H.GetVar("video")).asInt());
|
||||
}
|
||||
selectDefaultTracks();
|
||||
std::set<unsigned long> toRemove;
|
||||
if (H.GetVar("video") == "0"){
|
||||
for (std::set<unsigned long>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
|
||||
if (myMeta.tracks.at(*it).type=="video"){
|
||||
toRemove.insert(*it);
|
||||
if (H.GetVar("audio") != "" || H.GetVar("video") != ""){
|
||||
selectedTracks.clear();
|
||||
if (H.GetVar("audio") != ""){
|
||||
selectedTracks.insert(JSON::Value(H.GetVar("audio")).asInt());
|
||||
}
|
||||
if (H.GetVar("video") != ""){
|
||||
selectedTracks.insert(JSON::Value(H.GetVar("video")).asInt());
|
||||
}
|
||||
selectDefaultTracks();
|
||||
std::set<unsigned long> toRemove;
|
||||
if (H.GetVar("video") == "0"){
|
||||
for (std::set<unsigned long>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
|
||||
if (myMeta.tracks.at(*it).type=="video"){
|
||||
toRemove.insert(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (H.GetVar("audio") == "0"){
|
||||
for (std::set<unsigned long>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
|
||||
if (myMeta.tracks.at(*it).type=="audio"){
|
||||
toRemove.insert(*it);
|
||||
if (H.GetVar("audio") == "0"){
|
||||
for (std::set<unsigned long>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
|
||||
if (myMeta.tracks.at(*it).type=="audio"){
|
||||
toRemove.insert(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//remove those from selectedtracks
|
||||
for (std::set<unsigned long>::iterator it = toRemove.begin(); it != toRemove.end(); it++){
|
||||
selectedTracks.erase(*it);
|
||||
//remove those from selectedtracks
|
||||
for (std::set<unsigned long>::iterator it = toRemove.begin(); it != toRemove.end(); it++){
|
||||
selectedTracks.erase(*it);
|
||||
}
|
||||
}
|
||||
|
||||
onHTTP();
|
||||
|
|
|
@ -53,11 +53,6 @@ namespace Mist {
|
|||
Output::onFail();
|
||||
}
|
||||
|
||||
/// The HTTP output is always ready to play
|
||||
bool OutHTTP::isReadyForPlay() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void OutHTTP::init(Util::Config * cfg){
|
||||
HTTPOutput::init(cfg);
|
||||
capa.removeMember("deps");
|
||||
|
@ -65,6 +60,7 @@ namespace Mist {
|
|||
capa["desc"] = "Generic HTTP handler, required for all other HTTP-based outputs.";
|
||||
capa["provides"] = "HTTP";
|
||||
capa["protocol"] = "http://";
|
||||
capa["codecs"][0u][0u].append("*");
|
||||
capa["url_match"].append("/crossdomain.xml");
|
||||
capa["url_match"].append("/clientaccesspolicy.xml");
|
||||
capa["url_match"].append("/$.html");
|
||||
|
@ -340,12 +336,11 @@ namespace Mist {
|
|||
}
|
||||
|
||||
std::string trackSources;//this string contains all track sources for MBR smil
|
||||
DTSC::Scan tracks = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("streams").getMember(streamName).getMember("meta").getMember("tracks");
|
||||
unsigned int track_ctr = tracks.getSize();
|
||||
for (unsigned int i = 0; i < track_ctr; ++i){//for all video tracks
|
||||
DTSC::Scan trk = tracks.getIndice(i);
|
||||
if (trk.getMember("type").asString() == "video"){
|
||||
trackSources += " <video src='"+ streamName + "?track=" + trk.getMember("trackid").asString() + "' height='" + trk.getMember("height").asString() + "' system-bitrate='" + trk.getMember("bps").asString() + "' width='" + trk.getMember("width").asString() + "' />\n";
|
||||
initialize();
|
||||
if (!myConn){return;}
|
||||
for (std::map<unsigned int, DTSC::Track>::iterator trit = myMeta.tracks.begin(); trit != myMeta.tracks.end(); trit++){
|
||||
if (trit->second.type == "video"){
|
||||
trackSources += " <video src='"+ streamName + "?track=" + JSON::Value((long long)trit->first).asString() + "' height='" + JSON::Value((long long)trit->second.height).asString() + "' system-bitrate='" + JSON::Value((long long)trit->second.bps).asString() + "' width='" + JSON::Value((long long)trit->second.width).asString() + "' />\n";
|
||||
}
|
||||
}
|
||||
configLock.post();
|
||||
|
@ -388,59 +383,41 @@ namespace Mist {
|
|||
if (config->getString("nostreamtext") != ""){
|
||||
json_resp["on_error"] = config->getString("nostreamtext");
|
||||
}
|
||||
initialize();
|
||||
if (!myConn){
|
||||
return;
|
||||
}
|
||||
IPC::semaphore configLock(SEM_CONF, O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
||||
static char liveSemName[NAME_BUFFER_SIZE];
|
||||
snprintf(liveSemName, NAME_BUFFER_SIZE, SEM_LIVE, streamName.c_str());
|
||||
IPC::semaphore metaLocker(liveSemName, O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
||||
bool metaLock = false;
|
||||
configLock.wait();
|
||||
IPC::sharedPage serverCfg(SHM_CONF, DEFAULT_CONF_PAGE_SIZE);
|
||||
DTSC::Scan strm = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("streams").getMember(streamName).getMember("meta");
|
||||
IPC::sharedPage streamIndex;
|
||||
if (!strm){
|
||||
configLock.post();
|
||||
//Stream metadata not found - attempt to start it
|
||||
if (Util::startInput(streamName)){
|
||||
char pageId[NAME_BUFFER_SIZE];
|
||||
snprintf(pageId, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, streamName.c_str());
|
||||
streamIndex.init(pageId, DEFAULT_STRM_PAGE_SIZE);
|
||||
if (streamIndex.mapped){
|
||||
metaLock = true;
|
||||
metaLocker.wait();
|
||||
strm = DTSC::Packet(streamIndex.mapped, streamIndex.len, true).getScan();
|
||||
}
|
||||
}
|
||||
if (!strm){
|
||||
//stream failed to start or isn't configured
|
||||
response += "// Stream isn't configured and/or couldn't be started. Sorry.\n";
|
||||
}
|
||||
configLock.wait();
|
||||
}
|
||||
DTSC::Scan prots = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("config").getMember("protocols");
|
||||
if (strm && prots){
|
||||
DTSC::Scan trcks = strm.getMember("tracks");
|
||||
unsigned int trcks_ctr = trcks.getSize();
|
||||
for (unsigned int i = 0; i < trcks_ctr; ++i){
|
||||
if (trcks.getIndice(i).getMember("width").asInt() > json_resp["width"].asInt()){
|
||||
json_resp["width"] = trcks.getIndice(i).getMember("width").asInt();
|
||||
}
|
||||
if (trcks.getIndice(i).getMember("height").asInt() > json_resp["height"].asInt()){
|
||||
json_resp["height"] = trcks.getIndice(i).getMember("height").asInt();
|
||||
if (prots){
|
||||
bool hasVideo = false;
|
||||
for (std::map<unsigned int, DTSC::Track>::iterator trit = myMeta.tracks.begin(); trit != myMeta.tracks.end(); trit++){
|
||||
if (trit->second.type == "video"){
|
||||
hasVideo = true;
|
||||
if (trit->second.width > json_resp["width"].asInt()){
|
||||
json_resp["width"] = trit->second.width;
|
||||
}
|
||||
if (trit->second.height > json_resp["height"].asInt()){
|
||||
json_resp["height"] = trit->second.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (json_resp["width"].asInt() < 1 || json_resp["height"].asInt() < 1){
|
||||
json_resp["width"] = 640ll;
|
||||
json_resp["height"] = 480ll;
|
||||
if (!hasVideo){json_resp["height"] = 20ll;}
|
||||
}
|
||||
if (strm.getMember("vod")){
|
||||
if (myMeta.vod){
|
||||
json_resp["type"] = "vod";
|
||||
}
|
||||
if (strm.getMember("live")){
|
||||
if (myMeta.live){
|
||||
json_resp["type"] = "live";
|
||||
}
|
||||
|
||||
// show ALL the meta datas!
|
||||
json_resp["meta"] = strm.asJSON();
|
||||
json_resp["meta"] = myMeta.toJSON();
|
||||
jsonForEach(json_resp["meta"]["tracks"], it) {
|
||||
if (it->isMember("lang")){
|
||||
(*it)["language"] = Encodings::ISO639::decode((*it)["lang"].asStringRef());
|
||||
|
@ -518,10 +495,6 @@ namespace Mist {
|
|||
}else{
|
||||
json_resp["error"] = "The specified stream is not available on this server.";
|
||||
}
|
||||
if (metaLock){
|
||||
metaLocker.post();
|
||||
}
|
||||
|
||||
configLock.post();
|
||||
configLock.close();
|
||||
if (rURL.substr(0, 6) != "/json_"){
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Mist {
|
|||
static bool listenMode();
|
||||
virtual void onFail();
|
||||
void onHTTP();
|
||||
bool isReadyForPlay();
|
||||
void sendIcon();
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue