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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "librascontrolmessage.h"
namespace Codificador {
LibrasControlMessage::LibrasControlMessage() : LibrasControlSection() {
type = LIBRAS_MGM_TYPE;
messagelength = 11;
//resolution = 1;
timecontrolflag = 0;
//dictionaryversion = 1;
privatedatalength = 0;
privateDataBytes = NULL;
//dph = 0;
//dfh = 0;
//dfw = 0;
//dpv = 0;
}
LibrasControlMessage::~LibrasControlMessage() {
}
unsigned short LibrasControlMessage::getMessageLength() {
return messagelength;
}
unsigned char LibrasControlMessage::getResolution() {
return resolution;
}
unsigned char LibrasControlMessage::getDictionaryVersion() {
return dictionaryversion;
}
unsigned short LibrasControlMessage::getDPH() {
return dph;
}
unsigned short LibrasControlMessage::getDPV() {
return dpv;
}
unsigned short LibrasControlMessage::getDFW() {
return dfw;
}
unsigned short LibrasControlMessage::getDFH() {
return dfh;
}
unsigned char LibrasControlMessage::getPrivateDataLength() {
return privatedatalength;
}
unsigned char *LibrasControlMessage::getPrivateDataBytes() {
return privateDataBytes;
}
void LibrasControlMessage::setMessageLength(unsigned short messagelength) {
this->messagelength = messagelength;
}
void LibrasControlMessage::setResolution(string resolution) {
if(resolution.compare("1920x1080") == 0)
this->resolution = 0;
if(resolution.compare("1280x720") == 0)
this->resolution = 1;
if(resolution.compare("640x480") == 0)
this->resolution = 2;
if(resolution.compare("960x540") == 0)
this->resolution = 3;
if(resolution.compare("720x480") == 0)
this->resolution = 4;
}
void LibrasControlMessage::setDictionaryVersion(unsigned char dictionaryversion) {
this->dictionaryversion = dictionaryversion;
}
void LibrasControlMessage::setDPH(unsigned short dph) {
this->dph = dph;
}
void LibrasControlMessage::setDPV(unsigned short dpv) {
this->dpv = dpv;
}
void LibrasControlMessage::setDFW(unsigned short dfw) {
this->dfw = dfw;
}
void LibrasControlMessage::setDFH(unsigned short dfh) {
this->dfh = dfh;
}
void LibrasControlMessage::setPrivateDataLength(unsigned char privatedatalength) {
this->privatedatalength = privatedatalength;
}
void LibrasControlMessage::setPrivateDataBytes(unsigned char *privateDataBytes, int len) {
if (this->privateDataBytes) {
delete (this->privateDataBytes);
}
this->privateDataBytes = new unsigned char[len];
memcpy(this->privateDataBytes, privateDataBytes, len);
}
unsigned char *LibrasControlMessage::generateBytes(unsigned short *librasLen) {
unsigned char *librasDataBytes;
*librasLen = privatedatalength + messagelength + 3;
librasDataBytes = new unsigned char[*librasLen];
messageid = MESSAGE_ID_CONTROL;
messagelength += privatedatalength;
librasDataBytes[0] = messageid & 0xFF;
librasDataBytes[1] = (messagelength >> 8) & 0xFF;
librasDataBytes[2] = messagelength & 0xFF;
librasDataBytes[3] = ((resolution << 1) & 0x1E) | (timecontrolflag & 0x01);
librasDataBytes[4] = dictionaryversion & 0xFF;
librasDataBytes[5] = (dph >> 8) & 0xFF;
librasDataBytes[6] = dph & 0xFF;
librasDataBytes[7] = (dpv >> 8) & 0xFF;
librasDataBytes[8] = dpv & 0xFF;
librasDataBytes[9] = (dfw >> 8) & 0xFF;
librasDataBytes[10] = dfw & 0xFF;
librasDataBytes[11] = (dfh >> 8) & 0xFF;
librasDataBytes[12] = dfh & 0xFF;
librasDataBytes[13] = privatedatalength & 0xFF;
memcpy(librasDataBytes + 11, privateDataBytes, privatedatalength);
return librasDataBytes;
}
}