buzolive
New Member
hello sir,
when i am going live then camera going so much zoom and some time crashing on media connection exception..
here is my code to start publish...
Flashphoner.init(this);
Flashphoner.getAudioManager().setUseSpeakerPhone(true);
binding.localRender.setZOrderMediaOverlay(true);
binding.preview.setPosition(0, 0, 100, 100);
binding.localRender.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
binding.localRender.setMirror(true);
binding.localRender.requestLayout();
URI u = null;
try {
u = new URI("my url");
} catch (URISyntaxException e) {
Commn.showErrorLog("URISyntaxException:" + e.getMessage() + "," + e.getReason() + "");
e.printStackTrace();
}
String url = null;
if (u != null) {
url = u.getScheme() + "://" + u.getHost() + ":" + u.getPort();
Commn.showErrorLog("get url:" + url + "");
} else {
Commn.showErrorLog("null uri:" + "");
}
SessionOptions sessionOptions = new SessionOptions(url);
sessionOptions.setLocalRenderer(binding.localRender);
session = Flashphoner.createSession(sessionOptions);
session.on(new SessionEvent() {
@Override
public void onAppData(Data data) {
Commn.showErrorLog("onAppData" + data.toString() + "");
}
@Override
public void onConnected(final Connection connection) {
runOnUiThread(() -> {
Commn.showErrorLog("my_stream_name:" + stream_id + "");
StreamOptions streamOptions = new StreamOptions(stream_id);
VideoConstraints videoConstraints = new VideoConstraints();
//videoConstraints.setCameraId(((MediaDevice)mCameraSpinner.getSpinner().getSelectedItem()).getId());
videoConstraints.setCameraId(Flashphoner.getMediaDevices().getVideoList().get(1).getId());
DisplayMetrics metrics = getResources().getDisplayMetrics();
Commn.showErrorLog("my resolution:" + "width:" + metrics.widthPixels + ",height:" + metrics.heightPixels + "");
videoConstraints.setResolution(metrics.widthPixels, metrics.heightPixels);
videoConstraints.setQuality(200);
// videoConstraints.setBitrate(1200000);
streamOptions.getConstraints().setVideoConstraints(videoConstraints);
streamOptions.setConstraints(new Constraints(new AudioConstraints(), videoConstraints));
publishStream = session.createStream(streamOptions);
publishStream.publish();
publishStream.on(new StreamStatusEvent() {
@Override
public void onStreamStatus(Stream stream, StreamStatus streamStatus) {
Commn.showDebugLog("onConnected" + String.valueOf(streamStatus));
if (StreamStatus.FAILED.equals(streamStatus)) {
switch (stream.getInfo()) {
case StreamStatusInfo.SESSION_DOES_NOT_EXIST:
Commn.showErrorLog(streamStatus + ": Actual session does not exist");
break;
case StreamStatusInfo.STOPPED_BY_PUBLISHER_STOP:
Commn.showErrorLog(streamStatus + ": Related publisher stopped its stream or lost connection");
break;
case StreamStatusInfo.SESSION_NOT_READY:
Commn.showErrorLog(streamStatus + ": Session is not initialized or terminated on play ordinary stream");
break;
case StreamStatusInfo.RTSP_STREAM_NOT_FOUND:
Commn.showErrorLog(streamStatus + ": Rtsp stream not found where agent received '404-Not Found'");
break;
case StreamStatusInfo.FAILED_TO_CONNECT_TO_RTSP_STREAM:
Commn.showErrorLog(streamStatus + ": Failed to connect to rtsp stream");
break;
case StreamStatusInfo.FILE_NOT_FOUND:
Commn.showErrorLog(streamStatus + ": File does not exist, check filename");
break;
case StreamStatusInfo.FILE_HAS_WRONG_FORMAT:
Commn.showErrorLog(streamStatus + ": File has wrong format on play vod, this format is not supported");
break;
case StreamStatusInfo.STREAM_NAME_ALREADY_IN_USE:
Commn.myToast(context, "Server already has a publish stream with the same name, try using different one");
Commn.showErrorLog(streamStatus + ": Server already has a publish stream with the same name, try using different one");
break;
default: {
Commn.showErrorLog(stream.getInfo());
}
}
} else {
Commn.showErrorLog(streamStatus.toString());
}
}
});
});
when i am going live then camera going so much zoom and some time crashing on media connection exception..
here is my code to start publish...
Flashphoner.init(this);
Flashphoner.getAudioManager().setUseSpeakerPhone(true);
binding.localRender.setZOrderMediaOverlay(true);
binding.preview.setPosition(0, 0, 100, 100);
binding.localRender.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
binding.localRender.setMirror(true);
binding.localRender.requestLayout();
URI u = null;
try {
u = new URI("my url");
} catch (URISyntaxException e) {
Commn.showErrorLog("URISyntaxException:" + e.getMessage() + "," + e.getReason() + "");
e.printStackTrace();
}
String url = null;
if (u != null) {
url = u.getScheme() + "://" + u.getHost() + ":" + u.getPort();
Commn.showErrorLog("get url:" + url + "");
} else {
Commn.showErrorLog("null uri:" + "");
}
SessionOptions sessionOptions = new SessionOptions(url);
sessionOptions.setLocalRenderer(binding.localRender);
session = Flashphoner.createSession(sessionOptions);
session.on(new SessionEvent() {
@Override
public void onAppData(Data data) {
Commn.showErrorLog("onAppData" + data.toString() + "");
}
@Override
public void onConnected(final Connection connection) {
runOnUiThread(() -> {
Commn.showErrorLog("my_stream_name:" + stream_id + "");
StreamOptions streamOptions = new StreamOptions(stream_id);
VideoConstraints videoConstraints = new VideoConstraints();
//videoConstraints.setCameraId(((MediaDevice)mCameraSpinner.getSpinner().getSelectedItem()).getId());
videoConstraints.setCameraId(Flashphoner.getMediaDevices().getVideoList().get(1).getId());
DisplayMetrics metrics = getResources().getDisplayMetrics();
Commn.showErrorLog("my resolution:" + "width:" + metrics.widthPixels + ",height:" + metrics.heightPixels + "");
videoConstraints.setResolution(metrics.widthPixels, metrics.heightPixels);
videoConstraints.setQuality(200);
// videoConstraints.setBitrate(1200000);
streamOptions.getConstraints().setVideoConstraints(videoConstraints);
streamOptions.setConstraints(new Constraints(new AudioConstraints(), videoConstraints));
publishStream = session.createStream(streamOptions);
publishStream.publish();
publishStream.on(new StreamStatusEvent() {
@Override
public void onStreamStatus(Stream stream, StreamStatus streamStatus) {
Commn.showDebugLog("onConnected" + String.valueOf(streamStatus));
if (StreamStatus.FAILED.equals(streamStatus)) {
switch (stream.getInfo()) {
case StreamStatusInfo.SESSION_DOES_NOT_EXIST:
Commn.showErrorLog(streamStatus + ": Actual session does not exist");
break;
case StreamStatusInfo.STOPPED_BY_PUBLISHER_STOP:
Commn.showErrorLog(streamStatus + ": Related publisher stopped its stream or lost connection");
break;
case StreamStatusInfo.SESSION_NOT_READY:
Commn.showErrorLog(streamStatus + ": Session is not initialized or terminated on play ordinary stream");
break;
case StreamStatusInfo.RTSP_STREAM_NOT_FOUND:
Commn.showErrorLog(streamStatus + ": Rtsp stream not found where agent received '404-Not Found'");
break;
case StreamStatusInfo.FAILED_TO_CONNECT_TO_RTSP_STREAM:
Commn.showErrorLog(streamStatus + ": Failed to connect to rtsp stream");
break;
case StreamStatusInfo.FILE_NOT_FOUND:
Commn.showErrorLog(streamStatus + ": File does not exist, check filename");
break;
case StreamStatusInfo.FILE_HAS_WRONG_FORMAT:
Commn.showErrorLog(streamStatus + ": File has wrong format on play vod, this format is not supported");
break;
case StreamStatusInfo.STREAM_NAME_ALREADY_IN_USE:
Commn.myToast(context, "Server already has a publish stream with the same name, try using different one");
Commn.showErrorLog(streamStatus + ": Server already has a publish stream with the same name, try using different one");
break;
default: {
Commn.showErrorLog(stream.getInfo());
}
}
} else {
Commn.showErrorLog(streamStatus.toString());
}
}
});
});