Results 1 to 5 of 5

Thread: Voip

  1. #1
    kira is offline Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Default Voip

    hey,I want to ask about Java Sound API...using the code below, can I capture the audio coming from a microphone and send it using a Datagram packet?? if no, then please someone tell me what should I do...

    private void captureAudio() {
    try {
    final AudioFormat format = getFormat();
    DataLine.Info info = new DataLine.Info(
    TargetDataLine.class, format);
    final TargetDataLine line = (TargetDataLine)
    AudioSystem.getLine(info);
    line.open(format);
    line.start();
    Runnable runner = new Runnable() {
    int bufferSize = (int)format.getSampleRate()
    * format.getFrameSize();
    byte buffer[] = new byte[bufferSize];

    public void run() {
    out = new ByteArrayOutputStream();
    running = true;
    try {
    while (running) {
    int count =
    line.read(buffer, 0, buffer.length);
    if (count > 0) {
    out.write(buffer, 0, count);
    buf=out.toByteArray();
    sendPacket=new DatagramPacket ( buf,buf.length,address,portNumber);
    socket.send(sendPacket);
    }
    }
    out.close();
    } catch (IOException e) {
    System.err.println("I/O problems: " + e);
    System.exit(-1);
    }
    }
    };
    Thread captureThread = new Thread(runner);
    captureThread.start();
    } catch (LineUnavailableException e) {
    System.err.println("Line unavailable: " + e);
    System.exit(-2);}
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,196
    Rep Power
    19

    Default Re: Voip

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    kira is offline Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Default Re: Voip

    thnx...

  4. #4
    kira is offline Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Default voip,capture audio, and send datagram packet

    hey,I want to ask about Java Sound API...using the code below, can I capture the audio coming from a microphone and send it using a Datagram packet?? if no, then please someone tell me what should I do...
    Java Code:
    private void captureAudio() {
    try {
    final AudioFormat format = getFormat();
    DataLine.Info info = new DataLine.Info(
    TargetDataLine.class, format);
    final TargetDataLine line = (TargetDataLine)
    AudioSystem.getLine(info);
    line.open(format);
    line.start();
    Runnable runner = new Runnable() {
    int bufferSize = (int)format.getSampleRate()
    * format.getFrameSize();
    byte buffer[] = new byte[bufferSize];
    
    public void run() {
    out = new ByteArrayOutputStream();
    running = true;
    try {
    while (running) {
    int count =
    line.read(buffer, 0, buffer.length);
    if (count > 0) {
    out.write(buffer, 0, count);
    buf=out.toByteArray();
    sendPacket=new DatagramPacket ( buf,buf.length,address,portNumber);
    socket.send(sendPacket);
    }
    }
    out.close();
    } catch (IOException e) {
    System.err.println("I/O problems: " + e);
    System.exit(-1);
    }
    }
    };
    Thread captureThread = new Thread(runner);
    captureThread.start();
    } catch (LineUnavailableException e) {
    System.err.println("Line unavailable: " + e);
    System.exit(-2);}
    }

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,196
    Rep Power
    19

    Default Re: Voip

    Please don't start a new thread with the same question. I've merged the two threads here.

    Also, haven't you learned to format your code for readability? Code Conventions for the Java Programming Language: Contents

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. JAVA and VOIP, how to?
    By mr_anderson in forum Advanced Java
    Replies: 1
    Last Post: 05-31-2011, 03:39 PM
  2. Voip review
    By callsvoip in forum Reviews / Advertising
    Replies: 0
    Last Post: 02-22-2010, 02:16 PM
  3. Better Oppertunity To start Voip Buisness
    By taiger786 in forum Reviews / Advertising
    Replies: 0
    Last Post: 02-16-2010, 09:00 AM
  4. VOIP Server Hardware Requirements
    By asifsolkar in forum Networking
    Replies: 12
    Last Post: 05-21-2008, 04:23 AM
  5. Urgent Opening in C++/Java with SIP/VoIP
    By Satish.kumar in forum Jobs Offered
    Replies: 3
    Last Post: 03-30-2008, 09:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •