Ejemplo n.º 1
0
struct cluster_barrier *alloc_cluster_barrier(unique_id_t key)
{
	struct cluster_barrier *barrier;
	int r, i;

	if (!key)
		key = get_unique_id(&barrier_id_root);

	if (hashtable_find (barrier_table, key))
		return ERR_PTR(-EEXIST);

	barrier = kmalloc (sizeof(struct cluster_barrier), GFP_KERNEL);
	if (!barrier)
		return ERR_PTR(-ENOMEM);

	for (i = 0; i < 2; i++) {
		krgnodes_clear (barrier->core[i].nodes_in_barrier);
		krgnodes_clear (barrier->core[i].nodes_to_wait);
		init_waitqueue_head(&barrier->core[i].waiting_tsk);
		barrier->core[i].in_barrier = 0;
	}
	spin_lock_init(&barrier->lock);
	barrier->id.key = key;
	barrier->id.toggle = 0;

	r = hashtable_add (barrier_table, barrier->id.key, barrier);
	if (r) {
		kfree (barrier);
		return ERR_PTR(r);
	}

	return barrier;
}
Ejemplo n.º 2
0
static GstElement * try_codecs(GList *codecs, const gchar *name_prefix)
{
    GList *l;
    gchar *element_name;

    for (l = codecs; l; l = l->next) {
        GstElementFactory *f = l->data;
        GstElement *e;

        element_name = g_strdup_printf("%s_%s_%u", name_prefix,
                                       gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(f)),
                                       get_unique_id());

        e = gst_element_factory_create(f, element_name);
        g_free(element_name);

        if (!e)
            continue;

        /* Try setting to READY. If this fails the codec does not work, for
         * example because the hardware codec is currently busy
         */
        if (gst_element_set_state (e, GST_STATE_READY) != GST_STATE_CHANGE_SUCCESS) {
            gst_element_set_state (e, GST_STATE_NULL);
            gst_object_unref(e);
            continue;
        }

        return e;
    }

    return NULL;
}
Ejemplo n.º 3
0
static void on_connect(uv_stream_t* stream, int status)
{
    MALLOC(http_connection_t, conn);
    get_unique_id(conn->id); 
    conn->request   = NULL;
    conn->response  = NULL;
    conn->time      = timems();
    conn->routes    = (struct http_routes *)stream->data;
    conn->timeout   = NULL;
    conn->replied   = 0;
    REFERENCE_INIT(conn, _conn_destroy);

    uv_tcp_init(uv_loop, &conn->stream);
    http_parser_init(&conn->parser, HTTP_REQUEST);

    conn->write_req.data = conn;
    conn->parser.data = conn;
    conn->stream.data = conn;

    /* TODO: Use the return values from uv_accept() and
     * uv_read_start() */
    uv_accept(stream, (uv_stream_t*)&conn->stream);
    uv_read_start(
        (uv_stream_t*)&conn->stream,
        http_stream_on_alloc,
        http_stream_on_read
    );
}
Ejemplo n.º 4
0
void ABitTile::TileClicked(UPrimitiveComponent* ClickedComp)
{
	if (!Data.expired())
	{
		auto dataPtr = Data.lock();
		auto bitUniqueId = dataPtr->get_unique_id();
		FString bitName = dataPtr->get_bit_name().c_str();
		UE_LOG(LogTemp, Warning, TEXT("CLICKED ON TILE: %s, UNIQUE ID: %d"), *bitName, bitUniqueId)
	}
Ejemplo n.º 5
0
bool UDTPPeer::send_to(UDTPPacket* sendPacket){ /*Send from the server usually*/
    if(get_unique_id() != sendPacket->get_unique_id() ) {
        std::cout << "PACKET WILL NOT SEND: Packet's unique ID does not match with PEER's unique ID. This PEER may have disconnected (and removed from polling and peer list) and this packet was assigned that PEER's last position." << std::endl;
        return false;
    }
    std::cout << "HOST has sent out a packet" << std::endl;
    send(get_listen_socket(), sendPacket->get_raw_buffer(), sendPacket->get_packet_size(), 0); /*The UDTPPAclet's socket id is used to denote where to send the packet. The socket id is handled in the polling threads. For HOSTS, the socket id
                                                                                                                    will be the receiving socket's file descriptor. For PEER, it will always be its own _listenSocket being that that is where the central receiving and sending
                                                                                                                    happens.*/
}
Ejemplo n.º 6
0
void ABitPiece::PieceClicked(UPrimitiveComponent* ClickedComp)
{
	auto gameMode = GetWorld()->GetAuthGameMode();
	auto boardGameMode = dynamic_cast<ABoardGameGameMode*>(gameMode);
	
	if (boardGameMode != nullptr && !Data.expired() && IsAnOption)
	{
		auto dataPtr = Data.lock();
		auto bitUniqueId = dataPtr->get_unique_id();
		FString bitName = dataPtr->get_bit_name().c_str();
		UE_LOG(LogTemp, Warning, TEXT("SELECTED PIECE: %s, UNIQUE ID: %d"), *bitName, bitUniqueId);
		boardGameMode->ChooseOptionByBit(bitUniqueId);
	}
}
Ejemplo n.º 7
0
void BackupSystem::fix_up_stream_reference(FileSystemObject &fso, known_guids_t &known_guids){
	if (fso.get_type() == FileSystemObjectType::FileHardlink || fso.is_directoryish())
		return;
	auto &filish = static_cast<FilishFso &>(fso);
	auto &guid = filish.get_file_system_guid();
	if (guid.valid)
		return;
	auto it = known_guids.find(guid.data);
	if (it == known_guids.end())
		return;
	auto stream = it->second;
	filish.set_stream_id(stream->get_unique_id());
	filish.set_backup_stream(stream.get());
	auto &fsos = stream->get_file_system_objects();
	if (fsos.size())
		filish.set_latest_version(fsos.front()->get_latest_version());
	stream->add_file_system_object(&filish);
}
Ejemplo n.º 8
0
bool UDTPPeer::add_thread()
{
    if(!is_online())  return false; /*Not online? Can't add!*/
    unsigned int flowSocket;
    flowSocket = socket(AF_INET, SOCK_DGRAM, 0);
    if(flowSocket <0) return false;
    int optval = 1;
    if((setsockopt(flowSocket, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval))) < 0) return false;
    struct sockaddr_in flowAddress;
    if(host_local()){
        /*HOSTs have several destinations but luckily we stored the address on connect() here!*/
        /*Only downside is that when we receive messages from PEER on UDPs that we will not know where it is coming from!*/
        flowAddress = get_address();
    }else{
        /*PEER's only have one destination and that is the HOST!*/
        flowAddress.sin_addr.s_addr = inet_addr(udtp()->setup()->get_ip());
        flowAddress.sin_port = htons(udtp()->setup()->get_port());
        flowAddress.sin_family = AF_INET;
    }
    if( (bind(flowSocket, (struct sockaddr*)&flowAddress, sizeof(flowAddress))) < 0 )
    {
        perror("udp-bind");
        return false;
    }

    /*Start a flow thread!*/
    pthread_t flowThreadHandler;
    UDTPThreadFlow *newFlowThread = new UDTPThreadFlow((UDTP*)this, flowThreadHandler, flowSocket);
    newFlowThread->set_peer(this);
    pthread_create(&flowThreadHandler, NULL, UDTPPeer::flowThread, (UDTPThreadFlow*)newFlowThread);
    pthread_tryjoin_np(flowThreadHandler, NULL);
    /*Start a process thread!*/
    pthread_t processThreadHandler;
    UDTPThreadProcess *newProcessThread = new UDTPThreadProcess();
    newProcessThread->set_peer(this);
    pthread_create(&processThreadHandler, NULL, UDTPPeer::flowThread, (UDTPThreadProcess*)newProcessThread);
    pthread_tryjoin_np(processThreadHandler, NULL);



    std::cout << "PEER " << get_unique_id() << " has added a flow and process thread!"  << std::endl;
    increment_thread_count();
    return true;
}
Ejemplo n.º 9
0
static ALLEGRO_MENU_ITEM *create_menu_item(char const *title, uint16_t id, int flags, ALLEGRO_MENU *popup)
{
   ALLEGRO_MENU_ITEM *item = al_calloc(1, sizeof(*item));
   if (!item) return NULL;
   if (!get_unique_id(&item->unique_id)) {
      return NULL;
   }
   
   if (flags & ALLEGRO_MENU_ITEM_CHECKED)
      flags |= ALLEGRO_MENU_ITEM_CHECKBOX;
   
   if (title)
      item->caption = al_ustr_new(title);
   item->id = id;
   item->flags = flags;
   item->popup = popup;

   return item;
}
Ejemplo n.º 10
0
bool UDTPPeer::remove_thread()
{
    if(get_thread_count()  <= 0) return false;

    UDTPThreadFlow *removeFlowThread = front_flow_thread();
    UDTPThreadProcess *removeProcessThread = front_process_thread();

    removeFlowThread->kill();

    removeProcessThread->kill();
    sem_post(&_semProcessChunkThread); /*Have to post one!*/

    close(removeFlowThread->flow_socket()); /****FIND A WAY TO CLOSE BUT KEEP WHATEVER IS REMAINING INSIDE!*/

    removeFlowThread = NULL;
    removeProcessThread = NULL;


    std::cout << "PEER " << get_unique_id() << " has removed a flow and process thread!"  << std::endl;
    decrement_thread_count();
    pop_thread();
    return true;
}
Ejemplo n.º 11
0
GstElement * _owr_payload_create_encoder(OwrPayload *payload)
{
    GstElement *encoder = NULL;
    gchar *element_name = NULL;
    GstElementFactory *factory;
    const gchar *factory_name;

    g_return_val_if_fail(payload, NULL);

    switch (payload->priv->codec_type) {
    case OWR_CODEC_TYPE_H264:
        encoder = try_codecs(h264_encoders, "encoder");
        g_return_val_if_fail(encoder, NULL);

        factory = gst_element_get_factory(encoder);
        factory_name = gst_plugin_feature_get_name(factory);

        if (!strcmp(factory_name, "openh264enc")) {
            g_object_set(encoder, "gop-size", 0, NULL);
            gst_util_set_object_arg(G_OBJECT(encoder), "rate-control", "bitrate");
            g_object_bind_property(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE);
        } else if (!strcmp(factory_name, "x264enc")) {
            g_object_bind_property_full(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE,
                binding_transform_to_kbps, NULL, NULL, NULL);
            g_object_set(encoder, "tune", 0x04 /* zero-latency */, NULL);
        } else if (!strcmp(factory_name, "vtenc_h264")) {
            g_object_bind_property_full(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE,
                binding_transform_to_kbps, NULL, NULL, NULL);
        } else {
            /* Assume bits/s instead of kbit/s */
            g_object_bind_property(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE);
        }
        g_object_set(payload, "bitrate", evaluate_bitrate_from_payload(payload), NULL);
        break;

    case OWR_CODEC_TYPE_VP8:
        encoder = try_codecs(vp8_encoders, "encoder");
        g_return_val_if_fail(encoder, NULL);
        g_object_set(encoder, "end-usage", 1, "deadline", G_GINT64_CONSTANT(1), "lag-in-frames", 0,
            "error-resilient", 1, "keyframe-mode", 0, NULL);
        g_object_bind_property(payload, "bitrate", encoder, "target-bitrate", G_BINDING_SYNC_CREATE);
        g_object_set(payload, "bitrate", evaluate_bitrate_from_payload(payload), NULL);
        break;
    default:
        element_name = g_strdup_printf("encoder_%s_%u", OwrCodecTypeEncoderElementName[payload->priv->codec_type], get_unique_id());
        encoder = gst_element_factory_make(OwrCodecTypeEncoderElementName[payload->priv->codec_type], element_name);
        g_free(element_name);
        g_return_val_if_fail(encoder, NULL);
        break;
    }

    return encoder;
}
Ejemplo n.º 12
0
/* FUNCTIONS ******************************************************************/
void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
{
	SS7_FUNC_TRACE_ENTER (__FUNCTION__);
	
	sngss7_chan_data_t	*sngss7_info = ftdmchan->call_data;;
	const char			*clg_nadi = NULL;
	const char			*cld_nadi = NULL;
	const char			*clg_subAddr = NULL;
	const char			*cld_subAddr = NULL;
	char 				subAddrIE[MAX_SIZEOF_SUBADDR_IE];
	SiConEvnt 			iam;
	
	sngss7_info->suInstId 	= get_unique_id ();
	sngss7_info->spInstId 	= 0;
	sngss7_info->spId 		= 1;
	
	memset (&iam, 0x0, sizeof (iam));
	
	/* copy down the nature of connection indicators */
	iam.natConInd.eh.pres 				= PRSNT_NODEF;
	iam.natConInd.satInd.pres 			= PRSNT_NODEF;
	iam.natConInd.satInd.val 			= 0; /* no satellite circuit */
	iam.natConInd.contChkInd.pres 		= PRSNT_NODEF;
	iam.natConInd.contChkInd.val 		= CONTCHK_NOTREQ;
	iam.natConInd.echoCntrlDevInd.pres	= PRSNT_NODEF;
	iam.natConInd.echoCntrlDevInd.val 	= ECHOCDEV_INCL;
	
	/* copy down the forward call indicators */
	iam.fwdCallInd.eh.pres 				= PRSNT_NODEF;
	iam.fwdCallInd.natIntCallInd.pres 	= PRSNT_NODEF;
	iam.fwdCallInd.natIntCallInd.val 	= 0x00;
	iam.fwdCallInd.end2EndMethInd.pres 	= PRSNT_NODEF;
	iam.fwdCallInd.end2EndMethInd.val 	= E2EMTH_NOMETH;
	iam.fwdCallInd.intInd.pres 			= PRSNT_NODEF;
	iam.fwdCallInd.intInd.val 			= INTIND_NOINTW;
	iam.fwdCallInd.end2EndInfoInd.pres 	= PRSNT_NODEF;
	iam.fwdCallInd.end2EndInfoInd.val 	= E2EINF_NOINFO;
	iam.fwdCallInd.isdnUsrPrtInd.pres 	= PRSNT_NODEF;
	iam.fwdCallInd.isdnUsrPrtInd.val 	= ISUP_USED;
	iam.fwdCallInd.isdnUsrPrtPrfInd.pres = PRSNT_NODEF;
	iam.fwdCallInd.isdnUsrPrtPrfInd.val = PREF_PREFAW;
	iam.fwdCallInd.isdnAccInd.pres 		= PRSNT_NODEF;
	iam.fwdCallInd.isdnAccInd.val 		= ISDNACC_ISDN;
	iam.fwdCallInd.sccpMethInd.pres 	= PRSNT_NODEF;
	iam.fwdCallInd.sccpMethInd.val 		= SCCPMTH_NOIND;
	
	/* copy down the calling number information */
	iam.cgPtyCat.eh.pres 				= PRSNT_NODEF;
	iam.cgPtyCat.cgPtyCat.pres 			= PRSNT_NODEF;
	iam.cgPtyCat.cgPtyCat.val 			= CAT_ORD;	/* ordinary suscriber */
	
	/* copy down the transmission medium requirements */
	iam.txMedReq.eh.pres 				= PRSNT_NODEF;
	iam.txMedReq.trMedReq.pres 			= PRSNT_NODEF;
	iam.txMedReq.trMedReq.val 			= ftdmchan->caller_data.bearer_capability;

	if ((g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS88) ||
		(g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS92) ||
		(g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS95)) {

		/* include only if we're running ANSI */
		iam.fwdCallInd.transCallNInd.pres   = PRSNT_NODEF;
		iam.fwdCallInd.transCallNInd.val    = 0x0;

		iam.usrServInfoA.eh.pres				= PRSNT_NODEF;

		iam.usrServInfoA.infoTranCap.pres		= PRSNT_NODEF;
		switch (ftdmchan->caller_data.bearer_capability) {
		/**********************************************************************/
		case (FTDM_BEARER_CAP_SPEECH):
			iam.usrServInfoA.infoTranCap.val	= 0x0;			/* speech as per ATIS-1000113.3.2005 */
			break;
		/**********************************************************************/
		case (FTDM_BEARER_CAP_64K_UNRESTRICTED):
			iam.usrServInfoA.infoTranCap.val	= 0x8;			/* unrestricted digital as per ATIS-1000113.3.2005 */
			break;
		/**********************************************************************/
		case (FTDM_BEARER_CAP_3_1KHZ_AUDIO):
			iam.usrServInfoA.infoTranCap.val	= 0x10;			/* 3.1kHz audio as per ATIS-1000113.3.2005 */
			break;
		/**********************************************************************/
		default:
			SS7_ERROR_CHAN(ftdmchan, "Unknown Bearer capability falling back to speech%s\n", " ");
			iam.usrServInfoA.infoTranCap.val	= 0x0;			/* speech as per ATIS-1000113.3.2005 */
			break;
		/**********************************************************************/
		} /* switch (ftdmchan->caller_data.bearer_capability) */

		iam.usrServInfoA.cdeStand.pres			= PRSNT_NODEF;
		iam.usrServInfoA.cdeStand.val			= 0x0;				/* ITU-T standardized coding */
		iam.usrServInfoA.tranMode.pres			= PRSNT_NODEF;
		iam.usrServInfoA.tranMode.val			= 0x0;				/* circuit mode */
		iam.usrServInfoA.infoTranRate0.pres		= PRSNT_NODEF;
		iam.usrServInfoA.infoTranRate0.val		= 0x10;				/* 64kbps origination to destination */
		iam.usrServInfoA.infoTranRate1.pres		= PRSNT_NODEF;
		iam.usrServInfoA.infoTranRate1.val		= 0x10;				/* 64kbps destination to origination */
		iam.usrServInfoA.chanStruct.pres		= PRSNT_NODEF;
		iam.usrServInfoA.chanStruct.val			= 0x1;				/* 8kHz integrity */
		iam.usrServInfoA.config.pres			= PRSNT_NODEF;
		iam.usrServInfoA.config.val				= 0x0;				/* point to point configuration */
		iam.usrServInfoA.establish.pres			= PRSNT_NODEF;
		iam.usrServInfoA.establish.val			= 0x0;				/* on demand */
		iam.usrServInfoA.symmetry.pres			= PRSNT_NODEF;
		iam.usrServInfoA.symmetry.val			= 0x0;				/* bi-directional symmetric */
		iam.usrServInfoA.usrInfLyr1Prot.pres	= PRSNT_NODEF;
		iam.usrServInfoA.usrInfLyr1Prot.val		= 0x2;				/* G.711 ulaw */
		iam.usrServInfoA.rateMultiplier.pres	= PRSNT_NODEF;
		iam.usrServInfoA.rateMultiplier.val		= 0x1;				/* 1x rate multipler */
	} /* if ANSI */

	/* copy down the called number information */
	copy_cdPtyNum_to_sngss7 (&ftdmchan->caller_data, &iam.cdPtyNum);
	
	/* copy down the calling number information */
	
	copy_cgPtyNum_to_sngss7 (&ftdmchan->caller_data, &iam.cgPtyNum);

	/* check if the user would like a custom NADI value for the calling Pty Num */
	clg_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_clg_nadi");
	if ((clg_nadi != NULL) && (*clg_nadi)) {
		SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Calling NADI value \"%s\"\n", clg_nadi);
		iam.cgPtyNum.natAddrInd.val	= atoi(clg_nadi);
	} else {
		iam.cgPtyNum.natAddrInd.val	= g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].clg_nadi;
		SS7_DEBUG_CHAN(ftdmchan,"No user supplied NADI value found for CLG, using \"%d\"\n", iam.cgPtyNum.natAddrInd.val);
	}

	cld_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_nadi");
	if ((cld_nadi != NULL) && (*cld_nadi)) {
		SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Called NADI value \"%s\"\n", cld_nadi);
		iam.cdPtyNum.natAddrInd.val	= atoi(cld_nadi);
	} else {
		iam.cdPtyNum.natAddrInd.val	= g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].cld_nadi;
		SS7_DEBUG_CHAN(ftdmchan,"No user supplied NADI value found for CLD, using \"%d\"\n", iam.cdPtyNum.natAddrInd.val);
	}

	/* check if the user would like us to send a clg_sub-address */
	clg_subAddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_clg_subaddr");
	if ((clg_subAddr != NULL) && (*clg_subAddr)) {
		SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Calling Sub-Address value \"%s\"\n", clg_subAddr);
		
		/* clean out the subAddrIE */
		memset(subAddrIE, 0x0, sizeof(subAddrIE));

		/* check the first character in the sub-address to see what type of encoding to use */
		switch (clg_subAddr[0]) {
		case '0':						/* NSAP */
			encode_subAddrIE_nsap(&clg_subAddr[1], subAddrIE, SNG_CALLING);
			break;
		case '1':						/* national variant */
			encode_subAddrIE_nat(&clg_subAddr[1], subAddrIE, SNG_CALLING);
			break;
		default:
			SS7_ERROR_CHAN(ftdmchan,"Invalid Calling Sub-Address encoding requested: %c\n", clg_subAddr[0]);
			break;
		} /* switch (cld_subAddr[0]) */


		/* if subaddIE is still empty don't copy it in */
		if (subAddrIE[0] != '0') {
			/* check if the clg_subAddr has already been added */
			if (iam.accTrnspt.eh.pres == PRSNT_NODEF) {
				/* append the subAddrIE */
				memcpy(&iam.accTrnspt.infoElmts.val[iam.accTrnspt.infoElmts.len], subAddrIE, (subAddrIE[1] + 2));
				iam.accTrnspt.infoElmts.len		= iam.accTrnspt.infoElmts.len +subAddrIE[1] + 2;
			} else {
				/* fill in from the beginning */
				iam.accTrnspt.eh.pres			= PRSNT_NODEF;
				iam.accTrnspt.infoElmts.pres	= PRSNT_NODEF;
				memcpy(iam.accTrnspt.infoElmts.val, subAddrIE, (subAddrIE[1] + 2));
				iam.accTrnspt.infoElmts.len		= subAddrIE[1] + 2;
			} /* if (iam.accTrnspt.eh.pres */
		} /* if (subAddrIE[0] != '0') */
	}

	/* check if the user would like us to send a cld_sub-address */
	cld_subAddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_subaddr");
	if ((cld_subAddr != NULL) && (*cld_subAddr)) {
		SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Called Sub-Address value \"%s\"\n", cld_subAddr);
		
		/* clean out the subAddrIE */
		memset(subAddrIE, 0x0, sizeof(subAddrIE));

		/* check the first character in the sub-address to see what type of encoding to use */
		switch (cld_subAddr[0]) {
		case '0':						/* NSAP */
			encode_subAddrIE_nsap(&cld_subAddr[1], subAddrIE, SNG_CALLED);
			break;
		case '1':						/* national variant */
			encode_subAddrIE_nat(&cld_subAddr[1], subAddrIE, SNG_CALLED);
			break;
		default:
			SS7_ERROR_CHAN(ftdmchan,"Invalid Called Sub-Address encoding requested: %c\n", cld_subAddr[0]);
			break;
		} /* switch (cld_subAddr[0]) */

		/* if subaddIE is still empty don't copy it in */
		if (subAddrIE[0] != '0') {
			/* check if the cld_subAddr has already been added */
			if (iam.accTrnspt.eh.pres == PRSNT_NODEF) {
				/* append the subAddrIE */
				memcpy(&iam.accTrnspt.infoElmts.val[iam.accTrnspt.infoElmts.len], subAddrIE, (subAddrIE[1] + 2));
				iam.accTrnspt.infoElmts.len		= iam.accTrnspt.infoElmts.len +subAddrIE[1] + 2;
			} else {
				/* fill in from the beginning */
				iam.accTrnspt.eh.pres			= PRSNT_NODEF;
				iam.accTrnspt.infoElmts.pres	= PRSNT_NODEF;
				memcpy(iam.accTrnspt.infoElmts.val, subAddrIE, (subAddrIE[1] + 2));
				iam.accTrnspt.infoElmts.len		= subAddrIE[1] + 2;
			} /* if (iam.accTrnspt.eh.pres */
		} /* if (subAddrIE[0] != '0') */
	} /* if ((cld_subAddr != NULL) && (*cld_subAddr)) */

	sng_cc_con_request (sngss7_info->spId,
						sngss7_info->suInstId,
						sngss7_info->spInstId,
						sngss7_info->circuit->id, 
						&iam, 
						0);

	SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM clg = \"%s\" (NADI=%d), cld = \"%s\" (NADI=%d)\n",
							sngss7_info->circuit->cic,
							ftdmchan->caller_data.cid_num.digits,
							iam.cgPtyNum.natAddrInd.val,
							ftdmchan->caller_data.dnis.digits,
							iam.cdPtyNum.natAddrInd.val);


	SS7_FUNC_TRACE_EXIT (__FUNCTION__);
	return;
}
/* FUNCTIONS ******************************************************************/
void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
{
    SiConEvnt 			iam;
    sngss7_chan_data_t	*sngss7_info = ftdmchan->call_data;;

    SS7_FUNC_TRACE_ENTER (__FUNCTION__);

    sngss7_info->suInstId 	= get_unique_id ();
    sngss7_info->spInstId 	= 0;
    sngss7_info->spId 		= 1;

    memset (&iam, 0x0, sizeof (iam));

    if (sngss7_info->circuit->transparent_iam &&
            sngss7_retrieve_iam(ftdmchan, &iam) == FTDM_SUCCESS) {
        SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM (Transparent)\n", sngss7_info->circuit->cic);
    } else {
        /* Nature of Connection Indicators */
        copy_natConInd_to_sngss7(ftdmchan, &iam.natConInd);

        /* Forward Call Indicators */
        copy_fwdCallInd_to_sngss7(ftdmchan, &iam.fwdCallInd);

        /* Transmission medium requirements */
        copy_txMedReq_to_sngss7(ftdmchan, &iam.txMedReq);

        if (SNGSS7_SWITCHTYPE_ANSI(g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType)) {
            /* User Service Info A */
            copy_usrServInfoA_to_sngss7(ftdmchan, &iam.usrServInfoA);
        }

        /* Called Number information */
        copy_cdPtyNum_to_sngss7(ftdmchan, &iam.cdPtyNum);

        /* Calling Number information */
        copy_cgPtyNum_to_sngss7(ftdmchan, &iam.cgPtyNum);

        /* Generic Number information */
        copy_genNmb_to_sngss7(ftdmchan, &iam.genNmb);

        /* Calling Party's Category */
        copy_cgPtyCat_to_sngss7(ftdmchan, &iam.cgPtyCat);

        /* Redirecting Number */
        copy_redirgNum_to_sngss7(ftdmchan, &iam.redirgNum);

        /* Access Transport */
        copy_accTrnspt_to_sngss7(ftdmchan, &iam.accTrnspt);

        SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM clg = \"%s\" (NADI=%d), cld = \"%s\" (NADI=%d)\n",
                      sngss7_info->circuit->cic,
                      ftdmchan->caller_data.cid_num.digits,
                      iam.cgPtyNum.natAddrInd.val,
                      ftdmchan->caller_data.dnis.digits,
                      iam.cdPtyNum.natAddrInd.val);
    }

    sng_cc_con_request (sngss7_info->spId,
                        sngss7_info->suInstId,
                        sngss7_info->spInstId,
                        sngss7_info->circuit->id,
                        &iam,
                        0);

    SS7_FUNC_TRACE_EXIT (__FUNCTION__);
    return;
}
Ejemplo n.º 14
0
GstElement * _owr_payload_create_payload_depacketizer(OwrPayload *payload)
{
    GstElement * depay = NULL;
    gchar *element_name = NULL;

    g_return_val_if_fail(payload, NULL);

    element_name = g_strdup_printf("depay_%s_%u", OwrCodecTypeDepayElementName[payload->priv->codec_type], get_unique_id());
    depay = gst_element_factory_make(OwrCodecTypeDepayElementName[payload->priv->codec_type], element_name);

    g_free(element_name);
    return depay;
}
Ejemplo n.º 15
0
GstElement * _owr_payload_create_payload_packetizer(OwrPayload *payload)
{
    GstElement * pay = NULL;
    gchar *element_name = NULL;
    OwrMediaType media_type;

    g_return_val_if_fail(payload, NULL);

    element_name = g_strdup_printf("pay_%s_%u", OwrCodecTypePayElementName[payload->priv->codec_type], get_unique_id());
    pay = gst_element_factory_make(OwrCodecTypePayElementName[payload->priv->codec_type], element_name);
    g_free(element_name);

    g_object_bind_property(payload, "mtu", pay, "mtu", G_BINDING_SYNC_CREATE);

    g_object_get(payload, "media-type", &media_type, NULL);
    switch (media_type) {
    case OWR_MEDIA_TYPE_AUDIO:
        if (OWR_IS_AUDIO_PAYLOAD(payload)) {
            g_object_bind_property(OWR_AUDIO_PAYLOAD(payload), "ptime", pay, "min-ptime", G_BINDING_SYNC_CREATE);
            g_object_bind_property(OWR_AUDIO_PAYLOAD(payload), "ptime", pay, "max-ptime", G_BINDING_SYNC_CREATE);
        }

        break;

    case OWR_MEDIA_TYPE_VIDEO:
        if (payload->priv->codec_type == OWR_CODEC_TYPE_H264)
            g_object_set(pay, "config-interval", 1, NULL);
        break;

    default:
        g_warn_if_reached();
    }

    return pay;
}
Ejemplo n.º 16
0
GstElement * _owr_payload_create_parser(OwrPayload *payload)
{
    GstElement * parser = NULL;
    gchar *element_name = NULL;

    g_return_val_if_fail(payload, NULL);

    if (!g_strcmp0(OwrCodecTypeParserElementName[payload->priv->codec_type], "none"))
        return NULL;

    element_name = g_strdup_printf("parser_%s_%u", OwrCodecTypeParserElementName[payload->priv->codec_type], get_unique_id());
    parser = gst_element_factory_make(OwrCodecTypeParserElementName[payload->priv->codec_type], element_name);
    g_free(element_name);

    switch (payload->priv->codec_type) {
    case OWR_CODEC_TYPE_H264:
        g_object_set(parser, "disable-passthrough", TRUE, NULL);
        break;
    default:
        break;
    }
    return parser;
}
Ejemplo n.º 17
0
std::string get_unique_id_str() {
    return std::to_string(get_unique_id());
}
Ejemplo n.º 18
0
GstElement * _owr_payload_create_encoder(OwrPayload *payload)
{
    GstElement *encoder = NULL;
    gchar *element_name = NULL;
    GstElementFactory *factory;
    const gchar *factory_name;
    gint cpu_used;

    g_return_val_if_fail(payload, NULL);

    switch (payload->priv->codec_type) {
    case OWR_CODEC_TYPE_H264:
        encoder = try_codecs(h264_encoders, "encoder");
        g_return_val_if_fail(encoder, NULL);

        factory = gst_element_get_factory(encoder);
        factory_name = gst_plugin_feature_get_name(factory);

        if (!strcmp(factory_name, "openh264enc")) {
            g_object_set(encoder, "gop-size", 0, NULL);
            gst_util_set_object_arg(G_OBJECT(encoder), "rate-control", "bitrate");
            gst_util_set_object_arg(G_OBJECT(encoder), "complexity", "low");
            g_object_bind_property(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE);
        } else if (!strcmp(factory_name, "x264enc")) {
            g_object_bind_property_full(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE,
                binding_transform_to_kbps, NULL, NULL, NULL);
            gst_util_set_object_arg(G_OBJECT(encoder), "speed-preset", "ultrafast");
            gst_util_set_object_arg(G_OBJECT(encoder), "tune", "fastdecode+zerolatency");
        } else if (!strcmp(factory_name, "vtenc_h264")) {
            g_object_bind_property_full(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE,
                binding_transform_to_kbps, NULL, NULL, NULL);
            g_object_set(encoder,
                "allow-frame-reordering", FALSE,
                "realtime", TRUE,
#if defined(__APPLE__) && TARGET_OS_IPHONE
                "quality", 0.0,
#else
                "quality", 0.5,
#endif
                "max-keyframe-interval", G_MAXINT,
                NULL);
        } else if (!strcmp(factory_name, "omxh264enc")) {
            g_object_set(encoder, "control-rate", 2, NULL);
            g_object_bind_property(payload, "bitrate", encoder, "target-bitrate", G_BINDING_SYNC_CREATE);
        } else {
            /* Assume bits/s instead of kbit/s */
            g_object_bind_property(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE);
        }
        g_object_set(payload, "bitrate", evaluate_bitrate_from_payload(payload), NULL);
        //make_preset = TRUE;
        break;

    case OWR_CODEC_TYPE_VP8:
        encoder = try_codecs(vp8_encoders, "encoder");
        g_return_val_if_fail(encoder, NULL);

        factory = gst_element_get_factory(encoder);
        factory_name = gst_plugin_feature_get_name(factory);
#if (defined(__APPLE__) && TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR) || defined(__ANDROID__)
        cpu_used = -12; /* Mobile */
#else
        cpu_used = -6; /* Desktop */
#endif
        if (!strcmp(factory_name, "omxvp8enc"))
        {
            g_object_set(encoder, "control-rate", 2, NULL);
        }
        else // vp8enc
        {
            /* values are inspired by webrtc.org values in vp8_impl.cc */
            g_object_set(encoder,
                "end-usage", 1, /* VPX_CBR */
                "deadline", G_GINT64_CONSTANT(1), /* VPX_DL_REALTIME */
                "cpu-used", cpu_used,
                "min-quantizer", 2,
                "buffer-initial-size", 500,
                "buffer-optimal-size", 600,
                "buffer-size", 1000,
                "lag-in-frames", 0,
                "timebase", 1, 90000,
                "error-resilient", 1,
                "keyframe-mode", 0, /* VPX_KF_DISABLED */
                NULL);
        }

        g_object_bind_property(payload, "bitrate", encoder, "target-bitrate", G_BINDING_SYNC_CREATE);
        g_object_set(payload, "bitrate", evaluate_bitrate_from_payload(payload), NULL);
        //make_preset = TRUE;
        break;
    default:
        element_name = g_strdup_printf("encoder_%s_%u", OwrCodecTypeEncoderElementName[payload->priv->codec_type], get_unique_id());
        encoder = gst_element_factory_make(OwrCodecTypeEncoderElementName[payload->priv->codec_type], element_name);
        g_free(element_name);
        g_return_val_if_fail(encoder, NULL);
        break;
    }

    return encoder;
}
Ejemplo n.º 19
0
/* FUNCTIONS ******************************************************************/
void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
{
	SS7_FUNC_TRACE_ENTER (__FUNCTION__);
	
	sngss7_chan_data_t	*sngss7_info = ftdmchan->call_data;;
	const char			*nadi = NULL;
	SiConEvnt 			iam;
	
	sngss7_info->suInstId 	= get_unique_id ();
	sngss7_info->spInstId 	= 0;
	sngss7_info->spId 		= 1;
	
	memset (&iam, 0x0, sizeof (iam));
	
	/* copy down the nature of connection indicators */
	iam.natConInd.eh.pres 				= PRSNT_NODEF;
	iam.natConInd.satInd.pres 			= PRSNT_NODEF;
	iam.natConInd.satInd.val 			= 0; /* no satellite circuit */
	iam.natConInd.contChkInd.pres 		= PRSNT_NODEF;
	iam.natConInd.contChkInd.val 		= CONTCHK_NOTREQ;
	iam.natConInd.echoCntrlDevInd.pres	= PRSNT_NODEF;
	iam.natConInd.echoCntrlDevInd.val 	= ECHOCDEV_INCL;
	
	/* copy down the forward call indicators */
	iam.fwdCallInd.eh.pres 				= PRSNT_NODEF;
	iam.fwdCallInd.natIntCallInd.pres 	= PRSNT_NODEF;
	iam.fwdCallInd.natIntCallInd.val 	= 0x00;
	iam.fwdCallInd.end2EndMethInd.pres 	= PRSNT_NODEF;
	iam.fwdCallInd.end2EndMethInd.val 	= E2EMTH_NOMETH;
	iam.fwdCallInd.intInd.pres 			= PRSNT_NODEF;
	iam.fwdCallInd.intInd.val 			= INTIND_NOINTW;
	iam.fwdCallInd.end2EndInfoInd.pres 	= PRSNT_NODEF;
	iam.fwdCallInd.end2EndInfoInd.val 	= E2EINF_NOINFO;
	iam.fwdCallInd.isdnUsrPrtInd.pres 	= PRSNT_NODEF;
	iam.fwdCallInd.isdnUsrPrtInd.val 	= ISUP_USED;
	iam.fwdCallInd.isdnUsrPrtPrfInd.pres = PRSNT_NODEF;
	iam.fwdCallInd.isdnUsrPrtPrfInd.val = PREF_PREFAW;
	iam.fwdCallInd.isdnAccInd.pres 		= PRSNT_NODEF;
	iam.fwdCallInd.isdnAccInd.val 		= ISDNACC_ISDN;
	iam.fwdCallInd.sccpMethInd.pres 	= PRSNT_NODEF;
	iam.fwdCallInd.sccpMethInd.val 		= SCCPMTH_NOIND;
	
	/* copy down the calling number information */
	iam.cgPtyCat.eh.pres 				= PRSNT_NODEF;
	iam.cgPtyCat.cgPtyCat.pres 			= PRSNT_NODEF;
	iam.cgPtyCat.cgPtyCat.val 			= CAT_ORD;	/* ordinary suscriber */
	
	/* copy down the transmission medium requirements */
	iam.txMedReq.eh.pres 				= PRSNT_NODEF;
	iam.txMedReq.trMedReq.pres 			= PRSNT_NODEF;
	iam.txMedReq.trMedReq.val 			= ftdmchan->caller_data.bearer_capability;

	if ((g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].switchType == LSI_SW_ANS88) ||
		(g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].switchType == LSI_SW_ANS92) ||
		(g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].switchType == LSI_SW_ANS95)) {

		/* include only if we're running ANSI */
		iam.fwdCallInd.transCallNInd.pres   = PRSNT_NODEF;
		iam.fwdCallInd.transCallNInd.val    = 0x0;

		iam.usrServInfoA.eh.pres				= PRSNT_NODEF;

		iam.usrServInfoA.infoTranCap.pres		= PRSNT_NODEF;
		switch (ftdmchan->caller_data.bearer_capability) {
		/**********************************************************************/
		case (FTDM_BEARER_CAP_SPEECH):
			iam.usrServInfoA.infoTranCap.val	= 0x0;			/* speech as per ATIS-1000113.3.2005 */
			break;
		/**********************************************************************/
		case (FTDM_BEARER_CAP_64K_UNRESTRICTED):
			iam.usrServInfoA.infoTranCap.val	= 0x8;			/* unrestricted digital as per ATIS-1000113.3.2005 */
			break;
		/**********************************************************************/
		case (FTDM_BEARER_CAP_3_1KHZ_AUDIO):
			iam.usrServInfoA.infoTranCap.val	= 0x10;			/* 3.1kHz audio as per ATIS-1000113.3.2005 */
			break;
		/**********************************************************************/
		default:
			SS7_ERROR_CHAN(ftdmchan, "Unknown Bearer capability falling back to speech%s\n", " ");
			iam.usrServInfoA.infoTranCap.val	= 0x0;			/* speech as per ATIS-1000113.3.2005 */
			break;
		/**********************************************************************/
		} /* switch (ftdmchan->caller_data.bearer_capability) */

		iam.usrServInfoA.cdeStand.pres			= PRSNT_NODEF;
		iam.usrServInfoA.cdeStand.val			= 0x0;				/* ITU-T standardized coding */
		iam.usrServInfoA.tranMode.pres			= PRSNT_NODEF;
		iam.usrServInfoA.tranMode.val			= 0x0;				/* circuit mode */
		iam.usrServInfoA.infoTranRate0.pres		= PRSNT_NODEF;
		iam.usrServInfoA.infoTranRate0.val		= 0x10;				/* 64kbps origination to destination */
		iam.usrServInfoA.infoTranRate1.pres		= PRSNT_NODEF;
		iam.usrServInfoA.infoTranRate1.val		= 0x10;				/* 64kbps destination to origination */
		iam.usrServInfoA.chanStruct.pres		= PRSNT_NODEF;
		iam.usrServInfoA.chanStruct.val			= 0x1;				/* 8kHz integrity */
		iam.usrServInfoA.config.pres			= PRSNT_NODEF;
		iam.usrServInfoA.config.val				= 0x0;				/* point to point configuration */
		iam.usrServInfoA.establish.pres			= PRSNT_NODEF;
		iam.usrServInfoA.establish.val			= 0x0;				/* on demand */
		iam.usrServInfoA.symmetry.pres			= PRSNT_NODEF;
		iam.usrServInfoA.symmetry.val			= 0x0;				/* bi-directional symmetric */
		iam.usrServInfoA.usrInfLyr1Prot.pres	= PRSNT_NODEF;
		iam.usrServInfoA.usrInfLyr1Prot.val		= 0x2;				/* G.711 ulaw */
		iam.usrServInfoA.rateMultiplier.pres	= PRSNT_NODEF;
		iam.usrServInfoA.rateMultiplier.val		= 0x1;				/* 1x rate multipler */
	} /* if ANSI */
	
	/* copy down the called number information */
	copy_cdPtyNum_to_sngss7 (&ftdmchan->caller_data, &iam.cdPtyNum);
	
	/* copy down the calling number information */
	
	copy_cgPtyNum_to_sngss7 (&ftdmchan->caller_data, &iam.cgPtyNum);

	/* check if the user would like a custom NADI value for the calling Pty Num */
	nadi = ftdm_channel_get_var(ftdmchan, "ss7_nadi");
	if ((nadi != NULL) && (*nadi)) {
		SS7_DEBUG_CHAN(ftdmchan,"Found user supplied NADI value \"%s\"\n", nadi);
		iam.cgPtyNum.natAddrInd.val	= atoi(nadi);
	} else {
		SS7_DEBUG_CHAN(ftdmchan,"No user supplied NADI value found, using \"3\" %s\n", " ");
		iam.cgPtyNum.natAddrInd.val	= 0x03;
	}

	sng_cc_con_request (sngss7_info->spId,
						sngss7_info->suInstId,
						sngss7_info->spInstId,
						sngss7_info->circuit->id, 
						&iam, 
						0);

	SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM clg = \"%s\", cld = \"%s\"\n",
							sngss7_info->circuit->cic,
							ftdmchan->caller_data.cid_num.digits,
							ftdmchan->caller_data.dnis.digits);
	
	SS7_FUNC_TRACE_EXIT (__FUNCTION__);
	return;
}
Ejemplo n.º 20
0
GstElement * _owr_payload_create_decoder(OwrPayload *payload)
{
    GstElement * decoder = NULL;
    gchar *element_name = NULL;

    g_return_val_if_fail(payload, NULL);

    switch (payload->priv->codec_type) {
    case OWR_CODEC_TYPE_H264:
        decoder = try_codecs(h264_decoders, "decoder");
        g_return_val_if_fail(decoder, NULL);
        break;
    case OWR_CODEC_TYPE_VP8:
        decoder = try_codecs(vp8_decoders, "decoder");
        g_return_val_if_fail(decoder, NULL);
        break;
    default:
        element_name = g_strdup_printf("decoder_%s_%u", OwrCodecTypeDecoderElementName[payload->priv->codec_type], get_unique_id());
        decoder = gst_element_factory_make(OwrCodecTypeDecoderElementName[payload->priv->codec_type], element_name);
        g_free(element_name);
        g_return_val_if_fail(decoder, NULL);
        break;
    }

    return decoder;
}