本文整理汇总了C++中PLT_Service类的典型用法代码示例。如果您正苦于以下问题:C++ PLT_Service类的具体用法?C++ PLT_Service怎么用?C++ PLT_Service使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PLT_Service类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NPT_CHECK_WARNING
/*----------------------------------------------------------------------
| PLT_MediaRenderer::OnSetAVTransportURI
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaRenderer::OnSetAVTransportURI(PLT_ActionReference& action)
{
/*test*/
PLT_Service* serviceAVT;
NPT_CHECK_WARNING(FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", serviceAVT));
// update service state variables
//serviceAVT->SetStateVariable("TransportState", "TRANSITIONING");
/*test*/
if (m_Delegate) {
return m_Delegate->OnSetAVTransportURI(action);
}
// default implementation is using state variable
NPT_String uri;
NPT_CHECK_WARNING(action->GetArgumentValue("CurrentURI", uri));
NPT_String metadata;
NPT_CHECK_WARNING(action->GetArgumentValue("CurrentURIMetaData", metadata));
//PLT_Service* serviceAVT;
//NPT_CHECK_WARNING(FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", serviceAVT));
// update service state variables
serviceAVT->SetStateVariable("AVTransportURI", uri);
serviceAVT->SetStateVariable("AVTransportURIMetaData", metadata);
//serviceAVT->SetStateVariable("TransportState", "PLAYING");//test
OutputDebugString(uri.GetChars());
return NPT_SUCCESS;
}
示例2: lock
/*----------------------------------------------------------------------
| PLT_MediaBrowser::OnDeviceAdded
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaBrowser::OnDeviceAdded(PLT_DeviceDataReference& device)
{
// verify the device implements the function we need
PLT_Service* serviceCDS;
PLT_Service* serviceCMR;
NPT_String type;
if (!device->GetType().StartsWith("urn:schemas-upnp-org:device:MediaServer"))
return NPT_FAILURE;
type = "urn:schemas-upnp-org:service:ContentDirectory:*";
if (NPT_FAILED(device->FindServiceByType(type, serviceCDS))) {
NPT_LOG_WARNING_2("Service %s not found in device \"%s\"",
type.GetChars(),
device->GetFriendlyName().GetChars());
return NPT_FAILURE;
} else {
// in case it's a newer upnp implementation, force to 1
serviceCDS->ForceVersion(1);
}
type = "urn:schemas-upnp-org:service:ConnectionManager:*";
if (NPT_FAILED(device->FindServiceByType(type, serviceCMR))) {
NPT_LOG_WARNING_2("Service %s not found in device \"%s\"",
type.GetChars(),
device->GetFriendlyName().GetChars());
return NPT_FAILURE;
} else {
// in case it's a newer upnp implementation, force to 1
serviceCMR->ForceVersion(1);
}
{
NPT_AutoLock lock(m_MediaServers);
PLT_DeviceDataReference data;
NPT_String uuid = device->GetUUID();
// is it a new device?
if (NPT_SUCCEEDED(NPT_ContainerFind(m_MediaServers, PLT_DeviceDataFinder(uuid), data))) {
NPT_LOG_WARNING_1("Device (%s) is already in our list!", (const char*)uuid);
return NPT_FAILURE;
}
NPT_LOG_FINE_1("Device Found: %s", (const char*)*device);
m_MediaServers.Add(device);
}
if (m_Delegate && m_Delegate->OnMSAdded(device)) {
m_CtrlPoint->Subscribe(serviceCDS);
m_CtrlPoint->Subscribe(serviceCMR);
}
return NPT_SUCCESS;
}
示例3: RefreshServiceList
void GPAC_DeviceItem::RefreshServiceList()
{
u32 i;
NPT_Array<PLT_Service*> services = m_device->GetServices();
for (i=0; i<services.GetItemCount(); i++) {
PLT_Service *serv = services[i];
FindService(serv->GetServiceType());
}
}
示例4: 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());
}
示例5: PLT_Service
/*----------------------------------------------------------------------
| PLT_LightSampleDevice::SetupServices
+---------------------------------------------------------------------*/
NPT_Result
PLT_LightSampleDevice::SetupServices(PLT_DeviceData& data)
{
PLT_Service* service = new PLT_Service(
this,
"urn:schemas-upnp-org:service:SwitchPower:1",
"urn:upnp-org:serviceId:SwitchPower.001");
NPT_CHECK_FATAL(service->SetSCPDXML((const char*)SCPDXML));
NPT_CHECK_FATAL(service->InitURLs("SwitchPower", m_UUID));
NPT_CHECK_FATAL(data.AddService(service));
service->SetStateVariable("Status", "True");
return NPT_SUCCESS;
}
示例6: PLT_Service
/*----------------------------------------------------------------------
| PLT_Simple::SetupServices
+---------------------------------------------------------------------*/
NPT_Result
PLT_Simple::SetupServices()
{
PLT_Service* service = new PLT_Service(
this,
"urn:schemas-upnp-org:service:Test:1",
"urn:upnp-org:serviceId:Test.001",
"Test");
NPT_CHECK_FATAL(service->SetSCPDXML((const char*)SCPDXML_SIMPLE));
NPT_CHECK_FATAL(AddService(service));
service->SetStateVariable("Status", "True");
return NPT_SUCCESS;
}
示例7: msg
/*----------------------------------------------------------------------
| CUPnPRenderer::OnSetAVTransportURI
+---------------------------------------------------------------------*/
NPT_Result
CUPnPRenderer::OnSetNextAVTransportURI(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("NextURI", uri));
NPT_CHECK_SEVERE(action->GetArgumentValue("NextURIMetaData", meta));
CFileItemPtr item = GetFileItem(uri, meta);
if (!item) {
return NPT_FAILURE;
}
#if 0
if (g_application.m_pPlayer->IsPlaying()) {
int playlist = PLAYLIST_MUSIC;
if(item->IsVideo())
playlist = PLAYLIST_VIDEO;
{ CSingleLock lock(g_graphicsContext);
g_playlistPlayer.ClearPlaylist(playlist);
g_playlistPlayer.Add(playlist, item);
g_playlistPlayer.SetCurrentSong(-1);
g_playlistPlayer.SetCurrentPlaylist(playlist);
}
CGUIMessage msg(GUI_MSG_PLAYLIST_CHANGED, 0, 0);
g_windowManager.SendThreadMessage(msg);
service->SetStateVariable("NextAVTransportURI", uri);
service->SetStateVariable("NextAVTransportURIMetaData", meta);
NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable());
return NPT_SUCCESS;
} else if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) {
return NPT_FAILURE;
} else {
return NPT_FAILURE;
}
#endif
return NPT_SUCCESS;
}
示例8: PLT_DeviceHost
/*----------------------------------------------------------------------
| PLT_LightSampleDevice::PLT_LightSampleDevice
+---------------------------------------------------------------------*/
PLT_LightSampleDevice::PLT_LightSampleDevice(char* FriendlyName, char* UUID) :
PLT_DeviceHost("/", UUID, "urn:schemas-upnp-org:device:SwitchPower:1", FriendlyName)
{
PLT_Service* service = new PLT_Service(
this,
"urn:schemas-upnp-org:service:SwitchPower:1",
"urn:upnp-org:serviceId:SwitchPower.001");
if (SCPDXML &&
NPT_SUCCEEDED(service->SetSCPDXML((const char*)SCPDXML))) {
service->InitURLs("SwitchPower", m_UUID);
AddService(service);
} else {
delete service;
}
service->SetStateVariable("Status", "True");
}
示例9: PLT_Service
/*----------------------------------------------------------------------
| PLT_LightSampleDevice::SetupServices
+---------------------------------------------------------------------*/
NPT_Result
PLT_LightSampleDevice::SetupServices()
{
NPT_Result res;
PLT_Service* service = new PLT_Service(
this,
"urn:schemas-upnp-org:service:SwitchPower:1",
"urn:upnp-org:serviceId:SwitchPower.001",
"SwitchPower");
NPT_CHECK_LABEL_FATAL(res = service->SetSCPDXML((const char*)SCPDXML), failure);
NPT_CHECK_LABEL_FATAL(res = AddService(service), failure);
service->SetStateVariable("Status", "True");
return NPT_SUCCESS;
failure:
delete service;
return res;
}
示例10: if
/*----------------------------------------------------------------------
| CUPnPRenderer::OnPlay
+---------------------------------------------------------------------*/
NPT_Result
CUPnPRenderer::OnPlay(PLT_ActionReference& action)
{
if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) {
return NPT_SUCCESS;
} else if (g_application.m_pPlayer->IsPausedPlayback()) {
CApplicationMessenger::GetInstance().SendMsg(TMSG_MEDIA_PAUSE);
} else if (!g_application.m_pPlayer->IsPlaying()) {
NPT_String uri, meta;
PLT_Service* service;
// look for value set previously by SetAVTransportURI
NPT_CHECK_SEVERE(FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", service));
NPT_CHECK_SEVERE(service->GetStateVariableValue("AVTransportURI", uri));
NPT_CHECK_SEVERE(service->GetStateVariableValue("AVTransportURIMetaData", meta));
// if not set, use the current file being played
PlayMedia(uri, meta);
}
return NPT_SUCCESS;
}
示例11: NPT_CHECK_WARNING
/*----------------------------------------------------------------------
| PLT_MediaController::GetProtocolInfoSink
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaController::GetProtocolInfoSink(PLT_DeviceDataReference& device,
NPT_List<NPT_String>& sinks)
{
PLT_DeviceDataReference renderer;
NPT_CHECK_WARNING(FindRenderer(device->GetUUID(), renderer));
// look for ConnectionManager service
PLT_Service* serviceCMR;
NPT_CHECK_SEVERE(device->FindServiceByType(
"urn:schemas-upnp-org:service:ConnectionManager:*",
serviceCMR));
NPT_String value;
NPT_CHECK_SEVERE(serviceCMR->GetStateVariableValue(
"SinkProtocolInfo",
value));
sinks = value.Split(",");
return NPT_SUCCESS;
}
示例12: PLT_Service
/*----------------------------------------------------------------------
| PLT_Simple::SetupServices
+---------------------------------------------------------------------*/
NPT_Result
PLT_Simple::SetupServices()
{
NPT_Result res;
PLT_Service* service = new PLT_Service(
this,
"urn:schemas-upnp-org:service:Test:1",
"urn:upnp-org:serviceId:Test.001",
"Test");
NPT_CHECK_LABEL_FATAL(res = service->SetSCPDXML((const char*)SCPDXML_SIMPLE), failure);
NPT_CHECK_LABEL_FATAL(res = AddService(service), failure);
service->SetStateVariable("Status", "True");
return NPT_SUCCESS;
failure:
delete service;
return res;
}
示例13: NPT_CHECK_WARNING
/*----------------------------------------------------------------------
| PLT_MediaRenderer::OnSetAVTransportURI
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaRenderer::OnSetAVTransportURI(PLT_ActionReference& action)
{
if (m_Delegate) {
return m_Delegate->OnSetAVTransportURI(action);
}
// default implementation is using state variable
NPT_String uri;
NPT_CHECK_WARNING(action->GetArgumentValue("CurrentURI", uri));
NPT_String metadata;
NPT_CHECK_WARNING(action->GetArgumentValue("CurrentURIMetaData", metadata));
PLT_Service* serviceAVT;
NPT_CHECK_WARNING(FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", serviceAVT));
// update service state variables
serviceAVT->SetStateVariable("AVTransportURI", uri);
serviceAVT->SetStateVariable("AVTransportURIMetaData", metadata);
serviceAVT->SetStateVariable("TransportState", "STOPPED");
serviceAVT->SetStateVariable("TransportStatus", "OK");
serviceAVT->SetStateVariable("TransportPlaySpeed", "1");
NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable());
return NPT_SUCCESS;
}
示例14: lock
/*----------------------------------------------------------------------
| CUPnPRenderer::PlayMedia
+---------------------------------------------------------------------*/
NPT_Result
CUPnPRenderer::PlayMedia(const NPT_String& uri, const NPT_String& meta, PLT_Action* action)
{
PLT_Service* service;
NPT_CHECK_SEVERE(FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", service));
{ NPT_AutoLock lock(m_state);
service->SetStateVariable("TransportState", "TRANSITIONING");
service->SetStateVariable("TransportStatus", "OK");
}
CFileItemPtr item = GetFileItem(uri, meta);
if (!item) {
return NPT_FAILURE;
}
if (item->IsPicture()) {
CApplicationMessenger::GetInstance().PostMsg(TMSG_PICTURE_SHOW, -1, -1, nullptr, item->GetPath());
} else {
CFileItemList *l = new CFileItemList; //don't delete,
l->Add(std::make_shared<CFileItem>(*item));
CApplicationMessenger::GetInstance().PostMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l));
}
// just return success because the play actions are asynchronous
NPT_AutoLock lock(m_state);
service->SetStateVariable("TransportState", "PLAYING");
service->SetStateVariable("TransportStatus", "OK");
service->SetStateVariable("AVTransportURI", uri);
service->SetStateVariable("AVTransportURIMetaData", meta);
service->SetStateVariable("NextAVTransportURI", "");
service->SetStateVariable("NextAVTransportURIMetaData", "");
if (action) {
NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable());
}
return NPT_SUCCESS;
}
示例15: gf_list_count
GPAC_ServiceItem *GPAC_DeviceItem::FindService(const char *type)
{
u32 i, count;
GPAC_ServiceItem *serv;
count = gf_list_count(m_Services);
for (i=0; i<count; i++) {
serv = (GPAC_ServiceItem*)gf_list_get(m_Services, i);
if (serv->m_service->GetServiceType() == type)
return serv;
}
PLT_Service *service;
if (m_device->FindServiceByType(type, service) != NPT_SUCCESS) return NULL;
serv = new GPAC_ServiceItem(this, service);
#ifdef GPAC_HAS_SPIDERMONKEY
serv->js_ctx = js_ctx;
serv->obj = JS_NewObject(serv->js_ctx, &m_pUPnP->upnpServiceClass._class, 0, obj);
gf_js_add_root(serv->js_ctx, &serv->obj, GF_JSGC_OBJECT);
SMJS_SET_PRIVATE(serv->js_ctx, serv->obj, serv);
JS_DefineProperty(serv->js_ctx, serv->obj, "Name", STRING_TO_JSVAL( JS_NewStringCopyZ(serv->js_ctx, service->GetServiceID()) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineProperty(serv->js_ctx, serv->obj, "Type", STRING_TO_JSVAL( JS_NewStringCopyZ(serv->js_ctx, service->GetServiceType()) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineProperty(serv->js_ctx, serv->obj, "Hostname", STRING_TO_JSVAL( JS_NewStringCopyZ(serv->js_ctx, m_device->GetURLBase().GetHost() ) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(serv->js_ctx, serv->obj, "SetStateVariableListener", upnp_service_set_listener, 1, 0);
JS_DefineFunction(serv->js_ctx, serv->obj, "HasStateVariable", upnp_service_has_var, 1, 0);
JS_DefineFunction(serv->js_ctx, serv->obj, "HasAction", upnp_service_has_action, 2, 0);
JS_DefineFunction(serv->js_ctx, serv->obj, "CallAction", upnp_service_call_action, 2, 0);
JS_DefineFunction(serv->js_ctx, serv->obj, "SetActionListener", upnp_service_set_action_listener, 2, 0);
JS_DefineFunction(serv->js_ctx, serv->obj, "GetSCPD", upnp_service_get_scpd, 1, 0);
#endif
gf_list_add(m_Services, serv);
return serv;
}