2012-01-28 7 views
18

मैं सॉफ्टफोन बनाने के लिए एमजेएसआईपी का उपयोग कर रहा हूं। कोड में ऑडियो स्ट्रैमिंग के लिए तीन प्रकार का विकल्प है।क्यों एमएमएफ एमजीएसआईपी के साथ ऑडियो स्ट्रीमिंग पर काम नहीं कर रहा है?

  1. JMF (जावा मीडिया फ्रेमवर्क) का उपयोग करते हुए
  2. जावा ऑडियो
  3. का उपयोग

मैं RAT उपयोग नहीं कर रहा चूहे (मजबूत ऑडियो उपकरण) का उपयोग करना। इसका मूल्य खुद से झूठा बना दिया गया है। यह जेएमएफ को कॉल करने के लिए नीचे दिया गया कोड है:

public JMFAudioLauncher(int local_port, String remote_addr, int remote_port, int direction, Log logger) 
{ 
    log=logger; 
    localport=local_port; 
    remoteport=remote_port; 
    remoteaddr=remote_addr; 
    // Patch for working with JMF with local streams 
    if (remote_addr.startsWith("127.")) 
    { 
     printLog("Patch for JMF: replaced local destination address "+remote_addr+" with 255.255.255.255"); 
     remote_addr="255.255.255.255"; 
    } 
    dir=direction; 
    if (dir>=0) sender=new JMediaSender("audio",null,remote_addr,remote_port); 
    if (dir<=0) receiver=new JMediaReceiver("audio",local_port,null); 
} 

/** Starts media application */ 
public boolean startMedia() 
{ 
    printLog("launching JMF-Audio..."); 
    String err1=null, err2=null; 

    if (sender!=null) err1=sender.start(); 
    if (err1!=null) printLog("Error trying to send audio stream: "+err1);  

    if (receiver!=null) err2=receiver.start(); 
    if (err2!=null) printLog("Error trying to receive audio stream: "+err2);  

    return (err1==null && err2==null);  
} 

/** Stops media application */ 
public boolean stopMedia() 
{ 
    String err1=null, err2=null; 

    if (sender!=null) err1=sender.stop();  
    if (err1!=null) printLog("Error stopping audio sender: "+err1);  

    if (receiver!=null) err2=receiver.stop();  
    if (err2!=null) printLog("Error stopping audio receiver: "+err2);  

    return (err1==null && err2==null);  
} 

लेकिन इसे लॉन्च नहीं किया जा रहा है। मैं अभी भी अपने सॉफ्टफोन से बात कर सकता हूं। लेकिन लॉग में यह पता चलता है ...

UA: REGISTRATION 
UA: Registration success: 200 OK 
UA: INCOMING 
UA: CONFIRMED/CALL 
UA: Error trying to create the JMFAudioLauncher 
AudioInput: TargetDataLine: [email protected] 
AudioOutput: SourceDataLine: [email protected] 
AudioLauncher: starting java audio.. 

लेकिन JMF मूल्य का उपयोग कर user_agent_profile के लिए सच है और इस कोड से त्रुटि उत्पन्न करता है।

if (user_profile.audio && local_audio_port!=0 && remote_audio_port!=0) 
    { 
     if (user_profile.use_rat) 
     // create an audio_app and start it 
     { 
      audio_app=new RATLauncher(user_profile.bin_rat,local_audio_port,remote_media_address,remote_audio_port,log); 
     } 
     else if (user_profile.use_jmf) 
     { 
      // check if JMF is supported 
      try 
      { 
       Class myclass=Class.forName("local.ua.JMFAudioLauncher"); 
       Class[] parameter_types={ Class.forName("int"), Class.forName("java.lang.String"),Class.forName("int"), Class.forName("int"), Class.forName("org.zoolu.tools.Log") }; 
       Object[] parameters={ new Integer(local_audio_port), remote_media_address, new Integer(remote_audio_port), new Integer(dir), log }; 
       java.lang.reflect.Constructor constructor=myclass.getConstructor(parameter_types); 
       audio_app=(MediaLauncher)constructor.newInstance(parameters); 

      } 
      catch (Exception e) 
      { 
       printException(e,LogLevel.HIGH); 
       printLog("Error trying to create the JMFAudioLauncher",LogLevel.HIGH); 
      } 
     } 
     // else 
     if (audio_app==null) 
     { 
      // for testing.. 
      String audio_in=null; 
      if (user_profile.send_tone) audio_in=JAudioLauncher.TONE; 
      else if (user_profile.send_file!=null) audio_in=user_profile.send_file; 
      String audio_out=null; 
      if (user_profile.recv_file!=null) audio_out=user_profile.recv_file;   

      //audio_app=new JAudioLauncher(local_audio_port,remote_media_address,remote_audio_port,dir,log); 
      audio_app=new JAudioLauncher(local_audio_port,remote_media_address,remote_audio_port,dir,audio_in,audio_out,user_profile.audio_sample_rate,user_profile.audio_sample_size,user_profile.audio_frame_size,log); 
     } 
     audio_app.startMedia(); 
    } 

जेएमएफ को सक्षम करने के लिए मैं क्या कर सकता हूं?

+0

आप अपने कोड का इंडेंटेशन ठीक करना चाहेंगे। आप देख सकते हैं कि यह कैसा दिखता है। इसे ठीक करने से यह कम से कम अधिक पठनीय हो जाएगा। – Bart

+0

@ बार्ट: मैंने कुछ स्वरूपण में सुधार किया है, वास्तव में आप क्यों कह रहे हैं कि मेरा कोड अपठनीय है? मुझे बेहतर स्वरूपण पर विशिष्ट सुझाव दें। धन्यवाद –

+1

@ Alvi_1987 देखें कि अब आपके पास अधिक भाग्य है या नहीं। – Aristos

उत्तर

2

क्या आप कुछ समय ले सकते हैं और कोड के इस भाग पर त्रुटि को किस पंक्ति में फेंक दिया गया है?

// check if JMF is supported 
try{ 
    Class myclass=Class.forName("local.ua.JMFAudioLauncher"); 
    Class[] parameter_types={ Class.forName("int"), Class.forName("java.lang.String"),Class.forName("int"), Class.forName("int"), Class.forName("org.zoolu.tools.Log") }; 
    Object[] parameters={ new Integer(local_audio_port), remote_media_address, new Integer(remote_audio_port), new Integer(dir), log }; 
    java.lang.reflect.Constructor constructor=myclass.getConstructor(parameter_types); 
    audio_app=(MediaLauncher)constructor.newInstance(parameters); 
    } 
catch (Exception e){ 
    printException(e,LogLevel.HIGH); 
    printLog("Error trying to create the JMFAudioLauncher",LogLevel.HIGH); 
    } 
+0

बस उस q/a के संदर्भ के लिए, उस प्रश्न के बारे में मेटा पर एक प्रश्न था, मैं उस समय कुछ बक्षीस जोड़ता हूं और उस उत्तर को मदद करने का प्रयास करता हूं। मेटा प्रश्न यहां दिया गया है: http://meta.stackexchange.com/questions/122809/why-are-my-questions-remaining-unans reply-for-a-long-time – Aristos

संबंधित मुद्दे