Fixed DTSC::Stream::parsePacket with string buffers instead of sockets.
This commit is contained in:
parent
64c97d15a3
commit
68f44c3d29
1 changed files with 9 additions and 12 deletions
19
lib/dtsc.cpp
19
lib/dtsc.cpp
|
@ -43,25 +43,15 @@ bool DTSC::Stream::parsePacket(std::string & buffer){
|
|||
uint32_t len;
|
||||
static bool syncing = false;
|
||||
if (buffer.length() > 8){
|
||||
int version = 0;
|
||||
if (memcmp(buffer.c_str(), DTSC::Magic_Packet, 4) == 0){
|
||||
version = 1;
|
||||
}
|
||||
if (memcmp(buffer.c_str(), DTSC::Magic_Packet2, 4) == 0){
|
||||
version = 2;
|
||||
}
|
||||
if (memcmp(buffer.c_str(), DTSC::Magic_Header, 4) == 0){
|
||||
len = ntohl(((uint32_t *)buffer.c_str())[1]);
|
||||
if (buffer.length() < len + 8){
|
||||
return false;
|
||||
}
|
||||
unsigned int i = 0;
|
||||
if (version == 1){
|
||||
metadata = JSON::fromDTMI((unsigned char*)buffer.c_str() + 8, len, i);
|
||||
}else{
|
||||
metadata = JSON::fromDTMI2(buffer.substr(8));
|
||||
}
|
||||
metadata.removeMember("moreheader");
|
||||
metadata.netPrepare();
|
||||
trackMapping.clear();
|
||||
if (metadata.isMember("tracks")){
|
||||
for (JSON::ObjIter it = metadata["tracks"].ObjBegin(); it != metadata["tracks"].ObjEnd(); it++){
|
||||
|
@ -73,6 +63,13 @@ bool DTSC::Stream::parsePacket(std::string & buffer){
|
|||
return false;
|
||||
}
|
||||
}
|
||||
int version = 0;
|
||||
if (memcmp(buffer.c_str(), DTSC::Magic_Packet, 4) == 0){
|
||||
version = 1;
|
||||
}
|
||||
if (memcmp(buffer.c_str(), DTSC::Magic_Packet2, 4) == 0){
|
||||
version = 2;
|
||||
}
|
||||
if (version){
|
||||
len = ntohl(((uint32_t *)buffer.c_str())[1]);
|
||||
if (buffer.length() < len + 8){
|
||||
|
|
Loading…
Add table
Reference in a new issue