当前位置: 首页>>代码示例>>Java>>正文


Java Transport类代码示例

本文整理汇总了Java中org.ice4j.Transport的典型用法代码示例。如果您正苦于以下问题:Java Transport类的具体用法?Java Transport怎么用?Java Transport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Transport类属于org.ice4j包,在下文中一共展示了Transport类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addNewPermission

import org.ice4j.Transport; //导入依赖的package包/类
/**
 * Adds a new Permission for this Allocation.
 * 
 * @param permission the permission to be added to this allocation.
 */
public void addNewPermission(Permission permission)
{
    TransportAddress peerAddr =
        new TransportAddress(permission.getIpAddress().getAddress(), 0,
            Transport.UDP);
    if (this.permissions.containsKey(peerAddr))
    {
        this.permissions.get(permission.getIpAddress()).refresh();
    }
    else if (!this.canHaveMorePermisions())
    {
        return;
    }
    else
    {
        this.permissions.put(
            permission.getIpAddress(), permission);
        maybeStartPermissionExpireThread();
    }
}
 
开发者ID:jitsi,项目名称:turnserver,代码行数:26,代码来源:Allocation.java

示例2: createStream

import org.ice4j.Transport; //导入依赖的package包/类
private IceMediaStream createStream(int rtpPort, String streamName,
                                    Agent agent) throws Throwable
{
    long startTime = System.currentTimeMillis();
    IceMediaStream stream = agent.createMediaStream(streamName);
    // rtp
    Component component = agent.createComponent(stream, Transport.UDP,
                                                rtpPort, rtpPort, rtpPort + 100);

    long endTime = System.currentTimeMillis();
    log.info("Component Name:" + component.getName());
    log.info("RTP Component created in " + (endTime - startTime) + " ms");

    return stream;
}
 
开发者ID:hankcs,项目名称:IceNAT,代码行数:16,代码来源:IceClient.java

示例3: addChannelBind

import org.ice4j.Transport; //导入依赖的package包/类
/**
 * Binds a new Channel to this Allocation.
 * If an existing ChannelBind is found it is refreshed
 * else a new ChannelBind and permission is added.
 * 
 * @param channelBind the channelBind to be added to this allocation.
 * @throws IllegalArgumentException if the channelNo of the channelBind to
 *             be added is already occupied.
 */
public void addChannelBind(ChannelBind channelBind)
{
    TransportAddress peerAddr =
        new TransportAddress(
                channelBind.getPeerAddress().getAddress(),
                0, 
                Transport.UDP);
    if (isBadChannelRequest(channelBind))
    {
        throw new IllegalArgumentException("400: BAD REQUEST");
    }
    else if(!channelBindings.containsKey(channelBind.getChannelNo()) 
           && !peerToChannelMap.containsKey(channelBind.getPeerAddress()))
    {
        synchronized(this.channelBindings)
        {
            this.channelBindings.put(   channelBind.getChannelNo(),
                                        channelBind);
        }
        synchronized(this.peerToChannelMap)
        {
            this.peerToChannelMap.put(
                channelBind.getPeerAddress(), channelBind.getChannelNo());
        }
    }
    else
    {
        synchronized(this.channelBindings)
        {
            this.channelBindings.get(channelBind.getChannelNo()).refresh();
        }
    }
    this.addNewPermission(peerAddr);
    maybeStartChannelBindExpireThread();
}
 
开发者ID:jitsi,项目名称:turnserver,代码行数:45,代码来源:Allocation.java

示例4: parseCandidate

import org.ice4j.Transport; //导入依赖的package包/类
/**
 * Parses the <tt>attribute</tt>.
 *
 * @param attribute the attribute that we need to parse.
 * @param stream the {@link org.ice4j.ice.IceMediaStream} that the candidate is supposed
 * to belong to.
 *
 * @return a newly created {@link org.ice4j.ice.RemoteCandidate} matching the
 * content of the specified <tt>attribute</tt> or <tt>null</tt> if the
 * candidate belonged to a component we don't have.
 */
private static RemoteCandidate parseCandidate(Attribute      attribute,
                                              IceMediaStream stream)
{
    String value = null;

    try{
        value = attribute.getValue();
    }catch (Throwable t){}//can't happen

    StringTokenizer tokenizer = new StringTokenizer(value);

    //XXX add exception handling.
    String foundation = tokenizer.nextToken();
    int componentID = Integer.parseInt( tokenizer.nextToken() );
    Transport transport = Transport.parse(tokenizer.nextToken());
    long priority = Long.parseLong(tokenizer.nextToken());
    String address = tokenizer.nextToken();
    int port = Integer.parseInt(tokenizer.nextToken());

    TransportAddress transAddr
        = new TransportAddress(address, port, transport);

    tokenizer.nextToken(); //skip the "typ" String
    CandidateType type = CandidateType.parse(tokenizer.nextToken());

    Component component = stream.getComponent(componentID);

    if(component == null)
        return null;

    // check if there's a related address property

    RemoteCandidate relatedCandidate = null;
    if (tokenizer.countTokens() >= 4)
    {
        tokenizer.nextToken(); // skip the raddr element
        String relatedAddr = tokenizer.nextToken();
        tokenizer.nextToken(); // skip the rport element
        int relatedPort = Integer.parseInt(tokenizer.nextToken());

        TransportAddress raddr = new TransportAddress(
                        relatedAddr, relatedPort, Transport.UDP);

        relatedCandidate = component.findRemoteCandidate(raddr);
    }

    RemoteCandidate cand = new RemoteCandidate(transAddr, component, type,
                    foundation, priority, relatedCandidate);

    component.addRemoteCandidate(cand);

    return cand;
}
 
开发者ID:hankcs,项目名称:IceNAT,代码行数:65,代码来源:SdpUtils.java

示例5: createStream

import org.ice4j.Transport; //导入依赖的package包/类
public void createStream( String name ) throws BindException, IllegalArgumentException, IOException {
	IceMediaStream stream = agent.createMediaStream(name);
	int rtpPort = getStreamPort();
	agent.createComponent(stream, Transport.UDP, rtpPort, rtpPort, rtpPort+100);
	agent.createComponent(stream, Transport.UDP, rtpPort+1, rtpPort+1, rtpPort+101);
}
 
开发者ID:bejayoharen,项目名称:java-bells,代码行数:7,代码来源:IceAgent.java

示例6: startAddressFetch

import org.ice4j.Transport; //导入依赖的package包/类
private synchronized void startAddressFetch() {
	if( addressFetchThread != null )
		return;
	addressFetchThread = new Thread() {
		@Override
		public void run() {
			Record[] stunRecords = null;
			Record[] turnRecords = null;
			for( int i=0; i<hosts.length; ++i ) {
				String stunQuery = "_stun._udp." + hosts[i] ;
				String turnQuery = "_turn._udp." + hosts[i] ;
				
				try {
					if( stunRecords == null )
						stunRecords = lookupSrv( stunQuery );
					if( turnRecords == null )
						turnRecords = lookupSrv( turnQuery );
					if( stunRecords != null && turnRecords != null )
						break;
				} catch( TextParseException tpe ) {
					throw new RuntimeException( tpe );
				}
			}
			if( stunRecords == null ) {
				stunAddresses = null ;
			} else {
				stunAddresses = new TransportAddress[stunRecords.length];
				for( int i=0; i<stunRecords.length; ++i ) {
					SRVRecord srv = (SRVRecord) stunRecords[i] ;
					stunAddresses[i] = new TransportAddress(srv.getTarget().toString().replaceFirst("\\.$", ""), srv.getPort(), Transport.UDP);
				}
			}
			if( turnRecords == null ) {
				turnAddresses = null ;
			} else {
				turnAddresses = new TransportAddress[stunRecords.length];
				for( int i=0; i<turnAddresses.length; ++i ) {
					SRVRecord srv = (SRVRecord) turnRecords[i] ;
					turnAddresses[i] = new TransportAddress(srv.getTarget().toString().replaceFirst("\\.$", ""), srv.getPort(), Transport.UDP);
				}
			}
		}

		private Record[] lookupSrv(String query) throws TextParseException {
			while( true ) {
				try {
					// Bug 6427854 causes this to sometimes throw an NPE
					return new Lookup( query, Type.SRV ).run();
				} catch( NullPointerException npe ) {
					Thread.yield();
				}
			}
		}
	};
	addressFetchThread.start();
}
 
开发者ID:bejayoharen,项目名称:java-bells,代码行数:57,代码来源:StunTurnAddress.java


注:本文中的org.ice4j.Transport类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。