Kee Kong Sim

Greenhorn
+ Follow
since Jan 13, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kee Kong Sim

oh i know what i have missed, javax.media.AudioFormat;
19 years ago
the compiler don't understand the AudioFormat.MPEG_RTP,

when i code:
AudioFormat audio = AudioFormat(AudioFormat.GSM_RTP, 44100, 16, 2);
Vector deviceList = CaptureDeviceManager.getDeviceList(audio);


the compile error:
D:\KKSIM\PFI\PFI Chat Prog\CaptureNSend.java:27: cannot resolve symbol
symbol : variable GSM_RTP
location: class javax.sound.sampled.AudioFormat
AudioFormat audio = AudioFormat(AudioFormat.GSM_RTP, 44100, 16, 2);
^
D:\KKSIM\PFI\PFI Chat Prog\CaptureNSend.java:30: getDeviceList(javax.media.Format) in javax.media.CaptureDeviceManager cannot be applied to (javax.sound.sampled.AudioFormat)
Vector deviceList = CaptureDeviceManager.getDeviceList(audio);
^
Note: D:\KKSIM\PFI\PFI Chat Prog\CaptureNSend.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
2 errors

Process completed.



did i miss import anything?
my import:
import java.io.*;
import java.util.Vector;
import javax.media.protocol.*;
import javax.media.*;
import javax.media.rtp.*;
import java.net.*;
import javax.sound.sampled.*;
19 years ago
Stanley,

Can u help me check what's wrong with my codes? I'm developing a text+voice chat but only the text chat is working but voice chat not working. here is the link:

https://coderanch.com/t/272598/java/java/Help-voice-chat-JMF

i'm trying to voice chat another computer in the same LAN, which is thru a router. no error message come out but seem the programme doesn't run all the code. is it possible my router firewall block it my voice chat function? how to disable firewall in windows environment?
19 years ago
usually u can't send email to yahoo or hotmail (I mean those big and organized mail system) using ur own programme. This is to prevent spam and hack.

so try ur luck on a small/private/less security mail server.
19 years ago
I'm currently doing a voice & text chat in a LAN, after connection, text able to deliver to target computer in the same LAN but no voice transsmission. Here is my source code, what I have doing wrong? Any expert out there plz help me.


// Capture and Send Audio

import java.io.*;
import java.util.Vector;
import javax.media.protocol.*;
import javax.media.*;
import javax.media.rtp.*;
import java.net.*;


public class CaptureNSend {

CaptureDeviceInfo di;
Processor process;
DataSource DSource;
SendStream sStream;
SessionManager sesManager;
SessionAddress sessionAdd;
RTPManager rtpMgr;
Processor p=null;
String IP;
MediaLocator Locate;
public CaptureNSend(String ip) {
IP = ip;
//AudioFormat format = new AudioFormat("LINEAR", 8000, 8, 1);

Vector deviceList = CaptureDeviceManager.getDeviceList(new Format("linear"));
System.out.println(deviceList.size());
if (deviceList.size() > 0) {
di = (CaptureDeviceInfo)deviceList.get(1);
System.out.println(di.getName());
di = (CaptureDeviceInfo)deviceList.get(deviceList.size() - 1);
System.out.println(di.getName());
}
else
System.exit(-1);

MediaLocator locate = di.getLocator();

Locate = locate;
try{
p = Manager.createProcessor(Locate);
p.addControllerListener(new ProcessorEventHandler());

p.configure();
}catch(Exception e){
e.printStackTrace();
}

}


public void setOutputFormat(){

p.setContentDescriptor(new ContentDescriptor(ContentDescriptor.RAW_RTP));

System.out.println("Audio Format Set");
// transmitMedia();
}


public void setupSession () {
DSource = p.getDataOutput();
rtpMgr = RTPManager.newInstance();
System.out.println("source checked");
int port = 5000;

try {
InetAddress local=InetAddress.getLocalHost();
System.out.println("inetaddress checked");
sessionAdd = new SessionAddress(local,port);
InetAddress remote =InetAddress.getByName(IP);
SessionAddress tarAdd = new SessionAddress(remote,6638);
System.out.println(port);
System.out.println("Session address checked");

rtpMgr.initialize(sessionAdd);
rtpMgr.addTarget(tarAdd);
System.out.println("session add peer checked");
sStream = rtpMgr.createSendStream(DSource,0);
System.out.println("sending media");
sStream.start();
p.start();
} catch (Exception e) {
e.printStackTrace();
}
}


private class ProcessorEventHandler extends ControllerAdapter{

public void configureComplete(ConfigureCompleteEvent configureCompleteEvent) {

setOutputFormat();

System.out.println(" Configured");
p.realize();
}

public void realizeComplete (RealizeCompleteEvent realizeCompleteEvent) {

setupSession();
}

public void endOfMedia ( EndOfMediaEvent mediaEndEvent) {
stopTransmission();
System.out.println("Transmission completed.");
}
}

public void stopTransmission() {

}

/*public static void main(String[] args) {
CaptureNSend sCapture = new CaptureNSend();
} */

}


-------------------------------------------------------------------

// Receive and Playback Audio

import javax.media.*;
import java.util.*;

public class ReceiveMedia{
String ip = "10.10.50.171";
int port = 5000;
Player player;

public ReceiveMedia(){
String location = "rtp://" + ip + ":" + port + "/" + "audio" + "/1";
System.out.println("Setting up MediaLocator");
MediaLocator media = new MediaLocator(location);

try{
player = Manager.createPlayer(media);
player.addControllerListener(new PlayerHandlerEvent());
player.realize();
System.out.println("Player Realized");

} catch(Exception e){
e.printStackTrace();
}
}


public class PlayerHandlerEvent extends ControllerAdapter{

public void realizeComplete(RealizeCompleteEvent realizeDoneEvent){
player.prefetch();
}

public void prefetchComplete(PrefetchCompleteEvent prefetchDoneEvent){
player.start();
System.out.println("Start Playback");
} //end prefetchComplete method

public void endOfMedia(EndOfMediaEvent mediaEndEvent) {
player.setMediaTime(new Time(0));
player.stop();
}
}
}
19 years ago