From 75a420db2a3b052fdb2a2c6f8de3de1a56db27bd Mon Sep 17 00:00:00 2001 From: Thulinma Date: Thu, 23 Aug 2012 17:05:32 +0200 Subject: [PATCH] Fixed DTSC::File (now actually works) and updated DTSC metadata information in the documentation. --- lib/dtsc.cpp | 13 +++++++------ lib/dtsc.h | 8 ++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/dtsc.cpp b/lib/dtsc.cpp index 624e99bf..72042b22 100644 --- a/lib/dtsc.cpp +++ b/lib/dtsc.cpp @@ -520,9 +520,10 @@ DTSC::File::File(std::string filename, bool create){ /// Sets the file pointer to the first packet. std::string & DTSC::File::getHeader(){ fseek(F, 8, SEEK_SET); - strbuffer.reserve(headerSize); + strbuffer.resize(headerSize); fread((void*)strbuffer.c_str(), headerSize, 1, F); fseek(F, 8+headerSize, SEEK_SET); + return strbuffer; } /// (Re)writes the given string to the header area if the size is the same as the existing header. @@ -532,9 +533,9 @@ bool DTSC::File::writeHeader(std::string & header, bool force){ fprintf(stderr, "Could not overwrite header - not equal size\n"); return false; } - headerSize = header.size() - 8; - fseek(F, 0, SEEK_SET); - int ret = fwrite(header.c_str(), 8+headerSize, 1, F); + headerSize = header.size(); + fseek(F, 8, SEEK_SET); + int ret = fwrite(header.c_str(), headerSize, 1, F); fseek(F, 8+headerSize, SEEK_SET); return (ret == 1); } @@ -558,8 +559,8 @@ std::string & DTSC::File::getPacket(){ return strbuffer; } long packSize = ntohl(((uint32_t *)buffer)[0]); - strbuffer.reserve(packSize); - if (fread((void*)strbuffer.c_str(), packSize, 1, F)){ + strbuffer.resize(packSize); + if (fread((void*)strbuffer.c_str(), packSize, 1, F) != 1){ fprintf(stderr, "Could not read packet\n"); strbuffer = ""; return strbuffer; diff --git a/lib/dtsc.h b/lib/dtsc.h index c9205952..8a3815a6 100644 --- a/lib/dtsc.h +++ b/lib/dtsc.h @@ -13,15 +13,19 @@ /// Holds all DDVTECH Stream Container classes and parsers. -///Video: +///length (int, length in seconds, if available) +///video: /// - codec (string: H264, H263, VP6) /// - width (int, pixels) /// - height (int, pixels) /// - fpks (int, frames per kilosecond (FPS * 1000)) /// - bps (int, bytes per second) /// - init (string, init data) +/// - keyms (int, average ms per keyframe) +/// - keyvar (int, max ms per keyframe variance) +/// - keys (array of byte position ints - first is first keyframe, last is last keyframe, in between have ~equal spacing) /// -///Audio: +///audio: /// - codec (string: AAC, MP3) /// - rate (int, Hz) /// - size (int, bitsize)