Unable to handle format

I am very new to JMF so maybe this is a stupid question but I cannot make incoming RTP audio stream be played. I get this on player.start():

Unable to handle format: ULAW/rtp, 8000.0 Hz, 8-bit, Mono

Failed to prefetch: com.sun.media.PlaybackEngine@82254d

Error: Unable to prefetch com.sun.media.PlaybackEngine@82254d

Can anybody tell me what should I do to play that format? It is a stream from asterisk PBX. I use (and need to use) cross platform JMF.

[483 byte] By [fordfrog2a] at [2007-11-26 21:26:42]
# 1

> I am very new to JMF so maybe this is a stupid

> question but I cannot make incoming RTP audio stream

> be played. I get this on player.start():

>

> Unable to handle format: ULAW/rtp, 8000.0 Hz, 8-bit,

> Mono

> Failed to prefetch:

> com.sun.media.PlaybackEngine@82254d

> Error: Unable to prefetch

> com.sun.media.PlaybackEngine@82254d

>

> Can anybody tell me what should I do to play that

> format? It is a stream from asterisk PBX. I use (and

> need to use) cross platform JMF.

Change the format to ULAW 8000,8,1 and see.

qUesT_foR_knOwLeDgea at 2007-7-10 3:07:32 > top of Java-index,Security,Cryptography...
# 2
Thank you, but how can I do that? I mean where should I change the format?
fordfrog2a at 2007-7-10 3:07:32 > top of Java-index,Security,Cryptography...
# 3
Wait a second. I am having some scruples about what i just told. Post your code and use code tags
qUesT_foR_knOwLeDgea at 2007-7-10 3:07:32 > top of Java-index,Security,Cryptography...
# 4

Little more background on it. I try to code SIP phone. Signalization part seems to be working. Currently I'm working on the part that receives the RTP stream. This class is used to receive and play the RTP stream. Most of if is just rewrite of Jain-Sip-Applet-Phone. Error about the format is logged from 'player.start()' in controllerUpdate(). When starting to receive RTP stream, RTPReceiver is first instantiated and then receive() is called on it.

public class RTPReceiver implements ReceiveStreamListener,

SessionListener,

ControllerListener {

...

public void controllerUpdate(final ControllerEvent event) {

if (event instanceof RealizeCompleteEvent) {

final Player player = (Player) event.getSourceController();

player.start();

}

}

public void receive(final InetAddress localIPAddress) {

rTPManager = RTPManager.newInstance();

final SessionAddress localAddress =

new SessionAddress(

localIPAddress,

rTPSessionDescription.getLocalPort());

rTPManager.addSessionListener(this);

rTPManager.addReceiveStreamListener(this);

if (LOG.isInfoEnabled()) {

LOG.info("Initalizing RTP manager: " + localAddress);

}

try {

rTPManager.initialize(localAddress);

} catch (InvalidSessionAddressException ex) {

throw new ConfigurationException("Invalid session address", ex);

} catch (IOException ex) {

throw new SystemException("Cannot initialize RTP manager", ex);

}

final BufferControl bufferControl =

(BufferControl) rTPManager.getControl(

"javax.media.control.BufferControl");

if (bufferControl != null) {

bufferControl.setBufferLength(0);

bufferControl.setMinimumThreshold(0);

}

final SessionAddress remoteAddress =

new SessionAddress(

rTPSessionDescription.getRemoteAddress(),

rTPSessionDescription.getRemotePort());

if (LOG.isInfoEnabled()) {

LOG.info("Adding target to RTP manager: " + remoteAddress);

}

try {

rTPManager.addTarget(remoteAddress);

} catch (InvalidSessionAddressException ex) {

throw new ConfigurationException("Invalid session address", ex);

} catch (IOException ex) {

throw new SystemException("Cannot add target to RTP manager", ex);

}

}

public void update(final ReceiveStreamEvent event) {

if (event instanceof NewReceiveStreamEvent) {

final Participant participant = event.getParticipant();

final String participantName = getParticipantName(participant);

final DataSource dataSource =

event.getReceiveStream().getDataSource();

final RTPControl rTPControl =

(RTPControl) dataSource.getControl(

"javax.media.rtp.RTPControl");

if (rTPControl != null) {

LOG.info("Setting audio format to MPEG_RTP,48000,16,1");

rTPControl.addFormat(

new AudioFormat(AudioFormat.MPEG_RTP, 48000, 16, 1),

14);

}

LOG.info(

"Starting new player for received stream from participant: "

+ participantName);

final Player player;

try {

player = Manager.createPlayer(dataSource);

} catch (IOException ex) {

throw new SystemException("Cannot create player", ex);

} catch (NoPlayerException ex) {

throw new SystemException("Cannot create player", ex);

}

players.put(participantName, player);

player.addControllerListener(this);

player.realize();

} else if (event instanceof ByeEvent) {

final Participant participant = event.getParticipant();

final String participantName = getParticipantName(participant);

final Player player = players.get(participantName);

if (player != null) {

player.close();

players.remove(participantName);

}

}

}

...

I also tried to change codec at asterisk side to 'gsm' and got this:

Unable to handle format: gsm/rtp, 8000.0 Hz, Mono

Failed to prefetch: com.sun.media.PlaybackEngine@1a76eff

Error: Unable to prefetch com.sun.media.PlaybackEngine@1a76eff

fordfrog2a at 2007-7-10 3:07:32 > top of Java-index,Security,Cryptography...
# 5

Here is my list of supported codecs, if it helps:

dvi/rtp, 8000.0 Hz, 4-bit, Mono

dvi/rtp, 11025.0 Hz, 4-bit, Mono

dvi/rtp, 22050.0 Hz, 4-bit, Mono

g723/rtp, 8000.0 Hz, Mono, FrameSize=192 bits

gsm/rtp, 8000.0 Hz, Mono, FrameSize=264 bits

ULAW/rtp, 8000.0 Hz, 8-bit, Mono, FrameSize=8 bits

mpegaudio/rtp, 48000.0 Hz, 16-bit, Mono, BigEndian, Signed

mpegaudio/rtp, 22050.0 Hz, 16-bit, Mono, BigEndian, Signed

mpegaudio/rtp, 44100.0 Hz, 16-bit, Stereo, Signed

mpegaudio/rtp, 48000.0 Hz, 16-bit, Stereo, BigEndian, Signed

mpegaudio/rtp, 22050.0 Hz, 16-bit, Stereo, BigEndian, Signed

mpegaudio/rtp, 44100.0 Hz, 16-bit, Mono, BigEndian, Signed

mpegaudio/rtp, 44100.0 Hz, 16-bit, Stereo, BigEndian, Signed

fordfrog2a at 2007-7-10 3:07:32 > top of Java-index,Security,Cryptography...
# 6

Here is some more info I extracted from player before it is started. Unfortunately I still didn't make it work. I'd appreciate any help.

6718 [RTPEventHandler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Datasource content type: raw

6719 [RTPEventHandler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Received new RTP stream: gsm/rtp, 8000.0 Hz, Mono

6720 [RTPEventHandler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Datasource control:

RTPTime is 0

Seqno is 0

CodecInfo is {3=gsm/rtp, 8000.0 Hz, 8-bit, Mono}

6720 [RTPEventHandler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Starting new player for received stream from participant: noname

6790 [JMF thread: SendEventQueue: com.sun.media.content.unknown.Handler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Player format: gsm/rtp, 8000.0 Hz, Mono

6790 [JMF thread: SendEventQueue: com.sun.media.content.unknown.Handler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Player supported format: gsm/rtp, 8000.0 Hz, Mono

6791 [JMF thread: SendEventQueue: com.sun.media.content.unknown.Handler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Player control:

RTPTime is 0

Seqno is 0

CodecInfo is {3=gsm/rtp, 8000.0 Hz, 8-bit, Mono}

6791 [JMF thread: SendEventQueue: com.sun.media.content.unknown.Handler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Player control: com.sun.media.renderer.audio.JavaSoundRenderer$GCA@1add463

6791 [JMF thread: SendEventQueue: com.sun.media.content.unknown.Handler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Player control: com.sun.media.renderer.audio.AudioRenderer$BC@152bdc7

6791 [JMF thread: SendEventQueue: com.sun.media.content.unknown.Handler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Player control: com.sun.media.renderer.audio.JavaSoundRenderer$PeakVolumeMeter@1296d1d

6791 [JMF thread: SendEventQueue: com.sun.media.content.unknown.Handler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Player control: com.sun.media.PlaybackEngine$BitRateA@baa31b

6791 [JMF thread: SendEventQueue: com.sun.media.content.unknown.Handler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Player control: com.sun.media.BasicJMD[panel0,0,0,512x200,invalid,layout=java.awt.BorderLayout]

6791 [JMF thread: SendEventQueue: com.sun.media.content.unknown.Handler] INFO cz.startnet.utils.javax.rtp.RTPReceiver - Player control: com.sun.media.PlaybackEngine$PlayerTControl@12a66ea

Unable to handle format: gsm/rtp, 8000.0 Hz, Mono

Failed to prefetch: com.sun.media.PlaybackEngine@95215b

Error: Unable to prefetch com.sun.media.PlaybackEngine@95215b

fordfrog2a at 2007-7-10 3:07:32 > top of Java-index,Security,Cryptography...
# 7

Finally solved. The problem was asterisk PBX that is running on my dev laptop was blocking sound device (alsa) which caused that "Unable to handle format" error. So this message doesn't mean necessarily that JMF is not able to handle format but it also can mean the sound device is not accessible.

fordfrog2a at 2007-7-10 3:07:32 > top of Java-index,Security,Cryptography...