Added ability to mask source tracks for processes
This commit is contained in:
parent
3db3a869ae
commit
36a1a88cb0
8 changed files with 58 additions and 9 deletions
17
lib/dtsc.cpp
17
lib/dtsc.cpp
|
@ -17,9 +17,12 @@ namespace DTSC{
|
|||
char Magic_Packet2[] = "DTP2";
|
||||
char Magic_Command[] = "DTCM";
|
||||
|
||||
// If non-zero, this variable will override any live jitter value calculations with the set value
|
||||
/// If non-zero, this variable will override any live jitter value calculations with the set value
|
||||
uint64_t veryUglyJitterOverride = 0;
|
||||
|
||||
/// The mask that the current process will use to check if a track is valid
|
||||
uint8_t trackValidMask = TRACK_VALID_ALL;
|
||||
|
||||
/// Default constructor for packets - sets a null pointer and invalid packet.
|
||||
Packet::Packet(){
|
||||
data = NULL;
|
||||
|
@ -1943,7 +1946,7 @@ namespace DTSC{
|
|||
uint64_t firstValid = trackList.getDeleted();
|
||||
uint64_t beyondLast = firstValid + trackList.getPresent();
|
||||
for (size_t i = firstValid; i < beyondLast; i++){
|
||||
if (trackList.getInt(trackValidField, i) == 1){res.insert(i);}
|
||||
if (trackList.getInt(trackValidField, i) & trackValidMask){res.insert(i);}
|
||||
if (trackList.getInt(trackSourceTidField, i) != INVALID_TRACK_ID &&
|
||||
std::string(trackList.getPointer(trackEncryptionField, i)) != ""){
|
||||
res.erase(trackList.getInt(trackSourceTidField, i));
|
||||
|
@ -1962,7 +1965,7 @@ namespace DTSC{
|
|||
uint64_t firstValid = trackList.getDeleted();
|
||||
uint64_t beyondLast = firstValid + trackList.getPresent();
|
||||
for (size_t i = firstValid; i < beyondLast; i++){
|
||||
if (trackList.getInt(trackValidField, i) == 1 && trackList.getInt(trackPidField, i) == pid){
|
||||
if (trackList.getInt(trackValidField, i) && trackList.getInt(trackPidField, i) == pid){
|
||||
res.insert(i);
|
||||
}
|
||||
}
|
||||
|
@ -1970,9 +1973,9 @@ namespace DTSC{
|
|||
}
|
||||
|
||||
/// Sets the track valid field to 1, also calling markUpdated()
|
||||
void Meta::validateTrack(size_t trackIdx){
|
||||
void Meta::validateTrack(size_t trackIdx, uint8_t validType){
|
||||
markUpdated(trackIdx);
|
||||
trackList.setInt(trackValidField, 1, trackIdx);
|
||||
trackList.setInt(trackValidField, validType, trackIdx);
|
||||
}
|
||||
|
||||
void Meta::removeEmptyTracks(){
|
||||
|
@ -2775,8 +2778,8 @@ namespace DTSC{
|
|||
|
||||
/// Returns true if the given track index is marked as valid. For this the track does not have to
|
||||
/// be loaded as well
|
||||
bool Meta::trackValid(size_t idx) const{
|
||||
if (idx > trackList.getPresent()){return false;}
|
||||
uint8_t Meta::trackValid(size_t idx) const{
|
||||
if (idx > trackList.getPresent()){return 0;}
|
||||
return trackList.getInt(trackValidField, idx);
|
||||
}
|
||||
|
||||
|
|
10
lib/dtsc.h
10
lib/dtsc.h
|
@ -22,6 +22,11 @@
|
|||
#define DTSC_ARR 0x0A
|
||||
#define DTSC_CON 0xFF
|
||||
|
||||
#define TRACK_VALID_EXT_HUMAN 1 //(assumed) humans connecting externally
|
||||
#define TRACK_VALID_EXT_PUSH 2 //(assumed) humans connecting externally
|
||||
#define TRACK_VALID_INT_PROCESS 4 //internal processes
|
||||
#define TRACK_VALID_ALL 0xFF //all of the above, default
|
||||
|
||||
// Increase this value every time the DTSH file format changes in an incompatible way
|
||||
// Changelog:
|
||||
// Version 0-2: Undocumented changes
|
||||
|
@ -32,6 +37,7 @@
|
|||
namespace DTSC{
|
||||
|
||||
extern uint64_t veryUglyJitterOverride;
|
||||
extern uint8_t trackValidMask;
|
||||
|
||||
///\brief This enum holds all possible datatypes for DTSC packets.
|
||||
enum datatype{
|
||||
|
@ -285,7 +291,7 @@ namespace DTSC{
|
|||
void minimalFrom(const Meta &src);
|
||||
|
||||
bool trackLoaded(size_t idx) const;
|
||||
bool trackValid(size_t idx) const;
|
||||
uint8_t trackValid(size_t idx) const;
|
||||
size_t trackCount() const;
|
||||
|
||||
size_t addCopy(size_t source);
|
||||
|
@ -411,7 +417,7 @@ namespace DTSC{
|
|||
std::set<size_t> getValidTracks(bool skipEmpty = false) const;
|
||||
std::set<size_t> getMySourceTracks(size_t pid) const;
|
||||
|
||||
void validateTrack(size_t trackIdx);
|
||||
void validateTrack(size_t trackIdx, uint8_t validType = TRACK_VALID_ALL);
|
||||
void removeEmptyTracks();
|
||||
void removeTrack(size_t trackIdx);
|
||||
void removeFirstKey(size_t trackIdx);
|
||||
|
|
|
@ -17,6 +17,7 @@ void handleUSR1(int signum, siginfo_t *sigInfo, void *ignore){
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
DTSC::trackValidMask = TRACK_VALID_EXT_HUMAN;
|
||||
Util::redirectLogsIfNeeded();
|
||||
Util::Config conf(argv[0]);
|
||||
mistOut::init(&conf);
|
||||
|
|
|
@ -103,6 +103,9 @@ namespace Mist{
|
|||
realTime = 0;
|
||||
}
|
||||
}
|
||||
if (isRecording() && DTSC::trackValidMask == TRACK_VALID_EXT_HUMAN){
|
||||
DTSC::trackValidMask = TRACK_VALID_EXT_PUSH;
|
||||
}
|
||||
/*LTS-END*/
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ void sourceThread(void *){
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
DTSC::trackValidMask = TRACK_VALID_INT_PROCESS;
|
||||
Util::Config config(argv[0]);
|
||||
JSON::Value capa;
|
||||
|
||||
|
@ -85,6 +86,12 @@ int main(int argc, char *argv[]){
|
|||
capa["name"] = "MKVExec";
|
||||
capa["desc"] = "Pipe MKV in, expect MKV out. You choose the executable in between yourself.";
|
||||
|
||||
capa["optional"]["masksource"]["name"] = "Make source track(s) unavailable for users";
|
||||
capa["optional"]["masksource"]["help"] = "If enabled, makes the source track(s) internal-only, so that external users and pushes cannot access them.";
|
||||
capa["optional"]["masksource"]["type"] = "boolean";
|
||||
capa["optional"]["masksource"]["default"] = false;
|
||||
|
||||
|
||||
capa["required"]["exec"]["name"] = "Executable";
|
||||
capa["required"]["exec"]["help"] = "What to executable to run on the stream data";
|
||||
capa["required"]["exec"]["type"] = "string";
|
||||
|
|
|
@ -60,6 +60,13 @@ namespace Mist{
|
|||
realTime = 0;
|
||||
};
|
||||
void sendHeader(){
|
||||
if (opt["masksource"].asBool()){
|
||||
for (std::map<size_t, Comms::Users>::iterator ti = userSelect.begin(); ti != userSelect.end(); ++ti){
|
||||
if (ti->first == INVALID_TRACK_ID){continue;}
|
||||
INFO_MSG("Masking source track %zu", ti->first);
|
||||
meta.validateTrack(ti->first, meta.trackValid(ti->first) & ~(TRACK_VALID_EXT_HUMAN | TRACK_VALID_EXT_PUSH));
|
||||
}
|
||||
}
|
||||
realTime = 0;
|
||||
OutEBML::sendHeader();
|
||||
};
|
||||
|
|
|
@ -69,6 +69,7 @@ void sourceThread(void *){
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
DTSC::trackValidMask = TRACK_VALID_INT_PROCESS;
|
||||
Util::Config config(argv[0]);
|
||||
JSON::Value capa;
|
||||
|
||||
|
@ -96,6 +97,12 @@ int main(int argc, char *argv[]){
|
|||
capa["desc"] = "Use a local FFMPEG installed binary to do encoding"; // description
|
||||
capa["sort"] = "n"; // sort the parameters by this key
|
||||
|
||||
capa["optional"]["masksource"]["name"] = "Make source track unavailable for users";
|
||||
capa["optional"]["masksource"]["help"] = "If enabled, makes the source track internal-only, so that external users and pushes cannot access it.";
|
||||
capa["optional"]["masksource"]["type"] = "boolean";
|
||||
capa["optional"]["masksource"]["default"] = false;
|
||||
|
||||
|
||||
capa["required"]["x-LSP-kind"]["name"] = "Input type"; // human readable name of option
|
||||
capa["required"]["x-LSP-kind"]["help"] = "The type of input to use"; // extra information
|
||||
capa["required"]["x-LSP-kind"]["type"] = "select"; // type of input field to use
|
||||
|
@ -404,6 +411,10 @@ namespace Mist{
|
|||
void EncodeOutputEBML::sendHeader(){
|
||||
realTime = 0;
|
||||
size_t idx = getMainSelectedTrack();
|
||||
if (opt["masksource"].asBool()){
|
||||
INFO_MSG("Masking source track %zu", idx);
|
||||
meta.validateTrack(idx, meta.trackValid(idx) & ~(TRACK_VALID_EXT_HUMAN | TRACK_VALID_EXT_PUSH));
|
||||
}
|
||||
res_x = M.getWidth(idx);
|
||||
res_y = M.getHeight(idx);
|
||||
Enc.setResolution(res_x, res_y);
|
||||
|
|
|
@ -58,6 +58,11 @@ namespace Mist{
|
|||
};
|
||||
virtual void initialSeek(){
|
||||
if (!meta){return;}
|
||||
if (opt["masksource"].asBool()){
|
||||
size_t mainTrack = getMainSelectedTrack();
|
||||
INFO_MSG("Masking source track %zu", mainTrack);
|
||||
meta.validateTrack(mainTrack, meta.trackValid(mainTrack) & ~(TRACK_VALID_EXT_HUMAN | TRACK_VALID_EXT_PUSH));
|
||||
}
|
||||
if (!meta.getLive() || opt["leastlive"].asBool()){
|
||||
INFO_MSG("Seeking to earliest point in stream");
|
||||
seek(0);
|
||||
|
@ -407,6 +412,7 @@ void sourceThread(void *){
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
DTSC::trackValidMask = TRACK_VALID_INT_PROCESS;
|
||||
Util::Config config(argv[0]);
|
||||
JSON::Value capa;
|
||||
|
||||
|
@ -433,6 +439,11 @@ int main(int argc, char *argv[]){
|
|||
capa["name"] = "Livepeer";
|
||||
capa["desc"] = "Use livepeer to transcode video.";
|
||||
|
||||
capa["optional"]["masksource"]["name"] = "Make source track unavailable for users";
|
||||
capa["optional"]["masksource"]["help"] = "If enabled, makes the source track internal-only, so that external users and pushes cannot access it.";
|
||||
capa["optional"]["masksource"]["type"] = "boolean";
|
||||
capa["optional"]["masksource"]["default"] = false;
|
||||
|
||||
capa["optional"]["sink"]["name"] = "Target stream";
|
||||
capa["optional"]["sink"]["help"] = "What stream the encoded track should be added to. Defaults "
|
||||
"to source stream. May contain variables.";
|
||||
|
|
Loading…
Add table
Reference in a new issue