Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
R
RTSPDemo
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ubains-android-demo
RTSPDemo
Commits
84c45c5a
提交
84c45c5a
authored
11月 06, 2019
作者:
汪显鹏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GSY 优化 多任务播放模式
上级
474815a7
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
58 行增加
和
47 行删除
+58
-47
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+10
-3
EmptyActivity.java
app/src/main/java/com/ubains/rtspdemo/EmptyActivity.java
+20
-20
MutliActivity.java
app/src/main/java/com/ubains/rtspdemo/MutliActivity.java
+19
-9
activity_empty.xml
app/src/main/res/layout/activity_empty.xml
+4
-15
id.xml
app/src/main/res/values/id.xml
+5
-0
没有找到文件。
app/src/main/AndroidManifest.xml
浏览文件 @
84c45c5a
...
...
@@ -3,6 +3,10 @@
xmlns:tools=
"http://schemas.android.com/tools"
package=
"com.ubains.rtspdemo"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<application
android:allowBackup=
"true"
android:appComponentFactory=
""
...
...
@@ -25,23 +29,25 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<!-- 列表播放-->
<activity
android:name=
".ListMultiVideoActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"landscape"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
</activity>
<!--直接播放,不增加任何控件-->
<activity
android:name=
".EmptyActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"landscape"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
></activity>
<!--普通播放-->
<activity
android:name=
".MainActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize"
...
...
@@ -49,6 +55,7 @@
android:theme=
"@style/Theme.AppCompat.NoActionBar"
></activity>
</application>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
</manifest>
\ No newline at end of file
app/src/main/java/com/ubains/rtspdemo/EmptyActivity.java
浏览文件 @
84c45c5a
...
...
@@ -7,6 +7,7 @@ import android.annotation.TargetApi;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.view.WindowManager
;
import
com.shuyu.gsyvideoplayer.GSYVideoManager
;
import
com.shuyu.gsyvideoplayer.cache.CacheFactory
;
...
...
@@ -14,6 +15,7 @@ import com.shuyu.gsyvideoplayer.cache.ProxyCacheManager;
import
com.shuyu.gsyvideoplayer.model.VideoOptionModel
;
import
com.shuyu.gsyvideoplayer.player.IjkPlayerManager
;
import
com.shuyu.gsyvideoplayer.player.PlayerFactory
;
import
com.shuyu.gsyvideoplayer.utils.GSYVideoType
;
import
com.shuyu.gsyvideoplayer.utils.OrientationUtils
;
import
com.ubains.rtspdemo.vedio.EmptyControlVideo
;
...
...
@@ -27,8 +29,6 @@ import tv.danmaku.ijk.media.player.IjkMediaPlayer;
public
class
EmptyActivity
extends
AppCompatActivity
{
public
final
static
String
IMG_TRANSITION
=
"IMG_TRANSITION"
;
public
final
static
String
TRANSITION
=
"TRANSITION"
;
...
...
@@ -38,50 +38,51 @@ public class EmptyActivity extends AppCompatActivity {
private
boolean
isTransition
;
private
android
.
transition
.
Transition
transition
;
private
EmptyControlVideo
videoPlayer1
,
videoPlayer2
;
private
EmptyControlVideo
videoPlayer1
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_empty
);
//保持屏幕常亮
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
videoPlayer1
=
findViewById
(
R
.
id
.
detail_player1
);
videoPlayer2
=
findViewById
(
R
.
id
.
detail_player2
);
isTransition
=
getIntent
().
getBooleanExtra
(
TRANSITION
,
false
);
init
();
}
private
void
init
()
{
//EXOPlayer内核,支持格式更多
PlayerFactory
.
setPlayManager
(
Exo2PlayerManager
.
class
);
//系统内核模式
//PlayerFactory.setPlayManager(SystemPlayerManager.class);
//ijk内核,默认模式 ijk 模式才支持RTSP 播放
PlayerFactory
.
setPlayManager
(
IjkPlayerManager
.
class
);
//exo缓存模式,支持m3u8,只支持exo
// CacheFactory.setCacheManager(ExoPlayerCacheManager.class);
//代理缓存模式,支持所有模式,不支持m3u8等,默认
CacheFactory
.
setCacheManager
(
ProxyCacheManager
.
class
);
List
<
VideoOptionModel
>
list
=
new
ArrayList
<>();
GSYVideoType
.
setShowType
(
GSYVideoType
.
SCREEN_MATCH_FULL
);
GSYVideoType
.
setRenderType
(
GSYVideoType
.
TEXTURE
);
List
<
VideoOptionModel
>
list
=
new
ArrayList
<>();
//设置RTSP 连接方式
VideoOptionModel
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"rtsp_transport"
,
"tcp"
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"rtsp_flags"
,
"prefer_tcp"
);
list
.
add
(
videoOptionModel
);
//硬解码:1、打开,0、关闭
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"mediacodec"
,
1
);
list
.
add
(
videoOptionModel
);
//软解码:1、打开,0、关闭
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"videotoolbox"
,
1
);
list
.
add
(
videoOptionModel
);
//根据媒体类型来配置
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"allowed_media_types"
,
"video"
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"timeout"
,
20000
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"buffer_size"
,
1316
);
...
...
@@ -90,24 +91,25 @@ public class EmptyActivity extends AppCompatActivity {
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"analyzemaxduration"
,
100
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"probesize"
,
10240
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"probesize"
,
4096
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"analyzeduration"
,
"2000000"
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"flush_packets"
,
1
);
list
.
add
(
videoOptionModel
);
// 关闭播放器缓冲,这个必须关闭,否则会出现播放一段时间后,一直卡主,控制台打印 FFP_MSG_BUFFERING_START
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"packet-buffering"
,
0
);
list
.
add
(
videoOptionModel
);
GSYVideoManager
.
instance
().
setOptionModelList
(
list
);
String
url
=
"rtsp://admin:huawei@123@192.168.11.20/LiveMedia/ch1/Media1"
;
// String url = "rtsp://192.168.1.234:8556/channel=0";
videoPlayer1
.
setUp
(
url
,
true
,
""
);
// videoPlayer2.setUp(ur2, true, ""
);
videoPlayer1
.
startPlayLogic
(
);
//过渡动画
initTransition
();
//
initTransition();
}
...
...
@@ -125,7 +127,6 @@ public class EmptyActivity extends AppCompatActivity {
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
videoPlayer2
.
release
();
videoPlayer1
.
release
();
if
(
orientationUtils
!=
null
)
orientationUtils
.
releaseListener
();
...
...
@@ -135,7 +136,6 @@ public class EmptyActivity extends AppCompatActivity {
public
void
onBackPressed
()
{
//释放所有
videoPlayer1
.
setVideoAllCallBack
(
null
);
videoPlayer2
.
setVideoAllCallBack
(
null
);
GSYVideoManager
.
releaseAllVideos
();
if
(
isTransition
&&
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
super
.
onBackPressed
();
...
...
@@ -155,12 +155,12 @@ public class EmptyActivity extends AppCompatActivity {
if
(
isTransition
&&
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
postponeEnterTransition
();
ViewCompat
.
setTransitionName
(
videoPlayer1
,
IMG_TRANSITION
);
ViewCompat
.
setTransitionName
(
videoPlayer2
,
IMG_TRANSITION
);
// addTransitionListener();
// addTransitionListener();
startPostponedEnterTransition
();
}
else
{
videoPlayer1
.
startPlayLogic
();
videoPlayer2
.
startPlayLogic
();
}
}
...
...
app/src/main/java/com/ubains/rtspdemo/MutliActivity.java
浏览文件 @
84c45c5a
...
...
@@ -16,6 +16,7 @@ import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack;
import
com.shuyu.gsyvideoplayer.model.VideoOptionModel
;
import
com.shuyu.gsyvideoplayer.player.IjkPlayerManager
;
import
com.shuyu.gsyvideoplayer.player.PlayerFactory
;
import
com.shuyu.gsyvideoplayer.utils.GSYVideoType
;
import
com.ubains.rtspdemo.vedio.MultiSampleVideo
;
import
com.ubains.rtspdemo.vedio.manager.CustomManager
;
...
...
@@ -54,6 +55,7 @@ public class MutliActivity extends AppCompatActivity {
}
private
void
init
()
{
//EXOPlayer内核,支持格式更多
PlayerFactory
.
setPlayManager
(
Exo2PlayerManager
.
class
);
//系统内核模式
//PlayerFactory.setPlayManager(SystemPlayerManager.class);
...
...
@@ -61,12 +63,14 @@ public class MutliActivity extends AppCompatActivity {
PlayerFactory
.
setPlayManager
(
IjkPlayerManager
.
class
);
//exo缓存模式,支持m3u8,只支持exo
CacheFactory
.
setCacheManager
(
ExoPlayerCacheManager
.
class
);
//
CacheFactory.setCacheManager(ExoPlayerCacheManager.class);
//代理缓存模式,支持所有模式,不支持m3u8等,默认
CacheFactory
.
setCacheManager
(
ProxyCacheManager
.
class
);
GSYVideoType
.
setShowType
(
GSYVideoType
.
SCREEN_MATCH_FULL
);
GSYVideoType
.
setRenderType
(
GSYVideoType
.
TEXTURE
);
List
<
VideoOptionModel
>
list
=
new
ArrayList
<>();
List
<
VideoOptionModel
>
list
=
new
ArrayList
<>();
//设置RTSP 连接方式
VideoOptionModel
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"rtsp_transport"
,
"tcp"
);
list
.
add
(
videoOptionModel
);
...
...
@@ -76,31 +80,34 @@ public class MutliActivity extends AppCompatActivity {
//硬解码:1、打开,0、关闭
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"mediacodec"
,
1
);
list
.
add
(
videoOptionModel
);
//软解码:1、打开,0、关闭
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"videotoolbox"
,
1
);
list
.
add
(
videoOptionModel
);
//根据媒体类型来配置
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"allowed_media_types"
,
"video"
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"timeout"
,
20000
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"buffer_size"
,
1
024
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"buffer_size"
,
1
316
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"infbuf"
,
1
);
// 无限读
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"analyzemaxduration"
,
100
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"probesize"
,
10240
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"probesize"
,
4096
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"analyzeduration"
,
"2000000"
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"flush_packets"
,
1
);
list
.
add
(
videoOptionModel
);
// 关闭播放器缓冲,这个必须关闭,否则会出现播放一段时间后,一直卡主,控制台打印 FFP_MSG_BUFFERING_START
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"packet-buffering"
,
0
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"reconnect"
,
5
);
list
.
add
(
videoOptionModel
);
videoOptionModel
=
new
VideoOptionModel
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"framedrop"
,
30
);
list
.
add
(
videoOptionModel
);
GSYVideoManager
.
instance
().
setOptionModelList
(
list
);
// String url = "rtsp://admin:huawei@123@192.168.11.16/LiveMedia/ch1/Media1";
...
...
@@ -146,7 +153,8 @@ public class MutliActivity extends AppCompatActivity {
// String url3 = "rtsp://admin:huawei@123@192.168.11.19/LiveMedia/ch1/Media1";
// String url3 = "rtsp://admin:huawei@123@192.168.11.19/LiveMedia/ch1/Media2";
String
url3
=
"rtsp://admin:HZ0000001988@192.168.10.21:554/h264/ch1/main/av_stream"
;
// String url3 = "rtsp://admin:HZ0000001988@192.168.10.21:554/h264/ch1/main/av_stream";
String
url3
=
"rtsp://admin:HZ0000001988@192.168.10.28:554/h264/ch1/main/av_stream"
;
videoPlayer3
.
setPlayTag
(
"videoPlayer3"
);
videoPlayer3
.
setPlayPosition
(
3
);
...
...
@@ -167,6 +175,7 @@ public class MutliActivity extends AppCompatActivity {
// String url4 = "rtsp://admin:huawei@123@192.168.11.19/LiveMedia/ch1/Media1";
// String url4 = "rtsp://admin:huawei@123@192.168.11.23/LiveMedia/ch1/Media2";
String
url4
=
"rtsp://admin:huawei@123@192.168.11.23/LiveMedia/ch1/Media3"
;
// String url4 = "rtsp://192.168.1.234:8556/channel=0";
videoPlayer4
.
setPlayTag
(
"videoPlayer4"
);
videoPlayer4
.
setPlayPosition
(
4
);
...
...
@@ -174,6 +183,7 @@ public class MutliActivity extends AppCompatActivity {
if
(!
isPlaying4
)
{
videoPlayer4
.
setUpLazy
(
url4
,
false
,
null
,
null
,
""
);
}
videoPlayer4
.
setIsTouchWiget
(
false
);
// videoPlayer4.setRotateViewAuto(true);
// videoPlayer4.setLockLand(true);
...
...
app/src/main/res/layout/activity_empty.xml
浏览文件 @
84c45c5a
...
...
@@ -6,21 +6,10 @@
android:layout_height=
"match_parent"
tools:context=
".MainActivity"
>
<
LinearLayout
android:
orientation=
"horizontal
"
<
com.ubains.rtspdemo.vedio.EmptyControlVideo
android:
id=
"@+id/detail_player1
"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<com.ubains.rtspdemo.vedio.EmptyControlVideo
android:layout_weight=
"1"
android:id=
"@+id/detail_player1"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<com.ubains.rtspdemo.vedio.EmptyControlVideo
android:layout_weight=
"1"
android:id=
"@+id/detail_player2"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</LinearLayout>
android:layout_height=
"match_parent"
android:layout_weight=
"1"
/>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/values/id.xml
0 → 100644
浏览文件 @
84c45c5a
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item
name=
"custom_full_id"
type=
"id"
/>
<item
name=
"custom_small_id"
type=
"id"
/>
</resources>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论