Skip to content

Commit

Permalink
hide onRequestKeyframe
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Oct 12, 2023
1 parent 806dd63 commit d07a9bb
Show file tree
Hide file tree
Showing 18 changed files with 90 additions and 174 deletions.
18 changes: 7 additions & 11 deletions library/src/main/java/com/pedro/library/rtmp/RtmpCamera1.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,43 @@
* Created by pedro on 25/01/17.
*/

public class RtmpCamera1 extends Camera1Base implements StreamClientListener {
public class RtmpCamera1 extends Camera1Base {

private final RtmpClient rtmpClient;
private final RtmpStreamClient streamClient;
private final StreamClientListener streamClientListener = this::requestKeyFrame;

public RtmpCamera1(SurfaceView surfaceView, ConnectCheckerRtmp connectChecker) {
super(surfaceView);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

public RtmpCamera1(TextureView textureView, ConnectCheckerRtmp connectChecker) {
super(textureView);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public RtmpCamera1(OpenGlView openGlView, ConnectCheckerRtmp connectChecker) {
super(openGlView);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public RtmpCamera1(LightOpenGlView lightOpenGlView, ConnectCheckerRtmp connectChecker) {
super(lightOpenGlView);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public RtmpCamera1(Context context, ConnectCheckerRtmp connectChecker) {
super(context);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

public RtmpStreamClient getStreamClient() {
Expand Down Expand Up @@ -128,9 +129,4 @@ protected void onSpsPpsVpsRtp(ByteBuffer sps, ByteBuffer pps, ByteBuffer vps) {
protected void getH264DataRtp(ByteBuffer h264Buffer, MediaCodec.BufferInfo info) {
rtmpClient.sendVideo(h264Buffer, info);
}

@Override
public void onRequestKeyframe() {
requestKeyFrame();
}
}
18 changes: 7 additions & 11 deletions library/src/main/java/com/pedro/library/rtmp/RtmpCamera2.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@
* Created by pedro on 6/07/17.
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class RtmpCamera2 extends Camera2Base implements StreamClientListener {
public class RtmpCamera2 extends Camera2Base {

private final RtmpClient rtmpClient;
private final RtmpStreamClient streamClient;
private final StreamClientListener streamClientListener = this::requestKeyFrame;

/**
* @deprecated This view produce rotations problems and could be unsupported in future versions.
Expand All @@ -57,7 +58,7 @@ public class RtmpCamera2 extends Camera2Base implements StreamClientListener {
public RtmpCamera2(SurfaceView surfaceView, ConnectCheckerRtmp connectChecker) {
super(surfaceView);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

/**
Expand All @@ -69,25 +70,25 @@ public RtmpCamera2(SurfaceView surfaceView, ConnectCheckerRtmp connectChecker) {
public RtmpCamera2(TextureView textureView, ConnectCheckerRtmp connectChecker) {
super(textureView);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

public RtmpCamera2(OpenGlView openGlView, ConnectCheckerRtmp connectChecker) {
super(openGlView);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

public RtmpCamera2(LightOpenGlView lightOpenGlView, ConnectCheckerRtmp connectChecker) {
super(lightOpenGlView);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

public RtmpCamera2(Context context, boolean useOpengl, ConnectCheckerRtmp connectChecker) {
super(context, useOpengl);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

public RtmpStreamClient getStreamClient() {
Expand Down Expand Up @@ -137,10 +138,5 @@ protected void onSpsPpsVpsRtp(ByteBuffer sps, ByteBuffer pps, ByteBuffer vps) {
protected void getH264DataRtp(ByteBuffer h264Buffer, MediaCodec.BufferInfo info) {
rtmpClient.sendVideo(h264Buffer, info);
}

@Override
public void onRequestKeyframe() {
requestKeyFrame();
}
}

10 changes: 3 additions & 7 deletions library/src/main/java/com/pedro/library/rtmp/RtmpDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@
* Created by pedro on 9/08/17.
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class RtmpDisplay extends DisplayBase implements StreamClientListener {
public class RtmpDisplay extends DisplayBase {

private final RtmpClient rtmpClient;
private final RtmpStreamClient streamClient;
private final StreamClientListener streamClientListener = this::requestKeyFrame;

public RtmpDisplay(Context context, boolean useOpengl, ConnectCheckerRtmp connectChecker) {
super(context, useOpengl);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

public RtmpStreamClient getStreamClient() {
Expand Down Expand Up @@ -96,9 +97,4 @@ protected void onSpsPpsVpsRtp(ByteBuffer sps, ByteBuffer pps, ByteBuffer vps) {
protected void getH264DataRtp(ByteBuffer h264Buffer, MediaCodec.BufferInfo info) {
rtmpClient.sendVideo(h264Buffer, info);
}

@Override
public void onRequestKeyframe() {
requestKeyFrame();
}
}
16 changes: 6 additions & 10 deletions library/src/main/java/com/pedro/library/rtmp/RtmpFromFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,38 @@
* Created by pedro on 26/06/17.
*/
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public class RtmpFromFile extends FromFileBase implements StreamClientListener {
public class RtmpFromFile extends FromFileBase {

private final RtmpClient rtmpClient;
private final RtmpStreamClient streamClient;
private final StreamClientListener streamClientListener = this::requestKeyFrame;

public RtmpFromFile(ConnectCheckerRtmp connectChecker,
VideoDecoderInterface videoDecoderInterface, AudioDecoderInterface audioDecoderInterface) {
super(videoDecoderInterface, audioDecoderInterface);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

public RtmpFromFile(Context context, ConnectCheckerRtmp connectChecker,
VideoDecoderInterface videoDecoderInterface, AudioDecoderInterface audioDecoderInterface) {
super(context, videoDecoderInterface, audioDecoderInterface);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

public RtmpFromFile(OpenGlView openGlView, ConnectCheckerRtmp connectChecker,
VideoDecoderInterface videoDecoderInterface, AudioDecoderInterface audioDecoderInterface) {
super(openGlView, videoDecoderInterface, audioDecoderInterface);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

public RtmpFromFile(LightOpenGlView lightOpenGlView, ConnectCheckerRtmp connectChecker,
VideoDecoderInterface videoDecoderInterface, AudioDecoderInterface audioDecoderInterface) {
super(lightOpenGlView, videoDecoderInterface, audioDecoderInterface);
rtmpClient = new RtmpClient(connectChecker);
streamClient = new RtmpStreamClient(rtmpClient, this);
streamClient = new RtmpStreamClient(rtmpClient, streamClientListener);
}

public RtmpStreamClient getStreamClient() {
Expand Down Expand Up @@ -122,9 +123,4 @@ protected void getH264DataRtp(ByteBuffer h264Buffer, MediaCodec.BufferInfo info)
protected void getAacDataRtp(ByteBuffer aacBuffer, MediaCodec.BufferInfo info) {
rtmpClient.sendAudio(aacBuffer, info);
}

@Override
public void onRequestKeyframe() {
requestKeyFrame();
}
}
13 changes: 0 additions & 13 deletions library/src/main/java/com/pedro/library/rtmp/RtmpOnlyAudio.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,4 @@ protected void stopStreamRtp() {
protected void getAacDataRtp(ByteBuffer aacBuffer, MediaCodec.BufferInfo info) {
rtmpClient.sendAudio(aacBuffer, info);
}

/**
* 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 = streamClient.shouldRetry(reason);
if (result) {
streamClient.reConnect(delay, backupUrl);
}
return result;
}
}
13 changes: 7 additions & 6 deletions library/src/main/java/com/pedro/library/rtmp/RtmpStream.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ import java.nio.ByteBuffer
class RtmpStream(
context: Context, connectCheckerRtmp: ConnectCheckerRtmp, videoSource: VideoManager.Source,
audioSource: AudioManager.Source
): StreamBase(context, videoSource, audioSource), StreamClientListener {
): StreamBase(context, videoSource, audioSource) {

private val rtmpClient = RtmpClient(connectCheckerRtmp)
val streamClient = RtmpStreamClient(rtmpClient, this)
private val streamClientListener = object: StreamClientListener {
override fun onRequestKeyframe() {
requestKeyframe()
}
}
val streamClient = RtmpStreamClient(rtmpClient, streamClientListener)

constructor(context: Context, connectCheckerRtmp: ConnectCheckerRtmp):
this(context, connectCheckerRtmp, VideoManager.Source.CAMERA2, AudioManager.Source.MICROPHONE)
Expand Down Expand Up @@ -66,8 +71,4 @@ class RtmpStream(
override fun getAacDataRtp(aacBuffer: ByteBuffer, info: MediaCodec.BufferInfo) {
rtmpClient.sendAudio(aacBuffer, info)
}

override fun onRequestKeyframe() {
requestKeyframe()
}
}
18 changes: 7 additions & 11 deletions library/src/main/java/com/pedro/library/rtsp/RtspCamera1.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,43 @@
* Created by pedro on 10/02/17.
*/

public class RtspCamera1 extends Camera1Base implements StreamClientListener {
public class RtspCamera1 extends Camera1Base {

private final RtspClient rtspClient;
private final RtspStreamClient streamClient;
private final StreamClientListener streamClientListener = this::requestKeyFrame;

public RtspCamera1(SurfaceView surfaceView, ConnectCheckerRtsp connectCheckerRtsp) {
super(surfaceView);
rtspClient = new RtspClient(connectCheckerRtsp);
streamClient = new RtspStreamClient(rtspClient, this);
streamClient = new RtspStreamClient(rtspClient, streamClientListener);
}

public RtspCamera1(TextureView textureView, ConnectCheckerRtsp connectCheckerRtsp) {
super(textureView);
rtspClient = new RtspClient(connectCheckerRtsp);
streamClient = new RtspStreamClient(rtspClient, this);
streamClient = new RtspStreamClient(rtspClient, streamClientListener);
}

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public RtspCamera1(OpenGlView openGlView, ConnectCheckerRtsp connectCheckerRtsp) {
super(openGlView);
rtspClient = new RtspClient(connectCheckerRtsp);
streamClient = new RtspStreamClient(rtspClient, this);
streamClient = new RtspStreamClient(rtspClient, streamClientListener);
}

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public RtspCamera1(LightOpenGlView lightOpenGlView, ConnectCheckerRtsp connectCheckerRtsp) {
super(lightOpenGlView);
rtspClient = new RtspClient(connectCheckerRtsp);
streamClient = new RtspStreamClient(rtspClient, this);
streamClient = new RtspStreamClient(rtspClient, streamClientListener);
}

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public RtspCamera1(Context context, ConnectCheckerRtsp connectCheckerRtsp) {
super(context);
rtspClient = new RtspClient(connectCheckerRtsp);
streamClient = new RtspStreamClient(rtspClient, this);
streamClient = new RtspStreamClient(rtspClient, streamClientListener);
}

public RtspStreamClient getStreamClient() {
Expand Down Expand Up @@ -122,9 +123,4 @@ protected void onSpsPpsVpsRtp(ByteBuffer sps, ByteBuffer pps, ByteBuffer vps) {
protected void getH264DataRtp(ByteBuffer h264Buffer, MediaCodec.BufferInfo info) {
rtspClient.sendVideo(h264Buffer, info);
}

@Override
public void onRequestKeyframe() {
requestKeyFrame();
}
}
18 changes: 7 additions & 11 deletions library/src/main/java/com/pedro/library/rtsp/RtspCamera2.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@
* Created by pedro on 4/06/17.
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class RtspCamera2 extends Camera2Base implements StreamClientListener {
public class RtspCamera2 extends Camera2Base {

private final RtspClient rtspClient;
private final RtspStreamClient streamClient;
private final StreamClientListener streamClientListener = this::requestKeyFrame;

/**
* @deprecated This view produce rotations problems and could be unsupported in future versions.
Expand All @@ -57,7 +58,7 @@ public class RtspCamera2 extends Camera2Base implements StreamClientListener {
public RtspCamera2(SurfaceView surfaceView, ConnectCheckerRtsp connectCheckerRtsp) {
super(surfaceView);
rtspClient = new RtspClient(connectCheckerRtsp);
streamClient = new RtspStreamClient(rtspClient, this);
streamClient = new RtspStreamClient(rtspClient, streamClientListener);
}

/**
Expand All @@ -69,25 +70,25 @@ public RtspCamera2(SurfaceView surfaceView, ConnectCheckerRtsp connectCheckerRts
public RtspCamera2(TextureView textureView, ConnectCheckerRtsp connectCheckerRtsp) {
super(textureView);
rtspClient = new RtspClient(connectCheckerRtsp);
streamClient = new RtspStreamClient(rtspClient, this);
streamClient = new RtspStreamClient(rtspClient, streamClientListener);
}

public RtspCamera2(OpenGlView openGlView, ConnectCheckerRtsp connectCheckerRtsp) {
super(openGlView);
rtspClient = new RtspClient(connectCheckerRtsp);
streamClient = new RtspStreamClient(rtspClient, this);
streamClient = new RtspStreamClient(rtspClient, streamClientListener);
}

public RtspCamera2(LightOpenGlView lightOpenGlView, ConnectCheckerRtsp connectCheckerRtsp) {
super(lightOpenGlView);
rtspClient = new RtspClient(connectCheckerRtsp);
streamClient = new RtspStreamClient(rtspClient, this);
streamClient = new RtspStreamClient(rtspClient, streamClientListener);
}

public RtspCamera2(Context context, boolean useOpengl, ConnectCheckerRtsp connectCheckerRtsp) {
super(context, useOpengl);
rtspClient = new RtspClient(connectCheckerRtsp);
streamClient = new RtspStreamClient(rtspClient, this);
streamClient = new RtspStreamClient(rtspClient, streamClientListener);
}

public RtspStreamClient getStreamClient() {
Expand Down Expand Up @@ -130,10 +131,5 @@ protected void onSpsPpsVpsRtp(ByteBuffer sps, ByteBuffer pps, ByteBuffer vps) {
protected void getH264DataRtp(ByteBuffer h264Buffer, MediaCodec.BufferInfo info) {
rtspClient.sendVideo(h264Buffer, info);
}

@Override
public void onRequestKeyframe() {
requestKeyFrame();
}
}

Loading

0 comments on commit d07a9bb

Please sign in to comment.