@@ -59,7 +59,7 @@ public String createSession(Map<String, Collection<String>> params) throws Reque
59
59
60
60
Future <Response > request = this .preparePost (this .apiUrl + "/session/create" )
61
61
.setFormParams (paramsWithList )
62
- .addHeader ("Accept" , "application/json" ) // XML version is deprecated
62
+ .setHeader ("Accept" , "application/json" ) // XML version is deprecated
63
63
.execute ();
64
64
65
65
try {
@@ -119,7 +119,9 @@ public String signal(String sessionId, String connectionId, SignalProperties pro
119
119
120
120
public String getArchive (String archiveId ) throws RequestException {
121
121
String url = this .apiUrl + "/v2/project/" + this .apiKey + "/archive/" + archiveId ;
122
- Future <Response > request = this .prepareGet (url ).execute ();
122
+ Future <Response > request = this .prepareGet (url )
123
+ .setHeader ("Accept" , "application/json" )
124
+ .execute ();
123
125
124
126
try {
125
127
Response response = request .get ();
@@ -161,7 +163,9 @@ public String getArchives(String sessionId, int offset, int count) throws OpenTo
161
163
url += (url .contains ("?" ) ? "&" : "?" ) + "sessionId=" + sessionId ;
162
164
}
163
165
164
- Future <Response > request = this .prepareGet (url ).execute ();
166
+ Future <Response > request = this .prepareGet (url )
167
+ .setHeader ("Accept" , "application/json" )
168
+ .execute ();
165
169
166
170
try {
167
171
Response response = request .get ();
@@ -221,6 +225,7 @@ public String startArchive(String sessionId, ArchiveProperties properties) throw
221
225
Future <Response > request = this .preparePost (url )
222
226
.setBody (requestBody )
223
227
.setHeader ("Content-Type" , "application/json" )
228
+ .setHeader ("Accept" , "application/json" )
224
229
.execute ();
225
230
226
231
try {
@@ -251,7 +256,9 @@ public String startArchive(String sessionId, ArchiveProperties properties) throw
251
256
252
257
public String stopArchive (String archiveId ) throws RequestException {
253
258
String url = this .apiUrl + "/v2/project/" + this .apiKey + "/archive/" + archiveId + "/stop" ;
254
- Future <Response > request = this .preparePost (url ).execute ();
259
+ Future <Response > request = this .preparePost (url )
260
+ .setHeader ("Accept" , "application/json" )
261
+ .execute ();
255
262
256
263
try {
257
264
Response response = request .get ();
@@ -490,6 +497,7 @@ public String startBroadcast(String sessionId, BroadcastProperties properties) t
490
497
ObjectNode requestJson = nodeFactory .objectNode ();
491
498
requestJson .put ("sessionId" , sessionId );
492
499
requestJson .put ("streamMode" , properties .streamMode ().toString ());
500
+
493
501
if (properties .layout () != null ) {
494
502
ObjectNode layout = requestJson .putObject ("layout" );
495
503
screenshareType = properties .layout ().getScreenshareType ();
@@ -511,6 +519,7 @@ public String startBroadcast(String sessionId, BroadcastProperties properties) t
511
519
if (properties .resolution () != null ) {
512
520
requestJson .put ("resolution" , properties .resolution ());
513
521
}
522
+
514
523
ObjectNode outputs = requestJson .putObject ("outputs" );
515
524
if (properties .hasHls ()) {
516
525
ObjectNode hlsNode = nodeFactory .objectNode ();
@@ -521,6 +530,7 @@ public String startBroadcast(String sessionId, BroadcastProperties properties) t
521
530
hlsNode .put ("lowLatency" , hlsPojo .lowLatency ());
522
531
}
523
532
}
533
+
524
534
ArrayNode rtmp = outputs .putArray ("rtmp" );
525
535
for (RtmpProperties prop : properties .rtmpList ()) {
526
536
ObjectNode rtmpProps = nodeFactory .objectNode ();
@@ -540,6 +550,7 @@ public String startBroadcast(String sessionId, BroadcastProperties properties) t
540
550
Future <Response > request = this .preparePost (url )
541
551
.setBody (requestBody )
542
552
.setHeader ("Content-Type" , "application/json" )
553
+ .setHeader ("Accept" , "application/json" )
543
554
.execute ();
544
555
545
556
try {
@@ -566,11 +577,11 @@ public String startBroadcast(String sessionId, BroadcastProperties properties) t
566
577
}
567
578
568
579
public String stopBroadcast (String broadcastId ) throws OpenTokException {
569
- String requestBody = null ;
570
580
String url = this .apiUrl + "/v2/project/" + this .apiKey + "/broadcast/" + broadcastId + "/stop" ;
581
+
571
582
Future <Response > request = this .preparePost (url )
572
- .setBody (requestBody )
573
583
.setHeader ("Content-Type" , "application/json" )
584
+ .setHeader ("Accept" , "application/json" )
574
585
.execute ();
575
586
576
587
try {
@@ -595,14 +606,14 @@ public String stopBroadcast(String broadcastId) throws OpenTokException {
595
606
}
596
607
}
597
608
598
- public String getBroadcast (String broadcastId )
599
- throws OpenTokException {
600
- String requestBody = null ;
609
+ public String getBroadcast (String broadcastId ) throws OpenTokException {
601
610
String url = this .apiUrl + "/v2/project/" + this .apiKey + "/broadcast/" + broadcastId ;
611
+
602
612
Future <Response > request = this .prepareGet (url )
603
- .setBody (requestBody )
604
613
.setHeader ("Content-Type" , "application/json" )
614
+ .setHeader ("Accept" , "application/json" )
605
615
.execute ();
616
+
606
617
try {
607
618
Response response = request .get ();
608
619
switch (response .getStatusCode ()) {
@@ -629,13 +640,16 @@ public String patchBroadcast(String broadcastId, String addStream, String remove
629
640
String url = this .apiUrl + "/v2/project/" + this .apiKey + "/broadcast/" + broadcastId + "/streams" ;
630
641
JsonNodeFactory nodeFactory = JsonNodeFactory .instance ;
631
642
ObjectNode requestJson = nodeFactory .objectNode ();
643
+
632
644
if (removeStream != null && !removeStream .equals ("" )) {
633
645
requestJson .put ("removeStream" , removeStream );
634
- } else if (addStream != null && !addStream .equals ("" )) {
646
+ }
647
+ else if (addStream != null && !addStream .equals ("" )) {
635
648
requestJson .put ("hasAudio" , hasAudio );
636
649
requestJson .put ("hasVideo" , hasVideo );
637
650
requestJson .put ("addStream" , addStream );
638
- } else {
651
+ }
652
+ else {
639
653
throw new InvalidArgumentException ("Could not patch broadcast, needs one of: addStream or removeStream" );
640
654
}
641
655
@@ -682,6 +696,7 @@ public String setBroadcastLayout(String broadcastId, BroadcastProperties propert
682
696
String type = properties .layout ().getType ().toString ();
683
697
String stylesheet = properties .layout ().getStylesheet ();
684
698
String screenshareLayout = null ;
699
+
685
700
if (StringUtils .isEmpty (type )) {
686
701
throw new RequestException ("Could not set the layout. Either an invalid JSON or an invalid layout options." );
687
702
}
@@ -695,10 +710,13 @@ public String setBroadcastLayout(String broadcastId, BroadcastProperties propert
695
710
}
696
711
screenshareLayout = properties .layout ().getScreenshareType ().toString ();
697
712
}
713
+
698
714
String url = this .apiUrl + "/v2/project/" + this .apiKey + "/broadcast/" + broadcastId + "/layout" ;
715
+
699
716
JsonNodeFactory nodeFactory = JsonNodeFactory .instance ;
700
717
ObjectNode requestJson = nodeFactory .objectNode ();
701
718
requestJson .put ("type" , type );
719
+
702
720
if (type .equals (BroadcastLayout .Type .CUSTOM .toString ())) {
703
721
requestJson .put ("stylesheet" , properties .layout ().getStylesheet ());
704
722
}
@@ -716,6 +734,7 @@ public String setBroadcastLayout(String broadcastId, BroadcastProperties propert
716
734
.setBody (requestBody )
717
735
.setHeader ("Content-Type" , "application/json" )
718
736
.execute ();
737
+
719
738
try {
720
739
Response response = request .get ();
721
740
switch (response .getStatusCode ()) {
@@ -758,7 +777,6 @@ public String forceDisconnect(String sessionId, String connectionId) throws Open
758
777
} catch (InterruptedException | ExecutionException e ) {
759
778
throw new RequestException ("Could not force disconnect" , e );
760
779
}
761
-
762
780
}
763
781
764
782
public String sipDial (String sessionId , String token , SipProperties props ) throws OpenTokException {
@@ -817,7 +835,9 @@ public String sipDial(String sessionId, String token, SipProperties props) throw
817
835
Future <Response > request = this .preparePost (url )
818
836
.setBody (outputStream .toString ())
819
837
.setHeader ("Content-Type" , "application/json" )
838
+ .setHeader ("Accept" , "application/json" )
820
839
.execute ();
840
+
821
841
try {
822
842
Response response = request .get ();
823
843
switch (response .getStatusCode ()) {
@@ -870,7 +890,6 @@ public String playDtmf(String url, String dtmfDigits) throws OpenTokException {
870
890
} catch (InterruptedException | ExecutionException e ) {
871
891
throw new RequestException ("Could not play dtmf" );
872
892
}
873
-
874
893
}
875
894
876
895
public String playDtmfAll (String sessionId , String dtmfDigits ) throws OpenTokException {
@@ -1031,7 +1050,6 @@ public String disableForceMute(String sessionId) throws OpenTokException {
1031
1050
+ "sessionId: " + sessionId );
1032
1051
case 403 :
1033
1052
throw new RequestException ("Invalid OpenTok API key or JWT token." );
1034
-
1035
1053
case 408 :
1036
1054
throw new RequestException ("You passed in an invalid stream ID." );
1037
1055
case 500 :
@@ -1047,7 +1065,9 @@ public String disableForceMute(String sessionId) throws OpenTokException {
1047
1065
1048
1066
public String listStreams (String sessionId ) throws RequestException {
1049
1067
String url = this .apiUrl + "/v2/project/" + this .apiKey + "/session/" + sessionId + "/stream" ;
1050
- Future <Response > request = this .prepareGet (url ).execute ();
1068
+ Future <Response > request = this .prepareGet (url )
1069
+ .setHeader ("Accept" , "application/json" )
1070
+ .execute ();
1051
1071
1052
1072
try {
1053
1073
Response response = request .get ();
@@ -1069,7 +1089,6 @@ public String listStreams(String sessionId) throws RequestException {
1069
1089
} catch (InterruptedException | ExecutionException e ) {
1070
1090
throw new RequestException ("Could not get streams information" , e );
1071
1091
}
1072
-
1073
1092
}
1074
1093
1075
1094
public enum ProxyAuthScheme {
0 commit comments