The project is built with java 1.7.
Firstly, make sure you have gradle on your machine.
Then all you have to do is just
gradle build
okhttp
, okio
, Gson
compile 'com.qiniu.pili:pili-sdk-java:2.1.0'
Client cli = new Client(accessKey,secretKey);
String url = cli.RTMPPublishURL("publish-rtmp.test.com", "PiliSDKTest", "streamkey", 60);
/*
rtmp://publish-rtmp.test.com/PiliSDKTest/streamkey?e=1463023142&token=7O7hf7Ld1RrC_fpZdFvU8aCgOPuhw2K4eapYOdII:-5IVlpFNNGJHwv-2qKwVIakC0ME=
*/
String url = cli.RTMPPlayURL("live-rtmp.test.com", "PiliSDKTest", "streamkey");
/*
rtmp://live-rtmp.test.com/PiliSDKTest/streamkey
*/
url = cli.HLSPlayURL("live-hls.test.com", "PiliSDKTest", "streamkey");
/*
http://live-hls.test.com/PiliSDKTest/streamkey.m3u8
*/
url = cli.HDLPlayURL("live-hdl.test.com", "PiliSDKTest", "streamkey");
/*
http://live-hdl.test.com/PiliSDKTest/streamkey.flv
*/
url = cli.SnapshotPlayURL("live-snapshot.test.com", "PiliSDKTest", "streamkey");
/*
http://live-snapshot.test.com/PiliSDKTest/streamkey.jpg
*/
public static void main(String args[]) {
Client cli = new Client(accessKey, secretKey);
Hub hub = cli.newHub("PiliSDKTest");
// ...
}
Stream stream = hub.create("streamkey")
System.out.println(stream.toJson());
/*
{"Hub":"PiliSDKTest","Key":"streamkey","DisabledTill":0}
*/
Stream stream = hub.get("streamkey")
System.out.println(stream.toJson())
/*
{"Hub":"PiliSDKTest","Key":"streamkey","DisabledTill":0}
*/
Hub.ListRet listRet = hub.list("str", 10, "")
/*
keys=[streamkey] marker=
*/
Hub.ListRet listRet = hub.listLive("str", 10, "")
/*
keys=[] marker=
*/
Hub.BatchLiveStatus[] statuses = hub.batchLiveStatus(new String[]{"strm1","strm2"});
Get the latest stream info
Stream stream = hub.get("streamkey")
stream.disable()
// will get the latest info from server
stream = stream.info()
Stream stream = hub.get("streamkey")
stream.disable()
stream = hub.get("streamkey")
/*
before disable: {"Hub":"PiliSDKTest","Key":"streamkey","DisabledTill":0}
after disable: {"Hub":"PiliSDKTest","Key":"streamkey","DisabledTill":-1}
*/
stream.disable(1488540526L);
stream.info();
/*
after disable: {"Hub":"PiliSDKTest","Key":"streamkey","DisabledTill":1488540526}
*/
Stream stream = hub.get("streamkey")
stream.enable()
stream = hub.get("streamkey")
/*
before disable: {"Hub":"PiliSDKTest","Key":"streamkey","DisabledTill":-1}
after disable: {"Hub":"PiliSDKTest","Key":"streamkey","DisabledTill":0}
*/
Stream.LiveStatus status = stream.liveStatus();
/*
{"startAt":1463022236,"clientIP":"222.73.202.226","bps":248,"fps":{"audio":45,"vedio":28,"data":0}}
*/
Stream.Record[] records = stream.historyRecord(0, 0)
/*
[{1463022236,1463022518}]
*/
String fname = stream.save(0, 0)
/*
recordings/z1.hub1.strm1/0_1488529267.m3u8
*/
Stream.SnapshotOptions opts = new Stream.SnapshotOptions();
opts.fname = "test";
stream.snapshot(opts);
String[] profiles = {"480p", "720p"};
stream.updateConverts(profiles);