New keys approach in lib.

This commit is contained in:
Erik Zandvliet 2013-06-04 11:48:03 +02:00
parent e5ab3e3698
commit a2b70298fc

View file

@ -811,15 +811,21 @@ JSON::Value & DTSC::File::getJSON(){
bool DTSC::File::seek_time(int ms, int trackNo){ bool DTSC::File::seek_time(int ms, int trackNo){
seekPos tmpPos; seekPos tmpPos;
tmpPos.trackID = trackNo; tmpPos.trackID = trackNo;
tmpPos.seekTime = jsonbuffer["time"].asInt(); //if (jsonbuffer && ms > jsonbuffer["time"].asInt()){
tmpPos.seekPos = getBytePos(); // tmpPos.seekTime = jsonbuffer["time"].asInt();
for (int i = 0; i < metadata["tracks"][trackMapping[trackNo]]["keynum"].size(); i++){ // tmpPos.seekPos = getBytePos();
if (metadata["tracks"][trackMapping[trackNo]]["keytime"][i].asInt() > ms){ //}else{
tmpPos.seekTime = 0;
tmpPos.seekPos = 0;
// jsonbuffer["time"] = 0u;
//}
for (JSON::ArrIter keyIt = metadata["tracks"][trackMapping[trackNo]]["keys"].ArrBegin(); keyIt != metadata["tracks"][trackMapping[trackNo]]["keys"].ArrEnd(); keyIt++){
if ((*keyIt)["time"].asInt() > ms){
break; break;
} }
if (metadata["tracks"][trackMapping[trackNo]]["keytime"][i].asInt() > jsonbuffer["time"].asInt()){ if ((*keyIt)["time"].asInt() > jsonbuffer["time"].asInt()){
tmpPos.seekTime = metadata["tracks"][trackMapping[trackNo]]["keytime"][i].asInt(); tmpPos.seekTime = (*keyIt)["time"].asInt();
tmpPos.seekPos = metadata["tracks"][trackMapping[trackNo]]["keybpos"][i].asInt(); tmpPos.seekPos = (*keyIt)["bpos"].asInt();
} }
} }
bool foundPacket = false; bool foundPacket = false;
@ -835,7 +841,7 @@ bool DTSC::File::seek_time(int ms, int trackNo){
//check if packetID matches, if not, skip size + 8 bytes. //check if packetID matches, if not, skip size + 8 bytes.
int packSize = ntohl(((int*)header)[1]); int packSize = ntohl(((int*)header)[1]);
int packID = ntohl(((int*)header)[2]); int packID = ntohl(((int*)header)[2]);
if (packID != trackNo){ if (memcmp(header,Magic_Packet2,4) != 0 || packID != trackNo){
tmpPos.seekPos += 8 + packSize; tmpPos.seekPos += 8 + packSize;
continue; continue;
} }
@ -886,11 +892,15 @@ bool DTSC::File::atKeyframe(){
return true; return true;
} }
bool inHeader = false; bool inHeader = false;
for (JSON::ObjIter oIt = metadata["tracks"].ObjBegin(); oIt != metadata["tracks"].ObjEnd(); oIt++){ for (std::set<int>::iterator selectIt = selectedTracks.begin(); selectIt != selectedTracks.end(); selectIt++){
for (JSON::ArrIter aIt = oIt->second["keytime"].ArrBegin(); aIt != oIt->second["keytime"].ArrEnd(); aIt++){ for (JSON::ObjIter oIt = metadata["tracks"].ObjBegin(); oIt != metadata["tracks"].ObjEnd(); oIt++){
if ((*aIt).asInt() == jsonbuffer["time"].asInt()){ if (oIt->second["trackid"].asInt() == (*selectIt)){
inHeader = true; for (JSON::ArrIter aIt = oIt->second["keys"].ArrBegin(); aIt != oIt->second["keys"].ArrEnd(); aIt++){
break; if ((*aIt)["time"].asInt() == jsonbuffer["time"].asInt()){
inHeader = true;
break;
}
}
} }
} }
} }