-
Notifications
You must be signed in to change notification settings - Fork 153
Description
in Streamer class:
startStreaming method:
if (muxer.isConnected())
this condition called after muxer.open(url, width, height);
but muxer.open is async method.
so sometimes run muxer.isConnected() then run rtmpMuxer.open((String) msg.obj, msg.arg1, msg.arg2);
that's make muxer.isConnected() allways return false;
so in Muxer class:
private ArrayBlockingQueue waiterLock = new ArrayBlockingQueue<>(10);
void open(String url, int width, int height) {
Message message = handler.obtainMessage(MSG_OPEN, url);
message.arg1 = width;
message.arg2 = height;
handler.sendMessage(message);
try {
waiterLock.take();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
case MSG_OPEN:
rtmpMuxer.open((String) msg.obj, msg.arg1, msg.arg2);
try {
if (listener != null) {
uiHandler.post(new Runnable() {
@OverRide
public void run() {
if (isConnected()) {
listener.onStarted();
disconnected = false;
closed = false;
} else {
listener.onFailedToConnect();
}
}
});
}
waiterLock.put(true);
} catch (InterruptedException e) {
e.printStackTrace();
break;
}
break;