|
I just started researching jMF, and need to send voice and camera video synchronously. I need to find some materials that do not collect sound and video at the same time for RTP transmission. I know that multi-track transmission can be performed in RTPManager, but I don't know how to get a DataSource with sound and image. Do I need to do it in two parts? One program is responsible for collecting voice and then establishing RTP transmission, and the other program is responsible for capturing video and then transmitting. That would lose the value of RTPManager. However, in my program code, I use RTPManager to create multiple tracks, but I do n’t know how to get audio and video?
Please give pointers?
this.locator = new javax.media.CaptureDeviceManager (). getDevice ("vfw: Microsoft WDM Image Capture (Win32): 0"). getLocator ();
this.ipAddress = ipAddress;
Integer integer = Integer.valueOf (pb);
if (integer! = null)
this.portBase = integer.intValue ();
}
DataSource ds;
DataSource clone;
ds = javax.media.Manager.createDataSource (locator);
processor = javax.media.Manager.createProcessor (ds);
ContentDescriptor cd = new ContentDescriptor (ContentDescriptor.RAW_RTP);
processor.setContentDescriptor (cd);
Format supported [];
Format chosen;
boolean atLeastOneTrack = false;
for (int i = 0; i <tracks.length; i ++) {
Format format = tracks [i] .getFormat ();
if (tracks [i] .isEnabled ()) {
supported = tracks [i] .getSupportedFormats ();
if (supported.length> 0) {
if (supported [0] instanceof VideoFormat) {
chosen = checkForVideoSizes (tracks [i] .getFormat (), supported [0]);
} else
chosen = supported [0];
tracks [i] .setFormat (chosen);
System.err.println ("Track" + i + "is set to transmit as:");
System.err.println ("" + chosen);
atLeastOneTrack = true;
} else
tracks [i] .setEnabled (false);
} else
tracks [i] .setEnabled (false);
}
setJPEGQuality (processor, 0.5f);
dataOutput = processor.getDataOutput ();
return null;
}
private String createTransmitter () {
PushBufferDataSource pbds = (PushBufferDataSource) dataOutput;
PushBufferStream pbss [] = pbds.getStreams ();
rtpMgrs = new RTPManager [pbss.length];
SessionAddress localAddr, destAddr;
InetAddress ipAddr;
SendStream sendStream;
int port;
SourceDescription srcDesList [];
for (int i = 0; i <pbss.length; i ++) {
try {
rtpMgrs [i] = RTPManager.newInstance ();
port = portBase + 2 * i;
ipAddr = InetAddress.getByName (ipAddress);
localAddr = new SessionAddress (InetAddress.getLocalHost (),
port);
destAddr = new SessionAddress (ipAddr, port);
rtpMgrs [i] .initialize (localAddr);
rtpMgrs [i] .addTarget (destAddr);
System.err.println ("Created RTP session:" + ipAddress + "" + port);
sendStream = rtpMgrs [i] .createSendStream (dataOutput, i);
sendStream.start ();
} catch (Exception e) {
return e.getMessage ();
}
}
return null;
}
/ ************************************************ ***************
* Inner Classes
************************************************** ************** /
public static void main (String [] args) {
Format fmt = null;
int i = 0;
AVTransmit2 at = new AVTransmit2 ("192.168.0.63", "42020", fmt);
String result = at.start ();
} |
|