Commit graph

224 commits

Author SHA1 Message Date
Michael Kirk
8da3108b53 Drop stale EndCall/BusyCall messages
// FREEBIE
2017-08-11 07:35:48 -04:00
Matthew Chen
d9bc3ac806 Respond to CR.
// FREEBIE
2017-08-03 10:49:37 -04:00
Matthew Chen
791e270578 Terminate call if call view presentation is delayed.
// FREEBIE
2017-08-03 10:29:40 -04:00
Matthew Chen
634617b7d4 Terminate call if call view presentation is delayed.
// FREEBIE
2017-08-03 10:26:22 -04:00
Michael Kirk
81d7f28253 Timer to ensure call screen shown
// FREEBIE
2017-08-02 19:13:46 -04:00
Matthew Chen
dd13119f12 Add more instrumentation to CallService.
// FREEBIE
2017-07-27 13:57:29 -04:00
Matthew Chen
904515994f Add more instrumentation to CallService.
// FREEBIE
2017-07-27 13:28:05 -04:00
Matthew Chen
465711c2cb Add script to extract and gather analytics event names.
// FREEBIE
2017-07-27 12:45:29 -04:00
Matthew Chen
0cf9c01af2 Add script to extract and gather analytics event names.
// FREEBIE
2017-07-27 12:27:48 -04:00
Matthew Chen
8aff95c44e Add script to extract and gather analytics event names.
// FREEBIE
2017-07-27 12:26:02 -04:00
Matthew Chen
b4f348ad14 Add script to extract and gather analytics event names.
// FREEBIE
2017-07-27 12:26:02 -04:00
Matthew Chen
31ab9a00da Add script to extract and gather analytics event names.
// FREEBIE
2017-07-27 12:26:02 -04:00
Matthew Chen
863fd27abe Respond to CR.
// FREEBIE
2017-07-26 10:52:15 -04:00
Matthew Chen
8e51b5ade1 Clean up ahead of PR.
// FREEBIE
2017-07-26 10:01:43 -04:00
Matthew Chen
958a8b4c80 Instrument CallService.
// FREEBIE
2017-07-26 10:01:43 -04:00
Michael Kirk
03f1bbca62 Move state from CallViewController -> Call
I think whenever reasonable we prefer to consodlidate state on the call

// FREEBIE
2017-07-13 17:08:42 -04:00
Matthew Chen
ac616d6936 Reject the “call connected” promise immediately when clearing a call.
// FREEBIE
2017-07-12 18:12:27 -04:00
Michael Kirk
b82aedc3a0 Assertion failures for unexpected promise state
These don't currently result in failed calls, but we should at least
know about it in debug.

// FREEBIE
2017-07-12 16:15:22 -04:00
Michael Kirk
438635393b Don't send ICE updates until after the CallOffer has been sent.
This ensures message ordering for clients that can't handle out of order
call messages (legacy iOS and Android).

Even when we revert the previous commit, to send ICE Updates sooner,
we'll want to keep this (until we're confident all clients can receive
out of order call messages)

// FREEBIE
2017-07-12 16:15:22 -04:00
Michael Kirk
d910da0157 Partial revert of: Send ICE updates immediately - 2dcfb4e3b8
That change makes it more likely that the remote client will receive an
ICE update before their peer connection client is set.

We want to ship the robustness fix (waitForPeerConnection in
handleRemoteAddedIceCandidate) before we have the caller start sending
ICE updates immediately, in a future release.

At that time, we can simply revert this commit.

// FREEBIE
2017-07-12 16:15:22 -04:00
Matthew Chen
d639d6557e Add owsFail free function for swift.
// FREEBIE
2017-07-11 16:20:20 -04:00
Michael Kirk
2dcfb4e3b8 Send ICE updates immediately.
Now that SN changes do not block incoming messages, the caller does not
need to enqueue outgoing ICE updates.

However this introduces the possibility that the call recipient could
recieve an ICE update before their peerConnectionClient is set up - so
now we ensure that call service waits for it's peerConnectionClient
before processing incoming ICE updates.

// FREEBIE
2017-07-10 11:49:38 -05:00
Matthew Chen
1a400f8414 Respond to CR.
// FREEBIE
2017-07-10 12:39:44 -04:00
Matthew Chen
b6531a8b5d If two users call each other at the same time, ensure they both see “busy”.
// FREEBIE
2017-07-10 12:25:22 -04:00
Michael Kirk
f681712ea0 Code Cleanup
- make some logging clearer
- remove noisy unhelpful logging
- clearer method names

// FREEBIE
2017-07-10 11:09:39 -05:00
Matthew Chen
0244e134f5 Block device from sleeping during certain activities.
// FREEBIE
2017-07-06 17:35:47 -04:00
Michael Kirk
1f9f066fa9 print call record when declining a call
// FREEBIE
2017-07-05 12:45:34 -05:00
Michael Kirk
8abde1dff8 Non-Callkit adapter plays audio from notification when app is in
background

// FREEBIE
2017-07-05 11:53:16 -05:00
Matthew Chen
3d0811c03f Respond to CR.
// FREEBIE
2017-06-21 18:06:29 -04:00
Matthew Chen
029da7e0ce Hang up current call if we receive a call offer from the same user.
// FREEBIE
2017-06-21 17:47:42 -04:00
Matthew Chen
9fc92990f5 Improve logging in CallService.
// FREEBIE
2017-06-21 17:47:42 -04:00
Michael Kirk
36c09aeb84 cleanup ahead of PR
// FREEBIE
2017-06-20 16:24:59 -04:00
Michael Kirk
ff93732ed7 WIP: fix call from contacts when signal hasn't been launched yet 2017-06-20 16:17:37 -04:00
Matthew Chen
bd440f0878 Respond to post-holiday code reviews.
// FREEBIE
2017-06-17 13:38:19 -04:00
Matthew Chen
3bc73bea25 Don't return busy signal to untrusted callers.
// FREEBIE
2017-06-15 15:46:56 -04:00
Matthew Chen
f5f506d06f Investigate “call stuck on connecting” issue.
// FREEBIE
2017-06-13 11:18:27 -04:00
Michael Kirk
1a3204bf46 create interaction in thread when missing call due to changed identity
// FREEBIE
2017-06-07 15:04:21 -04:00
Michael Kirk
8c592a373a log error on assertion failure
// FREEBIE
2017-06-07 10:30:08 -04:00
Michael Kirk
c8d547a08f Only allow callback for identities that were not previously verified
// FREEBIE
2017-06-07 10:29:45 -04:00
Michael Kirk
1127553041 restore "confirm and callback" functionality
// FREEBIE
2017-06-07 10:29:01 -04:00
Michael Kirk
41a34e572b Update Safety Number alerts to work with verification
// FREEBIE
2017-06-07 10:18:16 -04:00
Matthew Chen
ceb210748e Sketch out OWSIdentityManager.
// FREEBIE
2017-06-07 10:18:16 -04:00
Michael Kirk
5b12f4afae Prevent outgoing calls started from various places unless have been seen
e.g. from contacts app

// FREEBIE
2017-06-01 12:59:34 -07:00
Michael Kirk
130aa132a0 Reject incoming calls from an unseen changed identity
// FREEBIE
2017-06-01 12:59:34 -07:00
Michael Kirk
20fc733bdf Clearer call logging
// FREEBIE
2017-05-10 13:03:45 -04:00
Matthew Chen
716aa772f6 Always sync and log push tokens. Apply OWSAlerts in more places.
// FREEBIE
2017-05-09 10:04:48 -04:00
Matthew Chen
ad3a1a671a Merge remote-tracking branch 'origin/hotfix/2.11.3' 2017-05-08 16:47:20 -04:00
Michael Kirk
d7c7fff679 Fix some compiler warnings
* explicit optional usage in strings
* remove some unused StringUtil code
* swiftlint affected files
* more concise optional casting (and avoid a `!`)

Compiler warnings: 343 -> 318

(Actually most of these are in external libs, but 115 remain in Signal/SSK)

// FREEBIE
2017-05-05 14:26:29 -04:00
Michael Kirk
6beee7c012 verify peerconnection at proper time
// FREEBIE
2017-05-04 15:15:14 -04:00
Michael Kirk
2ec893d315 Ensure we're retaining all promises to completion
// FREEBIE
2017-05-04 15:15:14 -04:00
Matthew Chen
e36c3aaed7 Reconcile audio and video enabling with call state.
// FREEBIE
2017-05-04 13:17:14 -04:00
Matthew Chen
1444cfc630 Merge remote-tracking branch 'origin/hotfix/2.11.2' 2017-05-04 10:45:12 -04:00
Matthew Chen
0f85284b82 Fix speakerphone vs. WebRTC AND Fix CallService edge cases.
// FREEBIE
2017-05-03 09:34:39 -04:00
Matthew Chen
6801963a1b Add SignalAccount class.
// FREEBIE
2017-05-02 09:28:50 -04:00
Matthew Chen
d06f358a23 Don't unwrap with ! in CallService.
// FREEBIE
2017-05-01 15:19:06 -04:00
Michael Kirk
700bd6e08a Fix build, remove unnecessary return
Fixup 27e55d2906

// FREEBIE
2017-05-01 11:16:14 -04:00
Michael Kirk
3a0f84cf36 Avoid crash in CallService
Rather than force unwrapping (`!`), use guards/implicit unwrapping to
handle the failure gracefully.

// FREEBIE
2017-05-01 10:31:23 -04:00
Matthew Chen
791dba9242 Respond to CR.
// FREEBIE
2017-04-19 10:18:03 -04:00
Matthew Chen
3368659d87 Improve handling of call service edge cases.
// FREEBIE
2017-04-19 10:09:40 -04:00
Matthew Chen
b4464f91a2 Improve handling of call service edge cases.
// FREEBIE
2017-04-19 10:09:40 -04:00
Matthew Chen
3c4955840d Improve handling of call service edge cases.
// FREEBIE
2017-04-19 10:09:40 -04:00
Matthew Chen
f920300f28 Improve handling of call service edge cases.
// FREEBIE
2017-04-19 10:09:40 -04:00
Matthew Chen
9db33a9651 Remove RedPhone code.
// FREEBIE
2017-03-29 12:25:33 -04:00
Matthew Chen
814c6d2505 Only initiate WebRTC calls, not RedPhone calls.
// FREEBIE
2017-03-22 17:02:42 -04:00
Michael Kirk
b5403175f1 Call sounds - connecting, outgoing ring, busy sound.
Also add vibration for remote hangup so you're not talking to dead air.

// FREEBIE
2017-02-27 11:21:51 -05:00
Michael Kirk
4b8a5f8ccb TURN-only option, and for unknown caller
Now, by default, we only use TURN for incoming calls from unknown
contacts. We will potentially directly connect for outgoing calls and
for incoming calls from known contacts.

Optionally, the user can disable direct connection altogether, at the
cost of some call quality.

// FREEBIE
2017-02-24 11:21:52 -08:00
Matthew Chen
dea37b422b Respond to CR.
// FREEBIE
2017-02-08 16:47:09 -05:00
Matthew Chen
06a775b41a Improve the call status messages in conversation view.
// FREEBIE
2017-02-08 16:47:09 -05:00
Michael Kirk
6cdf13ea5f Only time out the intended call
previously a followup call could get clobbered by the previous calls
timeout

// FREEBIE
2017-02-08 14:59:18 -05:00
Michael Kirk
c087c56b0c Fix call timeout
- Previously only incoming calls had their timeout promise fulfilled
- Previously we'd stop the timeout once ringing started, but we
should continue the timeout clock until the users are speaking.

// FREEBIE
2017-02-08 14:25:05 -05:00
Michael Kirk
2f6bf0e551 Code cleanup per CR
// FREEBIE
2017-02-08 10:33:43 -05:00
Michael Kirk
108720c2e7 End outgoing call with "No Answer" after 2 minutes
// FREEBIE
2017-02-08 10:33:43 -05:00
Matthew Chen
734dec12e9 Respond to CR.
// FREEBIE
2017-02-07 17:33:13 -05:00
Matthew Chen
c43063e1d6 Add “interstitial call view” that is shown during lengthy “webrtc supported” check.
// FREEBIE
2017-02-07 17:17:06 -05:00
Matthew Chen
ce9d9befb3 Prevent device lock during calls.
// FREEBIE
2017-02-07 16:00:17 -05:00
Matthew Chen
ca76ec6f36 Respond to CR.
// FREEBIE
2017-02-06 09:39:14 -05:00
Matthew Chen
6f3a45ff8c Avoid crashes when deallocating remote video tracks.
// FREEBIE
2017-02-06 09:33:47 -05:00
Matthew Chen
4ae786d0a2 Ignore CallService events related to obsolete calls.
// FREEBIE
2017-02-06 09:33:47 -05:00
Matthew Chen
d9bcd563b1 Avoid possible deadlock in PeerConnectionClient.
// FREEBIE
2017-02-06 09:33:47 -05:00
Matthew Chen
8f6483e9b4 Fix bug in the busy logic.
// FREEBIE
2017-02-03 16:47:34 -05:00
Matthew Chen
17fe3f66c0 Ensure audio service observation of call is always correctly wired up.
// FREEBIE
2017-02-03 15:47:33 -05:00
Michael Kirk
90388ebd63 Coordinate "busy" state across redphone and webrtc
Previously a redphone call didn't know when the user was busy due to
webrtc and vice versa

// FREEBIE
2017-02-03 14:10:06 -05:00
Matthew Chen
6e390d40b7 Respond to CR.
// FREEBIE
2017-02-03 11:29:47 -05:00
Matthew Chen
732144c9ed Respond to CR.
// FREEBIE
2017-02-03 11:29:47 -05:00
Matthew Chen
98caeb6a03 Be even more cautious when tearing down a PeerConnectionClient.
// FREEBIE
2017-02-03 11:29:47 -05:00
Michael Kirk
2a9aa4c852 users can opt out of CallKit
// FREEBIE
2017-02-02 19:09:37 -05:00
Matthew Chen
5687925513 Prevent simultaneous incoming and outgoing calls from leaving CallService in a bad state.
// FREEBIE
2017-02-02 18:22:32 -05:00
Matthew Chen
0893930485 Handle “busy signal” appropriately.
// FREEBIE
2017-02-02 18:19:38 -05:00
Michael Kirk
b6f098bfa7 Log when receiving unknown call datachannel message
// FREEBIE
2017-02-02 15:51:07 -05:00
Matthew Chen
f81feca2d6 Avoid crashes when closing peer connection client.
// FREEBIE
2017-02-01 21:52:01 -05:00
Matthew Chen
4dec1e2ded Avoid crashes when closing peer connection client.
// FREEBIE
2017-02-01 17:38:17 -05:00
Matthew Chen
b415b6142f Respond to CR, mainly by fixing broken tests.
// FREEBIE
2017-02-01 12:26:10 -05:00
Matthew Chen
49bb3d942d Clean up ahead of PR.
// FREEBIE
2017-02-01 10:44:29 -05:00
Matthew Chen
d294557bdd Rework concurrency in the signaling logic.
// FREEBIE
2017-02-01 10:24:23 -05:00
Matthew Chen
d6c849eab3 Revert whitespace changes.
// FREEBIE
2017-02-01 09:43:16 -05:00
Matthew Chen
af289145b5 Rework concurrency in the signaling logic.
// FREEBIE
2017-02-01 09:43:16 -05:00
Matthew Chen
8454c7dc2f Log reconnect events as such.
// FREEBIE
2017-01-31 17:10:29 -05:00
Matthew Chen
40b3d038db Disable local video in background.
// FREEBIE
2017-01-30 18:25:04 -05:00
Matthew Chen
c8e5884087 Respond to CR.
// FREEBIE
2017-01-30 15:54:31 -05:00
Matthew Chen
9a0a7bb6b1 Show alert when user tries to activate local video without camera permissions.
// FREEBIE
2017-01-30 14:08:53 -05:00
Matthew Chen
da53368bc2 Show alert when user tries to activate local video without camera permissions.
// FREEBIE
2017-01-30 14:08:53 -05:00
Matthew Chen
2ef80e569d Improve thread safety in call ui adapter and adatapees.
// FREEBIE
2017-01-30 14:08:53 -05:00
Matthew Chen
6ce33381a8 Prevent screen from dimming or device from locking during video call.
// FREEBIE
2017-01-30 14:08:08 -05:00
Michael Kirk
fff061ff3f Make sure WebRTC preferences are synced *every* call
This slows the UI, but only for people who have locally opted into
WebRTC calls, and the alternative is that users are likely to have stale
settings the first time a pair of people opt-in.

// FREEBIE
2017-01-27 14:33:12 -05:00
Matthew Chen
d560aa022a Reworked call view’s remote video mode. 2017-01-27 11:11:33 -05:00
Matthew Chen
204aeab69c Respond to CR.
// FREEBIE
2017-01-26 17:01:31 -05:00
Matthew Chen
ec1f77c630 Polish video calls.
* Send and handle messages around video status.
* Fix handling of callee data channel.
* Fix layout of local video view.

// FREEBIE
2017-01-26 16:56:35 -05:00
Matthew Chen
a65d3b7c4e Add video-related views.
// FREEBIE
2017-01-26 16:41:59 -05:00
Michael Kirk
814aec6cdd Recover CallKit state when remote client fails to hangup
Distinguish between localHangup, remoteHangup, and call failure.

This allows us to put CallKit in the proper state, ready to receive new
calls without having a backlog of phantom calls which haven't been
properly removed.

Note the "call error" occurs at the point ICE fails, which takes a
while. Anecdotally, like 10 seconds, which feels like a long to be
talking into the ether.

I briefly considered failing at 'disconnected', which happens much
sooner, but that's actually a recoverable state. E.g. if you toggle
airplane mode you can see that you bounce into `disconnected` and then
back to `connected`, so I don't think we'd want to fail the call as long
as WebRTC considers it "recoverable".

// FREEBIE
2017-01-26 13:18:06 -05:00
Michael Kirk
6c14f2f500 Fix "Answer" from iOS9 notification doesn't init audio
The removed code was from an older eon. CallService shouldn't be touched
except via the CallUIAdapter since only there is the omnipresent
distinction between CallKit vs. NonCallKit made.

i.e. when the RTCAudioSession get's started depends on the
CallUIAdaptee.

// FREEBIE
2017-01-25 12:32:36 -05:00
Michael Kirk
87ed662116 Persist AudioService if CallViewController is dismissed
...in response to CR, move the AudioService off of the CallViewController

Adopt multiple observer pattern vs. a singular delegate. Doing so
required implementing some machinery to address the ARC (see:
Weak.swift)

// FREEBIE
2017-01-24 14:13:29 -05:00
Matthew Chen
9e739433c5 Start work on video.
// FREEBIE
2017-01-23 13:41:59 -05:00
Michael Kirk
dbb29d7d7e Don't require recording permissions until call is ringing.
We do this by manually managing the RTCAudioSession.
Unfortunately to do this we have to include a couple of RTC headers not
exported by the default build of WebRTC.framework (see: Libraries/WebRTC)

// FREEBIE
2017-01-17 21:49:13 -05:00
Michael Kirk
0072ee3033 Ensure a stale peerConnectionClient doesn't call any methods on the CallService
Nil delegates when terminating call

// FREEBIE
2017-01-17 20:19:55 -05:00
Michael Kirk
32789bd960 Move RTCDataChannelDelegate to PeerConnectionClient
- minimizes CallService exposure to WebRTC

// FREEBIE
2017-01-17 20:14:33 -05:00
Michael Kirk
8998853aff Move RTCPeerConnectionDelegate to PeerConnectionClient
This makes sense as PeerConnectionClient is our interface to WebRTC

- Makes it easier to test PeerConnectionClient and CallService
- Allows us to shrink CallService class a bit (it's huge)

// FREEBIE
2017-01-17 20:14:33 -05:00
Michael Kirk
bd65dc6ba7 Fallback TURN servers if we can't get them from the server for some reason
// FREEBIE
2017-01-17 20:14:32 -05:00
Michael Kirk
f6e6e6b787 CallViewController only accesses CallService via the CallUIAdapter
This is an effort to better define boundaries and simplify
relationships.

This also fixes a theoretical problem where CallKit was showing the in-app
call screen before the call was successfully answered, now we wait until
the action is fulfilled.

// FREEBIE
2017-01-12 13:27:45 -05:00
Michael Kirk
947a637669 Sync "mute" controls between CallKit
In the process, extracted the CallDelegate to allow the
CAllViewController to observe useful call state properties (call.state
and call.isMuted)

// FREEBIE
2017-01-12 13:27:45 -05:00
Michael Kirk
c7449db289 remove stubbed audio manager implementation until it's clear what to do
with it.

// FREEBIE
2017-01-12 09:56:09 -05:00
Michael Kirk
6eecef99ba Promise aware Message sender
As this could be used elsewhere, ideally it'd added to the actual class
definition, but MessageSender (SSK) doesn't use PromiseKit

// FREEBIE
2017-01-12 09:56:08 -05:00
Michael Kirk
f9b44c8892 Added CallService documentation
// FREEBIE
2017-01-12 09:56:08 -05:00
Michael Kirk
57ad7a2808 cleanup 2017-01-12 09:56:08 -05:00
Michael Kirk
647b2b37e9 WIP: WebRTC calling
* Ensure NotificationsManager has dependencies
    Otherwise it's easy to mess up the order of the required dependencies.
* move AccountManager into Environment, it's heavy to construct

// FREEBIE
2017-01-12 09:56:05 -05:00