Commit 4a6c42f736a3c546db976d433cbcea9fe778001a
1 parent
fc440c2c
Exists in
master
and in
2 other branches
[UPDATE] Analisar PCR do vídeo quando for TS.
Showing
7 changed files
with
66 additions
and
54 deletions
Show diff stats
Makefile
| ... | ... | @@ -171,4 +171,4 @@ svn: |
| 171 | 171 | @find -iname "*.swp" -exec rm {} \; |
| 172 | 172 | @find -iname "*.tmp" -exec rm {} \; |
| 173 | 173 | @find -iname "*.svn-base" -exec rm -r {} \; |
| 174 | - @find -iname "*.svn" -exec rm -r {} \; | |
| 175 | 174 | \ No newline at end of file |
| 175 | + @find -iname "*.svn" -exec rm -r {} ;\ | |
| 176 | 176 | \ No newline at end of file | ... | ... |
extratorSRT/src/extratorSRT.cpp
| ... | ... | @@ -76,11 +76,11 @@ void ExtratorSRT::Run(){ |
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | void ExtratorSRT::notifyPCRBase(uint64_t pcrbase){ |
| 79 | - DDPRINTF("PCRBase = %ld\n", pcrbase); | |
| 79 | + //DDPRINTF("PCRBase = %ld\n", pcrbase); | |
| 80 | 80 | this->pcr_base = pcrbase; |
| 81 | 81 | this->hasPCRBase = true; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | uint64_t ExtratorSRT::calcula_pts(double msec) { |
| 85 | 85 | return (uint64_t)(pcr_base + ((msec/1000) * 100000.0)); |
| 86 | -} | |
| 87 | 86 | \ No newline at end of file |
| 87 | +} | ... | ... |
input/src/include/inputFile.h
input/src/inputFile.cpp
| ... | ... | @@ -20,26 +20,26 @@ InputFile::~InputFile(){ |
| 20 | 20 | |
| 21 | 21 | void InputFile::initialize(){ |
| 22 | 22 | ifstream filein(path, ifstream::binary); |
| 23 | - | |
| 24 | - if (filein.is_open()) { | |
| 25 | - | |
| 26 | - char buffer [MAX_SIZE_PACKET]; | |
| 27 | - DPRINTF("[AGUARDE] Lendo arquivo...\n") | |
| 28 | - while (!filein.eof()) { | |
| 29 | - filein.read(buffer, MAX_SIZE_PACKET); | |
| 30 | - unsigned char* packet = (unsigned char*) buffer; | |
| 31 | - notificaOuvintes(packet); | |
| 23 | + | |
| 24 | + if (strstr(path, ".ts") != NULL) { | |
| 25 | + if (filein.is_open()) { | |
| 26 | + char buffer [MAX_SIZE_PACKET]; | |
| 27 | + DPRINTF("[AGUARDE] Lendo arquivo...\n") | |
| 28 | + while (!filein.eof()) { | |
| 29 | + filein.read(buffer, MAX_SIZE_PACKET); | |
| 30 | + unsigned char* packet = (unsigned char*) buffer; | |
| 31 | + notificaOuvintes(packet); | |
| 32 | + } | |
| 33 | + printf("\n"); | |
| 34 | + filein.close(); | |
| 35 | + //finished = true; | |
| 36 | + } else { | |
| 37 | + finished = true; | |
| 38 | + Util::Logger::Instance()->writeLog((char*) "[ERRO: inputFile.cpp] Arquivo de vídeo não encontrado."); | |
| 39 | + throw InputException("Falha ao abrir o arquivo de vídeo! Verifique se o mesmo existe."); | |
| 32 | 40 | } |
| 33 | - | |
| 34 | - printf("\n"); | |
| 35 | - filein.close(); | |
| 36 | - finished = true; | |
| 37 | - | |
| 38 | - } else { | |
| 39 | - finished = true; | |
| 40 | - Util::Logger::Instance()->writeLog((char*) "[ERRO: inputFile.cpp] Arquivo de vídeo não encontrado."); | |
| 41 | - throw InputException("Falha ao abrir o arquivo de vídeo! Verifique se o mesmo existe."); | |
| 42 | 41 | } |
| 42 | + finished = true; | |
| 43 | 43 | |
| 44 | 44 | } |
| 45 | 45 | ... | ... |
monitorPCR/src/include/monitor_pcr.h
| ... | ... | @@ -30,6 +30,13 @@ class MonitorPCR: public OuvinteInput { |
| 30 | 30 | void notifyListenersWithPCRBase(uint64_t pcrbase); |
| 31 | 31 | uint64_t getPCRBase(); |
| 32 | 32 | void chegouInput(unsigned char* packet); |
| 33 | + | |
| 34 | + /** | |
| 35 | + * Informa para o monitor o formato do vídeo que está sendo manipulado. | |
| 36 | + * Caso seja qualquer outro diferente de Transport Stream (TS), os componentes | |
| 37 | + * observadores devem receber a notificação de um valor de PCR padrão. | |
| 38 | + */ | |
| 39 | + void setFormatVideo(char* format); | |
| 33 | 40 | |
| 34 | 41 | private: |
| 35 | 42 | ... | ... |
monitorPCR/src/monitor_pcr.cpp
| 1 | 1 | #include <stdio.h> |
| 2 | 2 | #include <string.h> |
| 3 | +#include <locale> | |
| 3 | 4 | #include "monitor_pcr.h" |
| 4 | 5 | #define PCRBASE_PADRAO 1000000 |
| 5 | 6 | using namespace std; |
| ... | ... | @@ -17,52 +18,45 @@ MonitorPCR::~MonitorPCR(){ |
| 17 | 18 | DDDPRINTF("Monitor PCR finalized!\n"); |
| 18 | 19 | } |
| 19 | 20 | |
| 21 | + | |
| 20 | 22 | uint64_t MonitorPCR::getPCRBase(){ |
| 21 | 23 | return pcr_base; |
| 22 | 24 | } |
| 23 | 25 | |
| 24 | -void MonitorPCR::chegouInput(unsigned char* packet) { | |
| 25 | - | |
| 26 | - //printf("\n\n\n\n\n\nEXTENSAOOO---2: %s\n\n\n\n\n\n", extvideo); | |
| 27 | 26 | |
| 28 | - if (!find) { // verifica se o PCRBase já foi encontrado | |
| 29 | - //printf("\n>>> 2\n"); | |
| 27 | +void MonitorPCR::setFormatVideo(char* format) { | |
| 28 | + extvideo = format; | |
| 29 | +} | |
| 30 | 30 | |
| 31 | - if (strcmp(extvideo, (char*) "ts") == 0) { // se for TS procura nos pacotes | |
| 32 | - readPCRBase(packet); | |
| 33 | - //printf("\n>>> 3\n"); | |
| 34 | 31 | |
| 32 | +void MonitorPCR::chegouInput(unsigned char* packet) { | |
| 35 | 33 | |
| 36 | - } | |
| 37 | - else // outros formatos de vídeo, define o PCR padrão = 1000000 | |
| 34 | + if (!find) { // verifica se o PCRBase já foi encontrado | |
| 35 | + *extvideo = tolower(*extvideo); | |
| 36 | + if (strcmp(extvideo, (char*) "ts") == 0) { // se for TS procura nos pacotes | |
| 37 | + readPCRBase(packet); | |
| 38 | + } else { // outros formatos de vídeo, define o PCR padrão = 1000000 | |
| 38 | 39 | notifyListenersWithPCRBase((uint64_t) PCRBASE_PADRAO); |
| 39 | - } | |
| 40 | + find = true; | |
| 41 | + } | |
| 42 | + } | |
| 43 | + | |
| 40 | 44 | } |
| 41 | 45 | |
| 46 | + | |
| 42 | 47 | void MonitorPCR::readPCRBase(unsigned char* packet){ |
| 43 | 48 | |
| 44 | - // printf("\n>>> 0\n"); | |
| 45 | - | |
| 46 | 49 | if (packet[0] == 0x47 && !find){ |
| 47 | - //printf("\n>>> 1\n"); | |
| 48 | - if((((packet[1] & 0x1F) << 8) | packet[2]) != 0xFF){ | |
| 49 | - | |
| 50 | - int adaptation_field_control = ((packet[3] & 0x30) >> 4); | |
| 51 | - | |
| 52 | - if (adaptation_field_control == 2 || adaptation_field_control == 3) { | |
| 53 | - | |
| 54 | - int adaptation_field_length = packet[4]; | |
| 55 | - | |
| 56 | - if (adaptation_field_length > 0) { | |
| 57 | - | |
| 58 | - if (((packet[5] & 0x10) >> 4) == 1) { | |
| 59 | - | |
| 50 | + if((((packet[1] & 0x1F) << 8) | packet[2]) != 0xFF) { | |
| 51 | + int adaptation_field_control = ((packet[3] & 0x30) >> 4); | |
| 52 | + if (adaptation_field_control == 2 || adaptation_field_control == 3) { | |
| 53 | + int adaptation_field_length = packet[4]; | |
| 54 | + if (adaptation_field_length > 0) { | |
| 55 | + if (((packet[5] & 0x10) >> 4) == 1) { | |
| 60 | 56 | uint64_t program_clock_reference_base = (uint64_t) packet[6] << 25 | packet[7] << 17 | packet[8] << 9 |
| 61 | - | packet[9] << 1 | (packet[10] & 0x80) >> 7; | |
| 62 | - | |
| 57 | + | packet[9] << 1 | (packet[10] & 0x80) >> 7; | |
| 63 | 58 | notifyListenersWithPCRBase(program_clock_reference_base); |
| 64 | - find = true; | |
| 65 | - | |
| 59 | + find = true; | |
| 66 | 60 | } |
| 67 | 61 | } |
| 68 | 62 | } |
| ... | ... | @@ -79,4 +73,4 @@ void MonitorPCR::notifyListenersWithPCRBase(uint64_t pcrbase){ |
| 79 | 73 | for(list<ListenerMonitorPCRBase*>::iterator it = this->listeners->begin(); it != this->listeners->end(); it++){ |
| 80 | 74 | (*it)->notifyPCRBase(pcrbase); |
| 81 | 75 | } |
| 82 | -} | |
| 83 | 76 | \ No newline at end of file |
| 77 | +} | ... | ... |
servico/src/serviceWindowGenerationFromSRT.cpp
| ... | ... | @@ -100,8 +100,18 @@ void ServiceWindowGenerationFromSRT::initialize() { |
| 100 | 100 | */ |
| 101 | 101 | |
| 102 | 102 | inputfile = new InputFile(this->path_input); |
| 103 | - extratorSRT = new ExtratorSRT(); | |
| 104 | - monitor_pcr_base = new MonitorPCR(); | |
| 103 | + extratorSRT = new ExtratorSRT(); | |
| 104 | + | |
| 105 | + monitor_pcr_base = new MonitorPCR(); | |
| 106 | + | |
| 107 | + /* [Temporário]: como o monitor do PCR não estava encontrando a extensão do | |
| 108 | + vídeo, este está sendo analisado e infomado no trecho de código a seguir. | |
| 109 | + */ | |
| 110 | + if (strstr(path_input, "ts") != NULL) { | |
| 111 | + char* format_video = new char[3]; | |
| 112 | + strcpy(format_video, "ts"); | |
| 113 | + monitor_pcr_base->setFormatVideo(format_video); | |
| 114 | + } | |
| 105 | 115 | |
| 106 | 116 | monitor_pcr_base->addListenerPCRBase(extratorSRT); |
| 107 | 117 | ... | ... |