本文整理汇总了C++中PLT_ActionReference::AsPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ PLT_ActionReference::AsPointer方法的具体用法?C++ PLT_ActionReference::AsPointer怎么用?C++ PLT_ActionReference::AsPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PLT_ActionReference
的用法示例。
在下文中一共展示了PLT_ActionReference::AsPointer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlayMedia
/*----------------------------------------------------------------------
| CUPnPRenderer::OnSetAVTransportURI
+---------------------------------------------------------------------*/
NPT_Result
CUPnPRenderer::OnSetAVTransportURI(PLT_ActionReference& action)
{
NPT_String uri, meta;
PLT_Service* service;
NPT_CHECK_SEVERE(FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", service));
NPT_CHECK_SEVERE(action->GetArgumentValue("CurrentURI", uri));
NPT_CHECK_SEVERE(action->GetArgumentValue("CurrentURIMetaData", meta));
// if not playing already, just keep around uri & metadata
// and wait for play command
if (!g_application.m_pPlayer->IsPlaying() && g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) {
service->SetStateVariable("TransportState", "STOPPED");
service->SetStateVariable("TransportStatus", "OK");
service->SetStateVariable("TransportPlaySpeed", "1");
service->SetStateVariable("AVTransportURI", uri);
service->SetStateVariable("AVTransportURIMetaData", meta);
service->SetStateVariable("NextAVTransportURI", "");
service->SetStateVariable("NextAVTransportURIMetaData", "");
NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable());
return NPT_SUCCESS;
}
return PlayMedia(uri, meta, action.AsPointer());
}
示例2: OnActionResponse
NPT_Result GPAC_GenericController::OnActionResponse(NPT_Result res, PLT_ActionReference& action, void* userdata)
{
#ifdef GPAC_HAS_SPIDERMONKEY
u32 i, count;
GPAC_DeviceItem *item = NULL;
GPAC_ServiceItem *serv = NULL;
GPAC_ActionArgListener *argl, *act_l;
PLT_Service* service = action->GetActionDesc().GetService();
NPT_String uuid;
GPAC_ActionUDTA *act_udta = (GPAC_ActionUDTA *)userdata;
/*this is NOT an actionResponse to an action triggered on a generic device*/
if (act_udta && act_udta->m_Reserved) act_udta = NULL;
GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[UPnP] Receive %s Response - error code %d\n", (char *) action->GetActionDesc().GetName(), res));
gf_mx_p(m_ControlPointLock);
/*get our device*/
uuid = service->GetDevice()->GetUUID();
count = gf_list_count(m_Devices);
for (i=0; i<count; i++) {
item = (GPAC_DeviceItem *) gf_list_get(m_Devices, i);
if (item->m_UUID == uuid ) {
break;
}
item = NULL;
}
gf_mx_v(m_ControlPointLock);
if (!item) {
GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[UPnP] Receive %s Response on unknown device (uuid %s)\n", (char *) action->GetActionDesc().GetName(), (char *) uuid));
goto exit;
}
/*get our service*/
count = gf_list_count(item->m_Services);
for (i=0; i<count; i++) {
serv = (GPAC_ServiceItem *)gf_list_get(item->m_Services, i);
if (serv->m_service == service) break;
}
if (!serv) {
GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[UPnP] Receive %s Response on unknown service %s\n", (char *) action->GetActionDesc().GetName(), (char *) service->GetServiceType()));
goto exit;
}
/*locate our listeners*/
act_l = NULL;
i=0;
while ((argl = (GPAC_ActionArgListener *)gf_list_enum(serv->m_ArgListeners, &i))) {
NPT_String value;
GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[UPnP] checking argument %s\n", (char *) argl->action->GetName() ));
if (argl->action->GetName() != action->GetActionDesc().GetName() ) continue;
/*global action listener*/
if (argl->arg==NULL) {
act_l = argl;
continue;
}
/*if error don't trigger listeners*/
if (res != NPT_SUCCESS) {
GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[UPnP] Receive %s Response: error on remote device %d\n", (char *) action->GetActionDesc().GetName(), res));
continue;
}
/*action arg listener*/
if (action->GetArgumentValue(argl->arg->GetName(), value) == NPT_SUCCESS) {
jsval argv[1], rval;
GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[UPnP] Calling handler for response %s argument %s\n", (char *) action->GetActionDesc().GetName(), (char *) argl->arg->GetName() ));
m_pUPnP->LockJavascript(GF_TRUE);
argv[0] = STRING_TO_JSVAL( JS_NewStringCopyZ(serv->js_ctx, value) );
JS_CallFunctionValue(serv->js_ctx, serv->obj, argl->on_event, 1, argv, &rval);
m_pUPnP->LockJavascript(GF_FALSE);
} else {
GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[UPnP] %s Response: couldn't get argument %s value\n", (char *) action->GetActionDesc().GetName(), (char *) argl->arg->GetName() ));
}
}
if (act_l) {
jsval rval;
m_pUPnP->LockJavascript(GF_TRUE);
if (act_l->is_script) {
JSObject *act_obj;
jsval argv[2];
GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[UPnP] Calling handler for response %s\n", (char *) action->GetActionDesc().GetName()));
act_obj = JS_NewObject(serv->js_ctx, &item->m_pUPnP->upnpDeviceClass._class, 0, item->obj);
SMJS_SET_PRIVATE(serv->js_ctx, act_obj, (void *)action.AsPointer() );
JS_DefineFunction(serv->js_ctx, act_obj, "GetArgumentValue", upnp_action_get_argument_value, 1, 0);
JS_DefineFunction(serv->js_ctx, act_obj, "GetErrorCode", upnp_action_get_error_code, 1, 0);
JS_DefineFunction(serv->js_ctx, act_obj, "GetError", upnp_action_get_error, 1, 0);
gf_js_add_root(serv->js_ctx, &act_obj, GF_JSGC_OBJECT);
argv[0] = OBJECT_TO_JSVAL(act_obj);
if (act_udta) {
argv[1] = act_udta->udta;
JS_CallFunctionValue(serv->js_ctx, serv->obj, act_l->on_event, 2, argv, &rval);
} else {
JS_CallFunctionValue(serv->js_ctx, serv->obj, act_l->on_event, 1, argv, &rval);
}
//.........这里部分代码省略.........