Added RIFF analyser
This commit is contained in:
parent
945e6f2d1a
commit
b7d1d38fb4
6 changed files with 350 additions and 0 deletions
44
src/analysers/analyser_riff.cpp
Normal file
44
src/analysers/analyser_riff.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include "analyser_riff.h"
|
||||
#include <iostream>
|
||||
#include <mist/riff.h>
|
||||
|
||||
void AnalyserRIFF::init(Util::Config &conf){
|
||||
Analyser::init(conf);
|
||||
}
|
||||
|
||||
AnalyserRIFF::AnalyserRIFF(Util::Config &conf) : Analyser(conf){
|
||||
curPos = prePos = 0;
|
||||
}
|
||||
|
||||
bool AnalyserRIFF::parsePacket(){
|
||||
prePos = curPos;
|
||||
// Read in smart bursts until we have enough data
|
||||
while (isOpen() && dataBuffer.size() < neededBytes()){
|
||||
uint64_t needed = neededBytes();
|
||||
dataBuffer.reserve(needed);
|
||||
for (uint64_t i = dataBuffer.size(); i < needed; ++i){
|
||||
dataBuffer += std::cin.get();
|
||||
++curPos;
|
||||
if (!std::cin.good()){dataBuffer.erase(dataBuffer.size() - 1, 1);}
|
||||
}
|
||||
}
|
||||
|
||||
if (dataBuffer.size() < 8){return false;}
|
||||
|
||||
RIFF::Chunk C(dataBuffer.data(), dataBuffer.size());
|
||||
INFO_MSG("Read a chunk at position %d", prePos);
|
||||
if (detail >= 2){C.toPrettyString(std::cout);}
|
||||
///\TODO update mediaTime with the current timestamp
|
||||
if (C){
|
||||
dataBuffer.erase(0, C.getPayloadSize()+8);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Calculates how many bytes we need to read a whole box.
|
||||
uint64_t AnalyserRIFF::neededBytes(){
|
||||
if (dataBuffer.size() < 8){return 8;}
|
||||
return RIFF::Chunk(dataBuffer.data()).getPayloadSize()+8;
|
||||
}
|
||||
|
15
src/analysers/analyser_riff.h
Normal file
15
src/analysers/analyser_riff.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include "analyser.h"
|
||||
|
||||
class AnalyserRIFF : public Analyser{
|
||||
public:
|
||||
AnalyserRIFF(Util::Config &conf);
|
||||
static void init(Util::Config &conf);
|
||||
bool parsePacket();
|
||||
|
||||
private:
|
||||
uint64_t neededBytes();
|
||||
std::string dataBuffer;
|
||||
uint64_t curPos;
|
||||
uint64_t prePos;
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue