我可以将ios应用程序与kurento room进行电话会议,没有任何问题,但是我无法将其与android连接,在这里,我正在按照Kurento WebRTC Peer For Android教程使Android客户端与kurento room进行连接。

这是我正在尝试的代码

public class MainActivity extends AppCompatActivity implements
RoomListener,NBMWebRTCPeer.Observer {

private LooperExecutor executor;
private static KurentoRoomAPI kurentoRoomAPI;

private EglBase rootEglBase;

private NBMWebRTCPeer nbmWebRTCPeer;
private SurfaceViewRenderer localView;
private SurfaceViewRenderer remoteView;
private VideoRenderer.Callbacks localRender;

private SessionDescription localSdp;
private SessionDescription remoteSdp;

NBMMediaConfiguration.NBMVideoFormat receiverVideoFormat = new NBMMediaConfiguration.NBMVideoFormat(1280, 720, ImageFormat.YUV_420_888, 30);
NBMMediaConfiguration mediaConfiguration = new NBMMediaConfiguration(NBMMediaConfiguration.NBMRendererType.OPENGLES, NBMMediaConfiguration.NBMAudioCodec.OPUS, 0, NBMMediaConfiguration.NBMVideoCodec.VP8, 0, receiverVideoFormat, NBMMediaConfiguration.NBMCameraPosition.FRONT);

private boolean isMyVideoPublished = false;
private boolean isMyIceCandidateSent = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

        int hasCameraPermission = checkSelfPermission(Manifest.permission.CAMERA);

        List<String> permissions = new ArrayList<String>();

        if (hasCameraPermission != PackageManager.PERMISSION_GRANTED) {
            permissions.add(Manifest.permission.CAMERA);

        }
        if (!permissions.isEmpty()) {
            requestPermissions(permissions.toArray(new String[permissions.size()]), 111);
        }
    }

    executor = new LooperExecutor();
    executor.requestStart();
    String wsRoomUri = "wss://172.16.1.9:8443/room";
    kurentoRoomAPI = new KurentoRoomAPI(executor, wsRoomUri, this);
    kurentoRoomAPI.connectWebSocket();


    localView = (SurfaceViewRenderer) findViewById(R.id.gl_surface_local);
    remoteView = (SurfaceViewRenderer) findViewById(R.id.gl_surface_remote);

    localView.init(EglBase.create().getEglBaseContext(), null);
    localView.setZOrderMediaOverlay(true);
    localView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
    localView.setMirror(true);
    localView.requestLayout();

    remoteView.init(EglBase.create().getEglBaseContext(), null);
    remoteView.setZOrderMediaOverlay(true);
    remoteView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
    remoteView.setMirror(true);
    remoteView.requestLayout();

    nbmWebRTCPeer = new NBMWebRTCPeer(mediaConfiguration, this, localView, this);
    nbmWebRTCPeer.initialize();

    //nbmWebRTCPeer.generateOffer("local", true);
    //nbmWebRTCPeer.generateOffer("MyRemotePeer", false);

}

@Override
public void onRoomResponse(RoomResponse response) {
    Log.d("onRoomResponse", "******** onRoomResponse : "+response.toString());
    if (response.getId() == 123) {
        Log.d("onRoomResponse", "Successfully connected to the room!");
        nbmWebRTCPeer.generateOffer("Jeeva", true);
        //kurentoRoomAPI.sendMessage("112233", "Jeeva Moto", "Hello room!", 125);
    } else if (response.getId() == 125) {
        Log.d("onRoomResponse", "The server received my message!");
    } else if (response.getId() == 126) {

    }else if (response.getId() == 129) {

    }
}

@Override
public void onRoomError(RoomError error) {
    Log.d("onRoomError", "******** onRoomError : "+error.toString());
}

@Override
public void onRoomNotification(RoomNotification notification) {
    if(notification.getMethod().equals(RoomListener.METHOD_SEND_MESSAGE)) {
        final String username = notification.getParam("user").toString();
        final String message = notification.getParam("message").toString();
        Log.d("onRoomNotification", "Oh boy! " + username + " sent me a message: " + message);
    }

    Log.d("onRoomNotification", "******** RoomNotification : " + notification);


    if(notification.getMethod().equals("iceCandidate"))
    {
        Map<String, Object> map = notification.getParams();
        Log.d("onRoomNotification", "******** Map RoomNotification : " + map);

        String sdpMid = map.get("sdpMid").toString();
        int sdpMLineIndex = Integer.valueOf(map.get("sdpMLineIndex").toString());
        String sdp = map.get("candidate").toString();

        IceCandidate ic = new IceCandidate(sdpMid, sdpMLineIndex, sdp);

        nbmWebRTCPeer.addRemoteIceCandidate(ic, "remote");
    }
}

@Override
public void onRoomConnected() {

    Log.d("onRoomConnected","******** Called");
    kurentoRoomAPI.sendJoinRoom("Jeeva", "112233", true, 123);
}

@Override
public void onRoomDisconnected() {

}

@Override
public void onInitialize() {

}

@Override
public void onLocalSdpOfferGenerated(SessionDescription localSdpOffer, NBMPeerConnection connection) {


    Log.d("onLclSdpOfrGen","******** localSdpOffer : "+localSdpOffer.description+" connection : "+connection.getConnectionId());

    if (!isMyVideoPublished) {

        kurentoRoomAPI.sendPublishVideo(localSdpOffer.description,false,129);

        //String username = "qwerty";
        //kurentoRoomAPI.sendReceiveVideoFrom(username, "webcam", localSdpOffer.description, 129);

        isMyVideoPublished = true;
    }else {

        String username = "qwerty";
        kurentoRoomAPI.sendReceiveVideoFrom(username, "webcam", localSdpOffer.description, 129);

    }


}

@Override
public void onLocalSdpAnswerGenerated(SessionDescription localSdpAnswer, NBMPeerConnection connection) {
    Log.d("onLclSdpAnsGen","******** localSdpAnswer : "+localSdpAnswer.description+" connection : "+connection.getConnectionId());
}

@Override
public void onIceCandidate(IceCandidate iceCandidate, NBMPeerConnection nbmPeerConnection) {

    Log.d("onIceCandidate", "******** iceCandidate : " + iceCandidate.sdp + " nbmPeerConnection : " + nbmPeerConnection.getConnectionId());

    if (!isMyIceCandidateSent){
        isMyIceCandidateSent = true;
        kurentoRoomAPI.sendOnIceCandidate("Jeeva", iceCandidate.sdp, iceCandidate.sdpMid, Integer.toString(iceCandidate.sdpMLineIndex),129);
    } else {
        kurentoRoomAPI.sendOnIceCandidate("qwerty", iceCandidate.sdp,
                iceCandidate.sdpMid, Integer.toString(iceCandidate.sdpMLineIndex), 129);
        nbmWebRTCPeer.addRemoteIceCandidate(iceCandidate, iceCandidate.sdp);
    }
}

@Override
public void onIceStatusChanged(PeerConnection.IceConnectionState state, NBMPeerConnection connection) {
    Log.d("onIceStatusChanged","******** state : "+state+" connection : "+connection);

}

@Override
public void onRemoteStreamAdded(MediaStream stream, NBMPeerConnection connection) {
    Log.d("onRemoteStreamAdded","******** stream : "+stream+" connection : "+connection);

    nbmWebRTCPeer.attachRendererToRemoteStream(remoteView, stream);
}

@Override
public void onRemoteStreamRemoved(MediaStream stream, NBMPeerConnection connection) {
    Log.d("onRemoteStreamRemoved","******** stream : "+stream+" connection : "+connection);

}

@Override
public void onPeerConnectionError(String error) {
    Log.d("onPeerConnectionError","******** error : "+error);

}

@Override
public void onDataChannel(DataChannel dataChannel, NBMPeerConnection connection) {
    Log.d("onDataChannel","******** dataChannel : "+dataChannel+" connection : "+connection);

}

@Override
public void onBufferedAmountChange(long l, NBMPeerConnection connection, DataChannel channel) {
    Log.d("onBufferedAmountChange","******** channel : "+channel+" connection : "+connection);

}

@Override
public void onStateChange(NBMPeerConnection connection, DataChannel channel) {
    Log.d("onStateChange","******** channel : "+channel+" connection : "+connection);

}

@Override
public void onMessage(DataChannel.Buffer buffer, NBMPeerConnection connection, DataChannel channel) {

    Log.d("onMessage","******** channel : "+channel+" buffer : "+buffer+" connection : "+connection);

}}


我正在寻找连接kurento进行电话会议的android客户端的任何工作示例。

最佳答案

Kurento还使用简单的UI完成了Android客户端。

它允许使用其KurentoAPI连接到“ kurento-room”服务器。

它只有2p2,但是包含所有必需信令的实现,因此这可能是一个不错的起点。

更多详细信息是there

关于android - kurento session 室的Android客户端,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44258756/

10-10 04:32