Board index » jbuilder » JMF package name for setFormat

JMF package name for setFormat


2004-12-21 04:50:58 AM
jbuilder4
Hello Newsgroup,
where can I find the package in which the following function residents:
setFormat( ((CaptureDevice) dataSo).getFormatControls(), (AudioFormat)
cdi.getFormats()[0]);
its from the console source, since I have pack it into a GUI source (main
class is a JFrame), it will not compile successfully.
here the dos snippet:
---
package test;
import java.net.InetAddress;
import javax.media.*;
import javax.media.Format;
import javax.media.format.AudioFormat;
import javax.media.protocol.*;
import javax.media.control.FormatControl;
import javax.media.rtp.*;
import javax.media.rtp.event.*;
import java.util.*;
import java.io.IOException;
import javax.swing.*;
import java.awt.event.*;
import java.awt.BorderLayout;
public class TestRTPManager3 implements ControllerListener,
ReceiveStreamListener, SessionListener
{
static TestRTPManager3 test = new TestRTPManager3();
static RTPManager mng; //both transmits and receives
static Processor proc; //converts captured audio to a format to
transmit
static SendStream ss ; //only one is needed to transmit to all of
them
static DataSource dataSo; //the microphone
static int port = 5004; //data port. The control port is 5005
static Map streams = new IdentityHashMap(); //ReceiveStream and
Players
static InetAddress[] ia; //remote and local IPs
static InetAddress localIP;
public static void main(String[] args) throws Exception
{
localIP = InetAddress.getLocalHost();
ia = new InetAddress[] {
InetAddress.getByName("80.144.189.121"),
InetAddress.getByName("62.226.145.176"),
InetAddress.getByName("192.168.178.7"),
};
List capturers = CaptureDeviceManager.getDeviceList(new
AudioFormat(AudioFormat.LINEAR));
CaptureDeviceInfo cdi = (CaptureDeviceInfo) capturers.get(0);
dataSo = Manager.createDataSource( cdi.getLocator() );
// setting the first audio format to capture
setFormat( ((CaptureDevice) dataSo).getFormatControls(), (AudioFormat)
cdi.getFormats()[0]);
...
---
and here the GUI snippet:
---
public class Eingang extends JFrame implements ControllerListener,
ReceiveStreamListener, SessionListener
{
static Eingang test = new Eingang();
static RTPManager mng;
static Processor proc;
static SendStream ss;
static DataSource dataSo;
static int Port = 5004;
static Map streams = new IdentityHashMap();
static InetAddress[] ia; // remote und local port
static InetAddress localIP;
public Eingang()
{
try {
localIP = InetAddress.getLocalHost();
ia = new InetAddress[] {
InetAddress.getByName("80.144.22.22"),
InetAddress.getByName("1.2.3.4"),
};
java.util.List capturers =
CaptureDeviceManager.getDeviceList(new AudioFormat(AudioFormat.LINEAR));
CaptureDeviceInfo cdi = (CaptureDeviceInfo) capturers.get(0);
dataSo = Manager.createDataSource( cdi.getLocator() );
// setting the first audio format to capture
setFormat( ((CaptureDevice) dataSo).getFormatControls(),
(AudioFormat) cdi.getFormats()[0]);
...
---
Thanks for helping
Jens
 
 

Re:JMF package name for setFormat

Jens Kallup wrote:
Quote
where can I find the package in which the following function residents:

setFormat( ((CaptureDevice) dataSo).getFormatControls(), (AudioFormat)
cdi.getFormats()[0]);

its from the console source, since I have pack it into a GUI source (main
class is a JFrame), it will not compile successfully.

here the dos snippet:
---
[...]
setFormat( ((CaptureDevice) dataSo).getFormatControls(),
(AudioFormat) cdi.getFormats()[0]);
No idea whatsoever.
Since "setFormat()" is not qualified, it means that
it has to be implemented in the current class or
one of its superclasses. Since there are no superclasses
involved here, your classes "Eingang" and "TestRTPManager3"
have to implement the method.
Where did you get this code? (Including that info in your
original message would have been quite beneficial. We
do sometimes pull rabbits out of hats, but not code out
of the ether.)
--
Paul Furbacher (TeamB)
Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
 

Re:JMF package name for setFormat

Hello Paul,
my mistake, I have forgott to decomment the function - it is in the class -
sorry:
private static void setFormat(FormatControl[] fca, AudioFormat format)
{
loop:
for (int i = 0; i < fca.length; i++) {
Format[] supported = fca[i].getSupportedFormats();
for (int j = 0; j < supported.length; j++) {
if (format.matches(supported[j]))
{
fca[i].setFormat(supported[j]);
break;
}
}
fca[i].setEnabled(false);
}
}
Jens
 

{smallsort}