令GstLibrary的callback可以針對多個實例作區分

This commit is contained in:
Barney
2022-08-05 14:12:23 +08:00
parent 80233d8b6e
commit 97cac9ba9a
9 changed files with 96 additions and 41 deletions
@@ -1,7 +1,7 @@
package com.hisharp.gstreamer_player;
public interface GstCallback {
public void onStatus(GstStatus gstStatus);
public void onMessage(String message);
public void onMediaSizeChanged (int width, int height);
public void onStatus(GstLibrary gstInstance, GstStatus gstStatus);
public void onMessage(GstLibrary gstInstance, String message);
public void onMediaSizeChanged (GstLibrary gstInstance, int width, int height);
}
@@ -77,11 +77,11 @@ public class GstLibrary implements SurfaceHolder.Callback {
private void setMessage(final String message) {
if (gstCallback == null) return;
if (message.contains("State changed to PAUSED")) {
gstCallback.onStatus(GstStatus.PAUSE);
gstCallback.onStatus(this, GstStatus.PAUSE);
} else if (message.contains("State changed to PLAYING")) {
gstCallback.onStatus(GstStatus.PLAYING);
gstCallback.onStatus(this, GstStatus.PLAYING);
}
gstCallback.onMessage(message);
gstCallback.onMessage(this, message);
}
// Called from native code. Native code calls this once it has created its pipeline and
@@ -90,7 +90,7 @@ public class GstLibrary implements SurfaceHolder.Callback {
Log.i ("GStreamer", "GStreamer initialized:");
if (gstCallback != null) {
gstCallback.onStatus(GstStatus.READY);
gstCallback.onStatus(this, GstStatus.READY);
}
// Restore previous playing state