22 #include "mythprotobase.h" 23 #include "../private/debug.h" 24 #include "../private/socket.h" 25 #include "../private/os/threads/mutex.h" 26 #include "../private/cppdef.h" 27 #include "../private/builtin.h" 45 {87,
"(ノಠ益ಠ)ノ彡┻━┻_No_entiendo!)"},
48 {84,
"CanaryCoalmine"},
49 {83,
"BreakingGlass"},
60 ProtoBase::ProtoBase(
const std::string& server,
unsigned port)
61 : m_mutex(
new OS::CMutex)
62 , m_socket(
new TcpSocket())
71 , m_protoError(ERROR_NO_ERROR)
73 m_socket->SetReadAttempt(6);
76 ProtoBase::~ProtoBase()
79 SAFE_DELETE(m_socket);
83 void ProtoBase::HangException()
85 DBG(DBG_ERROR,
"%s: protocol connection hang with error %d\n", __FUNCTION__, m_socket->GetErrNo());
91 bool ProtoBase::SendCommand(
const char *cmd,
bool feedback)
93 size_t l = strlen(cmd);
95 if (m_msgConsumed != m_msgLength)
97 DBG(DBG_ERROR,
"%s: did not consume everything\n", __FUNCTION__);
101 if (l > 0 && l < PROTO_SENDMSG_MAXSIZE)
106 sprintf(buf,
"%-8u", (
unsigned)l);
107 msg.append(buf).append(cmd);
108 DBG(DBG_PROTO,
"%s: %s\n", __FUNCTION__, cmd);
109 if (m_socket->SendData(msg.c_str(), msg.size()))
112 return RcvMessageLength();
115 DBG(DBG_ERROR,
"%s: failed (%d)\n", __FUNCTION__, m_socket->GetErrNo());
119 DBG(DBG_ERROR,
"%s: message size out of bound (%d)\n", __FUNCTION__, (
int)l);
123 size_t ProtoBase::GetMessageLength()
const 135 const char *str_sep = PROTO_STR_SEPARATOR;
136 size_t str_sep_len = PROTO_STR_SEPARATOR_LEN;
137 char buf[PROTO_BUFFER_SIZE];
138 size_t p = 0, p_ss = 0, l = m_msgLength, c = m_msgConsumed;
148 if (m_socket->ReceiveData(&buf[p], 1) < 1)
154 if (buf[p++] == str_sep[p_ss])
156 if (++p_ss >= str_sep_len)
159 buf[p - str_sep_len] =
'\0';
167 if (p > (PROTO_BUFFER_SIZE - 2 - str_sep_len))
188 m_msgConsumed = m_msgLength = 0;
192 bool ProtoBase::IsMessageOK(
const std::string& field)
const 194 if (field.size() == 2)
196 if ((field[0] ==
'O' || field[0] ==
'o') && (field[1] ==
'K' || field[1] ==
'k'))
202 size_t ProtoBase::FlushMessage()
204 char buf[PROTO_BUFFER_SIZE];
205 size_t r, n = 0, f = m_msgLength - m_msgConsumed;
209 r = (f > PROTO_BUFFER_SIZE ? PROTO_BUFFER_SIZE : f);
210 if (m_socket->ReceiveData(buf, r) != r)
218 m_msgLength = m_msgConsumed = 0;
222 bool ProtoBase::RcvMessageLength()
231 if (m_socket->ReceiveData(buf, 8) == 8)
233 if (0 == string_to_uint32(buf, &val))
235 DBG(DBG_PROTO,
"%s: %" PRIu32
"\n", __FUNCTION__, val);
236 m_msgLength = (size_t)val;
240 DBG(DBG_ERROR,
"%s: failed ('%s')\n", __FUNCTION__, buf);
268 DBG(DBG_ERROR,
"%s: did not consume everything\n", __FUNCTION__);
271 if (0 != string_to_uint32(field.c_str(), &val))
273 *version = (unsigned)val;
277 DBG(DBG_ERROR,
"%s: failed ('%s')\n", __FUNCTION__, field.c_str());
282 bool ProtoBase::OpenConnection(
int rcvbuf)
284 static unsigned my_version = 0;
289 OS::CLockGuard lock(*m_mutex);
293 tmp_ver = protomap->version;
296 tmp_ver = my_version;
301 m_protoError = ERROR_NO_ERROR;
306 while (map->version != 0 && map->version != tmp_ver)
309 if (map->version == 0)
311 m_protoError = ERROR_UNKNOWN_VERSION;
312 DBG(DBG_ERROR,
"%s: failed to connect with any version\n", __FUNCTION__);
316 if (!m_socket->Connect(m_server.c_str(), m_port, rcvbuf))
320 m_protoError = ERROR_SERVER_UNREACHABLE;
326 sprintf(cmd,
"MYTH_PROTO_VERSION %" PRIu32
" %s", map->version, map->token);
328 if (!SendCommand(cmd) || !
RcvVersion(&tmp_ver))
330 m_protoError = ERROR_SOCKET_ERROR;
334 DBG(DBG_DEBUG,
"%s: asked for version %" PRIu32
", got version %" PRIu32
"\n",
335 __FUNCTION__, map->version, tmp_ver);
337 if (map->version == tmp_ver)
339 DBG(DBG_DEBUG,
"%s: agreed on version %u\n", __FUNCTION__, tmp_ver);
340 if (tmp_ver != my_version)
341 my_version = tmp_ver;
343 m_protoVersion = tmp_ver;
347 m_socket->Disconnect();
350 m_socket->Disconnect();
356 void ProtoBase::Close()
358 OS::CLockGuard lock(*m_mutex);
360 if (m_socket->IsValid())
365 const char *cmd =
"DONE";
366 if (SendCommand(cmd,
false))
367 DBG(DBG_PROTO,
"%s: done\n", __FUNCTION__);
369 DBG(DBG_WARN,
"%s: gracefully failed (%d)\n", __FUNCTION__, m_socket->GetErrNo());
371 m_socket->Disconnect();
374 m_msgLength = m_msgConsumed = 0;
377 unsigned ProtoBase::GetProtoVersion()
const 380 return m_protoVersion;
384 std::string ProtoBase::GetServer()
const 389 unsigned ProtoBase::GetPort()
const 394 int ProtoBase::GetSocketErrNo()
const 396 return m_socket->GetErrNo();
399 int ProtoBase::GetSocket()
const 401 return (
int)(m_socket->GetHandle());
404 bool ProtoBase::HasHanging()
const 409 void ProtoBase::CleanHanging()
414 ProtoBase::ERROR_t ProtoBase::GetProtoError()
const 419 ProgramPtr ProtoBase::RcvProgramInfo75()
423 ProgramPtr program(
new Program());
436 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->season)))
439 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->episode)))
445 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.chanId)))
448 if (!
ReadField(program->channel.chanNum))
451 if (!
ReadField(program->channel.callSign))
454 if (!
ReadField(program->channel.channelName))
460 if (!
ReadField(field) || string_to_int64(field.c_str(), &(program->fileSize)))
463 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
465 program->startTime = (time_t)tmpi;
467 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
469 program->endTime = (time_t)tmpi;
477 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.sourceId)))
483 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.inputId)))
486 if (!
ReadField(field) || string_to_int32(field.c_str(), &(program->recording.priority)))
489 if (!
ReadField(field) || string_to_int8(field.c_str(), &(program->recording.status)))
492 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->recording.recordId)))
495 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.recType)))
498 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.dupInType)))
501 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.dupMethod)))
504 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
506 program->recording.startTs = (time_t)tmpi;
508 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
510 program->recording.endTs = (time_t)tmpi;
512 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->programFlags)))
515 if (!
ReadField(program->recording.recGroup))
518 if (!
ReadField(program->channel.chanFilters))
530 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
532 program->lastModified = (time_t)tmpi;
537 if (!
ReadField(field) || string_to_time(field.c_str(), &(program->airdate)))
540 if (!
ReadField(program->recording.playGroup))
549 if (!
ReadField(program->recording.storageGroup))
552 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->audioProps)))
555 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->videoProps)))
559 DBG(DBG_ERROR,
"%s: failed (%d) buf='%s'\n", __FUNCTION__, i, field.c_str());
564 ProgramPtr ProtoBase::RcvProgramInfo76()
568 ProgramPtr program(
new Program());
581 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->season)))
584 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->episode)))
593 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.chanId)))
596 if (!
ReadField(program->channel.chanNum))
599 if (!
ReadField(program->channel.callSign))
602 if (!
ReadField(program->channel.channelName))
608 if (!
ReadField(field) || string_to_int64(field.c_str(), &(program->fileSize)))
611 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
613 program->startTime = (time_t)tmpi;
615 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
617 program->endTime = (time_t)tmpi;
625 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.sourceId)))
631 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.inputId)))
634 if (!
ReadField(field) || string_to_int32(field.c_str(), &(program->recording.priority)))
637 if (!
ReadField(field) || string_to_int8(field.c_str(), &(program->recording.status)))
640 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->recording.recordId)))
643 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.recType)))
646 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.dupInType)))
649 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.dupMethod)))
652 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
654 program->recording.startTs = (time_t)tmpi;
656 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
658 program->recording.endTs = (time_t)tmpi;
660 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->programFlags)))
663 if (!
ReadField(program->recording.recGroup))
666 if (!
ReadField(program->channel.chanFilters))
678 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
680 program->lastModified = (time_t)tmpi;
685 if (!
ReadField(field) || string_to_time(field.c_str(), &(program->airdate)))
688 if (!
ReadField(program->recording.playGroup))
697 if (!
ReadField(program->recording.storageGroup))
700 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->audioProps)))
703 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->videoProps)))
706 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->subProps)))
719 DBG(DBG_ERROR,
"%s: failed (%d) buf='%s'\n", __FUNCTION__, i, field.c_str());
724 ProgramPtr ProtoBase::RcvProgramInfo79()
728 ProgramPtr program(
new Program());
741 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->season)))
744 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->episode)))
756 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.chanId)))
759 if (!
ReadField(program->channel.chanNum))
762 if (!
ReadField(program->channel.callSign))
765 if (!
ReadField(program->channel.channelName))
771 if (!
ReadField(field) || string_to_int64(field.c_str(), &(program->fileSize)))
774 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
776 program->startTime = (time_t)tmpi;
778 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
780 program->endTime = (time_t)tmpi;
788 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.sourceId)))
794 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.inputId)))
797 if (!
ReadField(field) || string_to_int32(field.c_str(), &(program->recording.priority)))
800 if (!
ReadField(field) || string_to_int8(field.c_str(), &(program->recording.status)))
803 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->recording.recordId)))
806 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.recType)))
809 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.dupInType)))
812 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.dupMethod)))
815 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
817 program->recording.startTs = (time_t)tmpi;
819 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
821 program->recording.endTs = (time_t)tmpi;
823 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->programFlags)))
826 if (!
ReadField(program->recording.recGroup))
829 if (!
ReadField(program->channel.chanFilters))
841 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
843 program->lastModified = (time_t)tmpi;
848 if (!
ReadField(field) || string_to_time(field.c_str(), &(program->airdate)))
851 if (!
ReadField(program->recording.playGroup))
860 if (!
ReadField(program->recording.storageGroup))
863 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->audioProps)))
866 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->videoProps)))
869 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->subProps)))
881 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
883 program->catType = CategoryTypeToString(m_protoVersion, CategoryTypeFromNum(m_protoVersion, (
int)tmpi));
886 DBG(DBG_ERROR,
"%s: failed (%d) buf='%s'\n", __FUNCTION__, i, field.c_str());
891 ProgramPtr ProtoBase::RcvProgramInfo82()
895 ProgramPtr program(
new Program());
908 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->season)))
911 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->episode)))
923 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.chanId)))
926 if (!
ReadField(program->channel.chanNum))
929 if (!
ReadField(program->channel.callSign))
932 if (!
ReadField(program->channel.channelName))
938 if (!
ReadField(field) || string_to_int64(field.c_str(), &(program->fileSize)))
941 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
943 program->startTime = (time_t)tmpi;
945 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
947 program->endTime = (time_t)tmpi;
955 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.sourceId)))
961 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.inputId)))
964 if (!
ReadField(field) || string_to_int32(field.c_str(), &(program->recording.priority)))
967 if (!
ReadField(field) || string_to_int8(field.c_str(), &(program->recording.status)))
970 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->recording.recordId)))
973 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.recType)))
976 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.dupInType)))
979 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.dupMethod)))
982 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
984 program->recording.startTs = (time_t)tmpi;
986 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
988 program->recording.endTs = (time_t)tmpi;
990 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->programFlags)))
993 if (!
ReadField(program->recording.recGroup))
996 if (!
ReadField(program->channel.chanFilters))
1008 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
1010 program->lastModified = (time_t)tmpi;
1015 if (!
ReadField(field) || string_to_time(field.c_str(), &(program->airdate)))
1018 if (!
ReadField(program->recording.playGroup))
1027 if (!
ReadField(program->recording.storageGroup))
1030 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->audioProps)))
1033 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->videoProps)))
1036 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->subProps)))
1048 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
1050 program->catType = CategoryTypeToString(m_protoVersion, CategoryTypeFromNum(m_protoVersion, (
int)tmpi));
1052 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->recording.recordedId)))
1056 DBG(DBG_ERROR,
"%s: failed (%d) buf='%s'\n", __FUNCTION__, i, field.c_str());
1061 ProgramPtr ProtoBase::RcvProgramInfo86()
1065 ProgramPtr program(
new Program());
1078 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->season)))
1081 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->episode)))
1093 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.chanId)))
1096 if (!
ReadField(program->channel.chanNum))
1099 if (!
ReadField(program->channel.callSign))
1102 if (!
ReadField(program->channel.channelName))
1108 if (!
ReadField(field) || string_to_int64(field.c_str(), &(program->fileSize)))
1111 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
1113 program->startTime = (time_t)tmpi;
1115 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
1117 program->endTime = (time_t)tmpi;
1125 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.sourceId)))
1131 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->channel.inputId)))
1134 if (!
ReadField(field) || string_to_int32(field.c_str(), &(program->recording.priority)))
1137 if (!
ReadField(field) || string_to_int8(field.c_str(), &(program->recording.status)))
1140 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->recording.recordId)))
1143 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.recType)))
1146 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.dupInType)))
1149 if (!
ReadField(field) || string_to_uint8(field.c_str(), &(program->recording.dupMethod)))
1152 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
1154 program->recording.startTs = (time_t)tmpi;
1156 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
1158 program->recording.endTs = (time_t)tmpi;
1160 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->programFlags)))
1163 if (!
ReadField(program->recording.recGroup))
1166 if (!
ReadField(program->channel.chanFilters))
1178 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
1180 program->lastModified = (time_t)tmpi;
1185 if (!
ReadField(field) || string_to_time(field.c_str(), &(program->airdate)))
1188 if (!
ReadField(program->recording.playGroup))
1197 if (!
ReadField(program->recording.storageGroup))
1200 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->audioProps)))
1203 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->videoProps)))
1206 if (!
ReadField(field) || string_to_uint16(field.c_str(), &(program->subProps)))
1218 if (!
ReadField(field) || string_to_int64(field.c_str(), &tmpi))
1220 program->catType = CategoryTypeToString(m_protoVersion, CategoryTypeFromNum(m_protoVersion, (
int)tmpi));
1222 if (!
ReadField(field) || string_to_uint32(field.c_str(), &(program->recording.recordedId)))
1232 DBG(DBG_ERROR,
"%s: failed (%d) buf='%s'\n", __FUNCTION__, i, field.c_str());
1237 void ProtoBase::MakeProgramInfo75(
const Program& program, std::string& msg)
1242 msg.append(program.title).append(PROTO_STR_SEPARATOR);
1243 msg.append(program.subTitle).append(PROTO_STR_SEPARATOR);
1244 msg.append(program.description).append(PROTO_STR_SEPARATOR);
1245 uint16_to_string(program.season, buf);
1246 msg.append(buf).append(PROTO_STR_SEPARATOR);
1247 uint16_to_string(program.episode, buf);
1248 msg.append(buf).append(PROTO_STR_SEPARATOR);
1249 msg.append(program.category).append(PROTO_STR_SEPARATOR);
1250 uint32_to_string(program.channel.chanId, buf);
1251 msg.append(buf).append(PROTO_STR_SEPARATOR);
1252 msg.append(program.channel.chanNum).append(PROTO_STR_SEPARATOR);
1253 msg.append(program.channel.callSign).append(PROTO_STR_SEPARATOR);
1254 msg.append(program.channel.channelName).append(PROTO_STR_SEPARATOR);
1255 msg.append(program.fileName).append(PROTO_STR_SEPARATOR);
1256 int64_to_string(program.fileSize, buf);
1257 msg.append(buf).append(PROTO_STR_SEPARATOR);
1258 int64_to_string((int64_t)program.startTime, buf);
1259 msg.append(buf).append(PROTO_STR_SEPARATOR);
1260 int64_to_string((int64_t)program.endTime, buf);
1261 msg.append(buf).append(PROTO_STR_SEPARATOR);
1262 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1263 msg.append(program.hostName).append(PROTO_STR_SEPARATOR);
1264 uint32_to_string(program.channel.sourceId, buf);
1265 msg.append(buf).append(PROTO_STR_SEPARATOR);
1266 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1267 uint32_to_string(program.channel.inputId, buf);
1268 msg.append(buf).append(PROTO_STR_SEPARATOR);
1269 int32_to_string(program.recording.priority, buf);
1270 msg.append(buf).append(PROTO_STR_SEPARATOR);
1271 int8_to_string(program.recording.status, buf);
1272 msg.append(buf).append(PROTO_STR_SEPARATOR);
1273 uint32_to_string(program.recording.recordId, buf);
1274 msg.append(buf).append(PROTO_STR_SEPARATOR);
1275 uint8_to_string(program.recording.recType, buf);
1276 msg.append(buf).append(PROTO_STR_SEPARATOR);
1277 uint8_to_string(program.recording.dupInType, buf);
1278 msg.append(buf).append(PROTO_STR_SEPARATOR);
1279 uint8_to_string(program.recording.dupMethod, buf);
1280 msg.append(buf).append(PROTO_STR_SEPARATOR);
1281 int64_to_string((int64_t)program.recording.startTs, buf);
1282 msg.append(buf).append(PROTO_STR_SEPARATOR);
1283 int64_to_string((int64_t)program.recording.endTs, buf);
1284 msg.append(buf).append(PROTO_STR_SEPARATOR);
1285 uint32_to_string(program.programFlags, buf);
1286 msg.append(buf).append(PROTO_STR_SEPARATOR);
1287 msg.append(program.recording.recGroup).append(PROTO_STR_SEPARATOR);
1288 msg.append(program.channel.chanFilters).append(PROTO_STR_SEPARATOR);
1289 msg.append(program.seriesId).append(PROTO_STR_SEPARATOR);
1290 msg.append(program.programId).append(PROTO_STR_SEPARATOR);
1291 msg.append(program.inetref).append(PROTO_STR_SEPARATOR);
1292 int64_to_string((int64_t)program.lastModified, buf);
1293 msg.append(buf).append(PROTO_STR_SEPARATOR);
1294 msg.append(program.stars).append(PROTO_STR_SEPARATOR);
1295 time_to_isodate(program.airdate, buf);
1296 msg.append(buf).append(PROTO_STR_SEPARATOR);
1297 msg.append(program.recording.playGroup).append(PROTO_STR_SEPARATOR);
1298 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1299 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1300 msg.append(program.recording.storageGroup).append(PROTO_STR_SEPARATOR);
1301 uint16_to_string(program.audioProps, buf);
1302 msg.append(buf).append(PROTO_STR_SEPARATOR);
1303 uint16_to_string(program.videoProps, buf);
1304 msg.append(buf).append(PROTO_STR_SEPARATOR);
1305 uint16_to_string(program.subProps, buf);
1306 msg.append(buf).append(PROTO_STR_SEPARATOR);
1310 void ProtoBase::MakeProgramInfo76(
const Program& program, std::string& msg)
1315 msg.append(program.title).append(PROTO_STR_SEPARATOR);
1316 msg.append(program.subTitle).append(PROTO_STR_SEPARATOR);
1317 msg.append(program.description).append(PROTO_STR_SEPARATOR);
1318 uint16_to_string(program.season, buf);
1319 msg.append(buf).append(PROTO_STR_SEPARATOR);
1320 uint16_to_string(program.episode, buf);
1321 msg.append(buf).append(PROTO_STR_SEPARATOR);
1322 msg.append(PROTO_STR_SEPARATOR);
1323 msg.append(program.category).append(PROTO_STR_SEPARATOR);
1324 uint32_to_string(program.channel.chanId, buf);
1325 msg.append(buf).append(PROTO_STR_SEPARATOR);
1326 msg.append(program.channel.chanNum).append(PROTO_STR_SEPARATOR);
1327 msg.append(program.channel.callSign).append(PROTO_STR_SEPARATOR);
1328 msg.append(program.channel.channelName).append(PROTO_STR_SEPARATOR);
1329 msg.append(program.fileName).append(PROTO_STR_SEPARATOR);
1330 int64_to_string(program.fileSize, buf);
1331 msg.append(buf).append(PROTO_STR_SEPARATOR);
1332 int64_to_string((int64_t)program.startTime, buf);
1333 msg.append(buf).append(PROTO_STR_SEPARATOR);
1334 int64_to_string((int64_t)program.endTime, buf);
1335 msg.append(buf).append(PROTO_STR_SEPARATOR);
1336 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1337 msg.append(program.hostName).append(PROTO_STR_SEPARATOR);
1338 uint32_to_string(program.channel.sourceId, buf);
1339 msg.append(buf).append(PROTO_STR_SEPARATOR);
1340 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1341 uint32_to_string(program.channel.inputId, buf);
1342 msg.append(buf).append(PROTO_STR_SEPARATOR);
1343 int32_to_string(program.recording.priority, buf);
1344 msg.append(buf).append(PROTO_STR_SEPARATOR);
1345 int8_to_string(program.recording.status, buf);
1346 msg.append(buf).append(PROTO_STR_SEPARATOR);
1347 uint32_to_string(program.recording.recordId, buf);
1348 msg.append(buf).append(PROTO_STR_SEPARATOR);
1349 uint8_to_string(program.recording.recType, buf);
1350 msg.append(buf).append(PROTO_STR_SEPARATOR);
1351 uint8_to_string(program.recording.dupInType, buf);
1352 msg.append(buf).append(PROTO_STR_SEPARATOR);
1353 uint8_to_string(program.recording.dupMethod, buf);
1354 msg.append(buf).append(PROTO_STR_SEPARATOR);
1355 int64_to_string((int64_t)program.recording.startTs, buf);
1356 msg.append(buf).append(PROTO_STR_SEPARATOR);
1357 int64_to_string((int64_t)program.recording.endTs, buf);
1358 msg.append(buf).append(PROTO_STR_SEPARATOR);
1359 uint32_to_string(program.programFlags, buf);
1360 msg.append(buf).append(PROTO_STR_SEPARATOR);
1361 msg.append(program.recording.recGroup).append(PROTO_STR_SEPARATOR);
1362 msg.append(program.channel.chanFilters).append(PROTO_STR_SEPARATOR);
1363 msg.append(program.seriesId).append(PROTO_STR_SEPARATOR);
1364 msg.append(program.programId).append(PROTO_STR_SEPARATOR);
1365 msg.append(program.inetref).append(PROTO_STR_SEPARATOR);
1366 int64_to_string((int64_t)program.lastModified, buf);
1367 msg.append(buf).append(PROTO_STR_SEPARATOR);
1368 msg.append(program.stars).append(PROTO_STR_SEPARATOR);
1369 time_to_isodate(program.airdate, buf);
1370 msg.append(buf).append(PROTO_STR_SEPARATOR);
1371 msg.append(program.recording.playGroup).append(PROTO_STR_SEPARATOR);
1372 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1373 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1374 msg.append(program.recording.storageGroup).append(PROTO_STR_SEPARATOR);
1375 uint16_to_string(program.audioProps, buf);
1376 msg.append(buf).append(PROTO_STR_SEPARATOR);
1377 uint16_to_string(program.videoProps, buf);
1378 msg.append(buf).append(PROTO_STR_SEPARATOR);
1379 uint16_to_string(program.subProps, buf);
1380 msg.append(buf).append(PROTO_STR_SEPARATOR);
1381 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1382 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1386 void ProtoBase::MakeProgramInfo79(
const Program& program, std::string& msg)
1391 msg.append(program.title).append(PROTO_STR_SEPARATOR);
1392 msg.append(program.subTitle).append(PROTO_STR_SEPARATOR);
1393 msg.append(program.description).append(PROTO_STR_SEPARATOR);
1394 uint16_to_string(program.season, buf);
1395 msg.append(buf).append(PROTO_STR_SEPARATOR);
1396 uint16_to_string(program.episode, buf);
1397 msg.append(buf).append(PROTO_STR_SEPARATOR);
1398 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1399 msg.append(PROTO_STR_SEPARATOR);
1400 msg.append(program.category).append(PROTO_STR_SEPARATOR);
1401 uint32_to_string(program.channel.chanId, buf);
1402 msg.append(buf).append(PROTO_STR_SEPARATOR);
1403 msg.append(program.channel.chanNum).append(PROTO_STR_SEPARATOR);
1404 msg.append(program.channel.callSign).append(PROTO_STR_SEPARATOR);
1405 msg.append(program.channel.channelName).append(PROTO_STR_SEPARATOR);
1406 msg.append(program.fileName).append(PROTO_STR_SEPARATOR);
1407 int64_to_string(program.fileSize, buf);
1408 msg.append(buf).append(PROTO_STR_SEPARATOR);
1409 int64_to_string((int64_t)program.startTime, buf);
1410 msg.append(buf).append(PROTO_STR_SEPARATOR);
1411 int64_to_string((int64_t)program.endTime, buf);
1412 msg.append(buf).append(PROTO_STR_SEPARATOR);
1413 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1414 msg.append(program.hostName).append(PROTO_STR_SEPARATOR);
1415 uint32_to_string(program.channel.sourceId, buf);
1416 msg.append(buf).append(PROTO_STR_SEPARATOR);
1417 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1418 uint32_to_string(program.channel.inputId, buf);
1419 msg.append(buf).append(PROTO_STR_SEPARATOR);
1420 int32_to_string(program.recording.priority, buf);
1421 msg.append(buf).append(PROTO_STR_SEPARATOR);
1422 int8_to_string(program.recording.status, buf);
1423 msg.append(buf).append(PROTO_STR_SEPARATOR);
1424 uint32_to_string(program.recording.recordId, buf);
1425 msg.append(buf).append(PROTO_STR_SEPARATOR);
1426 uint8_to_string(program.recording.recType, buf);
1427 msg.append(buf).append(PROTO_STR_SEPARATOR);
1428 uint8_to_string(program.recording.dupInType, buf);
1429 msg.append(buf).append(PROTO_STR_SEPARATOR);
1430 uint8_to_string(program.recording.dupMethod, buf);
1431 msg.append(buf).append(PROTO_STR_SEPARATOR);
1432 int64_to_string((int64_t)program.recording.startTs, buf);
1433 msg.append(buf).append(PROTO_STR_SEPARATOR);
1434 int64_to_string((int64_t)program.recording.endTs, buf);
1435 msg.append(buf).append(PROTO_STR_SEPARATOR);
1436 uint32_to_string(program.programFlags, buf);
1437 msg.append(buf).append(PROTO_STR_SEPARATOR);
1438 msg.append(program.recording.recGroup).append(PROTO_STR_SEPARATOR);
1439 msg.append(program.channel.chanFilters).append(PROTO_STR_SEPARATOR);
1440 msg.append(program.seriesId).append(PROTO_STR_SEPARATOR);
1441 msg.append(program.programId).append(PROTO_STR_SEPARATOR);
1442 msg.append(program.inetref).append(PROTO_STR_SEPARATOR);
1443 int64_to_string((int64_t)program.lastModified, buf);
1444 msg.append(buf).append(PROTO_STR_SEPARATOR);
1445 msg.append(program.stars).append(PROTO_STR_SEPARATOR);
1446 time_to_isodate(program.airdate, buf);
1447 msg.append(buf).append(PROTO_STR_SEPARATOR);
1448 msg.append(program.recording.playGroup).append(PROTO_STR_SEPARATOR);
1449 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1450 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1451 msg.append(program.recording.storageGroup).append(PROTO_STR_SEPARATOR);
1452 uint16_to_string(program.audioProps, buf);
1453 msg.append(buf).append(PROTO_STR_SEPARATOR);
1454 uint16_to_string(program.videoProps, buf);
1455 msg.append(buf).append(PROTO_STR_SEPARATOR);
1456 uint16_to_string(program.subProps, buf);
1457 msg.append(buf).append(PROTO_STR_SEPARATOR);
1458 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1459 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1460 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1461 uint8_to_string((uint8_t)CategoryTypeToNum(m_protoVersion, CategoryTypeFromString(m_protoVersion, program.catType)), buf);
1465 void ProtoBase::MakeProgramInfo82(
const Program& program, std::string& msg)
1470 msg.append(program.title).append(PROTO_STR_SEPARATOR);
1471 msg.append(program.subTitle).append(PROTO_STR_SEPARATOR);
1472 msg.append(program.description).append(PROTO_STR_SEPARATOR);
1473 uint16_to_string(program.season, buf);
1474 msg.append(buf).append(PROTO_STR_SEPARATOR);
1475 uint16_to_string(program.episode, buf);
1476 msg.append(buf).append(PROTO_STR_SEPARATOR);
1477 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1478 msg.append(PROTO_STR_SEPARATOR);
1479 msg.append(program.category).append(PROTO_STR_SEPARATOR);
1480 uint32_to_string(program.channel.chanId, buf);
1481 msg.append(buf).append(PROTO_STR_SEPARATOR);
1482 msg.append(program.channel.chanNum).append(PROTO_STR_SEPARATOR);
1483 msg.append(program.channel.callSign).append(PROTO_STR_SEPARATOR);
1484 msg.append(program.channel.channelName).append(PROTO_STR_SEPARATOR);
1485 msg.append(program.fileName).append(PROTO_STR_SEPARATOR);
1486 int64_to_string(program.fileSize, buf);
1487 msg.append(buf).append(PROTO_STR_SEPARATOR);
1488 int64_to_string((int64_t)program.startTime, buf);
1489 msg.append(buf).append(PROTO_STR_SEPARATOR);
1490 int64_to_string((int64_t)program.endTime, buf);
1491 msg.append(buf).append(PROTO_STR_SEPARATOR);
1492 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1493 msg.append(program.hostName).append(PROTO_STR_SEPARATOR);
1494 uint32_to_string(program.channel.sourceId, buf);
1495 msg.append(buf).append(PROTO_STR_SEPARATOR);
1496 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1497 uint32_to_string(program.channel.inputId, buf);
1498 msg.append(buf).append(PROTO_STR_SEPARATOR);
1499 int32_to_string(program.recording.priority, buf);
1500 msg.append(buf).append(PROTO_STR_SEPARATOR);
1501 int8_to_string(program.recording.status, buf);
1502 msg.append(buf).append(PROTO_STR_SEPARATOR);
1503 uint32_to_string(program.recording.recordId, buf);
1504 msg.append(buf).append(PROTO_STR_SEPARATOR);
1505 uint8_to_string(program.recording.recType, buf);
1506 msg.append(buf).append(PROTO_STR_SEPARATOR);
1507 uint8_to_string(program.recording.dupInType, buf);
1508 msg.append(buf).append(PROTO_STR_SEPARATOR);
1509 uint8_to_string(program.recording.dupMethod, buf);
1510 msg.append(buf).append(PROTO_STR_SEPARATOR);
1511 int64_to_string((int64_t)program.recording.startTs, buf);
1512 msg.append(buf).append(PROTO_STR_SEPARATOR);
1513 int64_to_string((int64_t)program.recording.endTs, buf);
1514 msg.append(buf).append(PROTO_STR_SEPARATOR);
1515 uint32_to_string(program.programFlags, buf);
1516 msg.append(buf).append(PROTO_STR_SEPARATOR);
1517 msg.append(program.recording.recGroup).append(PROTO_STR_SEPARATOR);
1518 msg.append(program.channel.chanFilters).append(PROTO_STR_SEPARATOR);
1519 msg.append(program.seriesId).append(PROTO_STR_SEPARATOR);
1520 msg.append(program.programId).append(PROTO_STR_SEPARATOR);
1521 msg.append(program.inetref).append(PROTO_STR_SEPARATOR);
1522 int64_to_string((int64_t)program.lastModified, buf);
1523 msg.append(buf).append(PROTO_STR_SEPARATOR);
1524 msg.append(program.stars).append(PROTO_STR_SEPARATOR);
1525 time_to_isodate(program.airdate, buf);
1526 msg.append(buf).append(PROTO_STR_SEPARATOR);
1527 msg.append(program.recording.playGroup).append(PROTO_STR_SEPARATOR);
1528 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1529 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1530 msg.append(program.recording.storageGroup).append(PROTO_STR_SEPARATOR);
1531 uint16_to_string(program.audioProps, buf);
1532 msg.append(buf).append(PROTO_STR_SEPARATOR);
1533 uint16_to_string(program.videoProps, buf);
1534 msg.append(buf).append(PROTO_STR_SEPARATOR);
1535 uint16_to_string(program.subProps, buf);
1536 msg.append(buf).append(PROTO_STR_SEPARATOR);
1537 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1538 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1539 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1540 uint8_to_string((uint8_t)CategoryTypeToNum(m_protoVersion, CategoryTypeFromString(m_protoVersion, program.catType)), buf);
1541 msg.append(buf).append(PROTO_STR_SEPARATOR);
1542 uint32_to_string(program.recording.recordedId, buf);
1546 void ProtoBase::MakeProgramInfo86(
const Program& program, std::string& msg)
1551 msg.append(program.title).append(PROTO_STR_SEPARATOR);
1552 msg.append(program.subTitle).append(PROTO_STR_SEPARATOR);
1553 msg.append(program.description).append(PROTO_STR_SEPARATOR);
1554 uint16_to_string(program.season, buf);
1555 msg.append(buf).append(PROTO_STR_SEPARATOR);
1556 uint16_to_string(program.episode, buf);
1557 msg.append(buf).append(PROTO_STR_SEPARATOR);
1558 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1559 msg.append(PROTO_STR_SEPARATOR);
1560 msg.append(program.category).append(PROTO_STR_SEPARATOR);
1561 uint32_to_string(program.channel.chanId, buf);
1562 msg.append(buf).append(PROTO_STR_SEPARATOR);
1563 msg.append(program.channel.chanNum).append(PROTO_STR_SEPARATOR);
1564 msg.append(program.channel.callSign).append(PROTO_STR_SEPARATOR);
1565 msg.append(program.channel.channelName).append(PROTO_STR_SEPARATOR);
1566 msg.append(program.fileName).append(PROTO_STR_SEPARATOR);
1567 int64_to_string(program.fileSize, buf);
1568 msg.append(buf).append(PROTO_STR_SEPARATOR);
1569 int64_to_string((int64_t)program.startTime, buf);
1570 msg.append(buf).append(PROTO_STR_SEPARATOR);
1571 int64_to_string((int64_t)program.endTime, buf);
1572 msg.append(buf).append(PROTO_STR_SEPARATOR);
1573 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1574 msg.append(program.hostName).append(PROTO_STR_SEPARATOR);
1575 uint32_to_string(program.channel.sourceId, buf);
1576 msg.append(buf).append(PROTO_STR_SEPARATOR);
1577 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1578 uint32_to_string(program.channel.inputId, buf);
1579 msg.append(buf).append(PROTO_STR_SEPARATOR);
1580 int32_to_string(program.recording.priority, buf);
1581 msg.append(buf).append(PROTO_STR_SEPARATOR);
1582 int8_to_string(program.recording.status, buf);
1583 msg.append(buf).append(PROTO_STR_SEPARATOR);
1584 uint32_to_string(program.recording.recordId, buf);
1585 msg.append(buf).append(PROTO_STR_SEPARATOR);
1586 uint8_to_string(program.recording.recType, buf);
1587 msg.append(buf).append(PROTO_STR_SEPARATOR);
1588 uint8_to_string(program.recording.dupInType, buf);
1589 msg.append(buf).append(PROTO_STR_SEPARATOR);
1590 uint8_to_string(program.recording.dupMethod, buf);
1591 msg.append(buf).append(PROTO_STR_SEPARATOR);
1592 int64_to_string((int64_t)program.recording.startTs, buf);
1593 msg.append(buf).append(PROTO_STR_SEPARATOR);
1594 int64_to_string((int64_t)program.recording.endTs, buf);
1595 msg.append(buf).append(PROTO_STR_SEPARATOR);
1596 uint32_to_string(program.programFlags, buf);
1597 msg.append(buf).append(PROTO_STR_SEPARATOR);
1598 msg.append(program.recording.recGroup).append(PROTO_STR_SEPARATOR);
1599 msg.append(program.channel.chanFilters).append(PROTO_STR_SEPARATOR);
1600 msg.append(program.seriesId).append(PROTO_STR_SEPARATOR);
1601 msg.append(program.programId).append(PROTO_STR_SEPARATOR);
1602 msg.append(program.inetref).append(PROTO_STR_SEPARATOR);
1603 int64_to_string((int64_t)program.lastModified, buf);
1604 msg.append(buf).append(PROTO_STR_SEPARATOR);
1605 msg.append(program.stars).append(PROTO_STR_SEPARATOR);
1606 time_to_isodate(program.airdate, buf);
1607 msg.append(buf).append(PROTO_STR_SEPARATOR);
1608 msg.append(program.recording.playGroup).append(PROTO_STR_SEPARATOR);
1609 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1610 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1611 msg.append(program.recording.storageGroup).append(PROTO_STR_SEPARATOR);
1612 uint16_to_string(program.audioProps, buf);
1613 msg.append(buf).append(PROTO_STR_SEPARATOR);
1614 uint16_to_string(program.videoProps, buf);
1615 msg.append(buf).append(PROTO_STR_SEPARATOR);
1616 uint16_to_string(program.subProps, buf);
1617 msg.append(buf).append(PROTO_STR_SEPARATOR);
1618 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1619 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1620 msg.append(
"0").append(PROTO_STR_SEPARATOR);
1621 uint8_to_string((uint8_t)CategoryTypeToNum(m_protoVersion, CategoryTypeFromString(m_protoVersion, program.catType)), buf);
1622 msg.append(buf).append(PROTO_STR_SEPARATOR);
1623 uint32_to_string(program.recording.recordedId, buf);
1625 msg.append(PROTO_STR_SEPARATOR);
1626 msg.append(PROTO_STR_SEPARATOR);
bool RcvVersion(unsigned *version)
bool m_hang
Connection hang: while true allow retry.
bool ReadField(std::string &field)
This is the main namespace that encloses all public classes.
bool m_tainted
Connection has hung since last reset.