| |

VerySource

 Forgot password?
 Register
Search
View: 861|Reply: 3

How does JMF capture audio and video for RTP transmission at the same time? anxious!

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-19 21:30:02
| Show all posts |Read mode
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 ();
    }
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-23 08:45:01
| Show all posts
Are you just video data transmission?
No audio data was collected when collecting
There are good examples of data collection in JAVA.
You search on java.sun.com
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Asia/Pacific Region

Post time: 2020-8-26 09:45:01
| Show all posts
Obtain the audio and video DataSources, and then use them to generate a MergingDataSource.
DataSource ds = Manager.createMergingDataSource(new DataSource[] {dsAudio, dsVideo });
Then use this DataSource to pass it together. I have written this and there is no problem.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-28 00:30:01
| Show all posts
I made a mistake in the video transmission of the camera. The transmission of sound, audio and video files can be done.
I have seen ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW_RTP);
p.setContentDescriptor(cd);
There is a problem with this one. If you add these two sentences, you will get an error when running to processor.realize, but without these two sentences,
Run to the transmit function, there will be an exception again, saying that the format is wrong. Couldn't create RTP data sink

Which master can help, I have been tortured for several days.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list