use of com.aliyun.oss.model.LiveChannelTarget in project aliyun-oss-java-sdk by aliyun.
the class RtmpTest method testGetLiveChannelInfo.
@Test
public void testGetLiveChannelInfo() {
final String liveChannel = "normal-get-live-channel-info";
final String liveChannelDesc = "my test live channel";
try {
LiveChannelTarget target = new LiveChannelTarget("HLS", 100, 99, "myplaylist.m3u8");
CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel, liveChannelDesc, LiveChannelStatus.Enabled, target);
ossClient.createLiveChannel(createLiveChannelRequest);
LiveChannelInfo liveChannelInfo = ossClient.getLiveChannelInfo(bucketName, liveChannel);
Assert.assertEquals(liveChannelInfo.getDescription(), liveChannelDesc);
Assert.assertEquals(liveChannelInfo.getStatus(), LiveChannelStatus.Enabled);
Assert.assertEquals(liveChannelInfo.getTarget().getType(), "HLS");
Assert.assertEquals(liveChannelInfo.getTarget().getFragDuration(), 100);
Assert.assertEquals(liveChannelInfo.getTarget().getFragCount(), 99);
Assert.assertEquals(liveChannelInfo.getTarget().getPlaylistName(), "myplaylist.m3u8");
Assert.assertEquals(liveChannelInfo.getRequestId().length(), REQUEST_ID_LEN);
ossClient.deleteLiveChannel(bucketName, liveChannel);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
use of com.aliyun.oss.model.LiveChannelTarget in project aliyun-oss-java-sdk by aliyun.
the class RtmpTest method testUnormalCreateLiveChannel.
@Test
public void testUnormalCreateLiveChannel() {
final String liveChannel = "unnormal-create-live-channel";
try {
LiveChannelTarget target = new LiveChannelTarget("RTMP", "myplaylist.m3u8");
CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel, "", LiveChannelStatus.Enabled, target);
ossClient.createLiveChannel(createLiveChannelRequest);
Assert.fail("Get live channel should not be successful.");
} catch (OSSException e) {
Assert.assertEquals(e.getErrorCode(), OSSErrorCode.INVALID_ARGUMENT);
}
try {
LiveChannelTarget target = new LiveChannelTarget("HLS", 200, 99, "myplaylist.m3u8");
CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel, "", LiveChannelStatus.Enabled, target);
ossClient.createLiveChannel(createLiveChannelRequest);
Assert.fail("Get live channel should not be successful.");
} catch (OSSException e) {
Assert.assertEquals(e.getErrorCode(), OSSErrorCode.INVALID_ARGUMENT);
}
try {
LiveChannelTarget target = new LiveChannelTarget("HLS", 100, 0, "myplaylist.m3u8");
CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel, "", LiveChannelStatus.Enabled, target);
ossClient.createLiveChannel(createLiveChannelRequest);
Assert.fail("Get live channel should not be successful.");
} catch (OSSException e) {
Assert.assertEquals(e.getErrorCode(), OSSErrorCode.INVALID_ARGUMENT);
}
try {
LiveChannelTarget target = new LiveChannelTarget("HLS", 100, 199, "myplaylist.m3u8");
CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel, "", LiveChannelStatus.Enabled, target);
ossClient.createLiveChannel(createLiveChannelRequest);
Assert.fail("Get live channel should not be successful.");
} catch (OSSException e) {
Assert.assertEquals(e.getErrorCode(), OSSErrorCode.INVALID_ARGUMENT);
}
}
use of com.aliyun.oss.model.LiveChannelTarget in project aliyun-oss-java-sdk by aliyun.
the class RtmpTest method testCreateLiveChannel.
@Test
public void testCreateLiveChannel() {
final String liveChannel = "normal-create-live-channel";
final String liveChannelDesc = "my test live channel";
try {
LiveChannelTarget target = new LiveChannelTarget("HLS", 100, 99, "myplaylist.m3u8");
CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel, liveChannelDesc, LiveChannelStatus.Disabled, target);
CreateLiveChannelResult createLiveChannelResult = ossClient.createLiveChannel(createLiveChannelRequest);
Assert.assertEquals(createLiveChannelResult.getPublishUrls().size(), 1);
Assert.assertTrue(createLiveChannelResult.getPublishUrls().get(0).startsWith("rtmp://"));
Assert.assertTrue(createLiveChannelResult.getPublishUrls().get(0).endsWith("live/" + liveChannel));
Assert.assertEquals(createLiveChannelResult.getPlayUrls().size(), 1);
Assert.assertTrue(createLiveChannelResult.getPlayUrls().get(0).startsWith("http://"));
Assert.assertTrue(createLiveChannelResult.getPlayUrls().get(0).endsWith(liveChannel + "/myplaylist.m3u8"));
Assert.assertEquals(createLiveChannelResult.getRequestId().length(), REQUEST_ID_LEN);
LiveChannelInfo liveChannelInfo = ossClient.getLiveChannelInfo(bucketName, liveChannel);
Assert.assertEquals(liveChannelInfo.getDescription(), liveChannelDesc);
Assert.assertEquals(liveChannelInfo.getStatus(), LiveChannelStatus.Disabled);
Assert.assertEquals(liveChannelInfo.getTarget().getType(), "HLS");
Assert.assertEquals(liveChannelInfo.getTarget().getFragDuration(), 100);
Assert.assertEquals(liveChannelInfo.getTarget().getFragCount(), 99);
Assert.assertEquals(liveChannelInfo.getTarget().getPlaylistName(), "myplaylist.m3u8");
Assert.assertEquals(liveChannelInfo.getRequestId().length(), REQUEST_ID_LEN);
ossClient.deleteLiveChannel(bucketName, liveChannel);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
use of com.aliyun.oss.model.LiveChannelTarget in project aliyun-oss-java-sdk by aliyun.
the class ResponseParsers method parseGetLiveChannelInfo.
/**
* Unmarshall get live channel info response body to corresponding result.
*/
public static LiveChannelInfo parseGetLiveChannelInfo(InputStream responseBody) throws ResponseParseException {
try {
Element root = getXmlRootElement(responseBody);
LiveChannelInfo result = new LiveChannelInfo();
result.setDescription(root.getChildText("Description"));
result.setStatus(LiveChannelStatus.parse(root.getChildText("Status")));
Element targetElem = root.getChild("Target");
LiveChannelTarget target = new LiveChannelTarget();
target.setType(targetElem.getChildText("Type"));
target.setFragDuration(Integer.parseInt(targetElem.getChildText("FragDuration")));
target.setFragCount(Integer.parseInt(targetElem.getChildText("FragCount")));
target.setPlaylistName(targetElem.getChildText("PlaylistName"));
result.setTarget(target);
return result;
} catch (JDOMParseException e) {
throw new ResponseParseException(e.getPartialDocument() + ": " + e.getMessage(), e);
} catch (Exception e) {
throw new ResponseParseException(e.getMessage(), e);
}
}
Aggregations