gapi_returnCode_t gapi_publisher_set_qos ( gapi_publisher _this, const gapi_publisherQos *qos) { gapi_returnCode_t result = GAPI_RETCODE_OK; u_result uResult; _Publisher publisher; v_publisherQos publisherQos; gapi_context context; gapi_publisherQos *existing_qos; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_SET_QOS); publisher = gapi_publisherClaim(_this, &result); if ( publisher && qos ) { result = gapi_publisherQosIsConsistent(qos, &context); } else { result = GAPI_RETCODE_BAD_PARAMETER; } if ((result == GAPI_RETCODE_OK ) && (_EntityEnabled(publisher))) { existing_qos = gapi_publisherQos__alloc(); uResult = _PublisherGetQos(publisher, existing_qos); result = kernelResultToApiResult(uResult); if(result == GAPI_RETCODE_OK) { result = gapi_publisherQosCheckMutability( qos, existing_qos, &context); } gapi_free(existing_qos); } if ( result == GAPI_RETCODE_OK ) { publisherQos = u_publisherQosNew(NULL); if (publisherQos) { if ( copyPublisherQosIn(qos, publisherQos) ) { uResult = u_entitySetQoS(_EntityUEntity(publisher), (v_qos)(publisherQos) ); result = kernelResultToApiResult(uResult); u_publisherQosFree(publisherQos); } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } _EntityRelease(publisher); return result; }
gapi_returnCode_t gapi_dataReader_set_qos ( gapi_dataReader _this, const gapi_dataReaderQos *qos) { gapi_returnCode_t result = GAPI_RETCODE_OK; u_result uResult; _DataReader dataReader; v_readerQos dataReaderQos; gapi_context context; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_SET_QOS); dataReader = gapi_dataReaderClaim(_this, &result); if ( dataReader ) { if ( qos ) { result = gapi_dataReaderQosIsConsistent(qos, &context); } else { result = GAPI_RETCODE_BAD_PARAMETER; } } if (( result == GAPI_RETCODE_OK ) && (_EntityEnabled(dataReader))){ gapi_dataReaderQos * existing_qos = gapi_dataReaderQos__alloc(); result = gapi_dataReaderQosCheckMutability(qos, _DataReaderGetQos(dataReader, existing_qos), &context); gapi_free(existing_qos); } if ( result == GAPI_RETCODE_OK ) { dataReaderQos = u_readerQosNew(NULL); if (dataReaderQos) { if ( gapi_kernelReaderQosCopyIn(qos, dataReaderQos) ) { uResult = u_entitySetQoS(_EntityUEntity(dataReader), (v_qos)(dataReaderQos) ); result = kernelResultToApiResult(uResult); u_readerQosFree(dataReaderQos); } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } _EntityRelease(dataReader); return result; }
/* ReturnCode_t * set_qos( * in DataReaderViewQos qos); * * Function will operate indepenedent of the enable flag */ gapi_returnCode_t gapi_dataReaderView_set_qos ( gapi_dataReaderView _this, const gapi_dataReaderViewQos *qos) { gapi_returnCode_t result = GAPI_RETCODE_OK; u_result uResult; _DataReaderView dataReaderView; v_dataViewQos dataReaderViewQos; gapi_context context; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_SET_QOS); dataReaderView = gapi_dataReaderViewClaim(_this, &result); if (dataReaderView != NULL) { if ( dataReaderView && qos) { result = gapi_dataReaderViewQosIsConsistent(qos, &context); } else { result = GAPI_RETCODE_BAD_PARAMETER; } if ( result == GAPI_RETCODE_OK ) { gapi_dataReaderViewQos * existing_qos = gapi_dataReaderViewQos__alloc(); result = gapi_dataReaderViewQosCheckMutability(qos, _DataReaderViewGetQos(dataReaderView, existing_qos), &context); gapi_free(existing_qos); } if ( result == GAPI_RETCODE_OK ) { dataReaderViewQos = u_dataViewQosNew(NULL); if (dataReaderViewQos) { if ( copyReaderViewQosIn(qos, dataReaderViewQos) ) { uResult = u_entitySetQoS(_EntityUEntity(dataReaderView),(v_qos)(dataReaderViewQos) ); result = kernelResultToApiResult(uResult); } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } u_dataViewQosFree(dataReaderViewQos); } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } _EntityRelease(dataReaderView); } return result; }
cms_service cms_serviceNew( const c_char* name, const c_char* uri) { cms_service service; c_bool success; const c_char* init; C_STRUCT(v_participantQos) q; struct sockaddr_in addr; socklen_t len; os_result errcode; char* ipTagStr = NULL; char* xmlStr = NULL; u_result result; os_result res; os_ifAttributes *ifList; os_uint32 nofIf, i; service = NULL; if(uri != NULL) { init = cmx_initialise(); if(strcmp(init, CMS_RESULT_OK) == 0) { service = cms_service(os_malloc(C_SIZEOF(cms_service))); cms_object(service)->kind = CMS_SERVICE; service->terminate = FALSE; service->leaseThread = NULL; service->clients = NULL; service->soap = NULL; service->configuration = NULL; service->garbageCollector = NULL; service->uservice = u_serviceNew(uri, CMSERVICE_ATTACH_TIMEOUT, name, NULL, U_SERVICE_CMSOAP, NULL); if(service->uservice != NULL) { /*disable all events.*/ u_dispatcherSetEventMask(u_dispatcher(service->uservice), 0); u_entityAction(u_entity(service->uservice), cms_serviceActionGroups, NULL); u_serviceChangeState(service->uservice, STATE_INITIALISING); success = cms_serviceInit(name, service); result = u_participantQosInit((v_participantQos)&q); if (result == U_RESULT_OK) { /* Insert service information in userData QoS */ len = sizeof(struct sockaddr); errcode = os_sockGetsockname (service->soap->master, (struct sockaddr*)&addr, len); if(errcode == os_resultSuccess) { OS_REPORT_1(OS_INFO, CMS_CONTEXT, 0, "SOAP service is reachable via port %d",ntohs(addr.sin_port)); ifList = os_malloc(MAX_INTERFACES * sizeof(*ifList)); #ifdef WITH_IPV6 res = os_sockQueryIPv6Interfaces(ifList, (os_uint32)MAX_INTERFACES, &nofIf); #else res = os_sockQueryInterfaces(ifList, (os_uint32)MAX_INTERFACES, &nofIf); #endif /* SOAP userdata layout: * <TunerService> * <Ip>x.x.x.x:port</Ip> [<Ip>x.x.x.x</Ip>]... * </TunerService> */ if (res == os_resultSuccess) { os_char tmp[64]; int chars; for (i = 0; i < nofIf; i++) { /* ignore the local loopback interface */ if (!os_sockaddrIsLoopback((os_sockaddr*)&ifList[i].address)) { os_sprintf(tmp,"%s",inet_ntoa(((os_sockaddr_in*)&ifList[i].address)->sin_addr)); if (strcmp(tmp,"0.0.0.0") != 0) { chars = os_sprintf(tmp, IP_TAG, inet_ntoa(((os_sockaddr_in*)&ifList[i].address)->sin_addr), ntohs(addr.sin_port)); if (chars > 0) { if (ipTagStr) { ipTagStr = os_realloc(ipTagStr, strlen(ipTagStr) + chars + 1); } else { ipTagStr = os_malloc(chars + 1); *ipTagStr = '\0'; } ipTagStr = os_strcat(ipTagStr, tmp); } } } } } else { if(service->configuration->verbosity >= 1) { OS_REPORT(OS_WARNING, CMS_CONTEXT, 0,"Could not get SOAP ip address."); } ipTagStr = os_malloc((strlen(IP_TAG) + INET6_ADDRSTRLEN_EXTENDED)); os_sprintf (ipTagStr, IP_TAG, "127.0.0.1", ntohs(addr.sin_port)); } os_free(ifList); xmlStr = os_malloc(strlen(ipTagStr) + strlen(SOAP_TAG)+1); os_sprintf (xmlStr, SOAP_TAG, ipTagStr); os_free(ipTagStr); q.userData.size = strlen(xmlStr); q.userData.value = os_malloc(q.userData.size); memcpy(q.userData.value, xmlStr, q.userData.size); if(service->configuration->verbosity >= 5) { OS_REPORT_1(OS_INFO, CMS_CONTEXT, 0, "SOAP userData: %s", xmlStr); } os_free(xmlStr); } else { q.userData.size = 0; q.userData.value = NULL; if(service->configuration->verbosity >= 1) { OS_REPORT(OS_WARNING, CMS_CONTEXT, 0, "Could not get SOAP port."); } } result = u_entitySetQoS(u_entity(service->uservice), (v_qos)&q); if (result != U_RESULT_OK) { if(service->configuration->verbosity >= 1) { OS_REPORT(OS_WARNING, CMS_CONTEXT, 0,"Could not update the participantQos for publication of the SOAP ip address and port."); } } os_free(q.userData.value); } else { if(service->configuration->verbosity >= 1) { OS_REPORT(OS_WARNING, CMS_CONTEXT, 0,"Could not initiate participantQos for SOAP service ip address and port publication."); } } if(success == FALSE) { cms_serviceFree(service); service = NULL; } else { u_serviceWatchSpliceDaemon(service->uservice, cms_serviceSplicedaemonListener, service); u_serviceChangeState(service->uservice, STATE_OPERATIONAL); } } else { OS_REPORT(OS_ERROR, CMS_CONTEXT, 0, "cms_serviceNew: user layer service could not be created."); cms_serviceFree(service); service = NULL; } } else { if(service && service->configuration->verbosity >= 1) { OS_REPORT(OS_ERROR, CMS_CONTEXT, 0, "cms_serviceNew: C&M API could not be initialized."); } } } else { if(service && service->configuration->verbosity > 0) { OS_REPORT(OS_ERROR, CMS_CONTEXT, 0, "cms_serviceNew: no uri supplied."); } } return service; }