Post on 05-Jan-2016
CS 290: VoIP Project
By Rudy Sevile
Summary
• AudioRecord
• AudioTrack
• UDP
• TCP
• Eclipse and LogCat
AudioRecord
• Use this class to record your voice from the microphone.
• Use startRecording() to start the recording and then “pull” data from the microphone using read(byte[] buffer, int offsetInBytes, int sizeInBytes).
• Call stop() to stop the recorder and release() to release the resources.
AudioTrack
• Allows you to play audio.• As with the AudioRecord, a buffer is set.• Use play() to start playing and audio track,
then send data to be played with write(byte[] buffer, int offsetInBytes, int sizeInBytes).
• Call stop() to stop the player and release() to release the resources.
UDP
• When implementing UDP, you can rely on the DatagramSocket class to make a connection. This class sends and receives DatagramPacket.
• Create a new socket using the DatagramSocket class then create a packet using the DatagramPacket class. The socket has a send() that takes a DatagramPacket as argument. The method receive() allows receiving DatagramPacket.
TCP
• Use the ServerSocket class to wait on TCP connection.
• Once a ServerSocket is created, use accept(). It will wait for an incoming connection and return a socket when one arrives.
• Use a Socket to establish a TCP connection. The connection can occur in the constructor if you pass enough parameters, or through the connect() method.
Eclipse and LogCat
References
Some links that you may find useful:
• Hello World:http://developer.android.com/resources/tutorials/hello-world.html
• Android Library:http://developer.android.com/reference/packages.html
• Sample code examples:http://developer.android.com/resources/samples/index.html