#include "serviceWindowGenerationFromREC.h" ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( char* path_video, int sublanguage, int position, int size, int transparency, char* id, int serviceType, char* rate) { setPathInput(path_video); setSubLanguage(sublanguage); setPosition(position); setSize(size); setTransparency(transparency); setServiceType(serviceType); setUserId(id); rec = new Recognize(path_video, id, rate); finish = false; DPRINTF("Done!\n"); } ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( char* path_video, int sublanguage, int position, int size, int transparency, char* id, int serviceType) { setPathInput(path_video); setSubLanguage(sublanguage); setPosition(position); setSize(size); setTransparency(transparency); setServiceType(serviceType); setUserId(id); rec = new Recognize(path_video, id); finish = false; DPRINTF("Done!\n"); } ServiceWindowGenerationFromREC::~ServiceWindowGenerationFromREC() { delete rec; DDDPRINTF("Service REC finished!\n"); } void ServiceWindowGenerationFromREC::notifyTranslator(unsigned char *text) { tradutor->traduz(text); } void ServiceWindowGenerationFromREC::notifyTextRecognized(unsigned char* text, int64_t pts) { adicionaPTS(pts); notifyTranslator(text); } bool ServiceWindowGenerationFromREC::isFinished(){ return finish; } void ServiceWindowGenerationFromREC::notifyEnd(int sentences_size) { DDPRINTF("Service REC recebeu: %d sentenças.\n", sentences_size); setSizeOfSubtitles(sentences_size); } void ServiceWindowGenerationFromREC::initialize() { rec->addListener(this); if (serviceType != SERVICE_TYPE_REC_ONLY_AUDIO){ inputfile = new InputFile(this->path_input); monitor_pcr_base = new MonitorPCR(); if (strstr(this->path_input, "ts") != NULL) { char* format_video = new char[3]; strcpy(format_video, "ts"); monitor_pcr_base->setFormatVideo(format_video); } monitor_pcr_base->addListenerPCRBase(rec); inputfile->addListener(monitor_pcr_base); try{ inputfile->initialize(); } catch(InputException ex){ throw ServiceException(ex.getMessage()); } } ServiceWindowGeneration::initialize(); try{ rec->initialize(); } catch(RecognizeException ex){ throw ServiceException(ex.getMessage()); } this->Start(); } void ServiceWindowGenerationFromREC::Run() { while (isRunning()) { usleep(200000); } finish = true; }