#include "serviceWindowGenerationFromREC.h" using namespace std; ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( char* path_video, int sublanguage, int position, int size, int transparency, int _serviceType) { path_input = path_video; setPosition(position); setSize(size); setTransparency(transparency); setSubLanguage(sublanguage); setServiceType(_serviceType); } ServiceWindowGenerationFromREC::~ServiceWindowGenerationFromREC() { if (rec) delete rec; } void ServiceWindowGenerationFromREC::initialize() { rec = new Recognize(path_input); rec->addListener(this); ServiceWindowGeneration::initialize(); rec->initializeRecognition(); this->Start(); } void ServiceWindowGenerationFromREC::notifyTextRecognized(unsigned char* text, int64_t pts) { printf("\nServiceWindowGenerationFromREC -> notifyTextRecognized -> %s\n", text); char option = getRunningOption(); if (option == '3') { notifySynchWithoutTranslator(text, pts); } else { adicionaPTS(pts); notifyTranslator(text); } } void ServiceWindowGenerationFromREC::notifyTranslator(unsigned char *text) { printf("\nnotifyTranslator -> %s\n", text); tradutor->traduz(text); } void ServiceWindowGenerationFromREC::notifySynchWithoutTranslator(unsigned char *text, int64_t pts) { printf("\nnotifySynchWithoutTranslator -> %s\n", text); char* pch = strtok((char*) text, " "); while (pch != NULL) { string pch_string = (string) pch; sincronizador->recebeglosa(pch_string, pts); pch = strtok(NULL, " "); } } void ServiceWindowGenerationFromREC::Run() { while (!finish) { if (rec->isFinished()) { this->finish = true; if (getRunningOption() == '3') { sincronizador->encerrouLegendas(); } } sleep(5); } printf("Saiu do ServiceWindowGenerationFromREC::Run()\n"); }