Пример #1
0
void DSMCall::onOutgoingInvite(const string& headers) {
  if (!process_invite) {
    // re-INVITE sent out
    return;
  }
  process_invite = false;

  // TODO: construct correct request of outgoing INVITE
  AmSipRequest req;
  req.hdrs = headers;

  bool run_session_invite = engine.onInvite(req, this);
  if (checkVar(DSM_CONNECT_SESSION, DSM_CONNECT_SESSION_FALSE)) {
    DBG("session choose to not connect media\n");
    // TODO: set flag to not connect RTP on session start
    run_session_invite = false;     // don't accept audio 
  }    
  
  if (checkVar(DSM_ACCEPT_EARLY_SESSION, DSM_ACCEPT_EARLY_SESSION_FALSE)) {
    DBG("session choose to not accept early session\n");
    accept_early_session = false;
  } else {
    DBG("session choose to accept early session\n");
    accept_early_session = true;
  }
}
Пример #2
0
static void parser(Memory* block, FILE* myfp, Lines* linhas) {
	int line = 1;
	int c;
	Stack *pilha = inicializa_pilha();
	while ((c = fgetc(myfp)) != EOF) {
		switch (c) {
			case 'r': { /* retorno */
					  int idx;
					  char var;
					  if (fscanf(myfp, "et %c%d", &var, &idx) != 2)
						  error("comando invalido", line);
					  if (var != '$')
						  checkVarP(var, idx, line);

					  //--//
					  gera(pilha, block, 'r', var, idx, 0, 0, 0, 0, 0, 0, line -1, linhas);

					  printf("ret %c%d\n", var, idx);
					  break;
				  }
			case 'i': { /* if */
					  int idx, n1, n2, n3;
					  char var;
					  if (fscanf(myfp, "f %c%d %d %d %d", &var, &idx, &n1, &n2, &n3) != 5)
						  error("comando invalido", line);
					  if (var != '$')
						  checkVar(var, idx, line);
					  linhas->gerouif = 1;
					  gera(pilha, block, 'i', 0, idx, 0, n1, 0, 0, n2, n3, line - 1, linhas);
					  printf("if %c%d %d %d %d\n", var, idx, n1, n2, n3);
					  break;
				  }
			case 'v': { /* atribuicao */
					  int idx0, idx1, idx2;
					  char var0 = c, var1, var2;
					  char op;
					  if (fscanf(myfp, "%d = %c%d %c %c%d", &idx0, &var1, &idx1, &op,
								  &var2, &idx2) != 6)
						  error("comando invalido", line);
					  checkVar(var0, idx0, line);
					  if (var1 != '$')
						  checkVarP(var1, idx1, line);
					  if (var2 != '$')
						  checkVarP(var2, idx2, line);
					  //--//
					  gera(pilha, block, 'v', var0, idx0, var1, idx1, op, var2, idx2, 0, line -1, linhas);
					  printf("%c%d = %c%d %c %c%d\n", var0, idx0, var1, idx1, op, var2,
							  idx2);
					  break;
				  }
			default:
				  error("comando desconhecido", line);
		}
		line++;
		fscanf(myfp, " ");
	}
}
Пример #3
0
void DSMCall::onSipRequest(const AmSipRequest& req) {

  if (checkVar(DSM_ENABLE_REQUEST_EVENTS, DSM_TRUE)) {
    map<string, string> params;
    params["method"] = req.method;
    params["r_uri"] = req.r_uri;
    params["from"] = req.from;
    params["to"] = req.to;
    params["hdrs"] = req.hdrs;
    params["cseq"] = int2str(req.cseq);

    // pass AmSipRequest for use by mod_dlg
    DSMSipRequest* sip_req = new DSMSipRequest(&req);
    avar[DSM_AVAR_REQUEST] = AmArg(sip_req);
    
    engine.runEvent(this, this, DSMCondition::SipRequest, &params);

    delete sip_req;
    avar.erase(DSM_AVAR_REQUEST);

    if (checkParam(DSM_PROCESSED, DSM_TRUE, &params)) {
      DBG("DSM script processed SIP request '%s', returning\n", 
	  req.method.c_str());
      return;
    }
  }

  AmB2BCallerSession::onSipRequest(req);  
}
Пример #4
0
VariableValue &
ScalarCoupleable::coupledScalarDotDu(const std::string & var_name, unsigned int comp)
{
  checkVar(var_name);
  validateExecutionerType(var_name, "coupledScalarDotDu");
  MooseVariableScalar * var = getScalarVar(var_name, comp);
  return var->duDotDu();
}
Пример #5
0
Order
ScalarCoupleable::coupledScalarOrder(const std::string & var_name, unsigned int comp)
{
  checkVar(var_name);
  if (!isCoupledScalar(var_name, comp))
    return _sc_fe_problem.getMaxScalarOrder();

  return getScalarVar(var_name, comp)->order();
}
Пример #6
0
VariableValue &
ScalarCoupleable::coupledScalarValue(const std::string & var_name, unsigned int comp)
{
  checkVar(var_name);
  if (!isCoupledScalar(var_name, comp))
    return *getDefaultValue(var_name);

  MooseVariableScalar * var = getScalarVar(var_name, comp);
  return (_sc_is_implicit) ? var->sln() : var->slnOld();
}
Пример #7
0
void DSMCall::onZRTPSecurityEvent(zrtp_security_event_t event, zrtp_stream_t *stream_ctx) {
    DBG("DSMCall::onZRTPSecurityEvent: %s\n", zrtp_security_event_desc(event));

    if (checkVar(DSM_ENABLE_ZRTP_EVENTS, DSM_TRUE)) {
        map<string, string> params;
        params["event"] = zrtp_security_event_desc(event);
        params["event_id"] = int2str(event);
        engine.runEvent(this, this, DSMCondition::ZRTPSecurityEvent, &params);
    }

}
Пример #8
0
void DSMCall::startSession(){

  engine.runEvent(this, this, DSMCondition::SessionStart, NULL);
  setReceiving(true);

  if (!checkVar(DSM_CONNECT_SESSION, DSM_CONNECT_SESSION_FALSE)) {
    if (!getInput())
      setInput(&playlist);

    setOutput(&playlist);
  }
}
Пример #9
0
VariableValue &
ScalarCoupleable::coupledScalarValueOlder(const std::string & var_name, unsigned int comp)
{
  checkVar(var_name);
  if (!isCoupledScalar(var_name, comp))
    return *getDefaultValue(var_name);

  validateExecutionerType(var_name, "coupledScalarValueOlder");
  MooseVariableScalar * var = getScalarVar(var_name, comp);
  if (_sc_is_implicit)
    return var->slnOlder();
  else
    mooseError("Older values not available for explicit schemes");
}
Пример #10
0
void DSMCall::onEarlySessionStart() {
  engine.runEvent(this, this, DSMCondition::EarlySession, NULL);

  if (checkVar(DSM_CONNECT_EARLY_SESSION, DSM_CONNECT_EARLY_SESSION_FALSE)) {
    DBG("call does not connect early session\n");
  } else {
    if (!getInput())
      setInput(&playlist);

    if (!getOutput())
      setOutput(&playlist);

    AmB2BCallerSession::onEarlySessionStart();
  }
}
Пример #11
0
void DSMCall::onSipReply(const AmSipRequest& req,
                         const AmSipReply& reply,
                         AmBasicSipDialog::Status old_dlg_status)
{

    if (checkVar(DSM_ENABLE_REPLY_EVENTS, DSM_TRUE)) {
        map<string, string> params;
        params["code"] = int2str(reply.code);
        params["reason"] = reply.reason;
        params["hdrs"] = reply.hdrs;
        params["cseq"] = int2str(reply.cseq);

        params["dlg_status"] = dlg->getStatusStr();
        params["old_dlg_status"] = AmBasicSipDialog::getStatusStr(old_dlg_status);

        // pass AmSipReply for use by mod_dlg (? sending ACK?)
        DSMSipReply* dsm_reply = new DSMSipReply(&reply);
        avar[DSM_AVAR_REPLY] = AmArg(dsm_reply);

        engine.runEvent(this, this, DSMCondition::SipReply, &params);

        delete dsm_reply;
        avar.erase(DSM_AVAR_REPLY);

        if (checkParam(DSM_PROCESSED, DSM_TRUE, &params)) {
            DBG("DSM script processed SIP reply '%u %s', returning\n",
                reply.code, reply.reason.c_str());
            return;
        }
    }

    AmB2BCallerSession::onSipReply(req, reply, old_dlg_status);

    if ((old_dlg_status < AmSipDialog::Connected) &&
            (dlg->getStatus() == AmSipDialog::Disconnected)) {
        DBG("Outbound call failed with reply %d %s.\n",
            reply.code, reply.reason.c_str());
        map<string, string> params;
        params["code"] = int2str(reply.code);
        params["reason"] = reply.reason;
        engine.runEvent(this, this, DSMCondition::FailedCall, &params);
        setStopped();
    }
}
Пример #12
0
unsigned int
ScalarCoupleable::coupledScalar(const std::string & var_name, unsigned int comp)
{
  checkVar(var_name);
  return getScalarVar(var_name, comp)->number();
}
Пример #13
0
funcp geracod(FILE* f) {
    int c;
    int linha = 0;
    int vars[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
    int qtdVars = 0;
    int i = 0;
    int j = 0;
    int qtd_while = 0;
    Var_while v_while[10];

    // Alocando espaço na memória para gravar os bytes de instrucões
    codigo = (unsigned char*)malloc(sizeof(unsigned char) * 2048);

    if(codigo == NULL) {
        printf("Nao foi possivel alocar espaco para o codigo.\n");
        exit(1);
    }

    SB_prologo();
    inicia_var_while(v_while, 10);

	// Funcao principal de leitura
	// Analisa cada caso e chama as funcoes apropriadas
    while((c = fgetc(f)) != EOF) {
        switch(c) {

            // Retorno
            case 'r': {
                fscanf(f, "et");

				for(i=0; i<qtd_while; i++) {
					SB_completa_while(v_while[i]);
				}

                SB_retorno();
                break;
            }

            // Atribuição
            case 'v': case 'p': case '$': {
                Var v, v1, v2;
                char op;

                if(fscanf(f, "%d = %c%d %c %c%d", &v.valor, &v1.tipo, &v1.valor, &op, &v2.tipo, &v2.valor) != 6)
                    error("Comando invalido", linha);

                // Mantem uma contagem de quantas variaveis locais foram declaradas no arquivo codigo-fonte SB
                if(c == 'v') {
                    if(vars[v.valor] == -1) {
                        qtdVars++;
                        vars[v.valor] = 1;
                    }
                }

                v.tipo = c;
                checkVar(v, linha);
                if(v1.tipo != '$')
                    checkVar(v1, linha);

                if(v2.tipo != '$')
                    checkVar(v2, linha);

                // Prepara o offset de cada variável, caso não seja uma constante
                // Valor variando de '-4' em '-4' para variáveis locais
                // e variando de '4' em '4' (somado a 8 para o início) para parâmetros
		v.valor = calc_offset(v);
		v1.valor = calc_offset(v1);
		v2.valor = calc_offset(v2);

                SB_atribuicao(v, v1, v2, op);
                break;
            }

            // While
            case 'w': {

                // Este loop roda até achar o primeiro espaço disponível no vetor de struct Var_while
                // para salvar as informações da variável parâmetro da instrução 'while'
				for(i=0; i<10; i++) {
					if(v_while[i].byte_while == -1) {
						if(fscanf(f, "hile %c%d", &v_while[i].tipo, &v_while[i].valor) != 2)
							error("Comando Invalido", linha);
						if(v_while[i].tipo == '$')
							error("Comando Invalido", linha);

						if(v_while[i].tipo == 'v')
							v_while[i].valor = -(4 * v_while[i].valor) - 4;

						else if(v_while[i].tipo == 'p')
							v_while[i].valor = 4 * v_while[i].valor + 8;

						v_while[i].byte_while = SB_while();
						break;
					}
				}
				qtd_while++;
                break;
            }

            // End (while)
            case 'e': {
                // Este loop roda de trás para frente, até achar um espaço no qual uma instrução while
                // já tenha guardado valores na struct Var_while
                // e preenche o campo 'byte_end' e transforma 'ja_usado' em 1 (verdadeiro)
				for(j=9; j >= 0; j--) {
					if(v_while[j].byte_while != -1 && v_while[j].ja_usado != 1) {
						fscanf(f, "nd");
						v_while[j].byte_end = SB_end_while();
						v_while[j].ja_usado = 1;
						break;
					}
				}
                break;
            }

            default:
                error("Comando desconhecido", linha);
        }
        linha++;

        if(linha > MAX_LINHAS)
            error("Numero maximo de linhas excedido", linha);

        fscanf(f, " ");
    }

    // A variável 'qtdVars' serviu como contador de quantas variáveis locais há no código-fonte SB
    // e agora substituimos o byte responsável pela alocação de espaco (em bytes, sendo 4 para cada var. local)
    // através do comando 'sub $0x??, %esp'
    codigo[5] = qtdVars * 4;
    return (funcp)codigo;
}
Пример #14
0
// main process
int process (Mat &cimg, int xstart, int ystart, int xend,
             int yend, int offset, double threshold,
             PicNodeList* picNodeList, RefillList* refillList) {
    
    if (xend - xstart < 4 || yend - ystart < 4 || offset < 4)
        return 0;
    
	int x = xstart;
	int y = ystart;
    
    printf("xend = %d\n", xend);
    printf("yend = %d\n", yend);
    
	while (x < xend) {
        //printf("x = %d\n", x);
		y = ystart;
		while (y < yend) {
			printf("x = %d, y = %d\n", x, y);
            
			int xp;
			int yp;
			if (x + offset >= cimg.rows)
				xp = cimg.rows - 1;
			else
				xp = x + offset;
			if (y + offset >= cimg.cols)
				yp = cimg.cols - 1;
			else
				yp = y + offset;
            
			Color *avgs = (Color*) malloc (sizeof(Color));
			computeAvg (cimg, x, y, xp, yp, avgs);
			Color *vars = (Color*) malloc (sizeof(Color));
			computeVar (cimg, x, y, xp, yp, avgs, vars);
            
			if (checkVar(vars, threshold)) {
				process (cimg, x, y, xp, yp, offset / 2, threshold, picNodeList, refillList);
                y += offset;
                continue;
			}
            
			PicNode *picNode = nullptr;
			if (findProperPic (avgs, vars, &picNode, picNodeList) == -1) {
                return -1;
			}
            
			ReplaceInfo *replaceInfo = (ReplaceInfo*) malloc (sizeof(ReplaceInfo));
			memset(replaceInfo, 0, sizeof(ReplaceInfo));
			replaceInfo->xstart = x;
			replaceInfo->ystart = y;
			replaceInfo->xend = xp;
			replaceInfo->yend = yp;
			replaceInfo->pNext = NULL;
			replaceInfo->picNode = picNode;
			last->pNext = replaceInfo;
            
//            printf("begin cshou debug Last Node##############\n");
//            printNode(last);
//            printf("end cshou debug Last Node##############\n");
//            printNode(replaceInfo);
            
            last = replaceInfo;
            
			y += offset;
		}
		x += offset;
	}
    
	return 0;
}