मैं आरटीपी प्रारूप में जेएमएफ 2.1.1e का उपयोग कर ऑडियो कैप्चर और स्ट्रीम करना चाहता हूं। मैंने एक साधारण ट्रांसमीटर लिखा, मैं ऑडियो भेज और प्राप्त कर सकता हूं। लेकिन जब मैंने वायर्सहार्क में देखा, तो मैंने पैकेट को यूडीपी के रूप में देखा। क्या कोई मुझे समस्या से बाहर इंगित कर सकता है, कृपया।यह यूडीपी क्यों है, जब मैं जेएमएफ का उपयोग कर स्ट्रीम करता हूं तो वायरसर्क में आरटीपी नहीं?
और यहां मेरा कार्य ऑडियो कैप्चर और ट्रांसमिट के लिए ज़िम्मेदार है।
public void captureAudio(){
// Get the device list for ULAW
Vector devices = captureDevices();
CaptureDeviceInfo captureDeviceInfo = null;
if (devices.size() > 0) {
//get the first device from the list and cast it as CaptureDeviceInfo
captureDeviceInfo = (CaptureDeviceInfo) devices.firstElement();
}
else {
// exit if we could not find the relevant capturedevice.
System.out.println("No such device found");
System.exit(-1);
}
Processor processor = null;
try {
//Create a Processor for the specified media.
processor = Manager.createProcessor(captureDeviceInfo.getLocator());
} catch (IOException ex) {
System.err.println(ex);
} catch (NoProcessorException ex) {
System.err.println(ex);
}
//Prepares the Processor to be programmed.
//puts the Processor into the Configuring state.
processor.configure();
//Wait till the Processor configured.
while (processor.getState() != Processor.Configured){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
//Sets the output content-type for this Processor
processor.setContentDescriptor(CONTENT_DESCRIPTOR);
/**
ContentDescriptor CONTENT_DESCRIPTOR
= new ContentDescriptor(ContentDescriptor.RAW_RTP);
*/
//Gets a TrackControl for each track in the media stream.
TrackControl track[] = processor.getTrackControls();
boolean encodingOk = false;
//searching through tracks to get a supported audio format track.
for (int i = 0; i < track.length; i++) {
if (!encodingOk && track[i] instanceof FormatControl) {
if (((FormatControl)
track[i]).setFormat(new AudioFormat(AudioFormat.ULAW_RTP, 8000, 8, 1)) == null)
{
track[i].setEnabled(false);
}
else {
encodingOk = true;
track[i].setEnabled(encodingOk);
System.out.println("enc: " + i);
}
} else {
// we could not set this track to ULAW, so disable it
track[i].setEnabled(false);
}
}
//If we could set this track to ULAW we proceed
if (encodingOk){
processor.realize();
while (processor.getState() != Processor.Realized){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
DataSource dataSource = null;
try {
dataSource = processor.getDataOutput();
} catch (NotRealizedError e) {
e.printStackTrace();
}
try {
String url= "rtp://192.168.1.99:49150/audio/1";
MediaLocator m = new MediaLocator(url);
DataSink d = Manager.createDataSink(dataSource, m);
d.open();
d.start();
System.out.println("transmitting...");
processor.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
और कृपया पूछें, अगर आपको कुछ अनुचित या अस्पष्ट लगता है। अग्रिम धन्यवाद। :)
स्पष्टीकरण: मैं आरटीपी स्ट्रीमिंग के लिए सी # कोड का एक टुकड़ा है। और जब मैं wireshark का उपयोग कर डेटा पर कब्जा, मैं उन्हें के रूप में देख सकते हैं आरटीपी, लेकिन समस्या यह है जब मैं उन्हें के रूप में यूडीपी दिखाने से JMF wireshark डाटा प्रवाह पर कब्जा। और मेरा सवाल है, क्यों?
मुझे यूडीपी और आरटीपी के बीच का अंतर पता है।
मुझे लगता है कि समस्या CONTENT_DESCRIPTOR पर है, यह कच्ची-आरटीपी है। – shibli049
मैं समझता हूं कि आप जिस समस्या का सामना कर रहे हैं उसे छोड़कर आप कोड चला रहे हैं। हमें जेएमएफ स्रोत कोड में देखने की ज़रूरत है कि जेएमएफ प्रोसेसर क्लास को कैसे लागू करता है जब यह CONTENT_DESCRIPTOR का उपयोग करता है जैसे ओस्बकुर ने क्या कहा है। शायद यह सी # कोड और जावा जेएमएफ कोड के बीच अंतर है। सी # संस्करण के लिए आप किस स्ट्रीमिंग लाइब्रेरी का उपयोग कर रहे हैं यह बताने की देखभाल करें? – ecle
@eee: सी # प्रोजेक्ट pjsipDll का उपयोग कर रहा है, मैंने इसे सिर्फ एक दोस्त से वायरसहार्क में पैकेट का परीक्षण करने के लिए लाया, और मुझे सी # के साथ काम करने के लिए उपयोग नहीं किया जाता है। तो, आपको सी # पर कोई और जानकारी नहीं दे सका। आपके अच्छे स्पष्टीकरण के लिए – shibli049