diff --git a/Controller.cpp b/Controller.cpp index c4121ac..4bfcf67 100644 --- a/Controller.cpp +++ b/Controller.cpp @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "TranscoderPacket.h" #include "Controller.h" @@ -414,11 +416,28 @@ void CController::ReadDevice(std::shared_ptr device, EAmbeType type) // the socket will automatically close after sending #ifdef DEBUG Dump(spPacket, "Completed Transcoder packet"); + AppendWave(spPacket); #endif } } } +void CController::AppendWave(const std::shared_ptr packet) const +{ + std::stringstream sstr; + sstr << std::hex << ntohs(packet->GetStreamId()) << ".raw"; + std::ofstream pcmfile(sstr.str(), std::ofstream::binary); + if (pcmfile.good()) + { + for (unsigned int i=0; i<160; i++) + pcmfile << packet->GetAudio()[i]; + + pcmfile.close(); + } + else + std::cerr << "could not open pcm file " << sstr.str(); +} + #ifdef DEBUG void CController::Dump(const std::shared_ptr p, const std::string &title) const { diff --git a/Controller.h b/Controller.h index 827c7b6..91f32fb 100644 --- a/Controller.h +++ b/Controller.h @@ -58,6 +58,7 @@ protected: void ReadDevice(std::shared_ptr dv3003, EAmbeType type); void AddFDSet(int &max, int newfd, fd_set *set) const; #ifdef DEBUG + void AppendWave(const std::shared_ptr packet) const; void Dump(const std::shared_ptr packet, const std::string &title) const; #endif };