WebRTC for Android: Crashes on second call - android

I have developed an Android app for video conference using WebRTC. I used the available Java Library for the same.
I can successfully make a P2P call. However, when i make the same P2P call again one-after-another, I get the following error:
SetRemoteDescription failed: Called with type in wrong state, type: answer state:
STATE_INPROGRESS
However when I restart the app, I can make the call again, it works flawlessly.
Summary: In order to make a second call, I have to restart the application. It might be because of some possible caching of some objects like PC, SDPObserver or PCObserver. I make all of them null and also kill the activity after the first call. Even then second call doesn't work unless I restart my app.
What can be the possible cause?

It sounds like the local resources are not properly disposed even though you are killing the activity.
Make sure you are calling when the video call ends:
peerConnection.dispose();
videoSource.dispose();
peerConnectionFactory.dispose();
You can test that this works on the AppRTCDemo reference app. Here is the reference code.

Related

Use Single PeerConnection for two different plugins of janus (VideoRoom & AudioBridge) in one Android Activity - Android

Prerequisite:
I have added VideoRoom functionality in one activity and it is working fine
Then i added AudioBridge functionality in another activity and it also worked fine
Then i went to add both the functionalities in one Activity. VideoRoom functionality called first so it worked fine. Then AudioBridge functionality calls to join audioRoom through AudioBridge, Here "ICE failed" happens with"hangup" janus event, but VideoRoom call working fine.
I have 2 separate PeerConnections for both. If i commented out VideoRoom call, then Audio call connected and works fine.
Required:
I want is to make 2 calls simultaneously in the same activity (i-e VideoRoom call and AudioBridge audio call).
Problem:
But here i guess 2 PeerConnections with same Janus Server cannot work.
I want to make Single PeerConnection so i can use that for both Calls (VideoRoom & AudioBridge).
How i can do it?. Can you refer any example like this. I am unable to find one.
Because While creating PeerConnection for VideoRoom i am passing PeerConnectionParameters for VideoRoom. Clearly i cannot use that as i have to pass parameters for AudioBridge in that while connecting.
Thanks.

Troubles calling web services with WSDL Importer

I have built an application that calls a webservice in order to retrieve some information. This application is designed to work both on android and windows (using the firemonkey framework).
The object that calls the webservice has been built with a WSDL importer and works great when running the application on windows.
Nonetheless, when i try to use my application on an android device, i can only call the webservice two times. On the third time, the application freeze.
I have tried to do some debug and it appears that the application freezes when trying to call the web service :
genEtq := GetIGenerationEtiquettes(); // Converts a THttpRio as a IGenerationEtiquette object
soapattachmnt := genEtq.GetImageEtiquette(idEtiquette); // Calls web service -> freeze on third time
//
// Do something ...
//
The webservice is hosted on my computer so i'm sure there is no troubles on the service side. In addition, when i restart the application, i can still call the web service two times.
My application has the authorization to access to the internet on my android device so i'm running out of ideas on what's the problem.
Also i have tried to monitor the network (via wireshark) and i had been able to see the two first requests but not the third one.
Do you have any ideas on how to find the problem ?
Finally i have found the answer, my mistake was to call everytime the GetIGenerationEtiquettes() function instead of storing the resulting object.
Now i can call my webservice as often as i want.
Hope this answer will help someone.

android: what is the onCreate equivalent in unity script?

I have a unity app that should run on android. I have some native code (inside a plugin) that I need to call in order to process deep-link activation of the app, and I need to call it from my unity script when the app gets reopened by that deep link. Where is the appropriate place to make that call?
Note OnApplicationPause is not a good option, since it mimics onResume, and you MUST NOT process deep links inside onResume on Android because it will cause them to get re-processed over and over every time the app is reopened after the initial click on the deep link.
So basically, I am looking for a lifecycle-equivalent to onCreate, but in unity script (I do not have legal permissions to replace the native unity activity in this case and simply override its onCreate method).
onCreate() is run basically on the initialization of any activity. It's kind of hard to think about it in terms of Unity3D. When you call a level the Start() and Awake() are called, the latter first. You could potentially UnitySendMessage() from your native plugin on the java Android side. I believe the syntax looks like:
UnityPlayer.UnitySendMessage("GameObjectName1", "MethodName1", "Message to send");
And inside your GameObjectName1 construct MethodName1 method with string params passed:
function void MethodName1 (message:String) {}
Not sure if this will suffice for your needs. I've done comparable with iOS, i'm sure there should be an Android equivalent with Unity3D.

Detect when an external android app runs onCreate, onStart, onResume methods

I want to know how to detect when an external app runs one of this methods. I'm working with some classmates in a project where we want to examinate the response time of other applications. The idea is to measure the time between the run of each method to get an aproximation of the response time when opening the app.
Is this possible to achieve?
Android apps are sandboxed and only expose content that they intend to expose. The methods you name are part of components that cannot be accessed directly from the "outside" world. In other ways, if an app wanted you to know when those methods are being called, they will expose that information (i.e. sending a Broadcast or maybe storing the information in a ContentProvider). You can try and see if you can get some information out of the logcat, but I cannot assure how accurate and consistent it will be.
This is imprecise, but I would monitor logcat activity. Depending on the device/VM/AVD logcat is super active during transitions (such as back-grounding and foregrounding) and idle when an app is awaiting user input.
EDIT:
Other than that, if you can do your analysis off the device, perhaps look into using DDMS?

Android SDK. call onDestroy() directly in scripting

I have an android app, ATV Trail Locator (http://www.youtube.com/watch?v=Wmk3cA2i2vI), that uses google maps.
Because my server is used for web serving and the Android app, I want to be able to kill the app in case it takes up too many server resources by setting a variable in my mysql database.
Because the application communicates with The server every second, it can get this variable and then shutdown the program if it is equal to 0.
I tried to call onDestroy() directly, but my program crashed. Do I need to use super.onDestroy() in order to kill the program without requiring back button push?
Thanks,
Have you tried calling finish() instead?
If this doesn't work, please post a code sample and your logcat errors so we can see what is happening.
Call finish() whenever you want to kill the current activity you're on. It'll call onDestroy() along with all the other required Activity lifecycle methods that need to be called.

Categories

Resources