replace java with kotlin in streaming

This commit is contained in:
Felix 2017-10-26 23:06:44 +02:00
parent 3167489c9f
commit 010f20ef2e
10 changed files with 277 additions and 516 deletions

View file

@ -1,43 +0,0 @@
package de.nicidienase.chaosflix.common.entities.streaming;
import java.util.ArrayList;
import java.util.List;
/**
* Created by felix on 23.03.17.
*/
public class Group {
String group;
List<Room> rooms;
public Group() {}
public Group(String group) {
this.group = group;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
public List<Room> getRooms() {
return rooms;
}
public void setRooms(List<Room> rooms) {
this.rooms = rooms;
}
public static Group getDummyObject(){
Group dummy = new Group();
dummy.setGroup("Dummy Group");
dummy.setRooms(new ArrayList<>());
dummy.getRooms().add(Room.getDummyObject());
return dummy;
}
}

View file

@ -0,0 +1,21 @@
package de.nicidienase.chaosflix.common.entities.streaming
import android.arch.persistence.room.Entity
import java.util.ArrayList
@Entity(tableName = "group")
class Group(
var group: String,
internal var rooms: MutableList<Room>){
companion object {
val dummyObject: Group
get() {
val dummy = Group("Dummy Group", ArrayList<Room>())
dummy.rooms.add(Room.dummyObject)
return dummy
}
}
}

View file

@ -1,101 +0,0 @@
package de.nicidienase.chaosflix.common.entities.streaming;
import java.util.ArrayList;
import java.util.List;
/**
* Created by felix on 23.03.17.
*/
public class LiveConference {
String conference;
String slug;
String author;
String description;
String keywords;
String startsAt;
String endsAt;
List<Group> groups;
public LiveConference() {}
public LiveConference(String conference, String description) {
this.conference = conference;
this.description = description;
}
public String getConference() {
return conference;
}
public void setConference(String conference) {
this.conference = conference;
}
public String getSlug() {
return slug;
}
public void setSlug(String slug) {
this.slug = slug;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getKeywords() {
return keywords;
}
public void setKeywords(String keywords) {
this.keywords = keywords;
}
public String getStartsAt() {
return startsAt;
}
public void setStartsAt(String startsAt) {
this.startsAt = startsAt;
}
public String getEndsAt() {
return endsAt;
}
public void setEndsAt(String endsAt) {
this.endsAt = endsAt;
}
public List<Group> getGroups() {
return groups;
}
public void setGroups(List<Group> groups) {
this.groups = groups;
}
public static LiveConference getDummyObject(){
LiveConference dummyCon = new LiveConference("DummyCon", "Conference McConferenceface");
dummyCon.setGroups(new ArrayList<>());
dummyCon.getGroups().add(Group.getDummyObject());
dummyCon.setSlug("duco");
dummyCon.setAuthor("");
dummyCon.setDescription("A placeholder conference");
dummyCon.setKeywords("");
return dummyCon;
}
}

View file

@ -0,0 +1,34 @@
package de.nicidienase.chaosflix.common.entities.streaming
import java.util.ArrayList
/**
* Created by felix on 23.03.17.
*/
class LiveConference(
var conference: String,
var slug: String,
var author: String,
var description: String,
var keywords: String,
var startsAt: String,
var endsAt: String,
var groups: MutableList<Group>){
constructor(conference: String, description: String) : this(conference,description,"","","","","",ArrayList())
companion object {
val dummyObject: LiveConference
get() {
val dummyCon = LiveConference("DummyCon", "Conference McConferenceface")
dummyCon.groups.add(Group.dummyObject)
dummyCon.slug = "duco"
dummyCon.author = ""
dummyCon.description = "A placeholder conference"
dummyCon.keywords = ""
return dummyCon
}
}
}

View file

@ -1,119 +0,0 @@
package de.nicidienase.chaosflix.common.entities.streaming;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.List;
/**
* Created by felix on 23.03.17.
*/
public class Room implements Parcelable {
String slug;
String shedulename;
String thumb;
String link;
String display;
List<Stream> streams;
public Room() {}
protected Room(Parcel in) {
slug = in.readString();
shedulename = in.readString();
thumb = in.readString();
link = in.readString();
display = in.readString();
streams = in.createTypedArrayList(Stream.CREATOR);
}
public static final Creator<Room> CREATOR = new Creator<Room>() {
@Override
public Room createFromParcel(Parcel in) {
return new Room(in);
}
@Override
public Room[] newArray(int size) {
return new Room[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(slug);
dest.writeString(shedulename);
dest.writeString(thumb);
dest.writeString(link);
dest.writeString(display);
dest.writeTypedList(streams);
}
public String getSlug() {
return slug;
}
public void setSlug(String slug) {
this.slug = slug;
}
public String getShedulename() {
return shedulename;
}
public void setShedulename(String shedulename) {
this.shedulename = shedulename;
}
public String getThumb() {
return thumb;
}
public void setThumb(String thumb) {
this.thumb = thumb;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public String getDisplay() {
return display;
}
public void setDisplay(String display) {
this.display = display;
}
public List<Stream> getStreams() {
return streams;
}
public void setStreams(List<Stream> streams) {
this.streams = streams;
}
public static Room getDummyObject(){
Room dummy = new Room();
dummy.setSlug("dummy_room");
dummy.setShedulename("Dummy Room");
dummy.setThumb("https://static.media.ccc.de/media/unknown.png");
dummy.setLink("");
dummy.setDisplay("Dummy Room");
dummy.setStreams(new ArrayList<>());
dummy.getStreams().add(Stream.getDummyObject());
return dummy;
}
}

View file

@ -0,0 +1,68 @@
package de.nicidienase.chaosflix.common.entities.streaming
import android.arch.persistence.room.Entity
import android.os.Parcel
import android.os.Parcelable
import java.util.ArrayList
/**
* Created by felix on 23.03.17.
*/
class Room (var slug: String,
var shedulename: String,
var thumb: String,
var link: String,
var display: String,
internal var streams: MutableList<Stream>): Parcelable{
protected constructor(`in`: Parcel) : this(
slug = `in`.readString(),
shedulename = `in`.readString(),
thumb = `in`.readString(),
link = `in`.readString(),
display = `in`.readString(),
streams = `in`.createTypedArrayList(Stream.CREATOR))
override fun describeContents(): Int {
return 0
}
override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeString(slug)
dest.writeString(shedulename)
dest.writeString(thumb)
dest.writeString(link)
dest.writeString(display)
dest.writeTypedList(streams)
}
companion object {
val CREATOR: Parcelable.Creator<Room> = object : Parcelable.Creator<Room> {
override fun createFromParcel(`in`: Parcel): Room {
return Room(`in`)
}
override fun newArray(size: Int): Array<Room?> {
return arrayOfNulls(size)
}
}
val dummyObject: Room
get() {
val dummy = Room(
"dummy_room",
"Dummy Room",
"https://static.media.ccc.de/media/unknown.png",
"",
"Dummy Room",
ArrayList())
dummy.streams.add(Stream.dummyObject)
return dummy
}
}
}

View file

@ -1,135 +0,0 @@
package de.nicidienase.chaosflix.common.entities.streaming;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Created by felix on 23.03.17.
*/
public class Stream implements Parcelable {
private static final String MAP_KEY = "map-key";
String slug;
String display;
String type;
boolean isTranslated;
int[] videoSize;
HashMap<String, StreamUrl> urls;
public Stream() {}
protected Stream(Parcel in) {
slug = in.readString();
display = in.readString();
type = in.readString();
isTranslated = in.readByte() != 0;
videoSize = in.createIntArray();
int mapSize = in.readInt();
urls = new HashMap<>();
for(int i = 0; i< mapSize; i++){
urls.put(in.readString(),in.readParcelable(StreamUrl.class.getClassLoader()));
}
}
public static final Creator<Stream> CREATOR = new Creator<Stream>() {
@Override
public Stream createFromParcel(Parcel in) {
return new Stream(in);
}
@Override
public Stream[] newArray(int size) {
return new Stream[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(slug);
dest.writeString(display);
dest.writeString(type);
dest.writeByte((byte) (isTranslated ? 1 : 0));
dest.writeIntArray(videoSize);
dest.writeInt(urls.size());
Set<String> keys = urls.keySet();
for(String s: keys){
dest.writeString(s);
dest.writeParcelable(urls.get(s),0);
}
}
public String getSlug() {
return slug;
}
public void setSlug(String slug) {
this.slug = slug;
}
public String getDisplay() {
return display;
}
public void setDisplay(String display) {
this.display = display;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public boolean isTranslated() {
return isTranslated;
}
public void setTranslated(boolean translated) {
isTranslated = translated;
}
public int[] getVideoSize() {
return videoSize;
}
public void setVideoSize(int[] videoSize) {
this.videoSize = videoSize;
}
public Map<String, StreamUrl> getUrls() {
return urls;
}
public void setUrls(HashMap<String, StreamUrl> urls) {
this.urls = urls;
}
public static Stream getDummyObject(){
Stream dummy = new Stream();
dummy.setSlug("dummy");
dummy.setDisplay("Dummy");
dummy.setType("video");
dummy.setTranslated(false);
dummy.setVideoSize(new int[]{1, 1});
dummy.setUrls(new HashMap<>());
dummy.getUrls().put("hls",StreamUrl.getDummyObject("hls"));
dummy.getUrls().put("dizzy",StreamUrl.getDummyObject("dizzy"));
dummy.getUrls().put("webm,vp8",StreamUrl.getDummyObject("webm,vp8"));
dummy.getUrls().put("mp4,h265",StreamUrl.getDummyObject("mp4,h265"));
dummy.getUrls().put("4x3",StreamUrl.getDummyObject("4x3"));
dummy.getUrls().put("winkekatze",StreamUrl.getDummyObject("winkekatze"));
dummy.setType("dummy");
return dummy;
}
}

View file

@ -0,0 +1,80 @@
package de.nicidienase.chaosflix.common.entities.streaming
import android.os.Parcel
import android.os.Parcelable
import kotlin.collections.HashMap
/**
* Created by felix on 23.03.17.
*/
class Stream(
var slug: String,
var display: String,
var type: String,
var isTranslated: Boolean = false,
var videoSize: IntArray,
var urls: MutableMap<String, StreamUrl>
) : Parcelable {
protected constructor(`in`: Parcel) : this(
slug = `in`.readString(),
display = `in`.readString(),
type = `in`.readString(),
isTranslated = `in`.readByte().toInt() != 0,
videoSize = `in`.createIntArray(),
urls = HashMap<String, StreamUrl>()
) {
val mapSize = `in`.readInt()
for (i in 0 until mapSize) {
urls.put(`in`.readString(), `in`.readParcelable(StreamUrl::class.java.classLoader))
}
}
override fun describeContents(): Int {
return 0
}
override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeString(slug)
dest.writeString(display)
dest.writeString(type)
dest.writeByte((if (isTranslated) 1 else 0).toByte())
dest.writeIntArray(videoSize)
dest.writeInt(urls.size)
val keys = urls.keys
for (s in keys) {
dest.writeString(s)
dest.writeParcelable(urls[s], 0)
}
}
companion object {
private val MAP_KEY = "map-key"
val CREATOR: Parcelable.Creator<Stream> = object : Parcelable.Creator<Stream> {
override fun createFromParcel(`in`: Parcel): Stream {
return Stream(`in`)
}
override fun newArray(size: Int): Array<Stream?> {
return arrayOfNulls(size)
}
}
val dummyObject: Stream
get() {
val dummy = Stream("dummy", "Dummy", "video", false, intArrayOf(1, 1), HashMap())
dummy.urls.put("hls", StreamUrl.getDummyObject("hls"))
dummy.urls.put("dizzy", StreamUrl.getDummyObject("dizzy"))
dummy.urls.put("webm,vp8", StreamUrl.getDummyObject("webm,vp8"))
dummy.urls.put("mp4,h265", StreamUrl.getDummyObject("mp4,h265"))
dummy.urls.put("4x3", StreamUrl.getDummyObject("4x3"))
dummy.urls.put("winkekatze", StreamUrl.getDummyObject("winkekatze"))
dummy.type = "dummy"
return dummy
}
}
}

View file

@ -1,118 +0,0 @@
package de.nicidienase.chaosflix.common.entities.streaming;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Created by felix on 23.03.17.
*/
public class StreamUrl implements Parcelable {
String display;
String tech;
String url;
protected StreamUrl(Parcel in) {
display = in.readString();
tech = in.readString();
url = in.readString();
}
public static final Creator<StreamUrl> CREATOR = new Creator<StreamUrl>() {
@Override
public StreamUrl createFromParcel(Parcel in) {
return new StreamUrl(in);
}
@Override
public StreamUrl[] newArray(int size) {
return new StreamUrl[size];
}
};
public StreamUrl() {
}
public StreamUrl(String display, String tech, String url) {
this.display = display;
this.tech = tech;
this.url = url;
}
public String getDisplay() {
return display;
}
public void setDisplay(String display) {
this.display = display;
}
public String getTech() {
return tech;
}
public void setTech(String tech) {
this.tech = tech;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(display);
dest.writeString(tech);
dest.writeString(url);
}
public static StreamUrl getDummyObject(String codec){
StreamUrl dummy = getDummyObject();
switch (codec){
case "webm,vp8":
dummy.setUrl("https://storage.googleapis.com/wvmedia/clear/vp9/tears/tears.mpd");
dummy.setDisplay("webm,vp8");
break;
case "mp4,h265":
dummy.setUrl("https://storage.googleapis.com/wvmedia/clear/hevc/tears/tears_hd.mpd");
dummy.setDisplay("mp4,h265");
break;
case "hls":
dummy.setUrl("https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8");
dummy.setDisplay("hls");
break;
case "4x3":
dummy.setUrl("https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8");
dummy.setDisplay("4x3");
break;
case "dizzy":
dummy.setUrl("http://html5demos.com/assets/dizzy.mp4");
dummy.setDisplay("dizzy");
break;
case "winkekatze":
dummy.setUrl("https://r5---sn-4g57knlz.googlevideo.com/videoplayback?id=acfd4764b9107d34&itag=299&source=youtube&requiressl=yes&initcwndbps=1472500&pl=20&mv=m&ei=RVj6WJbVMZO2cMvgqIAF&ms=au&mm=31&mn=sn-4g57knlz&ratebypass=yes&mime=video/mp4&gir=yes&clen=17985037641&lmt=1418590845082732&dur=36011.200&key=dg_yt0&mt=1492801526&upn=cA3U7DFBWOw&signature=537B4E86C9CD83ED2EACFAFCFAEE840E259C2DD1.12BF28ED6A0BA6AFDD4FD1631786AA46DC798D12&ip=109.192.170.65&ipbits=0&expire=1492823205&sparams=ip,ipbits,expire,id,itag,source,requiressl,initcwndbps,pl,mv,ei,ms,mm,mn,ratebypass,mime,gir,clen,lmt,dur");
dummy.setDisplay("winkekatze");
break;
}
return dummy;
}
public static StreamUrl getDummyObject(){
StreamUrl dummy = new StreamUrl();
dummy.setUrl("https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8");
dummy.setTech("");
dummy.setDisplay("HLS");
return dummy;
}
}

View file

@ -0,0 +1,74 @@
package de.nicidienase.chaosflix.common.entities.streaming
import android.os.Parcel
import android.os.Parcelable
class StreamUrl(var display: String,
var tech: String,
var url: String) : Parcelable {
protected constructor(`in`: Parcel) : this(
display = `in`.readString(),
tech = `in`.readString(),
url = `in`.readString())
override fun describeContents(): Int {
return 0
}
override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeString(display)
dest.writeString(tech)
dest.writeString(url)
}
companion object {
val CREATOR: Parcelable.Creator<StreamUrl> = object : Parcelable.Creator<StreamUrl> {
override fun createFromParcel(`in`: Parcel): StreamUrl {
return StreamUrl(`in`)
}
override fun newArray(size: Int): Array<StreamUrl?> {
return arrayOfNulls(size)
}
}
fun getDummyObject(codec: String): StreamUrl {
val dummy = dummyObject
when (codec) {
"webm,vp8" -> {
dummy.url = "https://storage.googleapis.com/wvmedia/clear/vp9/tears/tears.mpd"
dummy.display = "webm,vp8"
}
"mp4,h265" -> {
dummy.url = "https://storage.googleapis.com/wvmedia/clear/hevc/tears/tears_hd.mpd"
dummy.display = "mp4,h265"
}
"hls" -> {
dummy.url = "https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8"
dummy.display = "hls"
}
"4x3" -> {
dummy.url = "https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8"
dummy.display = "4x3"
}
"dizzy" -> {
dummy.url = "http://html5demos.com/assets/dizzy.mp4"
dummy.display = "dizzy"
}
"winkekatze" -> {
dummy.url = "https://r5---sn-4g57knlz.googlevideo.com/videoplayback?id=acfd4764b9107d34&itag=299&source=youtube&requiressl=yes&initcwndbps=1472500&pl=20&mv=m&ei=RVj6WJbVMZO2cMvgqIAF&ms=au&mm=31&mn=sn-4g57knlz&ratebypass=yes&mime=video/mp4&gir=yes&clen=17985037641&lmt=1418590845082732&dur=36011.200&key=dg_yt0&mt=1492801526&upn=cA3U7DFBWOw&signature=537B4E86C9CD83ED2EACFAFCFAEE840E259C2DD1.12BF28ED6A0BA6AFDD4FD1631786AA46DC798D12&ip=109.192.170.65&ipbits=0&expire=1492823205&sparams=ip,ipbits,expire,id,itag,source,requiressl,initcwndbps,pl,mv,ei,ms,mm,mn,ratebypass,mime,gir,clen,lmt,dur"
dummy.display = "winkekatze"
}
}
return dummy
}
val dummyObject: StreamUrl
get() {
return StreamUrl("https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8", "","HLS")
}
}
}