Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bug of high CPU utilization #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,9 @@ public void setPublicInetAddress(InetAddress inetAddress) {
@Override public void setRtpPort(int rtpPort) { }
@Override public void save() { }
@Override public void setAuthorizationUsername(String authorizationUsername) { }


public long getRtpSendInterval() {
return 0;
}

}
2 changes: 1 addition & 1 deletion peers-lib/src/main/java/net/sourceforge/peers/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ public interface Config {
public void setMediaFile(String mediaFile);
public void setRtpPort(int rtpPort);
public void setAuthorizationUsername(String authorizationUsername);

public long getRtpSendInterval();
}
4 changes: 4 additions & 0 deletions peers-lib/src/main/java/net/sourceforge/peers/JavaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public void setAuthorizationUsername(String authorizationUsername) {
this.authorizationUsername = authorizationUsername;
}

public long getRtpSendInterval() {
return 19562000;
}

@Override
public String getMediaFile() {
return mediaFile;
Expand Down
8 changes: 4 additions & 4 deletions peers-lib/src/main/java/net/sourceforge/peers/XmlConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@ public class XmlConfig implements Config {
public final static int RTP_DEFAULT_PORT = 8000;

private Logger logger;

private File file;
private Document document;

// persistent variables

private InetAddress localInetAddress;
private String userPart;
private String domain;
Expand Down Expand Up @@ -365,6 +361,10 @@ public void setAuthorizationUsername(String authorizationUsername) {
authUserNode.setTextContent(authorizationUsername);
}

public long getRtpSendInterval() {
return 0;
}

@Override
public String getMediaFile() {
return mediaFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public void sendDtmf(char digit) {
public void stopSession() {
if (rtpSession != null) {
rtpSession.stop();
while (!rtpSession.isSocketClosed()) {
while (rtpSession !=null && !rtpSession.isSocketClosed()) {
try {
Thread.sleep(15);
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ public void run() {
long offset = 0;
long lastSentTime = System.nanoTime();
// indicate if its the first time that we send a packet (dont wait)
boolean firstTime = true;

int firstTimes = 0;
while (!isStopped) {
numBytesRead = 0;
try {
Expand Down Expand Up @@ -150,12 +149,13 @@ public void run() {
timestamp += buf_size;
}
rtpPacket.setTimestamp(timestamp);
if (firstTime) {
if (firstTimes < 15) {
rtpSession.send(rtpPacket);
lastSentTime = System.nanoTime();
firstTime = false;
firstTimes++;
continue;
}
// todo改成config里取
sleepTime = 19500000 - (System.nanoTime() - lastSentTime) + offset;
if (sleepTime > 0) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,9 @@ public Void run() {
}

class Receiver implements Runnable {

private final byte[] buf = new byte[512];
@Override
public void run() {
int receiveBufferSize;
try {
receiveBufferSize = datagramSocket.getReceiveBufferSize();
} catch (SocketException e) {
logger.error("cannot get datagram socket receive buffer size",
e);
return;
}
byte[] buf = new byte[receiveBufferSize];
final DatagramPacket datagramPacket = new DatagramPacket(buf,
buf.length);
final int noException = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@

public interface SipListener {

public void registering(SipRequest sipRequest);
void registering(SipRequest sipRequest);

public void registerSuccessful(SipResponse sipResponse);
void registerSuccessful(SipResponse sipResponse);

public void registerFailed(SipResponse sipResponse);
void registerFailed(SipResponse sipResponse);

public void incomingCall(SipRequest sipRequest, SipResponse provResponse);
void incomingCall(SipRequest sipRequest, SipResponse provResponse);

public void remoteHangup(SipRequest sipRequest);
void remoteHangup(SipRequest sipRequest);

public void ringing(SipResponse sipResponse);
void ringing(SipResponse sipResponse);

public void calleePickup(SipResponse sipResponse);
void calleePickup(SipResponse sipResponse);

public void error(SipResponse sipResponse);
void error(SipResponse sipResponse);

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@

public interface ServerTransactionUser {

public void transactionFailure();
void transactionFailure();
}
Loading