Skip to content

Commit

Permalink
refactor base abstract methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Oct 12, 2023
1 parent 1a19e74 commit d5576da
Show file tree
Hide file tree
Showing 40 changed files with 651 additions and 2,134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void onClick(View v) {
String user = etWowzaUser.getText().toString();
String password = etWowzaPassword.getText().toString();
if (!user.isEmpty() && !password.isEmpty()) {
rtmpCamera1.setAuthorization(user, password);
rtmpCamera1.getStreamClient().setAuthorization(user, password);
}
if (rtmpCamera1.isRecording() || prepareEncoders()) {
rtmpCamera1.startStream(etUrl.getText().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,14 @@ public void onClick(View v) {
if (!rtspCamera1.isStreaming()) {
bStartStop.setText(getResources().getString(R.string.stop_button));
if (rbTcp.isChecked()) {
rtspCamera1.setProtocol(Protocol.TCP);
rtspCamera1.getStreamClient().setProtocol(Protocol.TCP);
} else {
rtspCamera1.setProtocol(Protocol.UDP);
rtspCamera1.getStreamClient().setProtocol(Protocol.UDP);
}
String user = etWowzaUser.getText().toString();
String password = etWowzaPassword.getText().toString();
if (!user.isEmpty() && !password.isEmpty()) {
rtspCamera1.setAuthorization(user, password);
rtspCamera1.getStreamClient().setAuthorization(user, password);
}
if (rtspCamera1.isRecording() || prepareEncoders()) {
rtspCamera1.startStream(etUrl.getText().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected void onCreate(Bundle savedInstanceState) {
etUrl = findViewById(R.id.et_rtp_url);
etUrl.setHint(R.string.hint_rtmp);
rtmpCamera1 = new RtmpCamera1(surfaceView, this);
rtmpCamera1.setReTries(10);
rtmpCamera1.getStreamClient().setReTries(10);
surfaceView.getHolder().addCallback(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void onCreate(Bundle savedInstanceState) {
etUrl = findViewById(R.id.et_rtp_url);
etUrl.setHint(R.string.hint_rtsp);
rtspCamera1 = new RtspCamera1(surfaceView, this);
rtspCamera1.setReTries(10);
rtspCamera1.getStreamClient().setReTries(10);
surfaceView.getHolder().addCallback(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void onCreate(Bundle savedInstanceState) {
etUrl = findViewById(R.id.et_rtp_url);
etUrl.setHint(R.string.hint_srt);
srtCamera1 = new SrtCamera1(surfaceView, this);
srtCamera1.setReTries(10);
srtCamera1.getStreamClient().setReTries(10);
surfaceView.getHolder().addCallback(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void onCreate(Bundle savedInstanceState) {
etUrl = findViewById(R.id.et_rtp_url);
etUrl.setHint(R.string.hint_rtmp);
rtmpCamera2 = new RtmpCamera2(surfaceView, this);
rtmpCamera2.setReTries(10);
rtmpCamera2.getStreamClient().setReTries(10);
surfaceView.getHolder().addCallback(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected void onCreate(Bundle savedInstanceState) {
etUrl = findViewById(R.id.et_rtp_url);
etUrl.setHint(R.string.hint_rtsp);
rtspCamera2 = new RtspCamera2(surfaceView, this);
rtspCamera2.setReTries(10);
rtspCamera2.getStreamClient().setReTries(10);
surfaceView.getHolder().addCallback(this);
}

Expand Down
59 changes: 0 additions & 59 deletions library/src/main/java/com/pedro/library/base/Camera1Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,6 @@ public boolean isAutoFocusEnabled() {
return cameraManager.isAutoFocusEnabled();
}

/**
* Basic auth developed to work with Wowza. No tested with other server
*
* @param user auth.
* @param password auth.
*/
public abstract void setAuthorization(String user, String password);

/**
* Call this method before use @startStream. If not you will do a stream without video. NOTE:
* Rotation with encoder is silence ignored in some devices.
Expand Down Expand Up @@ -780,53 +772,6 @@ public void stopStream() {
}
}

/**
* Retries to connect with the given delay. You can pass an optional backupUrl
* if you'd like to connect to your backup server instead of the original one.
* Given backupUrl replaces the original one.
*/
public boolean reTry(long delay, String reason, @Nullable String backupUrl) {
boolean result = shouldRetry(reason);
if (result) {
requestKeyFrame();
reConnect(delay, backupUrl);
}
return result;
}

public boolean reTry(long delay, String reason) {
return reTry(delay, reason, null);
}

protected abstract boolean shouldRetry(String reason);

public abstract void setReTries(int reTries);

protected abstract void reConnect(long delay, @Nullable String backupUrl);

//cache control
public abstract boolean hasCongestion();

public abstract void resizeCache(int newSize) throws RuntimeException;

public abstract int getCacheSize();

public abstract long getSentAudioFrames();

public abstract long getSentVideoFrames();

public abstract long getDroppedAudioFrames();

public abstract long getDroppedVideoFrames();

public abstract void resetSentAudioFrames();

public abstract void resetSentVideoFrames();

public abstract void resetDroppedAudioFrames();

public abstract void resetDroppedVideoFrames();

/**
* Get supported preview resolutions of back camera in px.
*
Expand Down Expand Up @@ -1017,10 +962,6 @@ public void setRecordController(BaseRecordController recordController) {
if (!isRecording()) this.recordController = recordController;
}

public abstract void setLogs(boolean enable);

public abstract void setCheckServerAlive(boolean enable);

private final GetCameraData getCameraData = frame -> {
videoEncoder.inputYUVData(frame);
};
Expand Down
59 changes: 0 additions & 59 deletions library/src/main/java/com/pedro/library/base/Camera2Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,6 @@ public void setFocusDistance(float distance) {
cameraManager.setFocusDistance(distance);
}

/**
* Basic auth developed to work with Wowza. No tested with other server
*
* @param user auth.
* @param password auth.
*/
public abstract void setAuthorization(String user, String password);

/**
* Call this method before use @startStream. If not you will do a stream without video.
*
Expand Down Expand Up @@ -725,53 +717,6 @@ public void stopStream() {
}
}

/**
* Retries to connect with the given delay. You can pass an optional backupUrl
* if you'd like to connect to your backup server instead of the original one.
* Given backupUrl replaces the original one.
*/
public boolean reTry(long delay, String reason, @Nullable String backupUrl) {
boolean result = shouldRetry(reason);
if (result) {
requestKeyFrame();
reConnect(delay, backupUrl);
}
return result;
}

public boolean reTry(long delay, String reason) {
return reTry(delay, reason, null);
}

protected abstract boolean shouldRetry(String reason);

public abstract void setReTries(int reTries);

protected abstract void reConnect(long delay, @Nullable String backupUrl);

//cache control
public abstract boolean hasCongestion();

public abstract void resizeCache(int newSize) throws RuntimeException;

public abstract int getCacheSize();

public abstract long getSentAudioFrames();

public abstract long getSentVideoFrames();

public abstract long getDroppedAudioFrames();

public abstract long getDroppedVideoFrames();

public abstract void resetSentAudioFrames();

public abstract void resetSentVideoFrames();

public abstract void resetDroppedAudioFrames();

public abstract void resetDroppedVideoFrames();

/**
* Get supported preview resolutions of back camera in px.
*
Expand Down Expand Up @@ -1072,10 +1017,6 @@ public void setRecordController(BaseRecordController recordController) {
if (!isRecording()) this.recordController = recordController;
}

public abstract void setLogs(boolean enable);

public abstract void setCheckServerAlive(boolean enable);

private final GetMicrophoneData getMicrophoneData = frame -> {
audioEncoder.inputPCMData(frame);
};
Expand Down
59 changes: 0 additions & 59 deletions library/src/main/java/com/pedro/library/base/DisplayBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,6 @@ public void setFpsListener(FpsListener.Callback callback) {
fpsListener.setCallback(callback);
}

/**
* Basic auth developed to work with Wowza. No tested with other server
*
* @param user auth.
* @param password auth.
*/
public abstract void setAuthorization(String user, String password);

/**
* Call this method before use @startStream. If not you will do a stream without video.
*
Expand Down Expand Up @@ -458,53 +450,6 @@ public void stopStream() {
}
}

/**
* Retries to connect with the given delay. You can pass an optional backupUrl
* if you'd like to connect to your backup server instead of the original one.
* Given backupUrl replaces the original one.
*/
public boolean reTry(long delay, String reason, @Nullable String backupUrl) {
boolean result = shouldRetry(reason);
if (result) {
requestKeyFrame();
reConnect(delay, backupUrl);
}
return result;
}

public boolean reTry(long delay, String reason) {
return reTry(delay, reason, null);
}

protected abstract boolean shouldRetry(String reason);

public abstract void setReTries(int reTries);

protected abstract void reConnect(long delay, @Nullable String backupUrl);

//cache control
public abstract boolean hasCongestion();

public abstract void resizeCache(int newSize) throws RuntimeException;

public abstract int getCacheSize();

public abstract long getSentAudioFrames();

public abstract long getSentVideoFrames();

public abstract long getDroppedAudioFrames();

public abstract long getDroppedVideoFrames();

public abstract void resetSentAudioFrames();

public abstract void resetSentVideoFrames();

public abstract void resetDroppedAudioFrames();

public abstract void resetDroppedVideoFrames();

public GlInterface getGlInterface() {
if (glInterface != null) {
return glInterface;
Expand Down Expand Up @@ -622,10 +567,6 @@ public void setRecordController(BaseRecordController recordController) {
if (!isRecording()) this.recordController = recordController;
}

public abstract void setLogs(boolean enable);

public abstract void setCheckServerAlive(boolean enable);

private final GetMicrophoneData getMicrophoneData = frame -> {
audioEncoder.inputPCMData(frame);
};
Expand Down
59 changes: 0 additions & 59 deletions library/src/main/java/com/pedro/library/base/FromFileBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,6 @@ public void setFpsListener(FpsListener.Callback callback) {
fpsListener.setCallback(callback);
}

/**
* Basic auth developed to work with Wowza. No tested with other server
*
* @param user auth.
* @param password auth.
*/
public abstract void setAuthorization(String user, String password);

/**
* @param filePath to video MP4 file.
* @param bitRate H264 in bps.
Expand Down Expand Up @@ -421,53 +413,6 @@ public void requestKeyFrame() {

protected abstract void stopStreamRtp();

/**
* Retries to connect with the given delay. You can pass an optional backupUrl
* if you'd like to connect to your backup server instead of the original one.
* Given backupUrl replaces the original one.
*/
public boolean reTry(long delay, String reason, @Nullable String backupUrl) {
boolean result = shouldRetry(reason);
if (result) {
requestKeyFrame();
reConnect(delay, backupUrl);
}
return result;
}

public boolean reTry(long delay, String reason) {
return reTry(delay, reason, null);
}

protected abstract boolean shouldRetry(String reason);

public abstract void setReTries(int reTries);

protected abstract void reConnect(long delay, @Nullable String backupUrl);

//cache control
public abstract boolean hasCongestion();

public abstract void resizeCache(int newSize) throws RuntimeException;

public abstract int getCacheSize();

public abstract long getSentAudioFrames();

public abstract long getSentVideoFrames();

public abstract long getDroppedAudioFrames();

public abstract long getDroppedVideoFrames();

public abstract void resetSentAudioFrames();

public abstract void resetSentVideoFrames();

public abstract void resetDroppedAudioFrames();

public abstract void resetDroppedVideoFrames();

/**
* Stop stream started with @startStream.
*/
Expand Down Expand Up @@ -632,10 +577,6 @@ public void setRecordController(BaseRecordController recordController) {
if (!isRecording()) this.recordController = recordController;
}

public abstract void setLogs(boolean enable);

public abstract void setCheckServerAlive(boolean enable);

private final GetMicrophoneData getMicrophoneData = frame -> {
if (audioTrackPlayer != null) {
audioTrackPlayer.write(frame.getBuffer(), frame.getOffset(), frame.getSize());
Expand Down
Loading

0 comments on commit d5576da

Please sign in to comment.