JMF error - Format of Stream not supported in RTP Session Manager

java.io.IOException: Format of Stream not supported in RTP Session Manager

at com.sun.media.datasink.rtp.Handler.open(Handler.java:139)

why this erro occors?

I already created the DataSink.

When I try to do this...

dsk.open();//here the error got

dsk.start();

Code of server of media

I want to sent audio (wav) like a radio, but from file. Without stop to send streaming. PullBufered

/**

*

*Class Server that you offers Streaming of midia

*

*/

public class Servidor {

private MediaLocator ml;

private Processor pro;

private javax.media.protocol.DataSource ds;

private DataSink dsk;

private boolean codificado = false;

//start the server service, passing the adress of media

// ex: d:\music\music.wav

// pass the ip and port, to make a server works

public void iniciarServicoServidor(String end,String ip, int porta)

{

try {

//capture media

capturarMidia(end);

//creates processor

criarProcessor();

// configure the processor

configurarProcessor();

//setContent RAW

descreverConteudoEnviado();

//format the media in right RTP format

formatRTP();

//creat the streaming

criarStreaming();

//configure the server

configurarServidor(ip, porta);

//in this method raise the excepition

iniciarServidor();

//when I try to open the DataSink.open() raises the exception

//java.io.IOException: Format of Stream not supported in RTP Session //Manager

//at com.sun.media.datasink.rtp.Handler.open(Handler.java:139)

} catch (RuntimeException e) {

System.out.println("Houve um erro em iniciarServicoServidor");

e.printStackTrace();

}

}

public void capturarMidia(String endereco)

{

try {

System.out.println("**************************************************************");

System.out.println("Iniciando processo de servidor de multimidia em " + Calendar.getInstance().getTime().toString());

ml = new MediaLocator("file:///" + endereco);

System.out.println("Midia realizada com sucesso.");

System.out.println ("[" + "file:///" + endereco +"]");

} catch (RuntimeException e) {

System.out.println("Houve um erro em capturarMidia");

e.printStackTrace ();

}

}

public void criarProcessor()

{

try {

System.out.println("**************************************************************");

pro = Manager.createProcessor(ml);

System.out.println("Processor criado com sucesso.");

System.out.println("Midia com durcao:" + pro.getDuration().getSeconds());

} catch (NoProcessorException e) {

System.out.println("Houve um erro em criarProcessor");

e.printStackTrace();

} catch (IOException e) {

System.out.println ("Houve um erro em criarProcessor");

e.printStackTrace();

}

}

public void configurarProcessor()

{

try {

System.out.println("**************************************************************");

System.out.println("Processor em estado de configura玢o.");

pro.configure();

System.out.println("Processor configurado.");

} catch (RuntimeException e) {

System.out.println("Houve um erro em configurarProcessor");

e.printStackTrace();

}

}

public void descreverConteudoEnviado()

{

try {

System.out.println("**************************************************************");

pro.setContentDescriptor(new ContentDescriptor(ContentDescriptor.RAW));

System.out.println("Descritor de conteudo:" + pro.getContentDescriptor().toString());

} catch (NotConfiguredError e) {

System.out.println("Houve um erro em descreverConteudoEnviado");

e.printStackTrace();

}

}

private Format checkForVideoSizes(Format original, Format supported) {

int width, height;

Dimension size = ((VideoFormat)original).getSize();

Format jpegFmt = new Format(VideoFormat.JPEG_RTP);

Format h263Fmt = new Format(VideoFormat.H263_RTP);

if (supported.matches(jpegFmt)) {

// For JPEG, make sure width and height are divisible by 8.

width = (size.width % 8 == 0 ? size.width :

(int)(size.width / 8) * 8);

height = (size.height % 8 == 0 ? size.height :

(int)(size.height / 8) * 8);

} else if (supported.matches(h263Fmt)) {

// For H.263, we only support some specific sizes.

if (size.width < 128) {

width = 128;

height = 96;

} else if ( size.width < 176) {

width = 176;

height = 144;

} else {

width = 352;

height = 288;

}

} else {

// We don't know this particular format. We'll just

// leave it alone then.

return supported;

}

return (new VideoFormat(null,

new Dimension(width, height),

Format.NOT_SPECIFIED ,

null,

Format.NOT_SPECIFIED)).intersects(supported);

}

public void formatRTP()

{

try {

// Program the tracks.

TrackControl tracks[] = pro.getTrackControls();

Format supported[];

Format chosen;

for (int i = 0; i < tracks.length; i++) {

Format format = tracks.getFormat();

if (tracks.isEnabled()) {

supported = tracks.getSupportedFormats();

// We've set the output content to the RAW_RTP.

// So all the supported formats should work with RTP.

// We'll just pick the first one.

if (supported.length > 0) {

if (supported[0] instanceof VideoFormat) {

// For video formats, we should double check the

// sizes since not all formats work in all sizes.

chosen = checkForVideoSizes(tracks.getFormat(),

supported[0]);

} else

chosen = supported[0];

tracks.setFormat(chosen);

System.err.println("Track " + i + " is set to transmit as:");

System.err.println(" " + chosen);

codificado = true;

} else

tracks.setEnabled(false);

} else

tracks.setEnabled(false);

}

} catch (RuntimeException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public void tocar()

{

pro.start();

}

public void criarStreaming()

{

try {

System.out.println("**************************************************************");

if (codificado)

{

System.out.println("Midia codificada...");

System.out.println("Processor entra em estado de realize.");

pro.realize();

System.out.println("Processor realized.");

System.out.println("Adquirindo o streaming a ser enviado.");

ds = pro.getDataOutput();

System.out.println("Streaming adquirido pronto a ser enviado.");

}

} catch (NotRealizedError e) {

System.out.println("Houve um erro em criarStreaming");

System.out.println(e.getMessage());

e.printStackTrace();

}

catch (Exception e) {

System.out.println(e.getMessage());

}

}

public void configurarServidor(String ip, int porta)

{

System.out.println("**************************************************************");

String url = "rtp://" + ip + ":" + porta + "/audio/1";

System.out.println("Servidor ira atender em " + url);

MediaLocator mml = new MediaLocator(url);

System.out.println("Localizador de midia ja criado");

try {

System.out.println("Criando um DataSink a ser enviado.");

dsk = Manager.createDataSink(ds, mml);

System.out.println("DataSink criado.");

} catch (NoDataSinkException e) {

e.printStackTrace();

}

}

public void iniciarServidor()

{

try {

System.out.println("**************************************************************");

dsk.open();

System.out.println("Servidor ligado.");

dsk.start();

System.out.println("Servidor iniciado.");

} catch (SecurityException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

}

Gives that output console.

All methods are executed but the last doesnt works.

The method that open the DataSink.

What can I do?

**************************************************************

Iniciando processo de servidor de multimidia em Sun May 13 22:37:02 BRT 2007

Midia realizada com sucesso.

[file:///c:\radio.wav ]

**************************************************************

Processor criado com sucesso.

Midia com durcao:9.223372036854776E9

**************************************************************

Processor em estado de configura玢o.

Processor configurado.

**************************************************************

Descritor de conteudo:RAW

**************************************************************

Midia codificada...

Processor entra em estado de realize.

Processor realized.

Adquirindo o streaming a ser enviado.

Streaming adquirido pronto a ser enviado.

**************************************************************

Servidor ira atender em rtp://127.0.0.1:22000/audio/1

Localizador de midia ja criado

Criando um DataSink a ser enviado.

streams is [Lcom.sun.media.multiplexer.RawBufferMux$RawBufferSourceStream;@a0dcd9 : 1

sink: setOutputLocator rtp://127.0.0.1:22000/audio/1

DataSink criado.

**************************************************************

Track 0 is set to transmit as:

unknown, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 176400.0 frame rate, FrameSize=32 bits

java.io.IOException: Format of Stream not supported in RTP Session Manager

at com.sun.media.datasink.rtp.Handler.open(Handler.java:139)

at br.org.multimidiasi.motor.Servidor.iniciarServidor(Servidor.java:291)

at br.org.multimidiasi.motor.Servidor.iniciarServicoServidor(Servidor.java:43)

at br.org.multimidiasi.motor.ConsoleServidor.main(ConsoleServidor.java:30)

****************************************************************************

Since already thanks so much.

Exactally in this method raises erros.

Ive tried another formats (avi, mp3) but all with the same error, what I can do?

publicvoid iniciarServidor()

{

try{

System.out.println("**************************************************************");

dsk.open();

System.out.println("Servidor ligado.");

dsk.start();

System.out.println("Servidor iniciado.");

}catch (SecurityException e){

e.printStackTrace();

}catch (IOException e){

e.printStackTrace();

}

}

Track 0 is set to transmit as:

unknown, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 176400.0 frame rate, FrameSize=32 bits

java.io.IOException: Format of Stream not supported in RTP Session Manager

at com.sun.media.datasink.rtp.Handler.open(Handler.java:139)

at br.org.multimidiasi.motor.Servidor.iniciarServidor(Servidor.java:291)

at br.org.multimidiasi.motor.Servidor.iniciarServicoServidor(Servidor.java:43)

at br.org.multimidiasi.motor.ConsoleServidor.main(ConsoleServidor.java:30)

[12020 byte] By [dreampeppers99a] at [2007-11-27 4:19:04]
# 1

unknown, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 176400.0 frame rate, FrameSize=32 bits

java.io.IOException: Format of Stream not supported in RTP Session Manager

The fact that it doesn't know what the format is might have to do with the problem. I've had similar problems, and I've traced it back to missing jars and codecs. Have you tried running the same code locally without the transmission to see if you player will even play the file?

kdajania at 2007-7-12 9:25:59 > top of Java-index,Java Essentials,Java Programming...
# 2

> unknown, 44100.0 Hz, 16-bit, Stereo,

> LittleEndian, Signed, 176400.0 frame rate,

> FrameSize=32 bits

> java.io.IOException: Format of Stream not supported

> in RTP Session Manager

>

> The fact that it doesn't know what the format is

> might have to do with the problem. I've had similar

> problems, and I've traced it back to missing jars and

> codecs. Have you tried running the same code locally

> without the transmission to see if you player will

> even play the file?

Already and it works, I used Player to play it and play normally, I try to make it with the diferents codecs of audio and video, but no sucess.

dreampeppers99a at 2007-7-12 9:25:59 > top of Java-index,Java Essentials,Java Programming...
# 3

> > unknown, 44100.0 Hz, 16-bit, Stereo,

> > LittleEndian, Signed, 176400.0 frame rate,

> > FrameSize=32 bits

> > java.io.IOException: Format of Stream not

> supported

> > in RTP Session Manager

I already put a not unknow format (like mp3 lame, mpge) but nothing happening, what can i do?

dreampeppers99a at 2007-7-12 9:25:59 > top of Java-index,Java Essentials,Java Programming...
# 4
That's a stumper : |I have been having similar problems. I'll be researching more, if I find anything I will post.
kdajania at 2007-7-12 9:25:59 > top of Java-index,Java Essentials,Java Programming...
# 5
> That's a stumper : |> > I have been having similar problems. I'll be> researching more, if I find anything I will post.thanks a lot.Maybe the code above is wrong..
dreampeppers99a at 2007-7-12 9:25:59 > top of Java-index,Java Essentials,Java Programming...
# 6
Well we know that, that's why it isn't working.
kdajania at 2007-7-12 9:25:59 > top of Java-index,Java Essentials,Java Programming...
# 7

> Well we know that, that's why it isn't working.

Yeah I will review the code and post back here, btw now i know that this formats are acept:

Audio: G.711 (U-law) 8 kHz

Audio: GSM mono

Audio: G.723 mono

Audio: 4-bit mono DVI 8 kHz

Audio: 4-bit mono DVI 11.025 kHz

Audio: 4-bit mono DVI 22.05 kHz

Audio: MPEG Layer I, II

Video: JPEG (420, 422, 444)*

Video: H.261 31

Video: H.263** 34

Video: MPEG-I***

Then when i format this i would choose one of them.

dreampeppers99a at 2007-7-12 9:25:59 > top of Java-index,Java Essentials,Java Programming...
# 8

public void iniciarServidor()

{

try {

System.out.println("**************************************************************");

dsk.open();

System.out.println("Servidor ligado.");

dsk.start();

System.out.println("Servidor iniciado.");

} catch (SecurityException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

Now I change to mp2, (MPEG_RTP) and the DataSink

.open()

.start()

Works, but dont open a port on my computer, dont send a stream and the worst not has more errors.

What can I do?

When I set the MediaLocator do create DataSink, I pass the ip of my machine (the server) ?

dreampeppers99a at 2007-7-12 9:25:59 > top of Java-index,Java Essentials,Java Programming...