修复m3u8点播无法设置tsurl转换器的问题

pull/617/head
laoyuyu 5 years ago
parent 2b0fcbb98f
commit 0822c053cb
  1. 4
      Aria/src/main/java/com/arialyy/aria/core/common/AbsBuilderTarget.java
  2. 2
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8LiveOption.java
  3. 35
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8Option.java
  4. 17
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8VodOption.java
  5. 3
      Aria/src/main/java/com/arialyy/aria/core/download/target/FtpBuilderTarget.java
  6. 6
      app/src/main/java/com/arialyy/simple/core/download/FtpDownloadActivity.java
  7. 2
      app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java

@ -37,7 +37,7 @@ public abstract class AbsBuilderTarget<TARGET extends AbsBuilderTarget> extends
/** /**
* 添加任务 * 添加任务
* *
* @return 正常添加返回任务id否则返回-1 * @return 添加成功返回任务id创建失败返回-1
*/ */
@Override @Override
public long add() { public long add() {
@ -47,7 +47,7 @@ public abstract class AbsBuilderTarget<TARGET extends AbsBuilderTarget> extends
/** /**
* 开始任务 * 开始任务
* *
* @return 正常启动返回任务id否则返回-1 * @return 创建成功返回任务id创建失败返回-1
*/ */
@Override @Override
public long create() { public long create() {

@ -22,7 +22,7 @@ import com.arialyy.aria.util.CheckUtil;
/** /**
* m3u8直播参数设置 * m3u8直播参数设置
*/ */
public class M3U8LiveOption extends M3U8Option { public class M3U8LiveOption extends M3U8Option<M3U8LiveOption> {
private ILiveTsUrlConverter liveTsUrlConverter; private ILiveTsUrlConverter liveTsUrlConverter;
private long liveUpdateInterval; private long liveUpdateInterval;

@ -25,13 +25,12 @@ import com.arialyy.aria.util.ComponentUtil;
/** /**
* m3u8任务设置 * m3u8任务设置
*/ */
public class M3U8Option extends BaseOption { public class M3U8Option<OP extends M3U8Option> extends BaseOption {
private boolean generateIndexFileTemp = false; private boolean generateIndexFileTemp = false;
private boolean mergeFile = false; private boolean mergeFile = false;
private int bandWidth; private int bandWidth;
private ITsMergeHandler mergeHandler; private ITsMergeHandler mergeHandler;
private IVodTsUrlConverter vodUrlConverter;
private IBandWidthUrlConverter bandWidthUrlConverter; private IBandWidthUrlConverter bandWidthUrlConverter;
M3U8Option() { M3U8Option() {
@ -43,9 +42,9 @@ public class M3U8Option extends BaseOption {
* 生成m3u8索引文件 * 生成m3u8索引文件
* 注意创建索引文件{@link #merge(boolean)}方法设置与否都不再合并文件 * 注意创建索引文件{@link #merge(boolean)}方法设置与否都不再合并文件
*/ */
public M3U8Option generateIndexFile() { public OP generateIndexFile() {
this.generateIndexFileTemp = true; this.generateIndexFileTemp = true;
return this; return (OP) this;
} }
/** /**
@ -53,31 +52,19 @@ public class M3U8Option extends BaseOption {
* *
* @param mergeFile {@code true}合并所有ts文件为一个 * @param mergeFile {@code true}合并所有ts文件为一个
*/ */
public M3U8Option merge(boolean mergeFile) { public OP merge(boolean mergeFile) {
this.mergeFile = mergeFile; this.mergeFile = mergeFile;
return this; return (OP) this;
} }
/** /**
* 如果你希望使用自行处理ts文件的合并可以使用{@link ITsMergeHandler}处理ts文件的合并 * 如果你希望使用自行处理ts文件的合并可以使用{@link ITsMergeHandler}处理ts文件的合并
* 需要注意的是只有{@link #merge(boolean)}设置合并ts文件该方法才会生效 * 需要注意的是只有{@link #merge(boolean)}设置合并ts文件该方法才会生效
*/ */
public M3U8Option setMergeHandler(ITsMergeHandler mergeHandler) { public OP setMergeHandler(ITsMergeHandler mergeHandler) {
CheckUtil.checkMemberClass(mergeHandler.getClass()); CheckUtil.checkMemberClass(mergeHandler.getClass());
this.mergeHandler = mergeHandler; this.mergeHandler = mergeHandler;
return this; return (OP) this;
}
/**
* M3U8 ts 文件url转换器对于某些服务器返回的ts地址可以是相对地址也可能是处理过的
* 对于这种情况你需要使用url转换器将地址转换为可正常访问的http地址
*
* @param vodUrlConverter {@link IVodTsUrlConverter}
*/
public M3U8Option setTsUrlConvert(IVodTsUrlConverter vodUrlConverter) {
CheckUtil.checkMemberClass(vodUrlConverter.getClass());
this.vodUrlConverter = vodUrlConverter;
return this;
} }
/** /**
@ -85,9 +72,9 @@ public class M3U8Option extends BaseOption {
* *
* @param bandWidth 指定的码率 * @param bandWidth 指定的码率
*/ */
public M3U8Option setBandWidth(int bandWidth) { public OP setBandWidth(int bandWidth) {
this.bandWidth = bandWidth; this.bandWidth = bandWidth;
return this; return (OP) this;
} }
/** /**
@ -96,9 +83,9 @@ public class M3U8Option extends BaseOption {
* *
* @param bandWidthUrlConverter {@link IBandWidthUrlConverter} * @param bandWidthUrlConverter {@link IBandWidthUrlConverter}
*/ */
public M3U8Option setBandWidthUrlConverter(IBandWidthUrlConverter bandWidthUrlConverter) { public OP setBandWidthUrlConverter(IBandWidthUrlConverter bandWidthUrlConverter) {
CheckUtil.checkMemberClass(bandWidthUrlConverter.getClass()); CheckUtil.checkMemberClass(bandWidthUrlConverter.getClass());
this.bandWidthUrlConverter = bandWidthUrlConverter; this.bandWidthUrlConverter = bandWidthUrlConverter;
return this; return (OP) this;
} }
} }

@ -15,20 +15,35 @@
*/ */
package com.arialyy.aria.core.download.m3u8; package com.arialyy.aria.core.download.m3u8;
import com.arialyy.aria.core.processor.IVodTsUrlConverter;
import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil;
/** /**
* m3u8点播文件参数设置 * m3u8点播文件参数设置
*/ */
public class M3U8VodOption extends M3U8Option { public class M3U8VodOption extends M3U8Option<M3U8VodOption> {
private long fileSize; private long fileSize;
private int maxTsQueueNum; private int maxTsQueueNum;
private int jumpIndex; private int jumpIndex;
private IVodTsUrlConverter vodUrlConverter;
public M3U8VodOption() { public M3U8VodOption() {
super(); super();
} }
/**
* M3U8 ts 文件url转换器对于某些服务器返回的ts地址可以是相对地址也可能是处理过的
* 对于这种情况你需要使用url转换器将地址转换为可正常访问的http地址
*
* @param vodUrlConverter {@link IVodTsUrlConverter}
*/
public M3U8VodOption setVodTsUrlConvert(IVodTsUrlConverter vodUrlConverter) {
CheckUtil.checkMemberClass(vodUrlConverter.getClass());
this.vodUrlConverter = vodUrlConverter;
return this;
}
/** /**
* 由于m3u8协议的特殊性质无法有效快速获取到正确到文件长度如果你需要显示文件中长度你需要自行设置文件长度 * 由于m3u8协议的特殊性质无法有效快速获取到正确到文件长度如果你需要显示文件中长度你需要自行设置文件长度
* *

@ -39,8 +39,7 @@ public class FtpBuilderTarget extends AbsBuilderTarget<FtpBuilderTarget> {
/** /**
* 设置登陆字符串编码ftps等参数 * 设置登陆字符串编码ftps等参数
*/ */
@com.arialyy.aria.core.common.CheckResult(suggest = Suggest.TASK_CONTROLLER) @CheckResult(suggest = Suggest.TASK_CONTROLLER)
//@CheckResult(suggest = Suggest.TASK_CONTROLLER)
public FtpBuilderTarget option(FtpOption option) { public FtpBuilderTarget option(FtpOption option) {
if (option == null) { if (option == null) {
throw new NullPointerException("ftp 任务配置为空"); throw new NullPointerException("ftp 任务配置为空");

@ -93,10 +93,10 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
case R.id.start: case R.id.start:
if (mTaskId == -1) { if (mTaskId == -1) {
Aria.download(this).loadFtp(mUrl) mTaskId = Aria.download(this).loadFtp(mUrl)
.setFilePath(mFilePath, true) .setFilePath(mFilePath, true)
.option(getFtpOption()); .option(getFtpOption())
//.create(); .create();
getBinding().setStateStr(getString(R.string.stop)); getBinding().setStateStr(getString(R.string.stop));
break; break;
} }

@ -304,7 +304,7 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
M3U8VodOption option = new M3U8VodOption(); M3U8VodOption option = new M3U8VodOption();
option option
.generateIndexFile() .generateIndexFile()
.setTsUrlConvert(new VodTsUrlConverter()) .setVodTsUrlConvert(new VodTsUrlConverter())
.setMergeHandler(new TsMergeHandler()); .setMergeHandler(new TsMergeHandler());
//.setBandWidthUrlConverter(new BandWidthUrlConverter(mUrl)); //.setBandWidthUrlConverter(new BandWidthUrlConverter(mUrl));
return option; return option;

Loading…
Cancel
Save