Small tweaks to various libraries and debugging messages.
This commit is contained in:
parent
a071182da9
commit
1bf574acb8
6 changed files with 39 additions and 16 deletions
|
@ -39,7 +39,7 @@ namespace Bit{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves a long in network order from the pointer p.
|
/// 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];
|
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.
|
/// 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];
|
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];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,10 @@ namespace DTSC {
|
||||||
//bpos, if >= 0, adds 9 bytes (integer type) and 6 bytes (2+namelen)
|
//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)
|
//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)
|
//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;
|
unsigned int sendLen = 24 + (packOffset?17:0) + (packBytePos?15:0) + (isKeyframe?19:0) + packDataSize+11;
|
||||||
resize(sendLen);
|
resize(sendLen);
|
||||||
//set internal variables
|
//set internal variables
|
||||||
|
|
|
@ -10,7 +10,8 @@ namespace h264 {
|
||||||
std::deque<nalu::nalData> res;
|
std::deque<nalu::nalData> res;
|
||||||
|
|
||||||
int offset = 0;
|
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;
|
nalu::nalData entry;
|
||||||
entry.nalSize = Bit::btohl(data + offset);
|
entry.nalSize = Bit::btohl(data + offset);
|
||||||
entry.nalType = (data + offset)[4] & 0x1F;
|
entry.nalType = (data + offset)[4] & 0x1F;
|
||||||
|
|
|
@ -230,9 +230,12 @@ namespace TS {
|
||||||
}
|
}
|
||||||
std::stringstream output;
|
std::stringstream output;
|
||||||
output << std::string(indent, ' ') << "[PID " << getPID() << "|" << std::hex << getContinuityCounter() << std::dec << ": " << getDataSize() << "b ";
|
output << std::string(indent, ' ') << "[PID " << getPID() << "|" << std::hex << getContinuityCounter() << std::dec << ": " << getDataSize() << "b ";
|
||||||
if (!getPID()){
|
switch (getPID()){
|
||||||
output << "PAT";
|
case 0: output << "PAT"; break;
|
||||||
}else{
|
case 1: output << "CAT"; break;
|
||||||
|
case 2: output << "TSDT"; break;
|
||||||
|
case 0x1FFF: output << "Null"; break;
|
||||||
|
default:
|
||||||
if (pmt_pids.count(getPID())){
|
if (pmt_pids.count(getPID())){
|
||||||
output << "PMT";
|
output << "PMT";
|
||||||
}else{
|
}else{
|
||||||
|
@ -242,6 +245,7 @@ namespace TS {
|
||||||
output << "Unknown";
|
output << "Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
output << "]";
|
output << "]";
|
||||||
if (getUnitStart()){
|
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];
|
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,
|
///This function prints a program association table,
|
||||||
///prints all values in a human readable format
|
///prints all values in a human readable format
|
||||||
///\param indent The indentation of the string printed as wanted by the user
|
///\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 << std::string(indent + 4, ' ') << "[" << i + 1 << "] ";
|
||||||
output << "Program Number: " << getProgramNumber(i) << ", ";
|
output << "Program Number: " << getProgramNumber(i) << ", ";
|
||||||
output << (getProgramNumber(i) == 0 ? "Network" : "Program Map") << " PID: " << getProgramPID(i);
|
output << (getProgramNumber(i) == 0 ? "Network" : "Program Map") << " PID: " << getProgramPID(i);
|
||||||
pmt_pids.insert(getProgramPID(i));
|
|
||||||
output << std::endl;
|
output << std::endl;
|
||||||
}
|
}
|
||||||
output << std::string(indent + 2, ' ') << "CRC32: " << std::hex << std::setw(8) << std::setfill('0') << std::uppercase << getCRC() << std::dec << 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) {
|
while (entry) {
|
||||||
output << std::string(indent + 4, ' ');
|
output << std::string(indent + 4, ' ');
|
||||||
stream_pids[entry.getElementaryPid()] = entry.getCodec() + std::string(" ") + entry.getStreamTypeString();
|
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();
|
entry.advance();
|
||||||
}
|
}
|
||||||
output << std::string(indent + 2, ' ') << "CRC32: " << std::hex << std::setw(8) << std::setfill('0') << std::uppercase << getCRC() << std::dec << std::endl;
|
output << std::string(indent + 2, ' ') << "CRC32: " << std::hex << std::setw(8) << std::setfill('0') << std::uppercase << getCRC() << std::dec << std::endl;
|
||||||
|
|
|
@ -97,6 +97,7 @@ namespace TS {
|
||||||
short getProgramNumber(short index) const;
|
short getProgramNumber(short index) const;
|
||||||
short getProgramPID(short index) const;
|
short getProgramPID(short index) const;
|
||||||
int getCRC() const;
|
int getCRC() const;
|
||||||
|
void parsePIDs();
|
||||||
std::string toPrettyString(size_t indent) const;
|
std::string toPrettyString(size_t indent) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -122,12 +122,16 @@ namespace Mist {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
parseHeader();
|
parseHeader();
|
||||||
|
MEDIUM_MSG("Header parsed, %lu tracks", myMeta.tracks.size());
|
||||||
|
|
||||||
if (!streamName.size()) {
|
if (!streamName.size()) {
|
||||||
|
MEDIUM_MSG("Starting convert");
|
||||||
convert();
|
convert();
|
||||||
} else if (!needsLock()) {
|
} else if (!needsLock()) {
|
||||||
|
MEDIUM_MSG("Starting stream");
|
||||||
stream();
|
stream();
|
||||||
}else{
|
}else{
|
||||||
|
MEDIUM_MSG("Starting serve");
|
||||||
serve();
|
serve();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue