當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。