修正gradle文件
This commit is contained in:
parent
ca3744f8be
commit
8288bc57c5
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<bytecodeTargetLevel target="16" />
|
<bytecodeTargetLevel target="11" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@ -7,7 +7,7 @@
|
|||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="semeru-16" />
|
<option name="gradleJvm" value="Embedded JDK" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|||||||
@ -16,5 +16,5 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" project-jdk-name="16" project-jdk-type="JavaSDK" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK" />
|
||||||
</project>
|
</project>
|
||||||
@ -4,12 +4,12 @@ plugins {
|
|||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk 32
|
compileSdk 33
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.ray650128.gstreamer_demo_app"
|
applicationId "com.ray650128.gstreamer_demo_app"
|
||||||
minSdk 26
|
minSdk 26
|
||||||
targetSdk 32
|
targetSdk 33
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import android.os.Bundle
|
|||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.SurfaceHolder
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
@ -15,7 +16,7 @@ import com.ray650128.gstreamer_demo_app.databinding.FragmentGridVideoBinding
|
|||||||
import kotlin.math.sqrt
|
import kotlin.math.sqrt
|
||||||
|
|
||||||
|
|
||||||
class GridVideoFragment : Fragment(), GstCallback {
|
class GridVideoFragment : Fragment(), GstCallback, SurfaceHolder.Callback {
|
||||||
|
|
||||||
private var mPageNum: Int = 0
|
private var mPageNum: Int = 0
|
||||||
private var splitMode = 0
|
private var splitMode = 0
|
||||||
@ -26,10 +27,12 @@ class GridVideoFragment : Fragment(), GstCallback {
|
|||||||
|
|
||||||
private lateinit var binding: FragmentGridVideoBinding
|
private lateinit var binding: FragmentGridVideoBinding
|
||||||
|
|
||||||
private var gstPlayers: ArrayList<GstLibrary?> = ArrayList()
|
private var gstPlayers: ArrayList<GstLibrary> = ArrayList()
|
||||||
|
|
||||||
private var videoViews: ArrayList<VideoView> = ArrayList()
|
private var videoViews: ArrayList<VideoView> = ArrayList()
|
||||||
|
|
||||||
|
private var surfaceHolders: ArrayList<SurfaceHolder> = ArrayList()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
@ -76,15 +79,14 @@ class GridVideoFragment : Fragment(), GstCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
for (i in gstPlayers.indices) {
|
||||||
|
gstPlayers[i].close()
|
||||||
|
}
|
||||||
Log.d("${TAG}_$mPageNum", "onDestroyView()")
|
Log.d("${TAG}_$mPageNum", "onDestroyView()")
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
for (i in gstPlayers.indices) {
|
|
||||||
gstPlayers[i]?.release()
|
|
||||||
gstPlayers[i] = null
|
|
||||||
}
|
|
||||||
Log.d("${TAG}_$mPageNum", "onDestroy()")
|
Log.d("${TAG}_$mPageNum", "onDestroy()")
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
@ -112,8 +114,8 @@ class GridVideoFragment : Fragment(), GstCallback {
|
|||||||
|
|
||||||
for (col in 0 until maxCol) {
|
for (col in 0 until maxCol) {
|
||||||
for (row in 0 until maxRow) {
|
for (row in 0 until maxRow) {
|
||||||
val videoView = VideoView(requireContext()).apply {
|
val videoView = VideoView(requireContext())
|
||||||
layoutParams = GridLayout.LayoutParams().apply {
|
val layoutParams = GridLayout.LayoutParams().apply {
|
||||||
height = cellHeight
|
height = cellHeight
|
||||||
width = cellWidth
|
width = cellWidth
|
||||||
|
|
||||||
@ -146,29 +148,32 @@ class GridVideoFragment : Fragment(), GstCallback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
baseView.addView(videoView)
|
baseView.addView(videoView, layoutParams)
|
||||||
videoViews.add(videoView)
|
videoViews.add(videoView)
|
||||||
|
|
||||||
|
videoView.videoView.holder.addCallback(this@GridVideoFragment)
|
||||||
|
surfaceHolders.add(videoView.videoView.holder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (index in videoViews.indices) {
|
for (index in videoViews.indices) {
|
||||||
gstPlayers.add(GstLibrary(requireContext(), data[index]))
|
gstPlayers.add(GstLibrary(requireContext(), data[index]))
|
||||||
gstPlayers[index]?.setSurfaceView(videoViews[index].videoView)
|
gstPlayers[index].setOnStatusChangeListener(this)
|
||||||
gstPlayers[index]?.setOnStatusChangeListener(this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun playAll() {
|
private fun playAll() {
|
||||||
for (index in data.indices) {
|
for (index in data.indices) {
|
||||||
gstPlayers[index]?.play()
|
gstPlayers[index].play()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stopAll() {
|
private fun stopAll() {
|
||||||
for (index in data.indices) {
|
for (index in data.indices) {
|
||||||
gstPlayers[index]?.stop()
|
gstPlayers[index].stop()
|
||||||
|
gstPlayers[index].close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +194,23 @@ class GridVideoFragment : Fragment(), GstCallback {
|
|||||||
Log.d("${TAG}_$mPageNum", "GstPlayer #$index: $message")
|
Log.d("${TAG}_$mPageNum", "GstPlayer #$index: $message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun surfaceCreated(holder: SurfaceHolder) {
|
||||||
|
val index = surfaceHolders.indexOf(holder)
|
||||||
|
gstPlayers[index].setSurfaceHolder(holder)
|
||||||
|
Log.d("GStreamer", "Surface created: " + holder.surface)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
|
||||||
|
//val index = surfaceHolders.indexOf(holder)
|
||||||
|
Log.d("GStreamer", "Surface changed to format $format width $width height $height")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun surfaceDestroyed(holder: SurfaceHolder) {
|
||||||
|
val index = surfaceHolders.indexOf(holder)
|
||||||
|
gstPlayers[index].releaseSurface()
|
||||||
|
Log.d("GStreamer", "Surface destroyed")
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val TAG = GridVideoFragment::class.java.simpleName
|
private val TAG = GridVideoFragment::class.java.simpleName
|
||||||
private const val ARG_PAGE_NUM = "page_number"
|
private const val ARG_PAGE_NUM = "page_number"
|
||||||
|
|||||||
@ -22,20 +22,31 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private lateinit var splitVideoViewAdapter: ViewPager2Adapter
|
private lateinit var splitVideoViewAdapter: ViewPager2Adapter
|
||||||
|
|
||||||
/*@SuppressLint("AuthLeak")
|
@SuppressLint("AuthLeak")
|
||||||
private val defaultMediaUris = arrayListOf(
|
private val defaultMediaUris = arrayListOf(
|
||||||
arrayListOf(
|
arrayListOf(
|
||||||
|
"rtsp://admin:admin@192.168.0.77:554/media/video2",
|
||||||
|
"rtsp://admin:1q2w3e4r!@192.168.0.79:554/media/video2",
|
||||||
|
"rtsp://admin:1q2w3e4r~@211.23.78.226:8588/media/video2",
|
||||||
"rtsp://admin:admin@211.23.78.226:8574/v02",
|
"rtsp://admin:admin@211.23.78.226:8574/v02",
|
||||||
"rtsp://admin:admin@211.23.78.226:8575/v02",
|
"rtsp://admin:admin@211.23.78.226:8575/v02",
|
||||||
"rtsp://admin:admin@192.168.0.77:554/media/video2",
|
"rtsp://admin:admin@192.168.0.77:554/media/video2",
|
||||||
"rtsp://admin:123456@192.168.0.80:554/profile2",
|
"rtsp://admin:1q2w3e4r!@192.168.0.79:554/media/video2",
|
||||||
"rtsp://admin:123456@192.168.0.83:554/profile2",
|
"rtsp://admin:1q2w3e4r~@211.23.78.226:8588/media/video2",
|
||||||
"rtsp://admin:123456@192.168.0.84:554/profile2",
|
"rtsp://admin:admin@211.23.78.226:8574/v02",
|
||||||
"rtsp://admin:admin@192.168.0.86:554/v2",
|
|
||||||
"rtsp://admin:admin@192.168.0.89:554/v02",
|
|
||||||
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c8/s1/live",
|
|
||||||
),
|
),
|
||||||
arrayListOf(
|
arrayListOf(
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
),
|
||||||
|
/*arrayListOf(
|
||||||
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c1/s1/live",
|
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c1/s1/live",
|
||||||
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c2/s1/live",
|
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c2/s1/live",
|
||||||
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c3/s1/live",
|
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c3/s1/live",
|
||||||
@ -45,7 +56,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c7/s1/live",
|
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c7/s1/live",
|
||||||
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c8/s1/live",
|
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c8/s1/live",
|
||||||
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c9/s1/live"
|
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c9/s1/live"
|
||||||
),
|
),*/
|
||||||
arrayListOf(
|
arrayListOf(
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
@ -57,9 +68,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
)
|
)
|
||||||
)*/
|
)
|
||||||
|
|
||||||
@SuppressLint("AuthLeak")
|
/*@SuppressLint("AuthLeak")
|
||||||
private val defaultMediaUris = arrayListOf(
|
private val defaultMediaUris = arrayListOf(
|
||||||
arrayListOf(
|
arrayListOf(
|
||||||
"rtsp://admin:admin@211.23.78.226:8574/v02"
|
"rtsp://admin:admin@211.23.78.226:8574/v02"
|
||||||
@ -69,8 +80,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
),
|
),
|
||||||
arrayListOf(
|
arrayListOf(
|
||||||
"rtsp://admin:admin@192.168.0.77:554/media/video2"
|
"rtsp://admin:admin@192.168.0.77:554/media/video2"
|
||||||
|
),
|
||||||
|
arrayListOf(
|
||||||
|
"http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4"
|
||||||
)
|
)
|
||||||
)
|
)*/
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 32
|
compileSdkVersion 33
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 32
|
targetSdkVersion 33
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
|
|||||||
@ -10,16 +10,15 @@ import android.view.SurfaceView;
|
|||||||
|
|
||||||
import org.freedesktop.gstreamer.GStreamer;
|
import org.freedesktop.gstreamer.GStreamer;
|
||||||
|
|
||||||
public class GstLibrary implements SurfaceHolder.Callback {
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class GstLibrary implements Closeable {
|
||||||
|
|
||||||
final Context mAppContext;
|
final Context mAppContext;
|
||||||
|
|
||||||
private GstCallback gstCallback;
|
private GstCallback gstCallback;
|
||||||
|
|
||||||
private GStreamerSurfaceView surfaceView;
|
|
||||||
|
|
||||||
private final Handler mainHandler = new Handler(Looper.getMainLooper());
|
|
||||||
|
|
||||||
private final String rtspUrl;
|
private final String rtspUrl;
|
||||||
|
|
||||||
public GstLibrary(Context context, String rtspUrl) {
|
public GstLibrary(Context context, String rtspUrl) {
|
||||||
@ -61,18 +60,11 @@ public class GstLibrary implements SurfaceHolder.Callback {
|
|||||||
nativeSurfaceFinalize();
|
nativeSurfaceFinalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void release() {
|
|
||||||
nativeFinalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOnStatusChangeListener(GstCallback callback) {
|
public void setOnStatusChangeListener(GstCallback callback) {
|
||||||
this.gstCallback = callback;
|
this.gstCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSurfaceView(GStreamerSurfaceView surfaceView) {
|
public void setSurfaceHolder(SurfaceHolder holder) {
|
||||||
this.surfaceView = surfaceView;
|
|
||||||
SurfaceHolder holder = this.surfaceView.getHolder();
|
|
||||||
holder.addCallback(this);
|
|
||||||
nativeSurfaceInit(holder.getSurface());
|
nativeSurfaceInit(holder.getSurface());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,11 +102,11 @@ public class GstLibrary implements SurfaceHolder.Callback {
|
|||||||
// Inform the video surface about the new size and recalculate the layout.
|
// Inform the video surface about the new size and recalculate the layout.
|
||||||
private void onMediaSizeChanged (int width, int height) {
|
private void onMediaSizeChanged (int width, int height) {
|
||||||
Log.i ("GStreamer", "Media size changed to " + width + "x" + height);
|
Log.i ("GStreamer", "Media size changed to " + width + "x" + height);
|
||||||
mainHandler.post(() -> {
|
/*mainHandler.post(() -> {
|
||||||
surfaceView.media_width = width;
|
surfaceView.media_width = width;
|
||||||
surfaceView.media_height = height;
|
surfaceView.media_height = height;
|
||||||
surfaceView.requestLayout();
|
surfaceView.requestLayout();
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -123,18 +115,12 @@ public class GstLibrary implements SurfaceHolder.Callback {
|
|||||||
nativeClassInit();
|
nativeClassInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
@Override
|
||||||
Log.d("GStreamer", "Surface changed to format " + format + " width " + width + " height " + height);
|
public void close() throws IOException {
|
||||||
|
try {
|
||||||
|
nativeFinalize();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void surfaceCreated(SurfaceHolder holder) {
|
|
||||||
Log.d("GStreamer", "Surface created: " + holder.getSurface());
|
|
||||||
nativeSurfaceInit (holder.getSurface());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
|
||||||
Log.d("GStreamer", "Surface destroyed");
|
|
||||||
nativePause();
|
|
||||||
nativeSurfaceFinalize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user