parent
ae3d24f471
commit
060b1f138e
@ -0,0 +1,109 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.download.m3u8; |
||||||
|
|
||||||
|
import android.os.Parcel; |
||||||
|
import android.os.Parcelable; |
||||||
|
import com.arialyy.aria.orm.DbEntity; |
||||||
|
|
||||||
|
/** |
||||||
|
* M3U8实体信息 |
||||||
|
*/ |
||||||
|
public class M3U8Entity extends DbEntity implements Parcelable { |
||||||
|
|
||||||
|
/** |
||||||
|
* 文件保存路径 |
||||||
|
*/ |
||||||
|
private String filePath; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前peer的位置 |
||||||
|
*/ |
||||||
|
private int peerIndex; |
||||||
|
|
||||||
|
/** |
||||||
|
* peer总数 |
||||||
|
*/ |
||||||
|
private int peerNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否是直播,true 直播 |
||||||
|
*/ |
||||||
|
private boolean isLive; |
||||||
|
|
||||||
|
public boolean isLive() { |
||||||
|
return isLive; |
||||||
|
} |
||||||
|
|
||||||
|
public void setLive(boolean live) { |
||||||
|
isLive = live; |
||||||
|
} |
||||||
|
|
||||||
|
public String getFilePath() { |
||||||
|
return filePath; |
||||||
|
} |
||||||
|
|
||||||
|
public void setFilePath(String filePath) { |
||||||
|
this.filePath = filePath; |
||||||
|
} |
||||||
|
|
||||||
|
public int getPeerIndex() { |
||||||
|
return peerIndex; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPeerIndex(int peerIndex) { |
||||||
|
this.peerIndex = peerIndex; |
||||||
|
} |
||||||
|
|
||||||
|
public int getPeerNum() { |
||||||
|
return peerNum; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPeerNum(int peerNum) { |
||||||
|
this.peerNum = peerNum; |
||||||
|
} |
||||||
|
|
||||||
|
public M3U8Entity() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override public int describeContents() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override public void writeToParcel(Parcel dest, int flags) { |
||||||
|
dest.writeString(this.filePath); |
||||||
|
dest.writeInt(this.peerIndex); |
||||||
|
dest.writeInt(this.peerNum); |
||||||
|
dest.writeByte(this.isLive ? (byte) 1 : (byte) 0); |
||||||
|
} |
||||||
|
|
||||||
|
protected M3U8Entity(Parcel in) { |
||||||
|
this.filePath = in.readString(); |
||||||
|
this.peerIndex = in.readInt(); |
||||||
|
this.peerNum = in.readInt(); |
||||||
|
this.isLive = in.readByte() != 0; |
||||||
|
} |
||||||
|
|
||||||
|
public static final Creator<M3U8Entity> CREATOR = new Creator<M3U8Entity>() { |
||||||
|
@Override public M3U8Entity createFromParcel(Parcel source) { |
||||||
|
return new M3U8Entity(source); |
||||||
|
} |
||||||
|
|
||||||
|
@Override public M3U8Entity[] newArray(int size) { |
||||||
|
return new M3U8Entity[size]; |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.download.m3u8; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.common.BaseDelegate; |
||||||
|
import com.arialyy.aria.core.download.DTaskWrapper; |
||||||
|
import com.arialyy.aria.core.inf.AbsTarget; |
||||||
|
import com.arialyy.aria.core.inf.AbsTaskWrapper; |
||||||
|
import com.arialyy.aria.util.ALog; |
||||||
|
|
||||||
|
/** |
||||||
|
* m3u8点播文件参数设置 |
||||||
|
*/ |
||||||
|
public class M3U8VodDelegate<TARGET extends AbsTarget> extends BaseDelegate<TARGET> { |
||||||
|
private DTaskWrapper mTaskWrapper; |
||||||
|
|
||||||
|
M3U8VodDelegate(TARGET target) { |
||||||
|
super(target); |
||||||
|
mTaskWrapper = (DTaskWrapper) mTarget.getTaskWrapper(); |
||||||
|
mTaskWrapper.setRequestType(AbsTaskWrapper.M3U8_VOD); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 由于m3u8协议的特殊性质,无法有效快速获取到正确到文件长度,如果你需要显示文件中长度,你需要自行设置文件长度 |
||||||
|
* |
||||||
|
* @param fileSize 文件长度 |
||||||
|
*/ |
||||||
|
public M3U8VodDelegate setFileSize(long fileSize) { |
||||||
|
if (fileSize <= 0) { |
||||||
|
ALog.e(TAG, "文件长度错误"); |
||||||
|
return this; |
||||||
|
} |
||||||
|
mTaskWrapper.getEntity().setFileSize(fileSize); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 默认情况下,对于同一点播文件的下载,最多同时下载4个ts分片,如果你希望增加或减少同时下载的ts分片数量,可以使用该方法设置同时下载的ts分片数量 |
||||||
|
* |
||||||
|
* @param num 同时下载的ts分片数量 |
||||||
|
*/ |
||||||
|
public M3U8VodDelegate setMaxTsQueueNum(int num) { |
||||||
|
if (num < 1) { |
||||||
|
ALog.e(TAG, "同时下载的分片数量不能小于1"); |
||||||
|
return this; |
||||||
|
} |
||||||
|
mTaskWrapper.asM3U8().setMaxTsQueueNum(num); |
||||||
|
return this; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue