主代码如下,创建连接后,视频和语音都能正常传输数据,但是视频正常,无法语音,不知道哪里出了问题。。传输和接收用sun的transmit2和receive2.。
public class V_Server extends JFrame implements ActionListener{

public static Panel Vpanel;
public static Panel Apanel;
private Button Vchat;
private Button Achat;

AVReceive2 avrAudio;
AVReceive2 avrVideo;

public V_Server(){
super("V");
setVisible(true);
setSize(640,480);

    setLayout(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public void actionPerformed(ActionEvent e){
  if (e.getSource()==Vchat){
 
     if (!avrVideo.initialize()) {
    System.err.println("Failed to initialize the sessions.");
    System.exit(-1);}
    
     Vpanel.add(PlayerPanel.vc);
    
    
        System.out.println("Success Initialise!!!");
  }
  else if (e.getSource()==Achat){
  if (!avrAudio.initialize()) {
      System.err.println("Failed to initialize the sessions.");
      System.exit(-1);}
  Apanel.add(PlayerPanel.cc);
  }
}

  
synchronized void send(String ClientAddr){
AVTransmit2 atVideo = new AVTransmit2(new MediaLocator("vfw://0"),
ClientAddr,"22232", null);
AVTransmit2 atAudio = new AVTransmit2(new MediaLocator("dsound://"),
ClientAddr,"22228", null);
   String result2 = atVideo.start();
   String result1 = atAudio.start();
  
/*if (result1 != null && result2 != null) {
       System.err.println("OH!TransmitError : " + result1 + result2);
       System.exit(0);
   }*/
  
}

  

   synchronized void recv(String ClientAddr) {
// JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
// Generated using JFormDesigner Open Source Project license - unknown
    Vpanel=new Panel();
Vpanel.setBounds(30,30,240,320);
add(Vpanel);

Apanel=new Panel();
Apanel.setBounds(30,360,220,120);
add(Apanel);


Vchat=new Button("启动视频");
Vchat.setBounds(360, 30, 120, 30);
add(Vchat);
Vchat.addActionListener(this);

Achat=new Button("启动语音");
Achat.setBounds(360, 90, 120, 30);
add(Achat);
Achat.addActionListener(this);




String [] sVideo = {ClientAddr+"/22220"};
String [] sAudio = {ClientAddr+"/22224"};
  
avrVideo = new AVReceive2(sVideo);//construct receive object
avrAudio = new AVReceive2(sAudio);


/*setBorder(new javax.swing.border.CompoundBorder(
new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
"", javax.swing.border.TitledBorder.CENTER,
javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 18),
java.awt.Color.red), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});
*/
setLayout(null);

setBackground(new Color(102, 255, 204));

{ // compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < getComponentCount(); i++) {
Rectangle bounds = getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
setMinimumSize(preferredSize);
setPreferredSize(preferredSize);
validate();
} // JFormDesigner - End of component initialization  //GEN-END:initComponents
}
 
public static void main(String args[]) {
 ServerSocket server=null;
     Socket you=null;
             
     V_Server vs=new V_Server();
         
     
      try { 
             server=new ServerSocket(6666);
             System.out.println("服务器启动");             
                        }
      catch(IOException e1) 
           {
              System.out.println("服务器居然不能启动,OMG");
           } 
      while(true) 
      {
      try  {                 
          you=server.accept();                 
              InetAddress address=you.getInetAddress();
              System.out.println("用户的IP:"+address);
              vs.send(address.toString().substring(1));              
              vs.recv(address.toString().substring(1));
                            
           }
      catch (IOException e)
           {System.out.println("holy shit");
           }
          }
      
}      }