?? binarycomms.c
字號:
Service_t *newservice = SetCurrentService(serviceName); if (newservice) { MessageRERR(message, RERR_OK, ""); } else { MessageRERR(message, RERR_NOTFOUND, serviceName); } free(serviceName);}static void ProcessSecondaryServiceAdd(Connection_t *connection, Message_t *message){ Output_t *output = NULL; char *serviceOutputName = NULL; char *destination = NULL; READ2STRINGS(serviceOutputName, destination); printlog(LOG_DEBUGV,"Add Service Output Name = \"%s\" Destination = \"%s\"\n", serviceOutputName, destination); output = OutputAllocate(serviceOutputName, OutputType_Service, destination); if (output) { MessageRERR(message, RERR_OK, ""); } else { output = OutputFind(serviceOutputName, OutputType_Service); MessageRERR(message, output ? RERR_EXISTS:RERR_GENERIC, OutputErrorStr); } free(serviceOutputName); free(destination);}static void ProcessSecondaryServiceSet(Connection_t *connection, Message_t *message){ Output_t *output = NULL; Service_t *newService = NULL; Service_t *oldService = NULL; char *serviceOutputName = NULL; char *serviceName = NULL; READ2STRINGS(serviceOutputName, serviceName); printlog(LOG_DEBUGV,"Set Service Output Name = \"%s\" Service = \"%s\"\n", serviceOutputName, serviceName); output = OutputFind(serviceOutputName, OutputType_Service); if (!output) { MessageRERR(message, RERR_NOTFOUND, serviceOutputName); } else { newService = ServiceFindName(serviceName); if (!newService) { MessageRERR(message, RERR_NOTFOUND, serviceName); } else { OutputGetService(output, &oldService); OutputSetService(output, newService); if (oldService) { ServiceFree(oldService); } MessageRERR(message, RERR_OK, ""); } } free(serviceOutputName); free(serviceName);}static void ProcessSecondaryServiceRemove(Connection_t *connection, Message_t *message){ Output_t *output = NULL; Service_t *oldService = NULL; char *serviceOutputName = NULL; READSTRING(serviceOutputName); if (strcmp(serviceOutputName, PrimaryService) == 0) { MessageRERR(message, RERR_GENERIC, "You cannot remove the primary service!"); free(serviceOutputName); return; } printlog(LOG_DEBUGV,"Remove Service Output Name = \"%s\"\n", serviceOutputName); output = OutputFind(serviceOutputName, OutputType_Service); if (!output) { MessageRERR(message, RERR_NOTFOUND, serviceOutputName); } else { OutputGetService(output, &oldService); OutputFree(output); if (oldService) { ServiceFree(oldService); } MessageRERR(message, RERR_OK, ""); } free(serviceOutputName);}static void ProcessOutputAdd(Connection_t *connection, Message_t *message){ Output_t *output = NULL; char *manualOutputName = NULL; char *destination = NULL; READ2STRINGS(manualOutputName, destination); printlog(LOG_DEBUGV,"Add Manual Output Name = \"%s\" Destination = \"%s\"\n", manualOutputName, destination); output = OutputAllocate(manualOutputName, OutputType_Manual, destination); if (output) { MessageRERR(message, RERR_OK, ""); } else { output = OutputFind(manualOutputName, OutputType_Manual); MessageRERR(message, output ? RERR_EXISTS:RERR_GENERIC, OutputErrorStr); } free(manualOutputName); free(destination);}static void ProcessOutputRemove(Connection_t *connection, Message_t *message){ Output_t *output = NULL; char *manualOutputName = NULL; READSTRING(manualOutputName); printlog(LOG_DEBUGV,"Remove Manual Output Name = \"%s\"\n", manualOutputName); output = OutputFind(manualOutputName, OutputType_Manual); if (!output) { MessageRERR(message, RERR_NOTFOUND, manualOutputName); } else { OutputFree(output); MessageRERR(message, RERR_OK, ""); } free(manualOutputName);}static void ProcessOutputPIDAdd(Connection_t *connection, Message_t *message){ Output_t *output = NULL; char *manualOutputName = NULL; READSTRING(manualOutputName); output = OutputFind(manualOutputName, OutputType_Manual); if (!output) { MessageRERR(message, RERR_NOTFOUND, manualOutputName); free(manualOutputName); } else { uint16_t i = 0; uint16_t pidCount = 0; uint16_t pid = 0; free(manualOutputName); READUINT16(pidCount); for (i = 0; i < pidCount; i ++) { READUINT16(pid); OutputAddPID(output, pid); } MessageRERR(message, RERR_OK, ""); }}static void ProcessOutputPIDRemove(Connection_t *connection, Message_t *message){ Output_t *output = NULL; char *manualOutputName = NULL; READSTRING(manualOutputName); output = OutputFind(manualOutputName, OutputType_Manual); if (!output) { MessageRERR(message, RERR_NOTFOUND, manualOutputName); free(manualOutputName); } else { uint16_t i = 0; uint16_t pidCount = 0; uint16_t pid = 0; free(manualOutputName); READUINT16(pidCount); for (i = 0; i < pidCount; i ++) { READUINT16(pid); OutputRemovePID(output, pid); } MessageRERR(message, RERR_OK, ""); }}static void ProcessPrimaryServiceCurrent(Connection_t *connection, Message_t *message){ if (CurrentService) { MessageRERR(message, RERR_OK, CurrentService->name); } else { MessageRERR(message, RERR_GENERIC, "No service selected"); }}static void ProcessSecondaryServiceList(Connection_t *connection, Message_t *message){ int i; uint8_t outputsCount = 0; MessageInit(message, MSGCODE_RSSL); MessageWriteUint8(message, outputsCount); for (i = 0; i < MAX_OUTPUTS; i ++) { if (Outputs[i].name && (Outputs[i].type == OutputType_Service)) { Service_t *service = NULL; char *name = NULL; OutputGetService(&Outputs[i], &service); if (service) { name = service->name; } MessageEncode(message,"sss", Outputs[i].name, UDPOutputDestination((void*)Outputs[i].filter->oparg), name); outputsCount ++; } } MessageSeek(message, 0); MessageWriteUint8(message, outputsCount);}static void ProcessOutputsList(Connection_t *connection, Message_t *message){ int i; uint8_t outputsCount = 0; MessageInit(message, MSGCODE_ROLO); MessageWriteUint8(message, outputsCount); for (i = 0; i < MAX_OUTPUTS; i ++) { if (Outputs[i].name && (Outputs[i].type == OutputType_Manual)) { MessageEncode(message, "ss", Outputs[i].name, UDPOutputDestination((void*)Outputs[i].filter->oparg)); outputsCount ++; } } MessageSeek(message, 0); MessageWriteUint8(message, outputsCount);}static void ProcessOutputListPids(Connection_t *connection, Message_t *message){ Output_t *output; char *outputName = NULL; if (MessageReadString(message, &outputName)) { LOG_MALFORMED(connection, "output name"); connection->connected = FALSE; return ; } output = OutputFind(outputName, OutputType_Manual); if (output) { int pidcount = 0, i; uint16_t *pids; OutputGetPIDs(output, &pidcount, &pids); MessageInit(message, MSGCODE_RLP); MessageWriteUint16(message, (uint8_t)pidcount); for (i = 0; i < pidcount; i ++) { MessageWriteUint16(message, pids[i]); } } else { MessageRERR(message, RERR_NOTFOUND, outputName); } free(outputName);}static void ProcessServiceFilterPacketCount(Connection_t *connection, Message_t *message){ Output_t *output; char *outputName = NULL; if (MessageReadString(message, &outputName)) { LOG_MALFORMED(connection, "output name"); connection->connected = FALSE; return ; } output = OutputFind(outputName, OutputType_Service); if (output) { MessageInit(message, MSGCODE_ROPC); MessageWriteUint32(message, output->filter->packetsfiltered); } else { MessageRERR(message, RERR_NOTFOUND, outputName); } free(outputName);}static void ProcessOutputPacketCount(Connection_t *connection, Message_t *message){ Output_t *output; char *outputName = NULL; if (MessageReadString(message, &outputName)) { LOG_MALFORMED(connection, "output name"); connection->connected = FALSE; return ; } output = OutputFind(outputName, OutputType_Manual); if (output) { MessageInit(message, MSGCODE_ROPC); MessageWriteUint32(message, output->filter->packetsfiltered); } else { MessageRERR(message, RERR_NOTFOUND, outputName); } free(outputName);}static void ProcessTSStats(Connection_t *connection, Message_t *message){ MessageInit(message, MSGCODE_RTSS); MessageWriteUint32(message, TSFilter->bitrate); MessageWriteUint32(message, TSFilter->totalpackets); MessageWriteUint32(message, PIDFilters[PIDFilterIndex_PAT]->packetsprocessed); MessageWriteUint32(message, PIDFilters[PIDFilterIndex_PMT]->packetsprocessed); MessageWriteUint32(message, PIDFilters[PIDFilterIndex_SDT]->packetsprocessed);}static void ProcessFEStatus(Connection_t *connection, Message_t *message){ fe_status_t status = 0; unsigned int ber = 0; unsigned int strength = 0; unsigned int snr = 0; DVBFrontEndStatus(DVBAdapter, &status, &ber, &strength, &snr); MessageInit(message, MSGCODE_RFES); MessageEncode(message, "bldd", status, ber, snr, strength);}static void ProcessServiceList(Connection_t *connection, Message_t *message, int all){ uint16_t count = 0; ServiceEnumerator_t enumerator = NULL; MessageInit(message, MSGCODE_RLS); MessageWriteUint16(message, count); if (all) { enumerator = ServiceEnumeratorGet(); } else { if (CurrentMultiplex != NULL) { enumerator = ServiceEnumeratorForMultiplex(CurrentMultiplex->freq); } } if (enumerator != NULL) { Service_t *service; do { service = ServiceGetNext(enumerator); if (service) { MessageWriteString(message, service->name); count ++; ServiceFree(service); } } while (service && !ExitProgram); ServiceEnumeratorDestroy(enumerator); MessageSeek(message, 0); MessageWriteUint16(message, count); }}static void ProcessServicePids(Connection_t *connection, Message_t *message){ Service_t *service; char *serviceName = NULL; if (MessageReadString(message, &serviceName)) { LOG_MALFORMED(connection, "sevice name"); connection->connected = FALSE; return ; } service = ServiceFindName(serviceName); if (service) { int cached = 1; int i; int count = 0; PID_t *pids; pids = CachePIDsGet(service, &count); if (pids == NULL) { count = ServicePIDCount(service); cached = 0; } if ((count > 0) && (!cached)) { pids = calloc(count, sizeof(PID_t)); if (pids) { ServicePIDGet(service, pids, &count); } else { MessageRERR(message, RERR_GENERIC, "No memory to retrieve PIDs\n"); return ; } } MessageInit(message, MSGCODE_RLP); MessageWriteUint16(message, (uint16_t)count); for (i = 0; i < count; i ++) { MessageWriteUint16(message, pids[i].pid); } if ((count > 0) && (!cached)) { free(pids); } ServiceFree(service); } else { MessageRERR(message, RERR_NOTFOUND, serviceName); } free(serviceName);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -