Search in sources :

Example 1 with LiveChannelInfo

use of com.aliyun.oss.model.LiveChannelInfo in project aliyun-oss-java-sdk by aliyun.

the class RtmpTest method testSetLiveChannelStatusRepeated.

@Test
public void testSetLiveChannelStatusRepeated() {
    final String liveChannel = "normal-set-live-channel-status-repeated";
    try {
        CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel);
        ossClient.createLiveChannel(createLiveChannelRequest);
        // set disabled
        ossClient.setLiveChannelStatus(bucketName, liveChannel, LiveChannelStatus.Disabled);
        ossClient.setLiveChannelStatus(bucketName, liveChannel, LiveChannelStatus.Disabled);
        LiveChannelInfo liveChannelInfo = ossClient.getLiveChannelInfo(bucketName, liveChannel);
        Assert.assertEquals(liveChannelInfo.getStatus(), LiveChannelStatus.Disabled);
        Assert.assertEquals(liveChannelInfo.getRequestId().length(), REQUEST_ID_LEN);
        // set enabled
        ossClient.setLiveChannelStatus(bucketName, liveChannel, LiveChannelStatus.Enabled);
        ossClient.setLiveChannelStatus(bucketName, liveChannel, LiveChannelStatus.Enabled);
        liveChannelInfo = ossClient.getLiveChannelInfo(bucketName, liveChannel);
        Assert.assertEquals(liveChannelInfo.getStatus(), LiveChannelStatus.Enabled);
        Assert.assertEquals(liveChannelInfo.getRequestId().length(), REQUEST_ID_LEN);
        // set disabled
        ossClient.setLiveChannelStatus(bucketName, liveChannel, LiveChannelStatus.Disabled);
        ossClient.setLiveChannelStatus(bucketName, liveChannel, LiveChannelStatus.Disabled);
        liveChannelInfo = ossClient.getLiveChannelInfo(bucketName, liveChannel);
        Assert.assertEquals(liveChannelInfo.getStatus(), LiveChannelStatus.Disabled);
        Assert.assertEquals(liveChannelInfo.getRequestId().length(), REQUEST_ID_LEN);
        // set enabled
        ossClient.setLiveChannelStatus(bucketName, liveChannel, LiveChannelStatus.Enabled);
        ossClient.setLiveChannelStatus(bucketName, liveChannel, LiveChannelStatus.Enabled);
        liveChannelInfo = ossClient.getLiveChannelInfo(bucketName, liveChannel);
        Assert.assertEquals(liveChannelInfo.getStatus(), LiveChannelStatus.Enabled);
        Assert.assertEquals(liveChannelInfo.getRequestId().length(), REQUEST_ID_LEN);
        ossClient.deleteLiveChannel(bucketName, liveChannel);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
}
Also used : LiveChannelInfo(com.aliyun.oss.model.LiveChannelInfo) CreateLiveChannelRequest(com.aliyun.oss.model.CreateLiveChannelRequest) OSSException(com.aliyun.oss.OSSException) ParseException(java.text.ParseException) Test(org.junit.Test)

Example 2 with LiveChannelInfo

use of com.aliyun.oss.model.LiveChannelInfo 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());
    }
}
Also used : LiveChannelInfo(com.aliyun.oss.model.LiveChannelInfo) CreateLiveChannelRequest(com.aliyun.oss.model.CreateLiveChannelRequest) LiveChannelTarget(com.aliyun.oss.model.LiveChannelTarget) OSSException(com.aliyun.oss.OSSException) ParseException(java.text.ParseException) Test(org.junit.Test)

Example 3 with LiveChannelInfo

use of com.aliyun.oss.model.LiveChannelInfo 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());
    }
}
Also used : CreateLiveChannelResult(com.aliyun.oss.model.CreateLiveChannelResult) LiveChannelInfo(com.aliyun.oss.model.LiveChannelInfo) CreateLiveChannelRequest(com.aliyun.oss.model.CreateLiveChannelRequest) OSSException(com.aliyun.oss.OSSException) ParseException(java.text.ParseException) Test(org.junit.Test)

Example 4 with LiveChannelInfo

use of com.aliyun.oss.model.LiveChannelInfo in project aliyun-oss-java-sdk by aliyun.

the class RtmpTest method testGeneratePushflowUri.

@Test
public void testGeneratePushflowUri() {
    final String liveChannel = "normal-generate-pushflow-uri";
    try {
        CreateLiveChannelRequest createLiveChannelRequest = new CreateLiveChannelRequest(bucketName, liveChannel);
        ossClient.createLiveChannel(createLiveChannelRequest);
        ossClient.setBucketAcl(bucketName, CannedAccessControlList.Private);
        LiveChannelInfo liveChannelInfo = ossClient.getLiveChannelInfo(bucketName, liveChannel);
        Assert.assertEquals(liveChannelInfo.getRequestId().length(), REQUEST_ID_LEN);
        // generate rtmp url
        long expires = System.currentTimeMillis() / 1000 + 3600;
        String uri = ossClient.generateRtmpUri(bucketName, liveChannel, liveChannelInfo.getTarget().getPlaylistName(), expires);
        // System.out.println("uri:" + uri);
        Assert.assertTrue(uri.startsWith("rtmp://" + bucketName));
        Assert.assertTrue(uri.endsWith("playlistName=" + liveChannelInfo.getTarget().getPlaylistName()));
        // Manually verify by url, with following cmd.
        // ./ffmpeg \-re \-i allstar.flv \-c copy \-f flv "<RTMP_URI>"
        // generate without parameters
        String uri2 = ossClient.generateRtmpUri(bucketName, liveChannel, liveChannelInfo.getTarget().getPlaylistName(), expires);
        Assert.assertEquals(uri, uri2);
        ossClient.deleteLiveChannel(bucketName, liveChannel);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
}
Also used : LiveChannelInfo(com.aliyun.oss.model.LiveChannelInfo) CreateLiveChannelRequest(com.aliyun.oss.model.CreateLiveChannelRequest) OSSException(com.aliyun.oss.OSSException) ParseException(java.text.ParseException) Test(org.junit.Test)

Example 5 with LiveChannelInfo

use of com.aliyun.oss.model.LiveChannelInfo 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());
    }
}
Also used : CreateLiveChannelResult(com.aliyun.oss.model.CreateLiveChannelResult) LiveChannelInfo(com.aliyun.oss.model.LiveChannelInfo) CreateLiveChannelRequest(com.aliyun.oss.model.CreateLiveChannelRequest) LiveChannelTarget(com.aliyun.oss.model.LiveChannelTarget) OSSException(com.aliyun.oss.OSSException) ParseException(java.text.ParseException) Test(org.junit.Test)

Aggregations

LiveChannelInfo (com.aliyun.oss.model.LiveChannelInfo)7 ParseException (java.text.ParseException)7 OSSException (com.aliyun.oss.OSSException)6 CreateLiveChannelRequest (com.aliyun.oss.model.CreateLiveChannelRequest)6 Test (org.junit.Test)6 LiveChannelTarget (com.aliyun.oss.model.LiveChannelTarget)3 CreateLiveChannelResult (com.aliyun.oss.model.CreateLiveChannelResult)2 ResponseParseException (com.aliyun.oss.common.parser.ResponseParseException)1 Element (org.jdom.Element)1 JDOMParseException (org.jdom.input.JDOMParseException)1