Added ability to mask source tracks for processes

This commit is contained in:
Thulinma 2020-06-05 22:27:05 +02:00
parent 3db3a869ae
commit 36a1a88cb0
8 changed files with 58 additions and 9 deletions

View file

@ -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);
}

View file

@ -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);