serviceWindowGenerationFromText.cpp 1.38 KB
#include "serviceWindowGenerationFromText.h"

ServiceWindowGenerationFromText::ServiceWindowGenerationFromText (
		char* path_file, char* username, int transp, int serviceType, char* client_type) {

	setPathInput(path_file);
	setClientType(client_type);
	setUserId(username);
    setTransparency(transp);
    setServiceType(serviceType);
	alive = true;
    DPRINTF("Done!\n");
}

ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() {
	delete extratorTXT;
	DDDPRINTF("Service Text finished!\n");
}

void ServiceWindowGenerationFromText::initialize() {
	DDPRINTF("Service Text Initialize.\n");

    extratorTXT = new ExtratorTXT();	    
    extratorTXT->addListener(this);
    extratorTXT->setFilePath(getPathInput());
    
    ServiceWindowGeneration::initialize();

    try{
  	    extratorTXT->initialize();            
    }catch(ExtratorTxtException ex){
        throw ServiceException(ex.getMessage());
    }
    this->Start();
}

void ServiceWindowGenerationFromText::notifyEnd(int line_size) {
    DDPRINTF("Service SRT recebeu: %d linhas.\n", line_size);
    setSizeOfSubtitles(line_size);
}

void ServiceWindowGenerationFromText::notificaTradutor(unsigned char* line) {
	tradutor->traduz(line);
}

bool ServiceWindowGenerationFromText::isAlive() {
	return alive;
}

void ServiceWindowGenerationFromText::Run() {	
	while (isRunning()) {	  
	    usleep(200000); //200ms
	}	
	alive = false;
}