Skip to content

Commit

Permalink
v0.0.26 增加user-agent:Android_Station_V1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
caixingming committed Dec 25, 2021
1 parent 49e2df1 commit 91bc33c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 50 deletions.
62 changes: 16 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ ijkplayer open the rtsp & h265 surpport .
## 在主项目中build.gradle引入以下库

```groovy
implementation 'io.github.jdpxiaoming:ijkplayer-view:0.0.25'
implementation 'io.github.jdpxiaoming:ijkplayer-java:0.0.25'
implementation 'io.github.jdpxiaoming:ijkplayer-armv7a:0.0.25'
implementation 'io.github.jdpxiaoming:ijkplayer-view:0.0.26'
implementation 'io.github.jdpxiaoming:ijkplayer-java:0.0.26'
implementation 'io.github.jdpxiaoming:ijkplayer-armv7a:0.0.26'
//看情况如果需要64位so则引入.
implementation 'io.github.jdpxiaoming:ijkplayer-arm64:0.0.25'
implementation 'io.github.jdpxiaoming:ijkplayer-arm64:0.0.26'
```


Expand All @@ -29,31 +29,25 @@ IjkMediaPlayer.loadLibrariesOnce(null);
IjkMediaPlayer.native_profileBegin(IjkMediaPlayer.IJK_LIB_NAME_FFMPEG);
```

# 0.0.25 音频去掉opense硬解码,改为可配置
# 音频去掉opense硬解码,改为可配置
```java
//打开opense,h264下有效.
mVideoView.setAudioHardWare(true);
```

# 0.0.24 放开倍速播放超过2.0倍速无法倍速播放.
- 从jcenter更换到Google Maven Central

# 0.0.23 增加自定义参数选项.
# 增加自定义参数选项.
```java
mVideoView.setVideoPath(mVideoPath, IjkVideoView.IJK_TYPE_CUSTOMER_PLAY)
```

# 0.0.22 打开iJkview 设置旋转角度
# 打开iJkview 设置旋转角度
```java
//设置视频旋转角度.
mVideoView?.isIgnoreRotation = false;
mVideoView?.setVideoRotationDegree(0)
```

# 0.0.21 关闭无效的vp_duration的log信息.
- 2020/12/28 publish.

# 0.0.20 打开0延迟的时候默认增加同步方式为`AV_SYNC_VIDEO_MASTER`,默认为音频同步为主.
# 打开0延迟的时候默认增加同步方式为`AV_SYNC_VIDEO_MASTER`,默认为音频同步为主.
- you should invoke this method on prepare callback (需要再prepare回调方法中处理同步方式)
```java
//准备就绪,做一些配置操作,比如音视频同步方式.
Expand All @@ -66,42 +60,11 @@ mVideoView.setVideoPath(mVideoPath, IjkVideoView.IJK_TYPE_CUSTOMER_PLAY)
});
```

```c
/**
* 0延时开关.
*@delayOpen 0:关闭 1:开启 默认关闭.
*/
static void
IjkMediaPlayer_setZeroDelay(JNIEnv *env, jobject thiz, jint delayOpen)
{
ALOGD("IjkMediaPlayer_setZeroDelay delay_forbidden = %d",delayOpen);
MPTRACE("%s\n", __func__);
IjkMediaPlayer *mp = jni_get_media_player(env, thiz);
//给mediaplayer赋值.
mp->ffplayer->delay_forbidden = delayOpen;
//如果打开0延迟则设置视频为主同步
if(delayOpen){
mp->ffplayer->av_sync_type = AV_SYNC_VIDEO_MASTER;
} else {
mp->ffplayer->av_sync_type = AV_SYNC_AUDIO_MASTER;
}
ijkmp_dec_ref_p(&mp);
}

```
#0.0.19 增加0延迟开关(0延迟会有2s的音频不同步出现,慎用)
# 增加0延迟开关(0延迟会有2s的音频不同步出现,慎用)
```java
//打开视频0延迟.
mVideoView.openZeroVideoDelay(true);
```
# 0.0.18 优化直播延时.
- 升级ffmpeg3.4->ffmpeg4.0
- 优化直播0延时观看flv

# 0.0.17 修改ffmpeg的打包名字,解决和其他ffmpeg库的冲突.
- 修改libijkffmpeg.so->libijkwdzffmpeg


### 设置View的填充模式
```java
mVideoView.setAspectRatio(IRenderView.AR_16_9_FIT_PARENT);
Expand Down Expand Up @@ -149,10 +112,16 @@ public interface IRenderView {
```java
mVideoView.setVideoPath(mVideoPath, IjkVideoView.IJK_TYPE_HTTP_PLAY);
```
### 设置流请求时候`header`-`user-agent`
```java
//set the headers properties in user-agent.
mVideoView.setUserAgentStr("Android_Station_V1.1.1");
```

### 实现Mp4文件边下边播放
- 引入下载代理库 : `implementation 'com.danikula:videocache:2.7.1'`
- 定义Application.

```java
/**
* comment:
Expand All @@ -175,6 +144,7 @@ public class PApplication extends Application {
}
}
```

- 处理播放url
```java
mVideoPath = "https://ovopark-record.oss-cn-shanghai.aliyuncs.com/039570f6-e4c3-4a1b-9886-5ad7e6d7181f.mp4";
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
## 编译时使用守护进程
org.gradle.daemon=true

VERSION_NAME=0.0.25
VERSION_CODE=100025
VERSION_NAME=0.0.26
VERSION_CODE=100026
GROUP=io.github.jdpxiaoming

# http://central.sonatype.org/pages/requirements.html
POM_USER_ORG=media
POM_DESCRIPTION=Video player based on FFmpeg n3.1
POM_DESCRIPTION=Video player based on FFmpeg n4.0
POM_URL=https://github.com/jdpxiaoming/ijkrtspdemo
POM_SCM_URL=https://github.com/jdpxiaoming/ijkrtspdemo.git
POM_SCM_CONNECTION=scm:git:git@github.com:jdpxiaoming/ijkrtspdemo.git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected void onCreate(Bundle savedInstanceState) {
mSharedPreferences.edit().putString(key,String.valueOf(Settings.PV_PLAYER__IjkMediaPlayer)).apply();

// handle arguments
mVideoPath = "http://113.31.102.114:5581/rtsp/43e935c2-baa2-41e4-9924-ea2537f122be.flv";//IPC - h264.
mVideoPath = "rtsp://106.75.210.197:5555/rtsp/66fbb1e3-1834-466f-a4b8-b7e01e04a130";//IPC - h264.

// init UI
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Expand Down Expand Up @@ -119,6 +119,8 @@ protected void onCreate(Bundle savedInstanceState) {
//打开opense,h264下有效.
mVideoView.setAudioHardWare(true);
// mVideoView.setLogLevel(IjkMediaPlayer.IJK_LOG_DEBUG);
//set the headers properties in user-agent.
mVideoView.setUserAgentStr("Android_Station_V1.1.1");
//设置h265
if(mVideoPath.startsWith("rtsp")){
mVideoView.setH265(true);
Expand Down
8 changes: 8 additions & 0 deletions ijkplayerview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ android {
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}

//压制doc生成失败退出publish问题.
tasks.withType(Javadoc) {
failOnError false
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ public class IjkVideoView extends FrameLayout implements MediaController.MediaPl
private Map<String, Long> playerMap;
private Map<String, String> formatStringMap;

/**
* 版本好信息 用于头部的user-agent.
* @param context
*/
private String mUserAgentStr = "Android_Station_V1.1.1";

public IjkVideoView(Context context) {
super(context);
initVideoView(context);
Expand All @@ -182,6 +188,22 @@ public IjkVideoView(Context context, AttributeSet attrs, int defStyleAttr, int d
initVideoView(context);
}

/**
* 获取当前播放器的user-agent.
* @return
*/
public String getUserAgentStr() {
return mUserAgentStr;
}

/**
* 设置http和rtsp中的user-agent.
* @param userAgentStr
*/
public void setUserAgentStr(String userAgentStr) {
this.mUserAgentStr = userAgentStr;
}

// REMOVED: onMeasure
// REMOVED: onInitializeAccessibilityEvent
// REMOVED: onInitializeAccessibilityNodeInfo
Expand Down Expand Up @@ -1371,6 +1393,9 @@ public IMediaPlayer createPlayer(int playerType, int url_type) {
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "stimeout", mTimeOut);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "timeout", mTimeOut);
}
//user-argent.Android_Station_V1.1.1 方便媒体后台统计点播端来源.
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT,"user_agent",mUserAgentStr);

switch (mURLType) {
case IJK_TYPE_LIVING_LOW_DELAY://rtsp低延迟
//互动营销低延迟<300ms.
Expand Down

0 comments on commit 91bc33c

Please sign in to comment.