gpt4 book ai didi

java - 当我使用 jmf 流式传输时,为什么在 Wireshark 中是 UDP,而不是 RTP?

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:51:23 24 4
gpt4 key购买 nike

我想使用 JMF 2.1.1e 以 RTP 格式捕获和流式传输音频。我写了一个简单的发送器,我可以发送和接收音频。但是当我在 Wireshark 中看到时,我看到数据包是 UDP。请任何人指出我的问题。

这是我负责音频捕获和传输的功能。

public void captureAudio(){

// Get the device list for ULAW
Vector devices = captureDevices();

CaptureDeviceInfo captureDeviceInfo = null;

if (devices.size() > 0) {
//get the first device from the list and cast it as CaptureDeviceInfo
captureDeviceInfo = (CaptureDeviceInfo) devices.firstElement();
}
else {
// exit if we could not find the relevant capturedevice.
System.out.println("No such device found");
System.exit(-1);
}


Processor processor = null;
try {
//Create a Processor for the specified media.
processor = Manager.createProcessor(captureDeviceInfo.getLocator());
} catch (IOException ex) {
System.err.println(ex);
} catch (NoProcessorException ex) {
System.err.println(ex);
}
//Prepares the Processor to be programmed.
//puts the Processor into the Configuring state.
processor.configure();

//Wait till the Processor configured.
while (processor.getState() != Processor.Configured){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}


//Sets the output content-type for this Processor
processor.setContentDescriptor(CONTENT_DESCRIPTOR);
/**
ContentDescriptor CONTENT_DESCRIPTOR
= new ContentDescriptor(ContentDescriptor.RAW_RTP);
*/

//Gets a TrackControl for each track in the media stream.
TrackControl track[] = processor.getTrackControls();

boolean encodingOk = false;

//searching through tracks to get a supported audio format track.
for (int i = 0; i < track.length; i++) {
if (!encodingOk && track[i] instanceof FormatControl) {
if (((FormatControl)
track[i]).setFormat( new AudioFormat(AudioFormat.ULAW_RTP, 8000, 8, 1) ) == null)
{
track[i].setEnabled(false);
}
else {
encodingOk = true;
track[i].setEnabled(encodingOk);
System.out.println("enc: " + i);
}
} else {
// we could not set this track to ULAW, so disable it
track[i].setEnabled(false);
}
}

//If we could set this track to ULAW we proceed
if (encodingOk){
processor.realize();
while (processor.getState() != Processor.Realized){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

DataSource dataSource = null;
try {
dataSource = processor.getDataOutput();
} catch (NotRealizedError e) {
e.printStackTrace();
}

try {

String url= "rtp://192.168.1.99:49150/audio/1";
MediaLocator m = new MediaLocator(url);
DataSink d = Manager.createDataSink(dataSource, m);
d.open();
d.start();
System.out.println("transmitting...");
processor.start();

} catch (Exception e) {
e.printStackTrace();
}
}
}

如果您发现任何不当或模糊之处,请询问。提前致谢。 :)

说明:我有一段用于 RTP 流式传输的 C# 代码。当我使用 wireshark 捕获数据时,我可以将它们视为 RTP,但问题是当我从 JMF wireshark 捕获数据流时将它们显示为 UDP。我的问题是,为什么?

我知道UDP和RTP的区别。

最佳答案

RTP是应用层,UDP是传输层,那不是一个级别的!维基百科有助于详细解释这一点。因此,您的数据在 UDP“帧”中作为 RTP 流发送

小概览...

应用层:

* DHCP
* DHCPv6
* DNS
* FTP
* HTTP
* IMAP
* IRC
* LDAP
* MGCP
* NNTP
* BGP
* NTP
* POP
* RPC
* RTP
* RTSP
* RIP
* SIP
* SMTP
* SNMP
* SOCKS
* SSH
* Telnet
* TLS/SSL
* XMPP
* (more)

传输层

* TCP
* UDP
* DCCP
* SCTP
* RSVP
* (more)

互联网层

* IP
o IPv4
o IPv6
* ICMP
* ICMPv6
* ECN
* IGMP
* IPsec
* (more)

链接层

* ARP/InARP
* NDP
* OSPF
* Tunnels
o L2TP
* PPP
* Media access control
o Ethernet
o DSL
o ISDN
o FDDI
* (more)

关于java - 当我使用 jmf 流式传输时,为什么在 Wireshark 中是 UDP,而不是 RTP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9975604/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com