#include "inputFile.h" InputFile::InputFile(char* path) { this->path = path; this->listeners = new list(); finish = false; DPRINTF("Done!\n"); } InputFile::~InputFile(){ listeners->clear(); delete listeners; DDDPRINTF("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]; DPRINTF("[AGUARDE] 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; Util::Logger::Instance()->writeLog((char*) "[ERRO: 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); } }