提交 0396be26 authored 作者: 汪显鹏's avatar 汪显鹏

增加mjpeg 视屏解码。

上级 14fa8f98
...@@ -10,15 +10,11 @@ android { ...@@ -10,15 +10,11 @@ android {
versionName "1.0" versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
packagingOptions { packagingOptions {
exclude 'lib/armeabi-v7a/libijkplayer.so' exclude 'lib/armeabi-v7a/libijkplayer.so'
exclude 'lib/armeabi-v7a/libijkffmpeg.so' exclude 'lib/armeabi-v7a/libijkffmpeg.so'
...@@ -42,21 +38,35 @@ dependencies { ...@@ -42,21 +38,35 @@ dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.shuyu:gsyVideoPlayer-java:7.0.1' implementation 'com.shuyu:gsyVideoPlayer-java:7.1.4'
//是否需要ExoPlayer模式 //是否需要ExoPlayer模式
implementation 'com.shuyu:GSYVideoPlayer-exo2:7.0.1' implementation 'com.shuyu:GSYVideoPlayer-exo2:7.0.1'
implementation 'com.shuyu:gsyVideoPlayer-armv7a:7.0.1' implementation 'com.shuyu:gsyVideoPlayer-armv7a:7.0.1'
implementation 'com.shuyu:gsyVideoPlayer-java:7.0.1'
implementation 'com.shuyu:gsyVideoPlayer-java:7.0.1'
//是否需要ExoPlayer模式 //是否需要ExoPlayer模式
implementation 'com.shuyu:GSYVideoPlayer-exo2:7.0.1' implementation 'com.shuyu:GSYVideoPlayer-exo2:7.0.1'
//更多ijk的编码支持 //更多ijk的编码支持
implementation 'com.shuyu:gsyVideoPlayer-ex_so:7.0.1' implementation 'com.shuyu:gsyVideoPlayer-ex_so:7.0.1'
// implementation 'com.shuyu:gsyVideoPlayer-java:7.1.4'
// //是否需要ExoPlayer模式
// implementation 'com.shuyu:GSYVideoPlayer-exo2:7.1.4'
// //更多ijk的编码支持
// implementation 'com.shuyu:gsyVideoPlayer-ex_so:7.1.4'
implementation 'com.github.niqdev:mjpeg-view:1.7.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
package="com.ubains.rtspdemo"> package="com.ubains.rtspdemo">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:appComponentFactory="" android:appComponentFactory=""
...@@ -14,17 +15,25 @@ ...@@ -14,17 +15,25 @@
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning" tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:appComponentFactory"> tools:replace="android:appComponentFactory">
<activity android:name=".Main2Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize" android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="landscape" android:screenOrientation="landscape"
android:theme="@style/Theme.AppCompat.NoActionBar"> android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> </activity>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package com.ubains.rtspdemo;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.github.niqdev.mjpeg.DisplayMode;
import com.github.niqdev.mjpeg.Mjpeg;
import com.github.niqdev.mjpeg.MjpegSurfaceView;
public class Main2Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Mejpeg2();
}
private void Mejpeg2() {
MjpegSurfaceView mjpegView = (MjpegSurfaceView) findViewById(R.id.VIEW_NAME);
int TIMEOUT = 5; //seconds
Mjpeg.newInstance()
.credential("", "")
.open("http://192.168.1.231/stream", TIMEOUT)
.subscribe(inputStream -> {
mjpegView.setSource(inputStream);
mjpegView.setDisplayMode(DisplayMode.FULLSCREEN);
mjpegView.showFps(true);
});
}
}
package com.ubains.rtspdemo; package com.ubains.rtspdemo;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
...@@ -14,7 +13,6 @@ import com.shuyu.gsyvideoplayer.cache.ProxyCacheManager; ...@@ -14,7 +13,6 @@ import com.shuyu.gsyvideoplayer.cache.ProxyCacheManager;
import com.shuyu.gsyvideoplayer.model.VideoOptionModel; import com.shuyu.gsyvideoplayer.model.VideoOptionModel;
import com.shuyu.gsyvideoplayer.player.IjkPlayerManager; import com.shuyu.gsyvideoplayer.player.IjkPlayerManager;
import com.shuyu.gsyvideoplayer.player.PlayerFactory; import com.shuyu.gsyvideoplayer.player.PlayerFactory;
import com.shuyu.gsyvideoplayer.player.SystemPlayerManager;
import com.shuyu.gsyvideoplayer.utils.OrientationUtils; import com.shuyu.gsyvideoplayer.utils.OrientationUtils;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer; import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
...@@ -51,7 +49,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -51,7 +49,7 @@ public class MainActivity extends AppCompatActivity {
private void init() { private void init() {
videoPlayer = (StandardGSYVideoPlayer) findViewById(R.id.detail_player); videoPlayer = findViewById(R.id.detail_player);
List<VideoOptionModel> list = new ArrayList<>(); List<VideoOptionModel> list = new ArrayList<>();
...@@ -62,21 +60,23 @@ public class MainActivity extends AppCompatActivity { ...@@ -62,21 +60,23 @@ public class MainActivity extends AppCompatActivity {
list.add(videoOptionModel); list.add(videoOptionModel);
//硬解码:1、打开,0、关闭 //硬解码:1、打开,0、关闭
videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 1); videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 0);
list.add(videoOptionModel); list.add(videoOptionModel);
//软解码:1、打开,0、关闭 //软解码:1、打开,0、关闭
videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "videotoolbox", 1); videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "videotoolbox", 1);
list.add(videoOptionModel); list.add(videoOptionModel);
videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "allowed_media_types", "video"); //根据媒体类型来配置 //根据媒体类型来配置
videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "allowed_media_types", "video");
list.add(videoOptionModel); list.add(videoOptionModel);
videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "timeout", 2000); videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "timeout", 10);
list.add(videoOptionModel); list.add(videoOptionModel);
videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "buffer_size", 1316); videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "buffer_size", 10240);
list.add(videoOptionModel); list.add(videoOptionModel);
videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "infbuf", 1); // 无限读 // 无限读
videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "infbuf", 1);
list.add(videoOptionModel); list.add(videoOptionModel);
videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzemaxduration", 5); videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzemaxduration", 5);
list.add(videoOptionModel); list.add(videoOptionModel);
...@@ -93,7 +93,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -93,7 +93,7 @@ public class MainActivity extends AppCompatActivity {
/** /**
* 换成自己的流媒体地址 * 换成自己的流媒体地址
*/ */
String source1 = String.format(Locale.ENGLISH, "rtsp://admin:HZ0000001988@192.168.10.28:554/h264/ch1/main/av_stream", "192.168.10.28"); String source1 = String.format(Locale.ENGLISH, "rtsp://admin:huawei@123@192.168.1.21/LiveMedia/ch1/Media1", "192.168.10.28");
//String source1 = String.format(Locale.ENGLISH, "rtsp://admin:HZ0000001988@192.168.10.21:554/h264/ch1/main/av_stream", "192.168.10.21"); //String source1 = String.format(Locale.ENGLISH, "rtsp://admin:HZ0000001988@192.168.10.21:554/h264/ch1/main/av_stream", "192.168.10.21");
videoPlayer.setUp(source1, true, "测试视频"); videoPlayer.setUp(source1, true, "测试视频");
...@@ -145,8 +145,9 @@ public class MainActivity extends AppCompatActivity { ...@@ -145,8 +145,9 @@ public class MainActivity extends AppCompatActivity {
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
GSYVideoManager.releaseAllVideos(); GSYVideoManager.releaseAllVideos();
if (orientationUtils != null) if (orientationUtils != null) {
orientationUtils.releaseListener(); orientationUtils.releaseListener();
}
} }
@Override @Override
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:stream="http://schemas.android.com/apk/res-auto"
tools:context=".Main2Activity">
<com.github.niqdev.mjpeg.MjpegSurfaceView
android:id="@+id/VIEW_NAME"
android:layout_width="match_parent"
android:layout_height="match_parent"
stream:type="stream_default" />
</RelativeLayout>
\ No newline at end of file
...@@ -18,7 +18,7 @@ allprojects { ...@@ -18,7 +18,7 @@ allprojects {
repositories { repositories {
google() google()
jcenter() jcenter()
maven { url 'https://jitpack.io' }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论