提交 5b67304a authored 作者: 汪显鹏's avatar 汪显鹏

1.增加RTSP 相关配置

上级 f206ece2
package com.ubains.rtspdemo;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -13,6 +14,8 @@ import static org.junit.Assert.*;
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*
* Remote: You are not allowed to push code to this project. unable to access 'http://git.ubainsyun.com/ubains-android-demo/RTSPDemo.git/': The requested URL returned error: 403
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
......
......@@ -11,16 +11,20 @@ import androidx.appcompat.app.AppCompatActivity;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.cache.CacheFactory;
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.player.SystemPlayerManager;
import com.shuyu.gsyvideoplayer.utils.OrientationUtils;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import tv.danmaku.ijk.media.exo2.Exo2PlayerManager;
import tv.danmaku.ijk.media.exo2.ExoPlayerCacheManager;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
public class MainActivity extends AppCompatActivity {
......@@ -50,16 +54,48 @@ public class MainActivity extends AppCompatActivity {
private void init() {
videoPlayer = (StandardGSYVideoPlayer) findViewById(R.id.detail_player);
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);
//硬解码
videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 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);
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);
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 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:HZ0000001988@192.168.10.28:554/h264/ch1/main/av_stream", "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, "测试视频");
//增加封面
ImageView imageView = new ImageView(this);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论