std::shared_ptr<TlsListener> SipTransportBroker::getTlsListener(const SipTransportDescr& d, const pjsip_tls_setting* settings) { RETURN_IF_FAIL(settings, nullptr, "TLS settings not specified"); auto family = pjsip_transport_type_get_af(d.type); IpAddr listeningAddress = (d.interface == ip_utils::DEFAULT_INTERFACE) ? ip_utils::getAnyHostAddr(family) : ip_utils::getInterfaceAddr(d.interface, family); listeningAddress.setPort(d.listenerPort); RETURN_IF_FAIL(listeningAddress, nullptr, "Could not determine IP address for this transport"); RING_DBG("Creating TLS listener %s on %s...", d.toString().c_str(), listeningAddress.toString(true).c_str()); #if 0 RING_DBG(" ca_list_file : %s", settings->ca_list_file.ptr); RING_DBG(" cert_file : %s", settings->cert_file.ptr); RING_DBG(" ciphers_num : %d", settings->ciphers_num); RING_DBG(" verify server %d client %d client_cert %d", settings->verify_server, settings->verify_client, settings->require_client_cert); RING_DBG(" reuse_addr : %d", settings->reuse_addr); #endif pjsip_tpfactory *listener = nullptr; const pj_status_t status = pjsip_tls_transport_start2(endpt_, settings, listeningAddress.pjPtr(), nullptr, 1, &listener); if (status != PJ_SUCCESS) { RING_ERR("TLS listener did not start: %s", sip_utils::sip_strerror(status).c_str()); return nullptr; } return std::make_shared<TlsListener>(listener); }
std::shared_ptr<SipTransport> SipTransportBroker::createUdpTransport(const SipTransportDescr& d) { RETURN_IF_FAIL(d.listenerPort != 0, nullptr, "Could not determine port for this transport"); auto family = pjsip_transport_type_get_af(d.type); IpAddr listeningAddress = (d.interface == ip_utils::DEFAULT_INTERFACE) ? ip_utils::getAnyHostAddr(family) : ip_utils::getInterfaceAddr(d.interface, family); listeningAddress.setPort(d.listenerPort); RETURN_IF_FAIL(listeningAddress, nullptr, "Could not determine IP address for this transport"); pjsip_transport *transport = nullptr; pj_status_t status = listeningAddress.isIpv4() ? pjsip_udp_transport_start (endpt_, &static_cast<const pj_sockaddr_in&>(listeningAddress), nullptr, 1, &transport) : pjsip_udp_transport_start6(endpt_, &static_cast<const pj_sockaddr_in6&>(listeningAddress), nullptr, 1, &transport); if (status != PJ_SUCCESS) { RING_ERR("pjsip_udp_transport_start* failed with error %d: %s", status, sip_utils::sip_strerror(status).c_str()); RING_ERR("UDP IPv%s Transport did not start on %s", listeningAddress.isIpv4() ? "4" : "6", listeningAddress.toString(true).c_str()); return nullptr; } RING_DBG("Created UDP transport on %s : %s", d.interface.c_str(), listeningAddress.toString(true).c_str()); auto ret = std::make_shared<SipTransport>(transport); // dec ref because the refcount starts at 1 and SipTransport increments it ? // pjsip_transport_dec_ref(transport); return ret; }
void UpnpObjectList_RemoveObject(UpnpObjectList *thiz, const char *usn) { RETURN_IF_FAIL(thiz); RETURN_IF_FAIL(usn); TinyMap_Erase(&thiz->objects, usn); }
void UpnpObjectList_AddObject(UpnpObjectList *thiz, UpnpObject *object) { RETURN_IF_FAIL(thiz); RETURN_IF_FAIL(object); TinyMap_Insert(&thiz->objects, UpnpObject_GetUsn(object), object); }
HRESULT CVideoParseFilter::Transform(IMediaSample *pSample) { CAutoLock Lock( &m_Lock ); ++m_currentFrameNo; REFERENCE_TIME start = 0, end = 0; HRESULT hr = S_OK; RETURN_IF_FAIL(hr = pSample->GetTime(&start, &end)); m_currentStreamTime = start; BYTE* pBuf = NULL; RETURN_IF_FAIL(hr = pSample->GetPointer((BYTE**)&pBuf)); CFrame _frame; _frame.Id(m_currentFrameNo); _frame.BeginTime(start); //sometimes end time may be 0 if(end > start) _frame.EndTime(end); else _frame.EndTime(start); CRgbImage img; img.Allocate(m_imageWidth, m_imageHeight, -m_imageStride, pBuf + (m_imageHeight-1)*m_imageStride); _frame.AttachImage(&img); try{ hr = m_receivers.OnNewSegment(_frame); }catch( std::exception & err){ VxCore::LogOut(err.what()); return hr; } return hr; }
void UpnpStateVariableDefinition_Initialize(UpnpStateVariableDefinition *thiz, const char *name, DataType *type) { RETURN_IF_FAIL(thiz); RETURN_IF_FAIL(name); DataType_Copy(&thiz->dataType, type); strncpy(thiz->name, name, STATE_VARIABLE_NAME_LEN); }
void gt_resource_downloader_set_image_filetype(GtResourceDownloader* self, const gchar* image_filetype) { RETURN_IF_FAIL(GT_IS_RESOURCE_DOWNLOADER(self)); RETURN_IF_FAIL(!utils_str_empty(image_filetype)) GtResourceDownloaderPrivate* priv = gt_resource_downloader_get_instance_private(self); priv->image_filetype = g_strdup(image_filetype); }
/** ******************************************************************************* * @fn Run * @brief verify AMP result first and render window * * @return NOERROR on success and E_FAIL on failure ******************************************************************************/ int AMPInteropDX11::run() { // warm up and verify RETURN_IF_FAIL(AMPEngine::getInstance()->verifyResults()); if(quiet == 0) { RETURN_IF_FAIL(DX11Engine::getInstance()->run()); } return NOERROR; }
/** ******************************************************************************* * @fn init * @brief Initialize DX and AMP enovironment * * @return NOERROR on success and E_FAIL on failure ******************************************************************************/ int AMPInteropDX11::init() { RETURN_IF_FAIL(DX11Engine::DX11EngineFactory()); RETURN_IF_FAIL(DX11Engine::getInstance()->initializeDX11()); RETURN_IF_FAIL(AMPEngine::ampEngineFactory(DX11Engine::getInstance()->getD3D11Device())); RETURN_IF_FAIL(AMPEngine::getInstance()->setup(DX11Engine::getInstance()->getVertexPosBuffer())); RETURN_IF_FAIL(DX11Engine::getInstance()->createSRVFromAMPBuffer()); return NOERROR; }
void UpnpStateVariableDefinition_Copy(UpnpStateVariableDefinition *dst, UpnpStateVariableDefinition *src) { RETURN_IF_FAIL(dst); RETURN_IF_FAIL(src); if (dst != src) { UpnpStateVariableDefinition_Dispose(dst); DataType_Copy(&dst->dataType, &src->dataType); strncpy(dst->name, src->name, STATE_VARIABLE_NAME_LEN); } }
void TcpServer_Delete(TcpServer *thiz) { RETURN_IF_FAIL(thiz); TcpServer_Dispose(thiz); tiny_free(thiz); }
void UpnpActionInvoker_Delete(UpnpActionInvoker *thiz) { RETURN_IF_FAIL(thiz); UpnpActionInvoker_Dispose(thiz); tiny_free(thiz); }
void CtSelector_Delete(CtSelector *thiz) { RETURN_IF_FAIL(thiz); CtSelector_Dispose(thiz); ct_free(thiz); }
void UpnpObjectList_Delete(UpnpObjectList *thiz) { RETURN_IF_FAIL(thiz); UpnpObjectList_Dispose(thiz); tiny_free(thiz); }
void TcpClient_Delete(TcpClient *thiz) { RETURN_IF_FAIL(thiz); TcpClient_Dispose(thiz); tiny_free(thiz); }
void TinyMutex_Delete(TinyMutex *thiz) { RETURN_IF_FAIL(thiz); TinyMutex_Dispose(thiz); tiny_free(thiz); }
/** ******************************************************************************* * @fn DX11Cleanup * @brief Create shader resource view from AMP array buffer * * @return void ******************************************************************************/ int DX11Engine::createSRVFromAMPBuffer() { // Bind a resource view to the CS buffer D3D11_BUFFER_DESC descBuf; ZeroMemory(&descBuf, sizeof(descBuf)); if(NULL != pVertexPosBuffer) { pVertexPosBuffer->GetDesc(&descBuf); } else { return E_FAIL; } D3D11_SHADER_RESOURCE_VIEW_DESC DescRV; ZeroMemory(&DescRV, sizeof(DescRV)); DescRV.Format = DXGI_FORMAT_R32_TYPELESS; DescRV.ViewDimension = D3D11_SRV_DIMENSION_BUFFEREX; DescRV.BufferEx.Flags = D3D11_BUFFEREX_SRV_FLAG_RAW; DescRV.Buffer.FirstElement = 0; DescRV.Buffer.NumElements = descBuf.ByteWidth / sizeof(int); RETURN_IF_FAIL(pD3D11Device->CreateShaderResourceView(pVertexPosBuffer, &DescRV, &pColorMap)); return NOERROR; }
void CtSelector_Reset(CtSelector *thiz) { RETURN_IF_FAIL(thiz); thiz->max_fd = 0; FD_ZERO(&thiz->read_set); FD_ZERO(&thiz->write_set); }
void CtCondition_Delete(CtCondition *thiz) { RETURN_IF_FAIL(thiz); CtCondition_NotifyAll(thiz); CtCondition_Dispose(thiz); ct_free(thiz); }
static int lp8720_enable(struct i2c_client* client, int status) { int ret = 0; struct lp8720_platform_data* pdata = client->dev.platform_data; if (status == 0) { // Standby mode gpio_set_value(pdata->en_gpio_num, 0); udelay(25*7); //ts*7 udelay(200); //tbon } else { // Normal mode gpio_set_value(pdata->en_gpio_num, 1); udelay(200); //tbon udelay(25*7); //ts*7 // Recover LDE settings if (enabled == 0) { RETURN_IF_FAIL(i2c_smbus_write_byte_data(client, LP8720_LDO1_SETTING, 0x19)); // 2.8V VT_CAM_DRV_2.8V RETURN_IF_FAIL(i2c_smbus_write_byte_data(client, LP8720_LDO2_SETTING, 0x0c)); // 1.8V VT_CAM_IO_1.8V RETURN_IF_FAIL(i2c_smbus_write_byte_data(client, LP8720_LDO3_SETTING, 0x17)); // 2.7V 2.7V_5M_VANA RETURN_IF_FAIL(i2c_smbus_write_byte_data(client, LP8720_LDO4_SETTING, 0x11)); // 1.8V 1.8V_5M_VIO RETURN_IF_FAIL(i2c_smbus_write_byte_data(client, LP8720_LDO5_SETTING, 0x19)); // 2.8V 2.8V_5M_VCM RETURN_IF_FAIL(i2c_smbus_write_byte_data(client, LP8720_BUCK_SETTING1, 0x09)); // Buck = 1.2V 1.2V_5M_VDIG RETURN_IF_FAIL(i2c_smbus_write_byte_data(client, LP8720_BUCK_SETTING2, 0x09)); // Buck = 1.2V } } enabled = status; return ret; }
static void download_image_async_cb(GTask* task, gpointer source, gpointer task_data, GCancellable* cancel) { RETURN_IF_FAIL(GT_IS_RESOURCE_DOWNLOADER(source)); RETURN_IF_FAIL(G_IS_TASK(task)); RETURN_IF_FAIL(task_data != NULL); GtResourceDownloader* self = GT_RESOURCE_DOWNLOADER(source); GError* err = NULL; GenericTaskData* data = task_data; GdkPixbuf* ret = gt_resource_downloader_download_image(self, data->str_1, data->str_2, &err); if (err) g_task_return_error(task, err); else g_task_return_pointer(task, ret, (GDestroyNotify) g_object_unref); }
static int do_test (void) { for (int i = 0; i < 10; i++) { pthread_attr_t attr; cpu_set_t *cpuset = CPU_ALLOC (512); size_t cpusetsize = CPU_ALLOC_SIZE (512); CPU_ZERO_S (cpusetsize, cpuset); RETURN_IF_FAIL (pthread_attr_init, &attr); RETURN_IF_FAIL (pthread_attr_setaffinity_np, &attr, cpusetsize, cpuset); CPU_FREE (cpuset); cpuset = CPU_ALLOC (1); cpusetsize = CPU_ALLOC_SIZE (1); RETURN_IF_FAIL (pthread_attr_getaffinity_np, &attr, cpusetsize, cpuset); CPU_FREE (cpuset); } return 0; }
void Title::OnTvnBeginDrag(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR); HTREEITEM pTreeItem = reinterpret_cast<HTREEITEM>(pNMTreeView->itemNew.hItem); if(!ItemHasChildren(pTreeItem)) { User *user = reinterpret_cast<User *>(GetItemData(pTreeItem)); RETURN_IF_FAIL(user != nullptr); sinashow::SendMessage(WM_SELECT_USER, (WPARAM)0, (LPARAM)user); } }
static void send_message_cb(GObject* source, GAsyncResult* res, gpointer udata) { RETURN_IF_FAIL(SOUP_IS_SESSION(source)); RETURN_IF_FAIL(G_IS_ASYNC_RESULT(res)); RETURN_IF_FAIL(udata != NULL); ResourceData* data = udata; GtResourceDownloader* self = GT_RESOURCE_DOWNLOADER(data->self); GtResourceDownloaderPrivate* priv = gt_resource_downloader_get_instance_private(self); g_autoptr(GError) err = NULL; data->istream = soup_session_send_finish(SOUP_SESSION(source), res, &err); if (!err) g_thread_pool_push(dl_pool, data, NULL); else { data->cb(NULL, data->udata, g_steal_pointer(&err)); resource_data_free(data); } }
static int lp8720_ldo_update(struct i2c_client* client) { int ret = 0; u8 output = 0; printk(KERN_DEBUG "%s: cam(%d) af(%d) vt(%d)\n", __FUNCTION__, cam, af, vt); if (cam) output |= (BUCK_EN | LDO3_EN | LDO4_EN); if (af) output |= LDO5_EN; if (vt) output |= (LDO1_EN | LDO2_EN); if (output) output |= DVS_V1; RETURN_IF_FAIL(lp8720_enable(client, output)); if(output) { RETURN_IF_FAIL(i2c_smbus_write_byte_data(client, LP8720_OUTPUT_ENABLE, output)); } return ret; }
ste_adm_res_t il_tool_set_buffer_time(il_comp_t comp, OMX_U32 port, unsigned int buffer_time, unsigned buffer_count) { OMX_PARAM_PORTDEFINITIONTYPE portdef; IL_TOOL_INIT_CONFIG_STRUCT(portdef); portdef.nPortIndex = port; RETURN_IF_FAIL(il_tool_GetParameter(comp, OMX_IndexParamPortDefinition, &portdef)); if (buffer_time > 0) { OMX_AUDIO_PARAM_PCMMODETYPE pcmmode; IL_TOOL_INIT_CONFIG_STRUCT(pcmmode); pcmmode.nPortIndex = port; RETURN_IF_FAIL(il_tool_GetParameter(comp, OMX_IndexParamAudioPcm, &pcmmode)); unsigned int bytes = 2 * pcmmode.nChannels * pcmmode.nSamplingRate * buffer_time / 1000; portdef.nBufferSize = bytes; } if (buffer_count > 0) { portdef.nBufferCountActual = buffer_count; } return il_tool_SetParameter(comp, OMX_IndexParamPortDefinition, &portdef); }
/******************************************************************************** * Execution of program begins from here * ********************************************************************************/ int main(int argc, char **argv) { bool isVistaOrWin7 = false; std::cout << "**********************************************" << std::endl; std::cout << "C++ AMP DirectX 11 Interop" << std::endl; std::cout << "**********************************************" << std::endl; // Find the version of Windows OSVERSIONINFO vInfo; memset(&vInfo, 0, sizeof(vInfo)); vInfo.dwOSVersionInfoSize = sizeof(vInfo); if(!GetVersionEx(&vInfo)) { std::cout << "\nERROR : Unable to get Windows version information.\n" << std::endl; return E_FAIL; } if(vInfo.dwMajorVersion >= 6) isVistaOrWin7 = true; if(!isVistaOrWin7) { std::cout << "Unsupported OS!\n"; return NOERROR; } AMPInteropDX11 ampSimpleDX11; RETURN_IF_FAIL(ampSimpleDX11.parseOptions(argc, argv)); RETURN_IF_FAIL(ampSimpleDX11.init()); RETURN_IF_FAIL(ampSimpleDX11.run()); DX11Engine::getInstance()->exitWindow(); return NOERROR; }
hyresult DeRef() { Result res; TracerPtr tracer; res = This()->GetTracer(tracer.EditPtr()); if(mCount > 0) { --mCount; } if(mCount == 0) { res = This()->Destruct(); RETURN_IF_FAIL(res, tracer); } return res; }
void gt_resource_downloader_download_image_async(GtResourceDownloader* self, const gchar* uri, const gchar* name, GAsyncReadyCallback cb, GCancellable* cancel, gpointer udata) { RETURN_IF_FAIL(GT_IS_RESOURCE_DOWNLOADER(self)); g_autoptr(GTask) task = g_task_new(self, cancel, cb, udata); GenericTaskData* data = generic_task_data_new(); data->str_1 = g_strdup(uri); data->str_2 = g_strdup(name); g_task_set_task_data(task, data, (GDestroyNotify) generic_task_data_free); g_task_run_in_thread(task, download_image_async_cb); }
static void download_cb(ResourceData* data, gpointer udata) { RETURN_IF_FAIL(data != NULL); g_autoptr(GdkPixbuf) ret = NULL; g_autoptr(GError) err = NULL; gboolean from_file = FALSE; ret = download_image(data->self, data->uri, data->name, data->msg, data->istream, &from_file, &err); data->cb(from_file ? NULL : g_steal_pointer(&ret), data->udata, g_steal_pointer(&err)); resource_data_free(data); }