Small tweaks to various libraries and debugging messages.

This commit is contained in:
Thulinma 2016-07-06 11:16:17 +02:00
parent a071182da9
commit 1bf574acb8
6 changed files with 39 additions and 16 deletions

View file

@ -39,7 +39,7 @@ namespace Bit{
}
/// Retrieves a long in network order from the pointer p.
inline unsigned long btoh24(char * p) {
inline unsigned long btoh24(const char * p) {
return ((unsigned long)p[0] << 16) | ((unsigned long)p[1] << 8) | p[2];
}
@ -51,7 +51,7 @@ namespace Bit{
}
/// Retrieves a long long in network order from the pointer p.
inline unsigned long long btohll(char * p) {
inline unsigned long long btohll(const char * p) {
return ((unsigned long long)p[0] << 56) | ((unsigned long long)p[1] << 48) | ((unsigned long long)p[2] << 40) | ((unsigned long long)p[3] << 32) | ((unsigned long)p[4] << 24) | ((unsigned long)p[5] << 16) | ((unsigned long)p[6] << 8) | p[7];
}

View file

@ -211,6 +211,10 @@ namespace DTSC {
//bpos, if >= 0, adds 9 bytes (integer type) and 6 bytes (2+namelen)
//keyframe, if true, adds 9 bytes (integer type) and 10 bytes (2+namelen)
//data adds packDataSize+5 bytes (string type) and 6 bytes (2+namelen)
if (packDataSize < 1){
FAIL_MSG("Attempted to fill a packet with %lli bytes!", packDataSize);
return;
}
unsigned int sendLen = 24 + (packOffset?17:0) + (packBytePos?15:0) + (isKeyframe?19:0) + packDataSize+11;
resize(sendLen);
//set internal variables

View file

@ -10,7 +10,8 @@ namespace h264 {
std::deque<nalu::nalData> res;
int offset = 0;
while (offset < len){
//Make sure entire packet is within len
while (offset+5 < len && Bit::btohl(data + offset)+offset+4 <= len){
nalu::nalData entry;
entry.nalSize = Bit::btohl(data + offset);
entry.nalType = (data + offset)[4] & 0x1F;

View file

@ -230,18 +230,22 @@ namespace TS {
}
std::stringstream output;
output << std::string(indent, ' ') << "[PID " << getPID() << "|" << std::hex << getContinuityCounter() << std::dec << ": " << getDataSize() << "b ";
if (!getPID()){
output << "PAT";
}else{
if (pmt_pids.count(getPID())){
output << "PMT";
}else{
if (stream_pids.count(getPID())){
output << stream_pids[getPID()];
switch (getPID()){
case 0: output << "PAT"; break;
case 1: output << "CAT"; break;
case 2: output << "TSDT"; break;
case 0x1FFF: output << "Null"; break;
default:
if (pmt_pids.count(getPID())){
output << "PMT";
}else{
output << "Unknown";
if (stream_pids.count(getPID())){
output << stream_pids[getPID()];
}else{
output << "Unknown";
}
}
}
break;
}
output << "]";
if (getUnitStart()){
@ -649,6 +653,12 @@ namespace TS {
return ((int)(strBuf[loc]) << 24) | ((int)(strBuf[loc + 1]) << 16) | ((int)(strBuf[loc + 2]) << 8) | strBuf[loc + 3];
}
void ProgramAssociationTable::parsePIDs(){
for (int i = 0; i < getProgramCount(); i++) {
pmt_pids.insert(getProgramPID(i));
}
}
///This function prints a program association table,
///prints all values in a human readable format
///\param indent The indentation of the string printed as wanted by the user
@ -669,7 +679,6 @@ namespace TS {
output << std::string(indent + 4, ' ') << "[" << i + 1 << "] ";
output << "Program Number: " << getProgramNumber(i) << ", ";
output << (getProgramNumber(i) == 0 ? "Network" : "Program Map") << " PID: " << getProgramPID(i);
pmt_pids.insert(getProgramPID(i));
output << std::endl;
}
output << std::string(indent + 2, ' ') << "CRC32: " << std::hex << std::setw(8) << std::setfill('0') << std::uppercase << getCRC() << std::dec << std::endl;
@ -950,7 +959,11 @@ namespace TS {
while (entry) {
output << std::string(indent + 4, ' ');
stream_pids[entry.getElementaryPid()] = entry.getCodec() + std::string(" ") + entry.getStreamTypeString();
output << "Stream " << entry.getElementaryPid() << ": " << stream_pids[entry.getElementaryPid()] << " (" << entry.getStreamType() << "), InfoLen = " << entry.getESInfoLength() << std::endl;
output << "Stream " << entry.getElementaryPid() << ": " << stream_pids[entry.getElementaryPid()] << " (" << entry.getStreamType() << "), Info (" << entry.getESInfoLength() << ") = ";
for (unsigned int i = 0; i<entry.getESInfoLength(); ++i){
output << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (int)entry.getESInfo()[i] << std::dec;
}
output << std::endl;
entry.advance();
}
output << std::string(indent + 2, ' ') << "CRC32: " << std::hex << std::setw(8) << std::setfill('0') << std::uppercase << getCRC() << std::dec << std::endl;

View file

@ -97,6 +97,7 @@ namespace TS {
short getProgramNumber(short index) const;
short getProgramPID(short index) const;
int getCRC() const;
void parsePIDs();
std::string toPrettyString(size_t indent) const;
};

View file

@ -122,12 +122,16 @@ namespace Mist {
return 0;
}
parseHeader();
MEDIUM_MSG("Header parsed, %lu tracks", myMeta.tracks.size());
if (!streamName.size()) {
MEDIUM_MSG("Starting convert");
convert();
} else if (!needsLock()) {
MEDIUM_MSG("Starting stream");
stream();
}else{
MEDIUM_MSG("Starting serve");
serve();
}
return 0;