80 lines
2.7 KiB
Java
80 lines
2.7 KiB
Java
|
package us.shandian.giga.get;
|
||
|
|
||
|
import android.os.Parcel;
|
||
|
import android.os.Parcelable;
|
||
|
import android.support.annotation.NonNull;
|
||
|
|
||
|
import org.schabi.newpipe.extractor.MediaFormat;
|
||
|
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||
|
import org.schabi.newpipe.extractor.stream.Stream;
|
||
|
import org.schabi.newpipe.extractor.stream.SubtitlesStream;
|
||
|
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||
|
|
||
|
import java.io.Serializable;
|
||
|
|
||
|
public class MissionRecoveryInfo implements Serializable, Parcelable {
|
||
|
private static final long serialVersionUID = 0L;
|
||
|
//public static final String DIRECT_SOURCE = "direct-source://";
|
||
|
|
||
|
public MediaFormat format;
|
||
|
String desired;
|
||
|
boolean desired2;
|
||
|
int desiredBitrate;
|
||
|
|
||
|
transient int attempts = 0;
|
||
|
|
||
|
String validateCondition = null;
|
||
|
|
||
|
public MissionRecoveryInfo(@NonNull Stream stream) {
|
||
|
if (stream instanceof AudioStream) {
|
||
|
desiredBitrate = ((AudioStream) stream).average_bitrate;
|
||
|
desired2 = false;
|
||
|
} else if (stream instanceof VideoStream) {
|
||
|
desired = ((VideoStream) stream).getResolution();
|
||
|
desired2 = ((VideoStream) stream).isVideoOnly();
|
||
|
} else if (stream instanceof SubtitlesStream) {
|
||
|
desired = ((SubtitlesStream) stream).getLanguageTag();
|
||
|
desired2 = ((SubtitlesStream) stream).isAutoGenerated();
|
||
|
} else {
|
||
|
throw new RuntimeException("Unknown stream kind");
|
||
|
}
|
||
|
|
||
|
format = stream.getFormat();
|
||
|
if (format == null) throw new NullPointerException("Stream format cannot be null");
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public int describeContents() {
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void writeToParcel(Parcel parcel, int flags) {
|
||
|
parcel.writeInt(this.format.ordinal());
|
||
|
parcel.writeString(this.desired);
|
||
|
parcel.writeInt(this.desired2 ? 0x01 : 0x00);
|
||
|
parcel.writeInt(this.desiredBitrate);
|
||
|
parcel.writeString(this.validateCondition);
|
||
|
}
|
||
|
|
||
|
private MissionRecoveryInfo(Parcel parcel) {
|
||
|
this.format = MediaFormat.values()[parcel.readInt()];
|
||
|
this.desired = parcel.readString();
|
||
|
this.desired2 = parcel.readInt() != 0x00;
|
||
|
this.desiredBitrate = parcel.readInt();
|
||
|
this.validateCondition = parcel.readString();
|
||
|
}
|
||
|
|
||
|
public static final Parcelable.Creator<MissionRecoveryInfo> CREATOR = new Parcelable.Creator<MissionRecoveryInfo>() {
|
||
|
@Override
|
||
|
public MissionRecoveryInfo createFromParcel(Parcel source) {
|
||
|
return new MissionRecoveryInfo(source);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public MissionRecoveryInfo[] newArray(int size) {
|
||
|
return new MissionRecoveryInfo[size];
|
||
|
}
|
||
|
};
|
||
|
}
|