Skip to content

Commit 35addcc

Browse files
authored
Merge pull request #29 from aliyun/refine_rtmp
rtmp
2 parents 8e43551 + e71f600 commit 35addcc

File tree

9 files changed

+12
-93
lines changed

9 files changed

+12
-93
lines changed

src/main/java/com/aliyun/oss/OSS.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,20 +1648,6 @@ public void generateVodPlaylist(GenerateVodPlaylistRequest generateVodPlaylistRe
16481648
public String generateRtmpUri(String bucketName, String liveChannelName, String PlaylistName,
16491649
long expires) throws OSSException, ClientException;
16501650

1651-
/**
1652-
* 生成Live Channel的RTMP推流地址。
1653-
* @param bucketName Bucket名称。
1654-
* @param liveChannel Live Channel名称。
1655-
* @param PlaylistName 生成的点播用m3u8文件的basename,例如playlist.m3u8。
1656-
* @param expires 期望的过期时间,格式采用epoch time,例如1459922563。
1657-
* @param parameters 用户自定义参数,没有填null。
1658-
* @return Live Channel的RTMP推流地址。
1659-
* @throws OSSException OSS Server异常信息。
1660-
* @throws ClientException OSS Client异常信息。
1661-
*/
1662-
public String generateRtmpUri(String bucketName, String liveChannelName, String PlaylistName,
1663-
long expires, Map<String, String> parameters) throws OSSException, ClientException;
1664-
16651651
/**
16661652
* 生成Live Channel的RTMP推流地址。
16671653
* @param generatePushflowUrlRequest 请求参数。

src/main/java/com/aliyun/oss/OSSClient.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,20 +1391,13 @@ public void generateVodPlaylist(GenerateVodPlaylistRequest generateVodPlaylistRe
13911391
public String generateRtmpUri(String bucketName, String liveChannelName, String PlaylistName,
13921392
long expires) throws OSSException, ClientException {
13931393
return this.generateRtmpUri(new GenerateRtmpUriRequest(bucketName, liveChannelName,
1394-
PlaylistName, expires, null));
1394+
PlaylistName, expires));
13951395
}
13961396

13971397
@Override
1398-
public String generateRtmpUri(String bucketName, String liveChannelName, String PlaylistName,
1399-
long expires, Map<String, String> parameters) throws OSSException, ClientException {
1400-
return this.generateRtmpUri(new GenerateRtmpUriRequest(bucketName, liveChannelName,
1401-
PlaylistName, expires, parameters));
1402-
}
1403-
1404-
@Override
1405-
public String generateRtmpUri(GenerateRtmpUriRequest generatePushflowUrlRequest)
1398+
public String generateRtmpUri(GenerateRtmpUriRequest generateRtmpUriRequest)
14061399
throws OSSException, ClientException {
1407-
return liveChannelOperation.generatePushflowUrl(generatePushflowUrlRequest);
1400+
return liveChannelOperation.generateRtmpUri(generateRtmpUriRequest);
14081401
}
14091402

14101403
@Override

src/main/java/com/aliyun/oss/internal/LiveChannelOperation.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public void generateVodPlaylist(GenerateVodPlaylistRequest generateVodPlaylistRe
336336
doOperation(request, emptyResponseParser, bucketName, key);
337337
}
338338

339-
public String generatePushflowUrl(GenerateRtmpUriRequest request)
339+
public String generateRtmpUri(GenerateRtmpUriRequest request)
340340
throws OSSException, ClientException {
341341

342342
assertParameterNotNull(request, "request");
@@ -368,11 +368,6 @@ public String generatePushflowUrl(GenerateRtmpUriRequest request)
368368

369369
// Parameters
370370
requestMessage.addParameter(RequestParameters.PLAYLIST_NAME, playlistName);
371-
if (request.getParameters() != null && request.getParameters().size() > 0) {
372-
for (Map.Entry<String, String> entry : request.getParameters().entrySet()) {
373-
requestMessage.addParameter(entry.getKey(), entry.getValue());
374-
}
375-
}
376371

377372
if (useSecurityToken) {
378373
requestMessage.addParameter(SECURITY_TOKEN, currentCreds.getSecurityToken());

src/main/java/com/aliyun/oss/model/GenerateRtmpUriRequest.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919

2020
package com.aliyun.oss.model;
2121

22-
import java.util.LinkedHashMap;
23-
import java.util.Map;
24-
2522
/**
2623
* 生成带有签名信息的推流地址的请求
2724
*/
@@ -34,15 +31,6 @@ public GenerateRtmpUriRequest(String bucketName, String liveChannelName,
3431
this.playlistName = playlistName;
3532
this.expires = expires;
3633
}
37-
38-
public GenerateRtmpUriRequest(String bucketName, String liveChannelName,
39-
String playlistName, long expires, Map<String, String> parameters) {
40-
this.bucketName = bucketName;
41-
this.liveChannelName = liveChannelName;
42-
this.playlistName = playlistName;
43-
this.expires = expires;
44-
this.parameters = parameters;
45-
}
4634

4735
public String getBucketName() {
4836
return bucketName;
@@ -76,22 +64,9 @@ public void setExpires(long expires) {
7664
this.expires = expires;
7765
}
7866

79-
public Map<String, String> getParameters() {
80-
return parameters;
81-
}
82-
83-
public void setParameters(Map<String, String> params) {
84-
this.parameters = params;
85-
}
86-
87-
public void addParameter(String key, String value) {
88-
this.parameters.put(key, value);
89-
}
90-
9167
private String bucketName;
9268
private String liveChannelName;
9369
private String playlistName;
9470
private Long expires;
95-
private Map<String, String> parameters = new LinkedHashMap<String, String>();
9671

9772
}

src/test/java/com/aliyun/oss/OSSClientRequestTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public void run() throws Exception{
178178
bucketOp.setBucketAcl(new SetBucketAclRequest(bucketName, null));
179179
}
180180
};
181-
executeTest(test1, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "",
181+
executeTest(test1, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "?acl",
182182
new HashMap<String, String>(){
183183
{
184184
}
@@ -189,7 +189,7 @@ public void run() throws Exception{
189189
bucketOp.setBucketAcl(new SetBucketAclRequest(bucketName, CannedAccessControlList.PublicRead));
190190
}
191191
};
192-
executeTest(test2, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "",
192+
executeTest(test2, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "?acl",
193193
new HashMap<String, String>(){
194194
{
195195
put("x-oss-acl", "public-read");
@@ -201,7 +201,7 @@ public void run() throws Exception{
201201
bucketOp.setBucketAcl(new SetBucketAclRequest(bucketName, CannedAccessControlList.PublicReadWrite));
202202
}
203203
};
204-
executeTest(test3, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "",
204+
executeTest(test3, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "?acl",
205205
new HashMap<String, String>(){
206206
{
207207
put("x-oss-acl", "public-read-write");
@@ -213,7 +213,7 @@ public void run() throws Exception{
213213
bucketOp.setBucketAcl(new SetBucketAclRequest(bucketName, CannedAccessControlList.Private));
214214
}
215215
};
216-
executeTest(test4, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "",
216+
executeTest(test4, HttpMethod.PUT, bucketName + "." + endpoint.getHost(), "?acl",
217217
new HashMap<String, String>(){
218218
{
219219
put("x-oss-acl", "private");

src/test/java/com/aliyun/oss/integrationtests/BucketInfoTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public void testListBucketWithEndpoint() {
6464

6565
BucketList buckets = ossClient.listBuckets(listBucketsRequest);
6666
Assert.assertEquals(buckets.getBucketList().size(), 1);
67-
Assert.assertTrue(buckets.getBucketList().get(0).getExtranetEndpoint().endsWith(".aliyuncs.com"));
68-
Assert.assertTrue(buckets.getBucketList().get(0).getIntranetEndpoint().endsWith(".aliyuncs.com"));
67+
Assert.assertNotNull(buckets.getBucketList().get(0).getExtranetEndpoint());
68+
Assert.assertNotNull(buckets.getBucketList().get(0).getIntranetEndpoint());
6969
} catch (Exception e) {
7070
e.printStackTrace();
7171
Assert.fail(e.getMessage());

src/test/java/com/aliyun/oss/integrationtests/RtmpTest.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121

2222
import java.text.ParseException;
2323
import java.util.Date;
24-
import java.util.HashMap;
2524
import java.util.List;
26-
import java.util.Map;
27-
2825
import junit.framework.Assert;
2926

3027
import org.junit.Ignore;
@@ -571,17 +568,10 @@ public void testGeneratePushflowUri() {
571568

572569
// generate without parameters
573570
String uri2 = ossClient.generateRtmpUri(bucketName, liveChannel,
574-
liveChannelInfo.getTarget().getPlaylistName(), expires, null);
571+
liveChannelInfo.getTarget().getPlaylistName(), expires);
575572

576573
Assert.assertEquals(uri, uri2);
577574

578-
// generate with parameters
579-
Map<String, String> params = new HashMap<String, String>();
580-
params.put("mykey", "myvalue");
581-
String uri3 = ossClient.generateRtmpUri(bucketName, liveChannel,
582-
liveChannelInfo.getTarget().getPlaylistName(), expires, params);
583-
584-
Assert.assertTrue(uri3.endsWith("mykey=myvalue"));
585575
} catch (Exception e) {
586576
Assert.fail(e.getMessage());
587577
}

src/test/java/com/aliyun/oss/integrationtests/UploadPartCopyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public void testNormalUploadPartCopyWithSpecialChars() {
339339
final String sourceBucket = "normal-upload-part-copy-by-range-bucket-source";
340340
final String targetBucket = "normal-upload-part-copy-by-range-bucket-target";
341341
final String sourceKey = "测\\r试-中.~,+\"'*&¥#@%!(文)+字符|?/.zip";
342-
final String targetKey = "测\\r试-中.~,+\"'*&¥#@%!(文)+字符|?/-2.zip";
342+
final String targetKey = "测\\r试-中.~,+\"'*&¥#@%!(文)+字符|?-2.zip";
343343
final long partSize = 128 * 1024; //128KB
344344

345345
try {

src/test/java/com/aliyun/oss/integrationtests/UploadPartTest.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import static com.aliyun.oss.integrationtests.TestConstants.BUCKET_NOT_EMPTY_ERR;
2424
import static com.aliyun.oss.integrationtests.TestConstants.ENTITY_TOO_SMALL_ERR;
2525
import static com.aliyun.oss.integrationtests.TestConstants.INVALID_PART_ERR;
26-
import static com.aliyun.oss.integrationtests.TestConstants.INVALID_PART_ORDER_ERR;
2726
import static com.aliyun.oss.integrationtests.TestConstants.NO_SUCH_BUCKET_ERR;
2827
import static com.aliyun.oss.integrationtests.TestConstants.NO_SUCH_UPLOAD_ERR;
2928
import static com.aliyun.oss.integrationtests.TestUtils.calcMultipartsETag;
@@ -913,25 +912,6 @@ public void testUnormalCompleteMultipartUpload() {
913912
partETags.set(partNumber - 1, originalPartETag);
914913
}
915914

916-
// Invalid part number order(MUST be in ascending order)
917-
final int swapFrom = 2;
918-
final int swapTo = 5;
919-
PartETag tmp = partETags.get(swapTo);
920-
partETags.set(swapTo, partETags.get(2));
921-
partETags.set(swapFrom, tmp);
922-
try {
923-
CompleteMultipartUploadRequest completeMultipartUploadRequest =
924-
new CompleteMultipartUploadRequest(bucketName, key, uploadId, partETags);
925-
ossClient.completeMultipartUpload(completeMultipartUploadRequest);
926-
Assert.fail("Complete multipart upload should not be successful");
927-
} catch (OSSException e) {
928-
Assert.assertEquals(OSSErrorCode.INVALID_PART_ORDER, e.getErrorCode());
929-
Assert.assertTrue(e.getMessage().startsWith(INVALID_PART_ORDER_ERR));
930-
} finally {
931-
partETags.set(swapFrom, partETags.get(swapTo));
932-
partETags.set(swapTo, tmp);
933-
}
934-
935915
// Try to complete multipart upload with non-existent part
936916
PartETag nonexistentPartETag = new PartETag(partCount + 1, invalidETag);
937917
partETags.add(nonexistentPartETag);

0 commit comments

Comments
 (0)