本文整理汇总了C++中PLT_ActionReference::SetError方法的典型用法代码示例。如果您正苦于以下问题:C++ PLT_ActionReference::SetError方法的具体用法?C++ PLT_ActionReference::SetError怎么用?C++ PLT_ActionReference::SetError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PLT_ActionReference
的用法示例。
在下文中一共展示了PLT_ActionReference::SetError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
/*----------------------------------------------------------------------
| PLT_LightSampleDevice::OnAction
+---------------------------------------------------------------------*/
NPT_Result
PLT_LightSampleDevice::OnAction(PLT_ActionReference& action, NPT_SocketInfo* /* info */)
{
/* parse the action name */
NPT_String name = action->GetActionDesc()->GetName();
if (name.Compare("SetTarget") == 0) {
NPT_String value;
action->GetArgumentValue("newTargetValue", value);
PLT_StateVariable* variable = action->GetActionDesc()->GetService()->FindStateVariable("Status");
if (NPT_FAILED(variable->SetValue(value))) {
action->SetError(402, "Invalid Args");
return NPT_FAILURE;
}
return NPT_SUCCESS;
} else if (name.Compare("GetStatus") == 0) {
PLT_StateVariable* variable = action->GetActionDesc()->GetService()->FindStateVariable("Status");
if (variable) {
action->SetArgumentValue("ResultStatus", variable->GetValue());
return NPT_SUCCESS;
}
}
action->SetError(501, "Action Failed");
return NPT_FAILURE;
}
示例2: OnBrowseDirectChildren
/*----------------------------------------------------------------------
| PLT_FileMediaConnectDelegate::OnSearchContainer
+---------------------------------------------------------------------*/
NPT_Result
PLT_FileMediaConnectDelegate::OnSearchContainer(PLT_ActionReference& action,
const char* object_id,
const char* search_criteria,
const char* filter,
NPT_UInt32 starting_index,
NPT_UInt32 requested_count,
const char* sort_criteria,
const PLT_HttpRequestContext& context)
{
/* parse search criteria */
/* TODO: HACK TO PASS DLNA */
if (search_criteria && NPT_StringsEqual(search_criteria, "Unknownfieldname")) {
/* error */
NPT_LOG_WARNING_1("Unsupported or invalid search criteria %s", search_criteria);
action->SetError(708, "Unsupported or invalid search criteria");
return NPT_FAILURE;
}
/* locate the file from the object ID */
NPT_String dir;
if (NPT_FAILED(GetFilePath(object_id, dir))) {
/* error */
NPT_LOG_WARNING("ObjectID not found.");
action->SetError(710, "No Such Container.");
return NPT_FAILURE;
}
/* retrieve the item type */
NPT_FileInfo info;
NPT_Result res = NPT_File::GetInfo(dir, &info);
if (NPT_FAILED(res) || (info.m_Type != NPT_FileInfo::FILE_TYPE_DIRECTORY)) {
/* error */
NPT_LOG_WARNING("No such container");
action->SetError(710, "No such container");
return NPT_FAILURE;
}
/* hack for now to return something back to XBox 360 */
return OnBrowseDirectChildren(action,
object_id,
filter,
starting_index,
requested_count,
sort_criteria,
context);
}
示例3:
/*----------------------------------------------------------------------
| PLT_MediaRenderer::OnGetCurrentConnectionInfo
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaRenderer::OnGetCurrentConnectionInfo(PLT_ActionReference& action)
{
if (NPT_FAILED(action->VerifyArgumentValue("ConnectionID", "0"))) {
action->SetError(706,"No Such Connection.");
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("RcsID", "0"))){
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("AVTransportID", "0"))) {
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("ProtocolInfo", "http-get:*:*:*"))) {
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("PeerConnectionManager", "/"))) {
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("PeerConnectionID", "-1"))) {
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("Direction", "Input"))) {
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("Status", "Unknown"))) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
示例4: called
NPT_Result
GPAC_GenericDevice::OnAction(PLT_ActionReference& action,
const PLT_HttpRequestContext& context)
{
NPT_COMPILER_UNUSED(context);
#ifdef GPAC_HAS_SPIDERMONKEY
gf_mx_p(m_pMutex);
#endif
PLT_ActionDesc &act_desc = action->GetActionDesc();
NPT_String name = act_desc.GetName();
#ifdef GPAC_HAS_SPIDERMONKEY
assert(!m_pSema);
#endif
GF_LOG(GF_LOG_INFO, GF_LOG_NETWORK, ("[UPnP] Action %s called (thread %d)\n", (char *) name, gf_th_id() ));
#ifdef GPAC_HAS_SPIDERMONKEY
if (JSVAL_IS_NULL(act_proc)) {
gf_mx_v(m_pMutex);
return NPT_SUCCESS;
}
jsval argv[2];
m_pUPnP->LockJavascript(GF_TRUE);
JSObject *js_action = JS_NewObject(m_pUPnP->m_pJSCtx, &m_pUPnP->upnpDeviceClass._class, 0, 0);
argv[0] = OBJECT_TO_JSVAL(js_action);
SMJS_SET_PRIVATE(m_pUPnP->m_pJSCtx, js_action, this);
act_ref = action;
JS_DefineProperty(m_pUPnP->m_pJSCtx, js_action, "Name", STRING_TO_JSVAL( JS_NewStringCopyZ(m_pUPnP->m_pJSCtx, name) ), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT);
GPAC_Service *service = (GPAC_Service *) act_desc.GetService();
JS_DefineProperty(m_pUPnP->m_pJSCtx, js_action, "Service", service->m_pObj ? OBJECT_TO_JSVAL( service->m_pObj) : JSVAL_NULL, 0, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(m_pUPnP->m_pJSCtx, js_action, "GetArgument", upnp_action_get_argument, 1, 0);
JS_DefineFunction(m_pUPnP->m_pJSCtx, js_action, "SendReply", upnp_action_send_reply, 1, 0);
/*create a semaphore*/
m_pSema = gf_sema_new(1, 0);
jsval rval;
JS_CallFunctionValue(m_pUPnP->m_pJSCtx, obj, act_proc, 1, argv, &rval);
SMJS_SET_PRIVATE(m_pUPnP->m_pJSCtx, js_action, NULL);
m_pUPnP->LockJavascript(GF_FALSE);
if (JSVAL_IS_INT(rval) && (JSVAL_TO_INT(rval) != 0)) {
action->SetError(JSVAL_TO_INT(rval), "Action Failed");
}
/*wait on the semaphore*/
if (!gf_sema_wait_for(m_pSema, 10000)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_NETWORK, ("[UPnP] Reply processing to action %s timeout - sending incomplete reply)\n", (char *) name));
}
gf_sema_del(m_pSema);
m_pSema = NULL;
gf_mx_v(m_pMutex);
#endif
return NPT_SUCCESS;
}
示例5:
/*----------------------------------------------------------------------
| PLT_MediaServer::OnGetCurrentConnectionInfo
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaServer::OnGetCurrentConnectionInfo(PLT_ActionReference& action,
const PLT_HttpRequestContext& context)
{
NPT_COMPILER_UNUSED(context);
if (NPT_FAILED(action->VerifyArgumentValue("ConnectionID", "0"))) {
action->SetError(706,"No Such Connection.");
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("RcsID", "-1"))){
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("AVTransportID", "-1"))) {
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("ProtocolInfo", "http-get:*:*:*"))) {
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("PeerConnectionManager", "/"))) {
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("PeerConnectionID", "-1"))) {
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("Direction", "Output"))) {
return NPT_FAILURE;
}
if (NPT_FAILED(action->SetArgumentValue("Status", "Unknown"))) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
示例6: OnBrowseRoot
/*----------------------------------------------------------------------
| PLT_MediaServer::OnBrowse
+---------------------------------------------------------------------*/
NPT_Result
CMediaCrawler::OnBrowse(PLT_ActionReference& action,
const NPT_HttpRequestContext& context)
{
NPT_Result res;
NPT_String object_id;
if (NPT_FAILED(action->GetArgumentValue("ObjectId", object_id))) {
NPT_LOG_WARNING("PLT_FileMediaServer::OnBrowse - invalid arguments.");
return NPT_FAILURE;
}
NPT_LOG_FINE_1("PLT_FileMediaServer::OnOnBrowse - id = %s\r\n", (const char*)object_id);
// extract server uuid and server object id from our object id
NPT_String server_uuid;
NPT_String server_object_id;
if (NPT_FAILED(SplitObjectId(object_id, server_uuid, server_object_id))) {
/* error */
NPT_LOG_WARNING("CMediaCrawler::OnBrowse - ObjectID not found.");
action->SetError(701, "No Such Object.");
return NPT_FAILURE;
}
// root ?
if (server_uuid.GetLength() == 0) {
res = OnBrowseRoot(action);
} else {
// we have a device to browse
// is it device root?
if (server_object_id.GetLength() == 0) {
server_object_id = "0";
}
res = OnBrowseDevice(action, server_uuid, server_object_id, context);
}
if (NPT_FAILED(res) && (action->GetErrorCode() == 0)) {
action->SetError(800, "Internal error");
}
return res;
}
示例7: OnSeek
NPT_Result GPAC_MediaRenderer::OnSeek(PLT_ActionReference& action)
{
u32 h, m, s;
Double time;
NPT_String unit, target;
if (NPT_FAILED(action->GetArgumentValue("Unit", unit))) {
return NPT_FAILURE;
}
if (NPT_FAILED(action->GetArgumentValue("Target", target))) {
return NPT_FAILURE;
}
if ((unit!="ABS_TIME") && (unit!="REL_TIME")) {
action->SetError(710,"Seek mode not supported");
return NPT_FAILURE;
}
sscanf(target, "%d:%d:%d", &h, &m, &s);
time = h*3600.0 + m*60.0 + s;
m_pUPnP->OnSeek(time);
return NPT_SUCCESS;
}
示例8: OnBrowse
/*----------------------------------------------------------------------
| PLT_MediaServer::OnAction
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaServer::OnAction(PLT_ActionReference& action,
const PLT_HttpRequestContext& context)
{
/* parse the action name */
NPT_String name = action->GetActionDesc().GetName();
// ContentDirectory
if (name.Compare("Browse", true) == 0) {
return OnBrowse(action, context);
}
if (name.Compare("Search", true) == 0) {
return OnSearch(action, context);
}
if (name.Compare("UpdateObject", true) == 0) {
return OnUpdate(action, context);
}
if (name.Compare("GetSystemUpdateID", true) == 0) {
return OnGetSystemUpdateID(action, context);
}
if (name.Compare("GetSortCapabilities", true) == 0) {
return OnGetSortCapabilities(action, context);
}
if (name.Compare("GetSearchCapabilities", true) == 0) {
return OnGetSearchCapabilities(action, context);
}
// ConnectionMananger
if (name.Compare("GetCurrentConnectionIDs", true) == 0) {
return OnGetCurrentConnectionIDs(action, context);
}
if (name.Compare("GetProtocolInfo", true) == 0) {
return OnGetProtocolInfo(action, context);
}
if (name.Compare("GetCurrentConnectionInfo", true) == 0) {
return OnGetCurrentConnectionInfo(action, context);
}
action->SetError(401,"No Such Action.");
return NPT_SUCCESS;
}
示例9: directory
/*----------------------------------------------------------------------
| PLT_FileMediaServer::OnBrowseDirectChildren
+---------------------------------------------------------------------*/
NPT_Result
PLT_FileMediaServer::OnBrowseDirectChildren(PLT_ActionReference& action,
const char* object_id,
NPT_SocketInfo* info /* = NULL */)
{
/* locate the file from the object ID */
NPT_String dir;
if (NPT_FAILED(GetFilePath(object_id, dir))) {
/* error */
NPT_LOG_WARNING("PLT_FileMediaServer::OnBrowse - ObjectID not found.");
action->SetError(701, "No Such Object.");
return NPT_FAILURE;
}
/* retrieve the item type */
NPT_DirectoryEntryInfo entry_info;
NPT_Result res = NPT_DirectoryEntry::GetInfo(dir, entry_info);
if (NPT_FAILED(res)) {
/* Object does not exist */
action->SetError(800, "Can't retrieve info " + dir);
return NPT_FAILURE;
}
if (entry_info.type != NPT_DIRECTORY_TYPE) {
/* error */
NPT_LOG_WARNING("PLT_FileMediaServer::OnBrowse - BROWSEDIRECTCHILDREN not allowed on an item.");
action->SetError(710, "item is not a container.");
return NPT_FAILURE;
}
NPT_String filter;
NPT_String startingInd;
NPT_String reqCount;
NPT_CHECK_SEVERE(action->GetArgumentValue("Filter", filter));
NPT_CHECK_SEVERE(action->GetArgumentValue("StartingIndex", startingInd));
NPT_CHECK_SEVERE(action->GetArgumentValue("RequestedCount", reqCount));
unsigned long start_index, req_count;
if (NPT_FAILED(startingInd.ToInteger(start_index)) ||
NPT_FAILED(reqCount.ToInteger(req_count))) {
return NPT_FAILURE;
}
NPT_String path = dir;
if (!path.EndsWith(m_DirDelimiter)) {
path += m_DirDelimiter;
}
/* start iterating through the directory */
NPT_Directory directory(path);
NPT_String entryName;
res = directory.GetNextEntry(entryName);
if (NPT_FAILED(res)) {
NPT_LOG_WARNING_1("PLT_FileMediaServer::OnBrowseDirectChildren - failed to open dir %s", (const char*) path);
return res;
}
unsigned long cur_index = 0;
unsigned long num_returned = 0;
unsigned long total_matches = 0;
//unsigned long update_id = 0;
NPT_String didl = didl_header;
PLT_MediaObjectReference item;
do {
item = BuildFromFilePath(path + entryName, true, info);
if (!item.IsNull()) {
if ((cur_index >= start_index) && ((num_returned < req_count) || (req_count == 0))) {
NPT_String tmp;
NPT_CHECK_SEVERE(PLT_Didl::ToDidl(*item.AsPointer(), filter, tmp));
didl += tmp;
num_returned++;
}
cur_index++;
total_matches++;
}
res = directory.GetNextEntry(entryName);
} while (NPT_SUCCEEDED(res));
didl += didl_footer;
NPT_CHECK_SEVERE(action->SetArgumentValue("Result", didl));
NPT_CHECK_SEVERE(action->SetArgumentValue("NumberReturned", NPT_String::FromInteger(num_returned)));
NPT_CHECK_SEVERE(action->SetArgumentValue("TotalMatches", NPT_String::FromInteger(total_matches)));
NPT_CHECK_SEVERE(action->SetArgumentValue("UpdateId", "1"));
return NPT_SUCCESS;
}
示例10: OnGetCurrentConnectionInfo
/*----------------------------------------------------------------------
| PLT_MediaRenderer::OnAction
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaRenderer::OnAction(PLT_ActionReference& action, NPT_SocketInfo* info /* = NULL */)
{
NPT_COMPILER_UNUSED(info);
/* parse the action name */
NPT_String name = action->GetActionDesc()->GetName();
/* Is it a ConnectionManager Service Action ? */
if (name.Compare("GetCurrentConnectionIDs", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetProtocolInfo", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetCurrentConnectionInfo", true) == 0) {
return OnGetCurrentConnectionInfo(action);
}
/* Is it a AVTransport Service Action ? */
// since all actions take an instance ID and we only support 1 instance
// verify that the Instance ID is 0 and return an error here now if not
NPT_String serviceType = action->GetActionDesc()->GetService()->GetServiceType();
if (serviceType.Compare("urn:schemas-upnp-org:service:AVTransport:1", true) == 0) {
if (NPT_FAILED(action->VerifyArgumentValue("InstanceID", "0"))) {
action->SetError(802,"Not valid InstanceID.");
return NPT_FAILURE;
}
}
if (name.Compare("GetCurrentTransportActions", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetDeviceCapabilities", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetMediaInfo", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetPositionInfo", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetTransportInfo", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetTransportSettings", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("Next", true) == 0) {
return OnNext(action);
}
if (name.Compare("Pause", true) == 0) {
return OnPause(action);
}
if (name.Compare("Play", true) == 0) {
return OnPlay(action);
}
if (name.Compare("Previous", true) == 0) {
return OnPrevious(action);
}
if (name.Compare("Seek", true) == 0) {
return OnSeek(action);
}
if (name.Compare("Stop", true) == 0) {
return OnStop(action);
}
if (name.Compare("SetAVTransportURI", true) == 0) {
return OnSetAVTransportURI(action);
}
if (name.Compare("SetPlayMode", true) == 0) {
return OnSetPlayMode(action);
}
//.........这里部分代码省略.........
示例11: GetMediaServers
/*----------------------------------------------------------------------
| CMediaCrawler::OnBrowseRoot
+---------------------------------------------------------------------*/
NPT_Result
CMediaCrawler::OnBrowseRoot(PLT_ActionReference& action)
{
NPT_String browseFlagValue;
if (NPT_FAILED(action->GetArgumentValue("BrowseFlag", browseFlagValue))) {
NPT_LOG_WARNING("PLT_FileMediaServer::OnBrowse - invalid arguments.");
return NPT_FAILURE;
}
/* extract browseFlag */
BrowseFlags browseFlag;
if (NPT_FAILED(GetBrowseFlag(browseFlagValue, browseFlag))) {
/* error */
NPT_LOG_WARNING("PLT_FileMediaServer::OnBrowseRoot - BrowseFlag value not allowed.");
action->SetError(402,"Invalid BrowseFlag arg.");
return NPT_FAILURE;
}
if (browseFlag == BROWSEMETADATA) {
PLT_MediaContainer item;
item.m_Title = "Root";
item.m_ParentID = "-1";
item.m_ObjectID = "0";
item.m_ChildrenCount = GetMediaServers().GetItemCount();
item.m_ObjectClass.type = "object.container";
/* convert item to didl */
NPT_String filter;
action->GetArgumentValue("Filter", filter);
NPT_String tmp;
NPT_CHECK_SEVERE(PLT_Didl::ToDidl(item, filter, tmp));
/* add didl header and footer */
NPT_String didl = didl_header + tmp + didl_footer;
action->SetArgumentValue("Result", didl);
action->SetArgumentValue("NumberReturned", "1");
action->SetArgumentValue("TotalMatches", "1");
// update ID may be wrong here, it should be the one of the container?
action->SetArgumentValue("UpdateId", "1");
// TODO: We need to keep track of the overall updateID of the CDS
} else {
NPT_String startingInd;
NPT_String reqCount;
NPT_String filter;
NPT_CHECK_SEVERE(action->GetArgumentValue("StartingIndex", startingInd));
NPT_CHECK_SEVERE(action->GetArgumentValue("RequestedCount", reqCount));
NPT_CHECK_SEVERE(action->GetArgumentValue("Filter", filter));
unsigned long start_index, req_count;
if (NPT_FAILED(startingInd.ToInteger(start_index)) ||
NPT_FAILED(reqCount.ToInteger(req_count))) {
return NPT_FAILURE;
}
unsigned long cur_index = 0;
unsigned long num_returned = 0;
unsigned long total_matches = 0;
//unsigned long update_id = 0;
PLT_MediaContainer item;
NPT_String tmp;
NPT_String didl = didl_header;
// populate a list of containers (one container per known servers)
const NPT_Lock<PLT_DeviceDataReferenceList>& devices = GetMediaServers();
NPT_Lock<PLT_DeviceDataReferenceList>::Iterator entry = devices.GetFirstItem();
while (entry) {
PLT_DeviceDataReference device = (*entry);
item.m_Title = device->GetFriendlyName();
item.m_ObjectID = FormatObjectId(device->GetUUID(), "0");
item.m_ParentID = "0";
item.m_ObjectClass.type = "object.container";
if ((cur_index >= start_index) && ((num_returned < req_count) || (req_count == 0))) {
NPT_CHECK_SEVERE(PLT_Didl::ToDidl(item, filter, tmp));
didl += tmp;
num_returned++;
}
cur_index++;
total_matches++;
++entry;
}
didl += didl_footer;
action->SetArgumentValue("Result", didl);
action->SetArgumentValue("NumberReturned", NPT_String::FromInteger(num_returned));
action->SetArgumentValue("TotalMatches", NPT_String::FromInteger(total_matches));
action->SetArgumentValue("UpdateId", "1");
}
return NPT_SUCCESS;
}
示例12: OnGetCurrentConnectionInfo
/*----------------------------------------------------------------------
| PLT_MediaRenderer::OnAction
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaRenderer::OnAction(PLT_ActionReference& action,
const PLT_HttpRequestContext& context)
{
NPT_COMPILER_UNUSED(context);
/* parse the action name */
NPT_String name = action->GetActionDesc().GetName();
// since all actions take an instance ID and we only support 1 instance
// verify that the Instance ID is 0 and return an error here now if not
NPT_String serviceType = action->GetActionDesc().GetService()->GetServiceType();
if (serviceType.Compare("urn:schemas-upnp-org:service:AVTransport:1", true) == 0) {
if (NPT_FAILED(action->VerifyArgumentValue("InstanceID", "0"))) {
action->SetError(718, "Not valid InstanceID");
return NPT_FAILURE;
}
}
serviceType = action->GetActionDesc().GetService()->GetServiceType();
if (serviceType.Compare("urn:schemas-upnp-org:service:RenderingControl:1", true) == 0) {
if (NPT_FAILED(action->VerifyArgumentValue("InstanceID", "0"))) {
action->SetError(702, "Not valid InstanceID");
return NPT_FAILURE;
}
}
/* Is it a ConnectionManager Service Action ? */
if (name.Compare("GetCurrentConnectionInfo", true) == 0) {
return OnGetCurrentConnectionInfo(action);
}
/* Is it a AVTransport Service Action ? */
if (name.Compare("Next", true) == 0) {
return OnNext(action);
}
if (name.Compare("Pause", true) == 0) {
return OnPause(action);
}
if (name.Compare("Play", true) == 0) {
return OnPlay(action);
}
if (name.Compare("Previous", true) == 0) {
return OnPrevious(action);
}
if (name.Compare("Seek", true) == 0) {
return OnSeek(action);
}
if (name.Compare("Stop", true) == 0) {
return OnStop(action);
}
if (name.Compare("SetAVTransportURI", true) == 0) {
return OnSetAVTransportURI(action);
}
if (name.Compare("SetNextAVTransportURI", true) == 0) {
return OnSetNextAVTransportURI(action);
}
if (name.Compare("SetPlayMode", true) == 0) {
return OnSetPlayMode(action);
}
/* Is it a RendererControl Service Action ? */
if (name.Compare("SetVolume", true) == 0) {
return OnSetVolume(action);
}
if (name.Compare("SetVolumeDB", true) == 0) {
return OnSetVolumeDB(action);
}
if (name.Compare("GetVolumeDBRange", true) == 0) {
return OnGetVolumeDBRange(action);
}
if (name.Compare("SetMute", true) == 0) {
return OnSetMute(action);
}
// other actions rely on state variables
NPT_CHECK_LABEL_WARNING(action->SetArgumentsOutFromStateVariable(), failure);
return NPT_SUCCESS;
failure:
action->SetError(401,"No Such Action.");
return NPT_FAILURE;
}
示例13: OnGetCurrentConnectionInfo
NPT_Result
GPAC_MediaRenderer::OnAction(PLT_ActionReference& action,
const PLT_HttpRequestContext& context)
{
NPT_COMPILER_UNUSED(context);
/* parse the action name */
NPT_String name = action->GetActionDesc().GetName();
m_ip_src = context.GetRemoteAddress().GetIpAddress().ToString();
/* Is it a ConnectionManager Service Action ? */
if (name.Compare("GetCurrentConnectionIDs", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetProtocolInfo", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetCurrentConnectionInfo", true) == 0) {
return OnGetCurrentConnectionInfo(action);
}
if (name.Compare("StopForMigration", true) == 0) {
NPT_String res = m_pUPnP->OnMigrate();
m_pMigrationService->SetStateVariable("MigrationStatus", "OK");
m_pMigrationService->SetStateVariable("MigrationMetaData", res);
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
/* Is it a AVTransport Service Action ? */
// since all actions take an instance ID and we only support 1 instance
// verify that the Instance ID is 0 and return an error here now if not
NPT_String serviceType = action->GetActionDesc().GetService()->GetServiceType();
if (serviceType.Compare("urn:schemas-upnp-org:service:AVTransport:1", true) == 0) {
if (NPT_FAILED(action->VerifyArgumentValue("InstanceID", "0"))) {
action->SetError(802,"Not valid InstanceID.");
return NPT_FAILURE;
}
}
if (name.Compare("GetCurrentTransportActions", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetDeviceCapabilities", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetMediaInfo", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetPositionInfo", true) == 0) {
if (m_pUPnP->m_pTerm->root_scene) {
char szVal[100];
m_pAVService->SetStateVariable("CurrentTrack", "0");
format_time_string(szVal, m_Duration);
m_pAVService->SetStateVariable("CurrentTrackDuration", szVal);
m_pAVService->SetStateVariable("CurrentTrackMetadata", "");
m_pAVService->SetStateVariable("CurrentTrackURI", "");
format_time_string(szVal, m_Time);
m_pAVService->SetStateVariable("RelativeTimePosition", szVal);
m_pAVService->SetStateVariable("AbsoluteTimePosition", szVal);
m_pAVService->SetStateVariable("RelativeCounterPosition", "2147483647"); // means NOT_IMPLEMENTED
m_pAVService->SetStateVariable("AbsoluteCounterPosition", "2147483647"); // means NOT_IMPLEMENTED
} else {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
}
return NPT_SUCCESS;
}
if (name.Compare("GetTransportInfo", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
return NPT_SUCCESS;
}
if (name.Compare("GetTransportSettings", true) == 0) {
if (NPT_FAILED(action->SetArgumentsOutFromStateVariable())) {
return NPT_FAILURE;
}
//.........这里部分代码省略.........
示例14: arguments
/*----------------------------------------------------------------------
| PLT_MediaServer::OnSearch
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaServer::OnSearch(PLT_ActionReference& action,
const PLT_HttpRequestContext& context)
{
NPT_COMPILER_UNUSED(context);
NPT_Result res;
NPT_String container_id;
NPT_String search;
NPT_String filter;
NPT_String start;
NPT_String count;
NPT_String sort;
NPT_List<NPT_String> sort_list;
if (NPT_FAILED(action->GetArgumentValue("ContainerId", container_id)) ||
NPT_FAILED(action->GetArgumentValue("SearchCriteria", search)) ||
NPT_FAILED(action->GetArgumentValue("Filter", filter)) ||
NPT_FAILED(action->GetArgumentValue("StartingIndex", start)) ||
NPT_FAILED(action->GetArgumentValue("RequestedCount", count)) ||
NPT_FAILED(action->GetArgumentValue("SortCriteria", sort))) {
NPT_LOG_WARNING("Missing arguments");
action->SetError(402, "Invalid args");
return NPT_SUCCESS;
}
/* convert index and counts to int */
NPT_UInt32 starting_index, requested_count;
if (NPT_FAILED(start.ToInteger(starting_index)) ||
NPT_FAILED(count.ToInteger(requested_count))) {
NPT_LOG_WARNING_2("Invalid arguments (%s, %s)",
start.GetChars(), count.GetChars());
action->SetError(402, "Invalid args");
return NPT_FAILURE;
}
/* parse sort criteria */
if (NPT_FAILED(ParseSort(sort, sort_list))) {
NPT_LOG_WARNING_1("Unsupported or invalid sort criteria error (%s)",
sort.GetChars());
action->SetError(709, "Unsupported or invalid sort criteria error");
return NPT_FAILURE;
}
NPT_LOG_INFO_5("Processing Search from %s with id=\"%s\", search=\"%s\", start=%d, count=%d",
(const char*)context.GetRemoteAddress().GetIpAddress().ToString(),
(const char*)container_id,
(const char*)search,
starting_index,
requested_count);
if (search.IsEmpty() || search == "*") {
res = OnBrowseDirectChildren(
action,
container_id,
filter,
starting_index,
requested_count,
sort,
context);
} else {
res = OnSearchContainer(
action,
container_id,
search,
filter,
starting_index,
requested_count,
sort,
context);
}
if (NPT_FAILED(res) && (action->GetErrorCode() == 0)) {
action->SetError(800, "Internal error");
}
return res;
}
示例15: allowed
/*----------------------------------------------------------------------
| PLT_MediaServer::OnBrowse
+---------------------------------------------------------------------*/
NPT_Result
PLT_MediaServer::OnBrowse(PLT_ActionReference& action,
const PLT_HttpRequestContext& context)
{
NPT_Result res;
NPT_String object_id;
NPT_String browse_flag_val;
NPT_String filter;
NPT_String start;
NPT_String count;
NPT_String sort;
NPT_List<NPT_String> sort_list;
if (NPT_FAILED(action->GetArgumentValue("ObjectId", object_id)) ||
NPT_FAILED(action->GetArgumentValue("BrowseFlag", browse_flag_val)) ||
NPT_FAILED(action->GetArgumentValue("Filter", filter)) ||
NPT_FAILED(action->GetArgumentValue("StartingIndex", start)) ||
NPT_FAILED(action->GetArgumentValue("RequestedCount", count)) ||
NPT_FAILED(action->GetArgumentValue("SortCriteria", sort))) {
NPT_LOG_WARNING("Missing arguments");
action->SetError(402, "Invalid args");
return NPT_SUCCESS;
}
/* extract flag */
BrowseFlags flag;
if (NPT_FAILED(ParseBrowseFlag(browse_flag_val, flag))) {
/* error */
NPT_LOG_WARNING_1("BrowseFlag value not allowed (%s)", (const char*)browse_flag_val);
action->SetError(402, "Invalid args");
return NPT_SUCCESS;
}
/* convert index and counts to int */
NPT_UInt32 starting_index, requested_count;
if (NPT_FAILED(start.ToInteger(starting_index)) ||
NPT_FAILED(count.ToInteger(requested_count)) ||
PLT_Didl::ConvertFilterToMask(filter) == 0) {
NPT_LOG_WARNING_3("Invalid arguments (%s, %s, %s)",
start.GetChars(), count.GetChars(), filter.GetChars());
action->SetError(402, "Invalid args");
return NPT_FAILURE;
}
/* parse sort criteria for validation */
if (NPT_FAILED(ParseSort(sort, sort_list))) {
NPT_LOG_WARNING_1("Unsupported or invalid sort criteria error (%s)",
sort.GetChars());
action->SetError(709, "Unsupported or invalid sort criteria error");
return NPT_FAILURE;
}
NPT_LOG_FINE_6("Processing %s from %s with id=\"%s\", filter=\"%s\", start=%d, count=%d",
(const char*)browse_flag_val,
(const char*)context.GetRemoteAddress().GetIpAddress().ToString(),
(const char*)object_id,
(const char*)filter,
starting_index,
requested_count);
/* Invoke the browse function */
if (flag == BROWSEMETADATA) {
res = OnBrowseMetadata(
action,
object_id,
filter,
starting_index,
requested_count,
sort,
context);
} else {
res = OnBrowseDirectChildren(
action,
object_id,
filter,
starting_index,
requested_count,
sort,
context);
}
if (NPT_FAILED(res) && (action->GetErrorCode() == 0)) {
action->SetError(800, "Internal error");
}
return res;
}