mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-20 19:25:01 +01:00
Additional logging
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
ef2d1b8c92
commit
7d44805c9e
@ -21,9 +21,11 @@
|
|||||||
|
|
||||||
package com.nextcloud.talk.webrtc;
|
package com.nextcloud.talk.webrtc;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import autodagger.AutoInjector;
|
||||||
import com.bluelinelabs.logansquare.LoganSquare;
|
import com.bluelinelabs.logansquare.LoganSquare;
|
||||||
import com.nextcloud.talk.R;
|
import com.nextcloud.talk.R;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
@ -33,15 +35,18 @@ import com.nextcloud.talk.events.SessionDescriptionSendEvent;
|
|||||||
import com.nextcloud.talk.events.WebSocketCommunicationEvent;
|
import com.nextcloud.talk.events.WebSocketCommunicationEvent;
|
||||||
import com.nextcloud.talk.models.json.signaling.DataChannelMessage;
|
import com.nextcloud.talk.models.json.signaling.DataChannelMessage;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCIceCandidate;
|
import com.nextcloud.talk.models.json.signaling.NCIceCandidate;
|
||||||
|
import com.nextcloud.talk.utils.LoggingUtils;
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.webrtc.*;
|
import org.webrtc.*;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@AutoInjector(NextcloudTalkApplication.class)
|
||||||
public class MagicPeerConnectionWrapper {
|
public class MagicPeerConnectionWrapper {
|
||||||
private static String TAG = "MagicPeerConnectionWrapper";
|
private static String TAG = "MagicPeerConnectionWrapper";
|
||||||
private List<IceCandidate> iceCandidates = new ArrayList<>();
|
private List<IceCandidate> iceCandidates = new ArrayList<>();
|
||||||
@ -62,12 +67,17 @@ public class MagicPeerConnectionWrapper {
|
|||||||
private boolean isMCUPublisher;
|
private boolean isMCUPublisher;
|
||||||
private String videoStreamType;
|
private String videoStreamType;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Context context;
|
||||||
|
|
||||||
public MagicPeerConnectionWrapper(PeerConnectionFactory peerConnectionFactory,
|
public MagicPeerConnectionWrapper(PeerConnectionFactory peerConnectionFactory,
|
||||||
List<PeerConnection.IceServer> iceServerList,
|
List<PeerConnection.IceServer> iceServerList,
|
||||||
MediaConstraints mediaConstraints,
|
MediaConstraints mediaConstraints,
|
||||||
String sessionId, String localSession, @Nullable MediaStream mediaStream,
|
String sessionId, String localSession, @Nullable MediaStream mediaStream,
|
||||||
boolean isMCUPublisher, boolean hasMCU, String videoStreamType) {
|
boolean isMCUPublisher, boolean hasMCU, String videoStreamType) {
|
||||||
|
|
||||||
|
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||||
|
|
||||||
this.localMediaStream = mediaStream;
|
this.localMediaStream = mediaStream;
|
||||||
this.videoStreamType = videoStreamType;
|
this.videoStreamType = videoStreamType;
|
||||||
|
|
||||||
@ -231,6 +241,8 @@ public class MagicPeerConnectionWrapper {
|
|||||||
data.get(bytes);
|
data.get(bytes);
|
||||||
String strData = new String(bytes);
|
String strData = new String(bytes);
|
||||||
Log.d(TAG, "Got msg: " + strData + " over " + TAG + " " + sessionId);
|
Log.d(TAG, "Got msg: " + strData + " over " + TAG + " " + sessionId);
|
||||||
|
LoggingUtils.writeLogEntryToFile(context,
|
||||||
|
"Got msg: " + strData + " over " + peerConnection.hashCode() + " " + sessionId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DataChannelMessage dataChannelMessage = LoganSquare.parse(strData, DataChannelMessage.class);
|
DataChannelMessage dataChannelMessage = LoganSquare.parse(strData, DataChannelMessage.class);
|
||||||
@ -284,6 +296,9 @@ public class MagicPeerConnectionWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
|
public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
|
||||||
|
LoggingUtils.writeLogEntryToFile(context,
|
||||||
|
"iceConnectionChangeTo: " + iceConnectionState.name() + " over " + peerConnection.hashCode() + " " + sessionId);
|
||||||
|
|
||||||
if (iceConnectionState.equals(PeerConnection.IceConnectionState.CONNECTED)) {
|
if (iceConnectionState.equals(PeerConnection.IceConnectionState.CONNECTED)) {
|
||||||
/*EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
/*EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||||
.PEER_CONNECTED, sessionId, null, null));*/
|
.PEER_CONNECTED, sessionId, null, null));*/
|
||||||
@ -363,11 +378,16 @@ public class MagicPeerConnectionWrapper {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreateFailure(String s) {
|
public void onCreateFailure(String s) {
|
||||||
Log.d(TAG, s);
|
Log.d(TAG, s);
|
||||||
|
LoggingUtils.writeLogEntryToFile(context,
|
||||||
|
"SDPObserver createFailure: " + s + " over " + peerConnection.hashCode() + " " + sessionId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetFailure(String s) {
|
public void onSetFailure(String s) {
|
||||||
Log.d(TAG, s);
|
Log.d(TAG, s);
|
||||||
|
LoggingUtils.writeLogEntryToFile(context,
|
||||||
|
"SDPObserver setFailure: " + s + " over " + peerConnection.hashCode() + " " + sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,6 +33,7 @@ import com.nextcloud.talk.models.database.UserEntity;
|
|||||||
import com.nextcloud.talk.models.json.signaling.NCMessageWrapper;
|
import com.nextcloud.talk.models.json.signaling.NCMessageWrapper;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage;
|
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.*;
|
import com.nextcloud.talk.models.json.websocket.*;
|
||||||
|
import com.nextcloud.talk.utils.LoggingUtils;
|
||||||
import com.nextcloud.talk.utils.MagicMap;
|
import com.nextcloud.talk.utils.MagicMap;
|
||||||
import com.nextcloud.talk.utils.singletons.MerlinTheWizard;
|
import com.nextcloud.talk.utils.singletons.MerlinTheWizard;
|
||||||
import com.novoda.merlin.Endpoint;
|
import com.novoda.merlin.Endpoint;
|
||||||
@ -143,6 +144,9 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
public void onMessage(WebSocket webSocket, String text) {
|
public void onMessage(WebSocket webSocket, String text) {
|
||||||
if (webSocket == internalWebSocket) {
|
if (webSocket == internalWebSocket) {
|
||||||
Log.d(TAG, "Receiving : " + text);
|
Log.d(TAG, "Receiving : " + text);
|
||||||
|
LoggingUtils.writeLogEntryToFile(context,
|
||||||
|
"WebSocket " + webSocket.hashCode() + " receiving: " + text);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BaseWebSocketMessage baseWebSocketMessage = LoganSquare.parse(text, BaseWebSocketMessage.class);
|
BaseWebSocketMessage baseWebSocketMessage = LoganSquare.parse(text, BaseWebSocketMessage.class);
|
||||||
String messageType = baseWebSocketMessage.getType();
|
String messageType = baseWebSocketMessage.getType();
|
||||||
@ -166,6 +170,8 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
case "error":
|
case "error":
|
||||||
ErrorOverallWebSocketMessage errorOverallWebSocketMessage = LoganSquare.parse(text, ErrorOverallWebSocketMessage.class);
|
ErrorOverallWebSocketMessage errorOverallWebSocketMessage = LoganSquare.parse(text, ErrorOverallWebSocketMessage.class);
|
||||||
if (("no_such_session").equals(errorOverallWebSocketMessage.getErrorWebSocketMessage().getCode())) {
|
if (("no_such_session").equals(errorOverallWebSocketMessage.getErrorWebSocketMessage().getCode())) {
|
||||||
|
LoggingUtils.writeLogEntryToFile(context,
|
||||||
|
"WebSocket " + webSocket.hashCode() + " resumeID " + resumeId + " expired");
|
||||||
resumeId = "";
|
resumeId = "";
|
||||||
restartWebSocket();
|
restartWebSocket();
|
||||||
} else if (("hello_expected").equals(errorOverallWebSocketMessage.getErrorWebSocketMessage().getCode())) {
|
} else if (("hello_expected").equals(errorOverallWebSocketMessage.getErrorWebSocketMessage().getCode())) {
|
||||||
@ -250,7 +256,9 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to WebSocket message");
|
LoggingUtils.writeLogEntryToFile(context,
|
||||||
|
"WebSocket " + webSocket.hashCode() + " IOException: " + e.getMessage());
|
||||||
|
Log.e(TAG, "Failed to recognize WebSocket message");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,11 +271,15 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onClosing(WebSocket webSocket, int code, String reason) {
|
public void onClosing(WebSocket webSocket, int code, String reason) {
|
||||||
Log.d(TAG, "Closing : " + code + " / " + reason);
|
Log.d(TAG, "Closing : " + code + " / " + reason);
|
||||||
|
LoggingUtils.writeLogEntryToFile(context,
|
||||||
|
"WebSocket " + webSocket.hashCode() + " Closing: " + reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||||
Log.d(TAG, "Error : " + t.getMessage());
|
Log.d(TAG, "Error : " + t.getMessage());
|
||||||
|
LoggingUtils.writeLogEntryToFile(context,
|
||||||
|
"WebSocket " + webSocket.hashCode() + " onFailure: " + t.getMessage());
|
||||||
closeWebSocket(webSocket);
|
closeWebSocket(webSocket);
|
||||||
restartWebSocket();
|
restartWebSocket();
|
||||||
}
|
}
|
||||||
@ -302,6 +314,8 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
internalWebSocket.send(message);
|
internalWebSocket.send(message);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
LoggingUtils.writeLogEntryToFile(context,
|
||||||
|
"WebSocket sendCalLMessage: " + e.getMessage() + "\n" + ncMessageWrapper.toString());
|
||||||
Log.e(TAG, "Failed to serialize signaling message");
|
Log.e(TAG, "Failed to serialize signaling message");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,6 +335,8 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||||||
internalWebSocket.send(message);
|
internalWebSocket.send(message);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
LoggingUtils.writeLogEntryToFile(context,
|
||||||
|
"WebSocket requestOfferForSessionIdWithType: " + e.getMessage() + "\n" + sessionIdParam + " " + roomType);
|
||||||
Log.e(TAG, "Failed to offer request");
|
Log.e(TAG, "Failed to offer request");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user