Improved audio/video/subtitle GET param selectors to no longer select tracks when unable to select requested tracks
This commit is contained in:
parent
b352b17de8
commit
0ee58e3096
1 changed files with 25 additions and 37 deletions
|
@ -420,12 +420,12 @@ namespace Mist{
|
||||||
if (trackVal == JSON::Value(trackNo).asString()){
|
if (trackVal == JSON::Value(trackNo).asString()){
|
||||||
//It's an integer number
|
//It's an integer number
|
||||||
if (!myMeta.tracks.count(trackNo)){
|
if (!myMeta.tracks.count(trackNo)){
|
||||||
WARN_MSG("Track %lld does not exist in stream, cannot select", trackNo);
|
INFO_MSG("Track %lld does not exist in stream, cannot select", trackNo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const DTSC::Track & Trk = myMeta.tracks[trackNo];
|
const DTSC::Track & Trk = myMeta.tracks[trackNo];
|
||||||
if (Trk.type != trackType && Trk.codec != trackType){
|
if (Trk.type != trackType && Trk.codec != trackType){
|
||||||
WARN_MSG("Track %lld is not %s (%s/%s), cannot select", trackNo, trackType.c_str(), Trk.type.c_str(), Trk.codec.c_str());
|
INFO_MSG("Track %lld is not %s (%s/%s), cannot select", trackNo, trackType.c_str(), Trk.type.c_str(), Trk.codec.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
INFO_MSG("Selecting %s track %lld (%s/%s)", trackType.c_str(), trackNo, Trk.type.c_str(), Trk.codec.c_str());
|
INFO_MSG("Selecting %s track %lld (%s/%s)", trackType.c_str(), trackNo, Trk.type.c_str(), Trk.codec.c_str());
|
||||||
|
@ -471,10 +471,20 @@ namespace Mist{
|
||||||
selectedTracks.clear();
|
selectedTracks.clear();
|
||||||
|
|
||||||
/*LTS-START*/
|
/*LTS-START*/
|
||||||
|
bool noSelAudio = false, noSelVideo = false, noSelSub = false;
|
||||||
//Then, select the tracks we've been asked to select.
|
//Then, select the tracks we've been asked to select.
|
||||||
if (targetParams.count("audio")){selectTrack("audio", targetParams["audio"]);}
|
if (targetParams.count("audio") && targetParams["audio"].size()){
|
||||||
if (targetParams.count("video")){selectTrack("video", targetParams["video"]);}
|
selectTrack("audio", targetParams["audio"]);
|
||||||
if (targetParams.count("subtitle")){selectTrack("subtitle", targetParams["subtitle"]);}
|
noSelAudio = true;
|
||||||
|
}
|
||||||
|
if (targetParams.count("video") && targetParams["video"].size()){
|
||||||
|
selectTrack("video", targetParams["video"]);
|
||||||
|
noSelVideo = true;
|
||||||
|
}
|
||||||
|
if (targetParams.count("subtitle") && targetParams["subtitle"].size()){
|
||||||
|
selectTrack("subtitle", targetParams["subtitle"]);
|
||||||
|
noSelSub = true;
|
||||||
|
}
|
||||||
/*LTS-END*/
|
/*LTS-END*/
|
||||||
|
|
||||||
//check which tracks don't actually exist
|
//check which tracks don't actually exist
|
||||||
|
@ -561,6 +571,11 @@ namespace Mist{
|
||||||
if (myMeta.live){
|
if (myMeta.live){
|
||||||
for (std::map<unsigned int, DTSC::Track>::reverse_iterator trit = myMeta.tracks.rbegin(); trit != myMeta.tracks.rend(); trit++){
|
for (std::map<unsigned int, DTSC::Track>::reverse_iterator trit = myMeta.tracks.rbegin(); trit != myMeta.tracks.rend(); trit++){
|
||||||
if ((!byType && trit->second.codec == strRef.substr(shift)) || (byType && trit->second.type == strRef.substr(shift)) || strRef.substr(shift) == "*"){
|
if ((!byType && trit->second.codec == strRef.substr(shift)) || (byType && trit->second.type == strRef.substr(shift)) || strRef.substr(shift) == "*"){
|
||||||
|
/*LTS-START*/
|
||||||
|
if (noSelAudio && trit->second.type == "audio"){continue;}
|
||||||
|
if (noSelVideo && trit->second.type == "video"){continue;}
|
||||||
|
if (noSelSub && (trit->second.type == "subtitle" || trit->second.codec == "subtitle")){continue;}
|
||||||
|
/*LTS-END*/
|
||||||
selectedTracks.insert(trit->first);
|
selectedTracks.insert(trit->first);
|
||||||
found = true;
|
found = true;
|
||||||
if (!multiSel){break;}
|
if (!multiSel){break;}
|
||||||
|
@ -569,6 +584,11 @@ namespace Mist{
|
||||||
}else{
|
}else{
|
||||||
for (std::map<unsigned int, DTSC::Track>::iterator trit = myMeta.tracks.begin(); trit != myMeta.tracks.end(); trit++){
|
for (std::map<unsigned int, DTSC::Track>::iterator trit = myMeta.tracks.begin(); trit != myMeta.tracks.end(); trit++){
|
||||||
if ((!byType && trit->second.codec == strRef.substr(shift)) || (byType && trit->second.type == strRef.substr(shift)) || strRef.substr(shift) == "*"){
|
if ((!byType && trit->second.codec == strRef.substr(shift)) || (byType && trit->second.type == strRef.substr(shift)) || strRef.substr(shift) == "*"){
|
||||||
|
/*LTS-START*/
|
||||||
|
if (noSelAudio && trit->second.type == "audio"){continue;}
|
||||||
|
if (noSelVideo && trit->second.type == "video"){continue;}
|
||||||
|
if (noSelSub && (trit->second.type == "subtitle" || trit->second.codec == "subtitle")){continue;}
|
||||||
|
/*LTS-END*/
|
||||||
selectedTracks.insert(trit->first);
|
selectedTracks.insert(trit->first);
|
||||||
found = true;
|
found = true;
|
||||||
if (!multiSel){break;}
|
if (!multiSel){break;}
|
||||||
|
@ -581,38 +601,6 @@ namespace Mist{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*LTS-START*/
|
|
||||||
//Finally, we strip anything unwanted that the above may have auto-selected.
|
|
||||||
toRemove.clear();
|
|
||||||
if (targetParams.count("subtitle") && targetParams["subtitle"] == "0"){
|
|
||||||
for (std::set<unsigned long>::iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
|
|
||||||
if (myMeta.tracks.at(*it).codec=="subtitle"){
|
|
||||||
toRemove.insert(*it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (targetParams.count("video") && targetParams["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 (targetParams.count("audio") && targetParams["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);
|
|
||||||
}
|
|
||||||
/*LTS-END*/
|
|
||||||
|
|
||||||
|
|
||||||
if (Util::Config::printDebugLevel >= DLVL_MEDIUM){
|
if (Util::Config::printDebugLevel >= DLVL_MEDIUM){
|
||||||
//print the selected tracks
|
//print the selected tracks
|
||||||
std::stringstream selected;
|
std::stringstream selected;
|
||||||
|
|
Loading…
Add table
Reference in a new issue