Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes can not publish #33

Open
Anveena opened this issue Feb 9, 2020 · 0 comments
Open

Sometimes can not publish #33

Anveena opened this issue Feb 9, 2020 · 0 comments

Comments

@Anveena
Copy link

Anveena commented Feb 9, 2020

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant