use of com.aliyun.oss.model.LiveRecord in project aliyun-oss-java-sdk by aliyun.
the class RtmpTest method testGetLiveChannelHistoryWithoutPushflow.
@Test
public void testGetLiveChannelHistoryWithoutPushflow() {
final String liveChannel = "normal-get-live-channel-history-without-pushflow";
try {
CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel);
ossClient.createLiveChannel(createLiveChannelRequest);
List<LiveRecord> liveRecords = ossClient.getLiveChannelHistory(bucketName, liveChannel);
Assert.assertEquals(liveRecords.size(), 0);
ossClient.deleteLiveChannel(bucketName, liveChannel);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
use of com.aliyun.oss.model.LiveRecord in project aliyun-oss-java-sdk by aliyun.
the class RtmpTest method testGetLiveChannelHistory.
@Ignore
public void testGetLiveChannelHistory() {
final String liveChannel = "normal-get-live-channel-history";
try {
CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel);
ossClient.createLiveChannel(createLiveChannelRequest);
ossClient.setBucketAcl(bucketName, CannedAccessControlList.PublicReadWrite);
// Manually enable pusing streaming with following cmd:
// ./ffmpeg \-re \-i allstar.flv \-c copy \-f flv "rtmp://oss-live-channel-2.demo-oss-cn-shenzhen.aliyuncs.com/live/normal-get-live-channel-history?playlistName=playlist.m3u8"
Thread.sleep(5 * 1000);
List<LiveRecord> liveRecords = ossClient.getLiveChannelHistory(bucketName, liveChannel);
Assert.assertTrue(liveRecords.size() >= 1);
for (LiveRecord liveRecord : liveRecords) {
Assert.assertTrue(dateAfterValidator(liveRecord.getStartDate()));
Assert.assertTrue(dateAfterValidator(liveRecord.getEndDate()));
Assert.assertTrue(liveRecord.getRemoteAddress().length() >= new String("0.0.0.0:0").length());
}
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
use of com.aliyun.oss.model.LiveRecord in project aliyun-oss-java-sdk by aliyun.
the class ResponseParsers method parseGetLiveChannelHistory.
/**
* Unmarshall get live channel history response body to corresponding
* result.
*/
@SuppressWarnings("unchecked")
public static List<LiveRecord> parseGetLiveChannelHistory(InputStream responseBody) throws ResponseParseException {
try {
Element root = getXmlRootElement(responseBody);
List<LiveRecord> liveRecords = new ArrayList<LiveRecord>();
List<Element> recordElements = root.getChildren("LiveRecord");
for (Element recordElem : recordElements) {
LiveRecord record = new LiveRecord();
record.setStartDate(DateUtil.parseIso8601Date(recordElem.getChildText("StartTime")));
record.setEndDate(DateUtil.parseIso8601Date(recordElem.getChildText("EndTime")));
record.setRemoteAddress(recordElem.getChildText("RemoteAddr"));
liveRecords.add(record);
}
return liveRecords;
} catch (JDOMParseException e) {
throw new ResponseParseException(e.getPartialDocument() + ": " + e.getMessage(), e);
} catch (Exception e) {
throw new ResponseParseException(e.getMessage(), e);
}
}
Aggregations