Skip at least some corruption in TS
This commit is contained in:
parent
98c50762e8
commit
0fff6f8773
6 changed files with 25 additions and 18 deletions
|
@ -142,15 +142,15 @@ namespace aac {
|
|||
if (syncWord != 0xfff){
|
||||
res << " Sync word " << std::hex << syncWord << " != fff!" << std::endl;
|
||||
}
|
||||
if (data[1] & 0x8 == 0x8){
|
||||
if ((data[1] & 0x8) == 0x8){
|
||||
res << " MPEG-2" << std::endl;
|
||||
}else{
|
||||
res << " MPEG-4" << std::endl;
|
||||
}
|
||||
if (data[1] & 0x6 != 0){
|
||||
if ((data[1] & 0x6) != 0){
|
||||
res << " Non-zero layer!" << std::endl;
|
||||
}
|
||||
if (data[1] & 0x1 == 0x0){
|
||||
if ((data[1] & 0x1) == 0x0){
|
||||
res << " CRC present" << std::endl;
|
||||
}
|
||||
res << " MPEG-4 audio object type: " << getAACProfile() << std::endl;
|
||||
|
@ -161,7 +161,7 @@ namespace aac {
|
|||
return res.str();
|
||||
}
|
||||
adts::operator bool() const{
|
||||
return hasSync() && len && len >= getHeaderSize() && getFrequency();
|
||||
return hasSync() && len && len >= getHeaderSize() && getFrequency() && getChannelCount() && getSampleCount();
|
||||
}
|
||||
bool adts::hasSync() const{
|
||||
return len && (((int)data[0] << 4) | ((data[1] >> 4) & 0x0F)) == 0xfff;
|
||||
|
|
|
@ -219,7 +219,7 @@ namespace DTSC {
|
|||
//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 (packData && packDataSize < 1){
|
||||
FAIL_MSG("Attempted to fill a packet with %lli bytes!", packDataSize);
|
||||
FAIL_MSG("Attempted to fill a packet with %lli bytes for timestamp %llu, track %llu!", packDataSize, packTime, packTrack);
|
||||
return;
|
||||
}
|
||||
unsigned int sendLen = 24 + (packOffset?17:0) + (packBytePos?15:0) + (isKeyframe?19:0) + packDataSize+11;
|
||||
|
|
|
@ -305,7 +305,7 @@ namespace TS{
|
|||
}
|
||||
std::deque<Packet> &inStream = pesStreams[tid];
|
||||
if (inStream.size() <= 1){
|
||||
HIGH_MSG("No PES packets to parse");
|
||||
FAIL_MSG("No PES packets to parse");
|
||||
return;
|
||||
}
|
||||
// Find number of packets before unit Start
|
||||
|
@ -325,7 +325,7 @@ namespace TS{
|
|||
}
|
||||
}
|
||||
if (!finished && curPack == inStream.end()){
|
||||
INFO_MSG("No PES packets to parse (%lu)", seenUnitStart[tid]);
|
||||
FAIL_MSG("No PES packets to parse (%lu)", seenUnitStart[tid]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -518,14 +518,18 @@ namespace TS{
|
|||
adtsInfo[tid] = adtsPack;
|
||||
}
|
||||
out.push_back(DTSC::Packet());
|
||||
out.back().genericFill(timeStamp + msRead, timeOffset, tid,
|
||||
adtsPack.getPayload(), adtsPack.getPayloadSize(), bPos,
|
||||
0);
|
||||
msRead += (adtsPack.getSampleCount() * 1000) / adtsPack.getFrequency();
|
||||
offsetInPes += adtsPack.getCompleteSize();
|
||||
if (adtsPack.getPayloadSize()){
|
||||
out.back().genericFill(timeStamp + msRead, timeOffset, tid,
|
||||
adtsPack.getPayload(), adtsPack.getPayloadSize(), bPos,
|
||||
0);
|
||||
offsetInPes += adtsPack.getCompleteSize();
|
||||
msRead += (adtsPack.getSampleCount() * 1000) / adtsPack.getFrequency();
|
||||
}else{
|
||||
offsetInPes++;
|
||||
}
|
||||
}else{
|
||||
/// \todo What about the case that we have an invalid start, going over the PES boundary?
|
||||
if (!adtsPack.hasSync()){
|
||||
if (!adtsPack){
|
||||
offsetInPes++;
|
||||
}else{
|
||||
// remainder, keep it, use it next time
|
||||
|
@ -815,7 +819,7 @@ namespace TS{
|
|||
|
||||
for (std::map<unsigned long, std::deque<DTSC::Packet> >::iterator it = outPackets.begin();
|
||||
it != outPackets.end(); it++){
|
||||
if (it->second.front().getTime() < packTime){
|
||||
if (it->second.size() && it->second.front().getTime() < packTime){
|
||||
packTrack = it->first;
|
||||
packTime = it->second.front().getTime();
|
||||
}
|
||||
|
|
|
@ -178,8 +178,8 @@ std::string AnalyserTS::printPES(const std::string &d, unsigned long PID){
|
|||
counter = 0;
|
||||
}
|
||||
res << std::hex << std::setw(2) << std::setfill('0') << (int)(d[i] & 0xff) << " ";
|
||||
counter++;
|
||||
if ((counter) % 32 == 31){res << std::endl;}
|
||||
counter++;
|
||||
}
|
||||
res << std::endl;
|
||||
}
|
||||
|
|
|
@ -273,6 +273,9 @@ namespace Mist {
|
|||
if (packet.getUnitStart()){
|
||||
while (tsStream.hasPacketOnEachTrack()) {
|
||||
tsStream.getEarliestPacket(headerPack);
|
||||
if (!headerPack){
|
||||
break;
|
||||
}
|
||||
if (!myMeta.tracks.count(headerPack.getTrackId()) || !myMeta.tracks[headerPack.getTrackId()].codec.size()) {
|
||||
tsStream.initializeMetadata(myMeta, headerPack.getTrackId());
|
||||
}
|
||||
|
@ -302,13 +305,13 @@ namespace Mist {
|
|||
void inputTS::getNext(bool smart) {
|
||||
INSANE_MSG("Getting next");
|
||||
thisPacket.null();
|
||||
bool hasPacket = (selectedTracks.size() == 1 ? tsStream.hasPacket(*selectedTracks.begin()) : tsStream.hasPacketOnEachTrack());
|
||||
bool hasPacket = (selectedTracks.size() == 1 ? tsStream.hasPacket(*selectedTracks.begin()) : tsStream.hasPacket());
|
||||
while (!hasPacket && !feof(inFile) && (inputProcess == 0 || Util::Procs::childRunning(inputProcess)) && config->is_active) {
|
||||
tsBuf.FromFile(inFile);
|
||||
if (selectedTracks.count(tsBuf.getPID())) {
|
||||
tsStream.parse(tsBuf, 0);//bPos == 0
|
||||
if (tsBuf.getUnitStart()){
|
||||
hasPacket = (selectedTracks.size() == 1 ? tsStream.hasPacket(*selectedTracks.begin()) : tsStream.hasPacketOnEachTrack());
|
||||
hasPacket = (selectedTracks.size() == 1 ? tsStream.hasPacket(*selectedTracks.begin()) : tsStream.hasPacket());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -906,7 +906,7 @@ namespace Mist{
|
|||
stats();
|
||||
}
|
||||
if (nProxy.curPage[tid].mapped[tmp.offset] == 0){
|
||||
FAIL_MSG("Track %d no data (key %u@%llu) - timeout", tid, getKeyForTime(tid, pos) + (getNextKey?1:0), tmp.offset);
|
||||
FAIL_MSG("Track %d no data (key %u@%u) - timeout", tid, getKeyForTime(tid, pos) + (getNextKey?1:0), tmp.offset);
|
||||
}else{
|
||||
return seek(tid, pos, getNextKey);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue