use of com.aliyun.oss.model.CreateLiveChannelRequest in project aliyun-oss-java-sdk by aliyun.
the class RtmpTest method testDeleteLiveChannel.
@Test
public void testDeleteLiveChannel() {
final String liveChannel = "normal-delete-live-channel";
try {
CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel);
ossClient.createLiveChannel(createLiveChannelRequest);
ossClient.getLiveChannelInfo(bucketName, liveChannel);
ossClient.deleteLiveChannel(bucketName, liveChannel);
try {
ossClient.getLiveChannelInfo(bucketName, liveChannel);
} catch (OSSException e) {
Assert.assertEquals(e.getErrorCode(), OSSErrorCode.NO_SUCH_LIVE_CHANNEL);
}
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
use of com.aliyun.oss.model.CreateLiveChannelRequest in project aliyun-oss-java-sdk by aliyun.
the class RtmpTest method testCreateLiveChannelDefault.
@Test
public void testCreateLiveChannelDefault() {
final String liveChannel = "normal-create-live-channel-default";
try {
CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel);
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 + "/playlist.m3u8"));
Assert.assertEquals(createLiveChannelResult.getRequestId().length(), REQUEST_ID_LEN);
LiveChannelInfo liveChannelInfo = ossClient.getLiveChannelInfo(bucketName, liveChannel);
Assert.assertEquals(liveChannelInfo.getDescription(), "");
Assert.assertEquals(liveChannelInfo.getStatus(), LiveChannelStatus.Enabled);
Assert.assertEquals(liveChannelInfo.getTarget().getType(), "HLS");
Assert.assertEquals(liveChannelInfo.getTarget().getFragDuration(), 5);
Assert.assertEquals(liveChannelInfo.getTarget().getFragCount(), 3);
Assert.assertEquals(liveChannelInfo.getTarget().getPlaylistName(), "playlist.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.CreateLiveChannelRequest 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.CreateLiveChannelRequest 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.CreateLiveChannelRequest in project aliyun-oss-java-sdk by aliyun.
the class RtmpTest method testGenerateVodPlaylist.
@Test
public void testGenerateVodPlaylist() {
final String liveChannel = "normal-generate-vod-playlist";
try {
CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel);
ossClient.createLiveChannel(createLiveChannelRequest);
ossClient.setBucketAcl(bucketName, CannedAccessControlList.PublicReadWrite);
long startTime = System.currentTimeMillis() / 1000 - 3600;
long endTime = System.currentTimeMillis() / 1000 + 3600;
try {
ossClient.generateVodPlaylist(bucketName, liveChannel, "playlist.m3u8", startTime, endTime);
} catch (OSSException e) {
Assert.assertEquals(e.getErrorCode(), OSSErrorCode.INVALID_ARGUMENT);
Assert.assertTrue(e.getMessage().indexOf("No ts file found in specified time span.") > -1);
}
ossClient.deleteLiveChannel(bucketName, liveChannel);
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
Aggregations