diff --git a/lib/ts_stream.cpp b/lib/ts_stream.cpp index 54763c9d..db1c45ac 100644 --- a/lib/ts_stream.cpp +++ b/lib/ts_stream.cpp @@ -1135,6 +1135,13 @@ namespace TS{ } } MEDIUM_MSG("Initialized track %zu as %s %s", idx, codec.c_str(), type.c_str()); + if (tid != INVALID_TRACK_ID){return;} + } + if (tid != INVALID_TRACK_ID){ + WARN_MSG("Could not init track %zu!", tid); + for (std::map::const_iterator it = pidToCodec.begin(); it != pidToCodec.end(); it++){ + INFO_MSG("Track %zu (%" PRIu32 ") no match", it->first, it->second); + } } } diff --git a/src/input/input_hls.cpp b/src/input/input_hls.cpp index 645b712f..be2eb3bd 100644 --- a/src/input/input_hls.cpp +++ b/src/input/input_hls.cpp @@ -324,7 +324,12 @@ namespace Mist{ } if (currBuf->size() < offset + 188 + 188){return false;} } - offset += 188; + // First packet is at offset 0, not 188. Skip increment for this one. + if (!firstPacket){ + offset += 188; + }else{ + firstPacket = false; + } packetPtr = *currBuf + offset; if (!packetPtr || packetPtr[0] != 0x47){ FAIL_MSG("Not a valid TS packet: first byte %" PRIu8, packetPtr?(uint8_t)packetPtr[0]:0); @@ -354,14 +359,16 @@ namespace Mist{ hexIvec.c_str()); offset = 0; + firstPacket = true; buffered = segBufs.count(entry.filename); if (!buffered){ + INFO_MSG("Reading non-cache: %s", entry.filename.c_str()); if (!segDL.open(entry.filename)){ FAIL_MSG("Could not open %s", entry.filename.c_str()); return false; } if (!segDL){return false;} - if (segBufs.size() > 60){ + if (segBufs.size() > 30){ segBufs.erase(segBufAccs.back()); segBufAccs.pop_back(); } @@ -848,7 +855,7 @@ namespace Mist{ } entId++; allowRemap = true; - while (!segDowner.atEnd() && config->is_active){ + while ((!segDowner.atEnd() || tsStream.hasPacket()) && config->is_active){ // Wait for packets on each track to make sure the offset is set based on the earliest packet hasPacket = tsStream.hasPacketOnEachTrack() || (segDowner.atEnd() && tsStream.hasPacket()); if (hasPacket){ @@ -868,7 +875,7 @@ namespace Mist{ // keyframe data exists, so always add 19 bytes keyframedata. uint32_t packOffset = headerPack.hasMember("offset") ? headerPack.getInt("offset") : 0; size_t packSendSize = 24 + (packOffset ? 17 : 0) + (entId >= 0 ? 15 : 0) + 19 + dataLen + 11; - VERYHIGH_MSG("Adding packet (%zuB) at %" PRIu64 " with an offset of %" PRIu32 " on track %zu", dataLen, packetTime, packOffset, idx); + DONTEVEN_MSG("Adding packet (%zuB) at %" PRIu64 " with an offset of %" PRIu32 " on track %zu", dataLen, packetTime, packOffset, idx); meta.update(packetTime, packOffset, idx, dataLen, entId, headerPack.hasMember("keyframe"), packSendSize); tsStream.getEarliestPacket(headerPack); } @@ -884,7 +891,7 @@ namespace Mist{ DTSC::Packet headerPack; tsStream.getEarliestPacket(headerPack); while (headerPack){ - int tmpTrackId = headerPack.getTrackId(); + size_t tmpTrackId = headerPack.getTrackId(); uint64_t packetId = getPacketID(pListIt->first, tmpTrackId); uint64_t packetTime = getPacketTime(headerPack.getTime(), tmpTrackId, pListIt->first, entryIt->mUTC); size_t idx = M.trackIDToIndex(packetId, getpid()); @@ -897,7 +904,7 @@ namespace Mist{ // keyframe data exists, so always add 19 bytes keyframedata. uint32_t packOffset = headerPack.hasMember("offset") ? headerPack.getInt("offset") : 0; size_t packSendSize = 24 + (packOffset ? 17 : 0) + (entId >= 0 ? 15 : 0) + 19 + dataLen + 11; - VERYHIGH_MSG("Adding packet (%zuB) at %" PRIu64 " with an offset of %" PRIu32 " on track %zu", dataLen, packetTime, packOffset, idx); + DONTEVEN_MSG("Adding packet (%zuB) at %" PRIu64 " with an offset of %" PRIu32 " on track %zu", dataLen, packetTime, packOffset, idx); meta.update(packetTime, packOffset, idx, dataLen, entId, headerPack.hasMember("keyframe"), packSendSize); tsStream.getEarliestPacket(headerPack); } diff --git a/src/input/input_hls.h b/src/input/input_hls.h index 897514aa..f160433f 100644 --- a/src/input/input_hls.h +++ b/src/input/input_hls.h @@ -65,6 +65,7 @@ namespace Mist{ bool encrypted; bool buffered; size_t offset; + bool firstPacket; Util::ResizeablePointer outData; Util::ResizeablePointer * currBuf; size_t encOffset;