#include "inputFile.h" InputFile::InputFile(char* path) { this->path = path; this->listeners = new list(); finish = false; PRINTL(util::_DEBUG, "Done!\n"); } InputFile::~InputFile(){ listeners->clear(); delete listeners; PRINTL(util::_DEBUG, "Input finalized!\n"); } void InputFile::initialize(){ ifstream filein(path, ifstream::binary); if (strstr(path, ".ts") != NULL) { if (filein.is_open()) { char buffer [MAX_SIZE_PACKET]; PRINTL(util::_INFO, "Lendo arquivo...\n"); while (!filein.eof()) { filein.read(buffer, MAX_SIZE_PACKET); unsigned char* packet = (unsigned char*) buffer; notifyListeners(packet); } printf("\n"); filein.close(); //finished = true; } else { finish = true; Logging::instance()->writeLog("inputFile.cpp : Arquivo de vídeo não encontrado."); throw InputException("Falha ao abrir o arquivo de vídeo! Verifique se o mesmo existe."); } } finish = true; } bool InputFile::isFinished(){ return this->finish; } void InputFile::addListener(ListenerInput* listener){ this->listeners->push_back(listener); } void InputFile::removeListener(ListenerInput* listener) { this->listeners->remove(listener); } void InputFile::notifyListeners(unsigned char* pack){ for(list::iterator it = this->listeners->begin(); it != this->listeners->end(); it++){ (*it)->notifyInput(pack); } }