• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MediaDescription类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testSDPParseOffer

import javax.sdp.MediaDescription; //导入依赖的package包/类
@Test
public void testSDPParseOffer() throws Exception {
    Exchange ex = new DefaultExchange(new DefaultCamelContext());
    ex.getIn().setBody(offerSdp);
    processor.process(ex);
    assertEquals(ex.getIn().getBody().getClass(),Offer.class);

    Offer offer = (Offer)ex.getIn().getBody();

    MediaDescription mediaDescription = (MediaDescription) offer.getSdp().getMediaDescriptions(true).get(0);

    String icePwd = mediaDescription.getAttribute("ice-pwd");
    String iceUfrag = mediaDescription.getAttribute("ice-ufrag");
    String fingerprint = offer.getSdp().getAttribute("fingerprint");

    assertEquals(icePwd,"c490fef46f74bdbe64edd636bc49a259");
    assertEquals(iceUfrag,"64dc2277");
    assertEquals(fingerprint,"sha-256 99:45:B1:94:7E:97:AE:F2:A5:75:86:89:B5:AD:06:BB:63:02:FA:05:04:B2:83:1B:52:C9:EF:0E:61:8F:38:73");
}
 
开发者ID:IIlllII,项目名称:bitbreeds-webrtc,代码行数:20,代码来源:ProcessSignalsTest.java


示例2: testWebRtcSdpParser

import javax.sdp.MediaDescription; //导入依赖的package包/类
public void testWebRtcSdpParser() throws Exception {
        SDPAnnounceParser parser = new SDPAnnounceParser(rtcSdp);
        SessionDescriptionImpl sessiondescription = parser.parse();
        sessiondescription.getAttribute("crypto:1");
        String nt = sessiondescription.getConnection()==null?null:sessiondescription.getConnection().getNetworkType();
        MediaDescription md = (MediaDescription) sessiondescription.getMediaDescriptions(false).get(0);
        nt = md.getConnection().getNetworkType();
        assertNotNull(nt);
        assertNotNull(md);

}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:12,代码来源:SdpParserTest.java


示例3: testSdpParser

import javax.sdp.MediaDescription; //导入依赖的package包/类
public void testSdpParser() throws Exception {
    for (String sdpdata : sdpData) {
        SDPAnnounceParser parser = new SDPAnnounceParser(sdpdata);
        SessionDescriptionImpl sessiondescription = parser.parse();

        Vector attrs = sessiondescription.getAttributes(false);

        if (attrs != null) {
            Attribute attrib = (Attribute) attrs.get(0);
            System.out.println("attrs = " + attrib.getName());
        }

        MediaDescription md = (MediaDescription) sessiondescription.getMediaDescriptions(
                false).get(0);

        System.out.println("md attributes " + md.getAttributes(false));

        SessionDescriptionImpl sessiondescription1 = new SDPAnnounceParser(sessiondescription
                .toString()).parse();

        System.out.println("sessionDescription1 " + sessiondescription1);

        assertNotNull(sessiondescription1);
        // Unfortunately equals is not yet implemented.
        // assertEquals("Equality check",
        // sessiondescription,sessiondescription1);
        
        // Check if SDP is serializable
        File outFile = File.createTempFile("sdpObj",".dat");
        outFile.deleteOnExit();
        ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(outFile, false));
        os.writeObject(sessiondescription1);
    }

}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:36,代码来源:SdpParserTest.java


示例4: parseSDP

import javax.sdp.MediaDescription; //导入依赖的package包/类
/**
 * Llegada la respuesta a una petición de DESCRIBE, esta debe contener
 * un SDP. Este método comprobará que el SDP viene y sacará los streams
 * que éste contiene almacenandolos para poder luego realizar las peticiones
 * SETUP/PLAY de estos streams.
 * @param content
 */
private void parseSDP(ChannelBuffer content) {

	if (content.readable()) {

		try {

			String str_content = content.toString(CharsetUtil.UTF_8);


			SDPAnnounceParser parser = new SDPAnnounceParser(str_content);
			SessionDescriptionImpl sdp = parser.parse();


			//Meto en el Player el SDP
			setSdp(sdp.toString());

			@SuppressWarnings("unchecked")
			Vector<MediaDescription> vec_md = sdp.getMediaDescriptions(false);

			//Obtengo del SDP los nombres de los medias que contiene.
			Iterator<MediaDescription> it = vec_md.iterator();

			streamsSetup = new ArrayList<String>();
			while(it.hasNext()) {
				MediaDescription md = it.next();
				String stream = md.getAttribute("control");
				streamsSetup.add(stream);
			}

		} catch (ParseException e) {
			createNotify("Parse SDP exception",false);
		} catch(Exception ex) {
			createNotify("Unhandled exception",false);
		}

	}
}
 
开发者ID:laggc,项目名称:rtsp_multicast_pfc,代码行数:45,代码来源:ClientRTSP.java


示例5: SessionDescriptionImpl

import javax.sdp.MediaDescription; //导入依赖的package包/类
/** Creates new SessionDescriptionImpl */
public SessionDescriptionImpl() {
  zoneAdjustments = new Vector<TimeZoneAdjustment>();
  emailList = new Vector<EMail>();
  phoneList = new Vector<Phone>();
  bandwidthList = new Vector<BandWidth>();
  timeDescriptions = new Vector<TimeDescription>();
  mediaDescriptions = new Vector<MediaDescription>();
  // Bug reported and fixed by Steve Crossley
  attributesList = new Vector<Attribute>();

}
 
开发者ID:darkmi,项目名称:rtspproxy,代码行数:13,代码来源:SessionDescriptionImpl.java


示例6: setMediaDescriptions

import javax.sdp.MediaDescription; //导入依赖的package包/类
/**
 * Removes all MediaDescriptions from the session description.
 * 
 * @param mediaDescriptions to set
 * @throws SdpException if the parameter is null
 */
public void setMediaDescriptions(Vector<MediaDescription> mediaDescriptions) throws SdpException {
  if (mediaDescriptions == null)
    throw new SdpException("The parameter is null");
  else
    this.mediaDescriptions = mediaDescriptions;
}
 
开发者ID:darkmi,项目名称:rtspproxy,代码行数:13,代码来源:SessionDescriptionImpl.java


示例7: startConversation

import javax.sdp.MediaDescription; //导入依赖的package包/类
void startConversation(Message response,
		Transaction clientTransaction) throws SipException,
		SdpParseException, SdpException, IOException,
		NoDataSourceException, NoProcessorException, InterruptedException,
		NotConfiguredError, NotRealizedError, NoDataSinkException,
		InvalidSessionAddressException, UnknownHostException {
	System.out.println("Starting conversation");

	String sdpData = new String(response.getRawContent());
	SdpFactory sdpFactory = new SdpFactory();
	SessionDescription sessionDescription = sdpFactory
			.createSessionDescription(sdpData);
	Vector mediaDescriptions = sessionDescription
			.getMediaDescriptions(true);
	for (int mdNum = 0; mdNum < mediaDescriptions.size(); mdNum++) {
		MediaDescription mediaDescription = (MediaDescription) mediaDescriptions
				.elementAt(mdNum);
		Media media = mediaDescription.getMedia();
		String proto = media.getProtocol();
		String type = media.getMediaType();
		int port = media.getMediaPort();

		Vector formats = media.getMediaFormats(true);

		if (formats.size() < 1) {
			BrokerFactory.getLoggingBroker().logWarn(
					"In SIP outbound call: No audio formats");
		}
		int sdpFormat = SdpConstants.PCMU;
		try {
			sdpFormat = Integer.parseInt((String) formats.elementAt(0));
		} catch (NumberFormatException nfExc) {
			nfExc.printStackTrace();
		}

		startReceiver(localMediaPort);
		transmitter = new RtpTransmitter(remoteHost, port, sdpFormat);
	}
}
 
开发者ID:davidrudder23,项目名称:OpenNotification,代码行数:40,代码来源:SipInboundCall.java


示例8: handleOffer

import javax.sdp.MediaDescription; //导入依赖的package包/类
/**
 *
 * @param offer the received offer
 * @return The answer to respond with.
 */
public Answer handleOffer(Offer offer) throws Exception {

    String fingerPrint = CertUtil.getCertFingerPrint(
            keyStoreInfo.getFilePath(),
            keyStoreInfo.getAlias(),
            keyStoreInfo.getPassword());

    SessionDescription sdp = offer.getSdp();
    sdp.setAttribute("fingerprint", fingerPrint);
    MediaDescription med = (MediaDescription)sdp.getMediaDescriptions(true).get(0);
    med.setAttribute("fingerprint", fingerPrint);

    String pwd = med.getAttribute("ice-pwd");
    String user = med.getAttribute("ice-ufrag");

    String cand = med.getAttribute("candidate");
    List<String> candData = Arrays.asList(cand.split(" "));

    String ip = candData.get(4);
    String port = candData.get(5);

    this.setRemote(new UserData(user,pwd));

    /**
     * TODO The below should be defined outside PeerConnection
     *
     * This is a huge hack now. Should follow browser API
     * and create datachannel from the outside.
     */
    DataChannelImpl conn = new DataChannelImpl(this);

    //Add handling of input
    conn.onOpen(() -> {
        logger.info("Running onOpen");
        conn.send("I'M SO OPEN!!!");
    });
    conn.onMessage((i)->{
        String in = new String(i.getData());
        //logger.info("Running onMessage: " + in);
        conn.send("ECHO: " + in);
    });
    conn.onError((i)->{
        logger.info("Received error",i.getError());
    });

    new Thread(conn).start();

    String localAddress = InetAddress.getLocalHost().getHostAddress();
    String address = System.getProperty("com.bitbreeds.ip",localAddress);
    logger.info("Adr: {}", address);
    med.setAttribute("ice-pwd",local.getPassword());
    med.setAttribute("ice-ufrag",local.getUserName());
    med.setAttribute("candidate","1 1 UDP 2122252543 "+address+" "+conn.getPort()+" typ host");

    return new Answer(sdp);
}
 
开发者ID:IIlllII,项目名称:bitbreeds-webrtc,代码行数:62,代码来源:PeerConnection.java


示例9: startConversation

import javax.sdp.MediaDescription; //导入依赖的package包/类
/**
 * @param response
 * @param clientTransaction
 * @throws SipException
 * @throws SdpParseException
 * @throws SdpException
 * @throws IOException
 * @throws NoDataSourceException
 * @throws NoProcessorException
 * @throws InterruptedException
 * @throws NotConfiguredError
 * @throws NotRealizedError
 * @throws NoDataSinkException
 * @throws InvalidSessionAddressException
 * @throws UnknownHostException
 */
void startConversation(Message response,
		Transaction clientTransaction) throws SipException,
		SdpParseException, SdpException, IOException,
		NoDataSourceException, NoProcessorException, InterruptedException,
		NotConfiguredError, NotRealizedError, NoDataSinkException,
		InvalidSessionAddressException, UnknownHostException {
	System.out.println("Starting conversation");

	String sdpData = new String(response.getRawContent());
	SdpFactory sdpFactory = new SdpFactory();
	SessionDescription sessionDescription = sdpFactory
			.createSessionDescription(sdpData);
	Vector mediaDescriptions = sessionDescription
			.getMediaDescriptions(true);
	BrokerFactory.getLoggingBroker().logDebug("We have "+mediaDescriptions.size()+" media descriptions");
	for (int mdNum = 0; mdNum < mediaDescriptions.size(); mdNum++) {
		MediaDescription mediaDescription = (MediaDescription) mediaDescriptions
				.elementAt(mdNum);
		Media media = mediaDescription.getMedia();
		String proto = media.getProtocol();
		String type = media.getMediaType();
		int port = media.getMediaPort();

		Vector formats = media.getMediaFormats(true);

		if (formats.size() < 1) {
			BrokerFactory.getLoggingBroker().logWarn(
					"In SIP outbound call: No audio formats");
		}
		int sdpFormat = SdpConstants.PCMU;
		try {
			sdpFormat = Integer.parseInt((String) formats.elementAt(0));
		} catch (NumberFormatException nfExc) {
			nfExc.printStackTrace();
		}

                       transmitter = new RtpTransmitter(remoteHost, port, sdpFormat);

		startReceiver(remoteHost, port);
		BrokerFactory.getLoggingBroker().logDebug("Starting transmitter");
		transmitter = new RtpTransmitter(remoteHost, port, sdpFormat);
		BrokerFactory.getLoggingBroker().logDebug("transmitter="+transmitter);
	}
}
 
开发者ID:davidrudder23,项目名称:OpenNotification,代码行数:61,代码来源:SipOutboundCall.java


示例10: generateHoldSdpDescription

import javax.sdp.MediaDescription; //导入依赖的package包/类
/**
 * Generates the Hold Description for a Call.
 *
 * @param setAudio set hold on Audio.
 * @param setVideo set hold on Video.
 * @param call     the call that you want to hold.
 * @return SessionDescription of a call.
 * @throws MediaException
 */
public SessionDescription generateHoldSdpDescription(boolean setAudio, boolean setVideo, Call call)
        throws MediaException {
    try {
        SessionDescription sessDescr = sdpFactory
                .createSessionDescription();

        Version v = sdpFactory.createVersion(0);

        InetSocketAddress publicAudioAddress = NetworkAddressManager
                .getPublicAddressFor(((MediaDescription) (call.getLocalSdpDescription().getMediaDescriptions(true).get(0))).getMedia().getMediaPort());
        InetAddress publicIpAddress = publicAudioAddress.getAddress();
        String addrType = publicIpAddress instanceof Inet6Address ? "IP6"
                : "IP4";

        Origin o = sdpFactory.createOrigin(SIPConfig.getUserName()
                .replace(' ', '_'), 20109217, 2, "IN", addrType,
                publicIpAddress.getHostAddress());
        SessionName s = sdpFactory.createSessionName("<SparkPhone>");
        Connection c = sdpFactory.createConnection("IN", addrType,
                publicIpAddress.getHostAddress());
        TimeDescription t = sdpFactory.createTimeDescription();
        Vector<TimeDescription> timeDescs = new Vector<TimeDescription>();
        timeDescs.add(t);
        String[] formats = new String[getAudioFormats().size()];

        int i = 0;
        for (AudioFormat audioFormat : getAudioFormats()) {
            formats[i++] = AudioFormatUtils.findCorrespondingSdpFormat(audioFormat.getEncoding());
        }

        MediaDescription am = sdpFactory.createMediaDescription(
                "audio", publicAudioAddress.getPort(), 1, "RTP/AVP",
                formats);

        am.setAttribute(setAudio ? "sendonly" : "sendrecv", null);

        am.setAttribute("rtmap:101", "telephone-event/"
                + publicAudioAddress.getPort());

        Vector<MediaDescription> mediaDescs = new Vector<MediaDescription>();

        mediaDescs.add(am);

        sessDescr.setVersion(v);
        sessDescr.setOrigin(o);
        sessDescr.setConnection(c);
        sessDescr.setSessionName(s);
        sessDescr.setTimeDescriptions(timeDescs);
        if (mediaDescs.size() > 0)
            sessDescr.setMediaDescriptions(mediaDescs);
        return sessDescr;
    }
    catch (SdpException exc) {
        throw new MediaException(
                "An SDP exception occurred while generating local sdp description",
                exc);
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:68,代码来源:JmfMediaManager.java


示例11: getMediaDescriptions

import javax.sdp.MediaDescription; //导入依赖的package包/类
/**
 * Adds a MediaDescription to the session description. These correspond to the m= fields of the
 * SDP data.
 * 
 * @param create boolean to set
 * @throws SdpException
 * @return media - the field to add.
 */
public Vector<MediaDescription> getMediaDescriptions(boolean create) throws SdpException {
  if (mediaDescriptions == null) {
    if (create) mediaDescriptions = new Vector<MediaDescription>();
  }
  return mediaDescriptions;
}
 
开发者ID:darkmi,项目名称:rtspproxy,代码行数:15,代码来源:SessionDescriptionImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MAC类代码示例发布时间:2022-05-22
下一篇:
Java EncryptedData类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap