forked from j62/ctbrec
1
0
Fork 0

Add origin stream source only, if mp4-ws sources are available

This commit is contained in:
0xboobface 2018-12-16 17:21:11 +01:00
parent 3d7fc64bf5
commit 1e47432714
1 changed files with 11 additions and 9 deletions

View File

@ -91,7 +91,6 @@ public class StreamateModel extends AbstractModel {
if(response.isSuccessful()) {
JSONObject json = new JSONObject(response.body().string());
JSONObject formats = json.getJSONObject("formats");
JSONObject ws = formats.getJSONObject("mp4-ws");
JSONObject hls = formats.getJSONObject("mp4-hls");
// add encodings
@ -108,6 +107,8 @@ public class StreamateModel extends AbstractModel {
}
// add raw source stream
if(formats.has("mp4-ws")) {
JSONObject ws = formats.getJSONObject("mp4-ws");
JSONObject origin = hls.getJSONObject("origin");
StreamSource src = new StreamSource();
src.mediaPlaylistUrl = origin.getString("location");
@ -116,6 +117,7 @@ public class StreamateModel extends AbstractModel {
src.height = origin.optInt("videoHeight");
src.bandwidth = (origin.optInt("videoKbps") + origin.optInt("audioKbps")) * 1024;
streamSources.add(src);
}
} else {
throw new HttpException(response.code(), response.message());
}