Skip to content

Commit

Permalink
Merge pull request #1304 from pedroSG94/refactor/base-abstract-method
Browse files Browse the repository at this point in the history
refactor base abstract methods
  • Loading branch information
pedroSG94 committed Oct 14, 2023
2 parents 1a19e74 + d07a9bb commit 2b5d3d1
Show file tree
Hide file tree
Showing 41 changed files with 521 additions and 2,205 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 All @@ -85,7 +85,7 @@ public void onConnectionSuccessRtmp() {

@Override
public void onConnectionFailedRtmp(final String reason) {
if (rtmpCamera1.reTry(5000, reason, null)) {
if (rtmpCamera1.getStreamClient().reTry(5000, reason, null)) {
Toast.makeText(ExampleRtmpActivity.this, "Retry", Toast.LENGTH_SHORT)
.show();
} else {
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 All @@ -87,7 +87,7 @@ public void onConnectionSuccessRtsp() {

@Override
public void onConnectionFailedRtsp(final String reason) {
if (rtspCamera1.reTry(5000, reason, null)) {
if (rtspCamera1.getStreamClient().reTry(5000, reason, null)) {
Toast.makeText(ExampleRtspActivity.this, "Retry", Toast.LENGTH_SHORT)
.show();
} else {
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 All @@ -87,7 +87,7 @@ public void onConnectionSuccessSrt() {

@Override
public void onConnectionFailedSrt(final String reason) {
if (srtCamera1.reTry(5000, reason, null)) {
if (srtCamera1.getStreamClient().reTry(5000, reason, null)) {
Toast.makeText(ExampleSrtActivity.this, "Retry", Toast.LENGTH_SHORT)
.show();
} else {
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 All @@ -87,7 +87,7 @@ public void onConnectionSuccessRtmp() {

@Override
public void onConnectionFailedRtmp(final String reason) {
if (rtmpCamera2.reTry(5000, reason, null)) {
if (rtmpCamera2.getStreamClient().reTry(5000, reason, null)) {
Toast.makeText(SurfaceModeRtmpActivity.this, "Retry", Toast.LENGTH_SHORT)
.show();
} else {
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 All @@ -91,7 +91,7 @@ public void onConnectionSuccessRtsp() {
@Override
public void onConnectionFailedRtsp(final String reason) {
//Wait 5s and retry connect stream
if (rtspCamera2.reTry(5000, reason, null)) {
if (rtspCamera2.getStreamClient().reTry(5000, reason, null)) {
Toast.makeText(SurfaceModeRtspActivity.this, "Retry", Toast.LENGTH_SHORT)
.show();
} else {
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
60 changes: 0 additions & 60 deletions library/src/main/java/com/pedro/library/base/DisplayBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import androidx.annotation.RequiresApi;

import com.pedro.encoder.EncoderErrorCallback;
import com.pedro.encoder.Frame;
import com.pedro.encoder.audio.AudioEncoder;
import com.pedro.encoder.audio.GetAacData;
import com.pedro.encoder.input.audio.CustomAudioEffect;
Expand Down Expand Up @@ -147,14 +146,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 +449,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 +566,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

0 comments on commit 2b5d3d1

Please sign in to comment.