Skip to content

Commit 40388f3

Browse files
committed
Added flag to prevent handshake validation failure with youtube
1 parent c1c9f7e commit 40388f3

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

src/main/java/org/red5/client/net/rtmp/OutboundHandshake.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public class OutboundHandshake extends RTMPHandshake {
5656
// server initial response S1
5757
private byte[] s1 = null;
5858

59+
// whether or not verification is mandatory
60+
private boolean forceVerification;
61+
5962
public OutboundHandshake() {
6063
super(RTMPConnection.RTMP_NON_ENCRYPTED);
6164
log = LoggerFactory.getLogger(OutboundHandshake.class);
@@ -377,6 +380,10 @@ private boolean getServerDigestPosition() {
377380
log.debug("Server digest position offset: {}", digestPosServer);
378381
if (!(result = verifyDigest(digestPosServer, s1, GENUINE_FMS_KEY, 36))) {
379382
log.warn("Server digest verification failed");
383+
// if we dont mind that verification routines failed
384+
if (!forceVerification) {
385+
return true;
386+
}
380387
} else {
381388
log.debug("Server digest verified");
382389
}
@@ -463,4 +470,8 @@ public byte[] getHandshakeBytes() {
463470
return c1;
464471
}
465472

473+
public void setForceVerification(boolean forceVerification) {
474+
this.forceVerification = forceVerification;
475+
}
476+
466477
}

src/test/java/org/red5/client/net/rtmp/YouTubeConnectTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ public void testYouTubePublish() throws InterruptedException {
4444
String youtubeHost = "a.rtmp.youtube.com";
4545
int youtubePort = 1935;
4646
String youtubeApp = "live2";
47-
final String youtubePublishName = System.getProperty("youtube.streamname");
48-
if (youtubePublishName == null) {
49-
log.info("You forgot to set a 'youtube.streamname' system property");
50-
return;
51-
}
47+
final String youtubePublishName = "dybx-y3ph-uqzx-30vx"; //System.getProperty("youtube.streamname");
48+
log.info("youtubePublishName: {}", youtubePublishName);
49+
// if (youtubePublishName == null) {
50+
// log.info("You forgot to set a 'youtube.streamname' system property");
51+
// return;
52+
// }
5253

5354
final RTMPClient client = new RTMPClient();
5455
client.setConnectionClosedHandler(new Runnable() {
@@ -66,13 +67,13 @@ public void handleException(Throwable throwable) {
6667
client.setStreamEventDispatcher(new IEventDispatcher() {
6768
@Override
6869
public void dispatchEvent(IEvent event) {
69-
log.info("ClientStream.dispachEvent() {}", event);
70+
log.info("ClientStream.dispachEvent: {}", event);
7071
}
7172
});
7273
final INetStreamEventHandler netStreamEventHandler = new INetStreamEventHandler() {
7374
@Override
7475
public void onStreamEvent(Notify notify) {
75-
log.info("ClientStream.dispachEvent() {}", notify);
76+
log.info("ClientStream.onStreamEvent: {}", notify);
7677
}
7778
};
7879
client.setStreamEventHandler(netStreamEventHandler);
@@ -91,7 +92,7 @@ public void resultReceived(IPendingServiceCall call) {
9192
client.createStream(new IPendingServiceCallback() {
9293
@Override
9394
public void resultReceived(IPendingServiceCall call) {
94-
int streamId = (Integer) call.getResult();
95+
double streamId = (Double) call.getResult();
9596
// live buffer 0.5s
9697
@SuppressWarnings("unused")
9798
RTMPConnection conn = (RTMPConnection) Red5.getConnectionLocal();

0 commit comments

Comments
 (0)