extratorVTT.h
1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* \file extratorVTT.h
*
* \author Wesnydy Ribeiro <wesnydy@lavid.ufpb.br>
* \date 2015
*/
#ifndef EXTRATORVTT_H
#define EXTRATORVTT_H
#include <list>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "jthread.h"
#include "extrator.h"
#include "subtitle.h"
#include "listenerSub.h"
#include <iostream>
#define SIGNATURE "WEBVTT"
#define TARGET_TIME "-->"
#define LESS_THAN "<"
#define MORE_THAN ">"
#define SIZE_SCAPE 1
using namespace std;
using namespace sndesc;
using namespace jthread;
/** \brief Classe que implementa o extrator de legenda.
*
* Instâncias desta classe extraem o conteúdo de
* arquivos webVTT.
*
* \headerfile extrator/src/include/extratorVTT.h
*/
class ExtratorVTT: public Extrator, public Thread {
public:
/** Construtor */
ExtratorVTT();
/** Destrutor */
~ExtratorVTT();
/** Define o path do arquivo de entrada.
*
* \param path O path do arquivo.
*/
void setFilePath(char* path);
/** Adiciona ouvintes do extratorVTT.
*
* \param listener O ouvinte a ser registrado.
*/
void addListener(ListenerSub* listener);
/** Inicializa o processo de extração da legendas.
*
* \exception ExtratorException caso o arquivo de legenda não seja encontrado.
*/
void initialize();
/** Indica o fim do processo de extração das legendas.
*
* \return O status do do processo.
*/
bool isFinished();
/** Este método é chamado quando a Thread for iniciada. */
void Run();
private:
Subtitle* subtitle;
list<ListenerSub*> *listeners;
int64_t seekPos;
bool hasNextCue;
void notifyEndExtraction(int size);
void notifyListeners(unsigned char* subtitle, uint64_t pts);
Subtitle* nextCue();
void encodingfiletoUTF8();
string formatText(string line);
int64_t str_to_time(string str_time);
};
#endif /* EXTRATORVTT_H */