⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ms_upnp.c

📁 1. 8623L平台
💻 C
字号:
/* * * Copyright (c) Sigma Designs, Inc. 2005. All rights reserved. * */#define ALLOW_OS_CODE 1#include "rmdef/rmdef.h"#include "rmcore/include/rmcore.h"#include "../include/ms_upnp.h"#include "ms_cardea_types.h"#include "wmdrmndcoreapi.h"#include "ms_cardea.h"/** If this is set to 1, it will force the device to register once, at least */static RMuint32 force_registration = 0;/** All the knwon ms_device, keep track of them, also used by ms_cardea.h, so not static */extern struct ms_upnp_extension_s *ms_device[MAX_MS_DEVICE];/** The callback to the UPnP stack we use to register with a MS server */registration_start_op_t ms_registration_start_op = NULL;/** The callback to the UPnP stack we use to verify we have been validated by a MS server */validation_check_op_t ms_validation_check_op = NULL;#ifdef WITH_CARDEA_DIRECT_API/* Testing purpose */extern void init_ms_client(void);#endif/** * Initialize internals * @param registration_start_op - operation used to start registration process, see above * @param validation_check_op - operation used to vefiry the device has been validated */void init_ms_upnp(registration_start_op_t registration_start_op,                  validation_check_op_t validation_check_op){	RMuint32 i;	RMDBGLOG((ENABLE,"init_ms_upnp..\n"));#ifdef WITH_CARDEA_DIRECT_API	/* Init our client internals, done by the daemon */	init_ms_client();#endif	RMDBGLOG((ENABLE,"init_ms_upnp..-1\n"));	for (i=0;i<MAX_MS_DEVICE; i++)		ms_device[i] = NULL;RMDBGLOG((ENABLE,"init_ms_upnp..-2\n"));	ms_registration_start_op = registration_start_op;	ms_validation_check_op = validation_check_op;}/** * Creates a new MS UPnP server extension * @param name - A name for this device * @param upnp_stack_data - private data needed by the UPnP stack * @return void * - opaque pointer to the MS UPnP server extension */void * new_ms_device(RMascii *name, void *upnp_stack_data){	RMuint32 i;	ms_upnp_extension *ms_upnp;RMDBGLOG((ENABLE,"new_ms_device..\n"));	ms_upnp = RMMalloc(sizeof(ms_upnp_extension));	if (ms_upnp == NULL)		return NULL;RMDBGLOG((ENABLE,"new_ms_device..-1\n"));	ms_upnp->flags = 0;	ms_upnp->use_count = 1;	ms_upnp->name = RMMalloc(RMasciiLength(name)+1);	if (ms_upnp->name == NULL)		return NULL;	RMCopyAscii(ms_upnp->name, name);RMDBGLOG((ENABLE,"new_ms_device..-2\n"));	ms_upnp->drm_context = init_wmdrmnet_context();	if (ms_upnp->drm_context == NULL){		RMDBGLOG((ENABLE,"Error creating DRM context\n"));		RMFree(ms_upnp);		return NULL;	} else {		if (force_registration){			RMDBGLOG((ENABLE,"Force registration on\n"));			ms_upnp->flags |= MS_FORCEREGISTER;		}	}RMDBGLOG((ENABLE,"new_ms_device..-3\n"));		for (i=0;i<MAX_URL_CTX; i++)		ms_upnp->urls[i] = NULL;	/* Keep upnp stack data for callbacks */	ms_upnp->upnp_stack_data = upnp_stack_data;RMDBGLOG((ENABLE,"new_ms_device..-4\n"));	/* Register this MS device */	for (i=0;i<MAX_MS_DEVICE;i++){		if (ms_device[i] == NULL){			ms_device[i] = ms_upnp;			break;		}	}RMDBGLOG((ENABLE,"new_ms_device..%x\n",ms_upnp));	return (void *)ms_upnp;}/** * Destroy a MS UPnP server * @param ms_upnp - handle to MS extension */void destroy_ms_device(ms_upnp_extension * ms_upnp){	RMuint32 i;	if (ms_upnp){		if ( --ms_upnp->use_count != 0 ) {			return;		}		if (ms_upnp->drm_context)			destroy_wmdrmnet_context(ms_upnp->drm_context);		if (ms_upnp->name)			RMFree(ms_upnp->name);		/* Unregister this MS device */		for (i=0;i<MAX_MS_DEVICE;i++){			if (ms_device[i] == ms_upnp){				ms_device[i] = NULL;				break;			}		}				RMFree(ms_upnp);	}}/** * Get the status of the device with a MS server * @param ms_upnp - handle to MS extension */RMuint32 ms_device_status(ms_upnp_extension *ms_upnp){	if (ms_upnp)		return ms_upnp->flags;	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -