teams-call icon indicating copy to clipboard operation
teams-call copied to clipboard

Question: How to detect ringing?

Open pabuta88 opened this issue 2 years ago • 12 comments

First of all, thank you very much for your script - it works like a charm.

I am wondering if there is a possibility to detect the ringing (i.e. an incoming or outgoing call) and not just being in call or not. Do you know that? If not, any suggestions how to figure that out?

Thank you very much!

pabuta88 avatar Apr 01 '22 14:04 pabuta88

I looked around a bit and I didn't find a state change that we could observe when it's ringing. If someone has an idea we can totally add support for it.

mre avatar Apr 04 '22 15:04 mre

Hello, I was looking around for something like this, about status for Teams, and it seems you're the only one that has proposed something as of today. I was playing with Teams calls, and seen that some info could be retrieved from storage.json file. I didn't try many scenario, just :

  • being called
  • declining call by receiver
  • decllning by caller
  • accepting call
  • closing call
  • emitting call "one-to-one" (as seen in ̀storage.json`)

The infos are there, in activityEvents.events and in appStates.states.

I hope this could help

PS : it seems that create_one_to_one_call is being written afterward, ie when the call is accepted/stopped

Zelnes avatar Dec 16 '22 10:12 Zelnes

Thanks for the info. Here are some more events I could find in my storage.json:

    "events": [
      "call_device_permissions",
      "video_stream_stopped",
      "video_stream_rendering",
      "oam_api",
      "substrateCallTokenFetch",
      "substrate_warmup_keepalive",
      "call_device_permissions",
      "window_manager_v2_page_title_updated",
      "video_stream_stopped",
      "leave_meetup",
      "periodicRefreshSubstrateAuthToken",
      "calling_call_disconnected",
      "call_quality_event",
      "inconsistent_result_category",
      "get_questionnaire_scenario",
      "display_modal_cqf",
      "data_channel_audience_stopped",
      "window_manager_v2_window_resize"
      "experience-renderer-console-error",
      "create_meetup",
      "calling_call_disconnected"
    ],

Crucially I didn't see a ring event yet (i.e. when I get called). If someone can find it, let me know.

mre avatar Dec 16 '22 11:12 mre

When I make a call from mobile to desktop, I can see the following sequence of events:

"desktop_render_window_info_enricher_enrich",
"toast_endtoend_tracking_desktopclient",
"panelview_toast_toastitem_toast"

At the same time this opens the call popup and waits for me to pick up. We might be able to use that sequence as an indicator for ringing in case it doesn't get used anywhere else in the app. Can somebody else confirm that they get the same?

mre avatar Dec 16 '22 11:12 mre

I've set up a small script with inotifywait which seems to work :

#!/bin/bash
# Script launched at boot time
# It tells Teams states in the file /tmp/teams/state
# It is used by my py3status file, with color associated to the status

TEAMS_STORAGE="${HOME}/.config/Microsoft/Microsoft Teams/storage.json"

printCurrentStatus() {
    local status="" color
    local current_status current_state

    current_status="$(jq -r '.activityEvents.events | last' < "$TEAMS_STORAGE")"
    current_state="$(jq -r '.appStates.states' < "$TEAMS_STORAGE" | sed 's/.*,//')"

    case "${current_state}${current_status}" in
        *incoming_call*)
            status="Incoming Call"
            color="#BA7238";;
        *InCall*|*call_accept*)
            status="In call"
            color="#552A8C";;
        *CallEnded*|*calling_call_disconnected*)
            status="IDLE"
            color="#FFFFFF";;
    esac

    if [ -n "$status" ]; then
        {
            echo "Teams : $status"
            echo "$color"
        } >/tmp/teams_state
    fi
}

# Launch a first check before waiting for a change
printCurrentStatus

inotifywait -m -e modify "$TEAMS_STORAGE" | while read _dummy; do
    printCurrentStatus
done

It tells me when someone calls me, with incoming_call isn't what you're looking for ?

Zelnes avatar Dec 16 '22 13:12 Zelnes

Very nice! Yeah, that's what I was looking for, however I don't see the event in my logs. Which OS are you on and what's your Teams version? I'm on macOS Monterey and have Microsoft Teams Version 1.5.00.17261. It was last updated today.

mre avatar Dec 16 '22 13:12 mre

Microsoft Teams version is 1.5.00.23861 (64 bits) On a Debian GNU/Linux 11 (bullseye)

Zelnes avatar Dec 16 '22 14:12 Zelnes

Aha! Thanks. So guess I need to test this on another mac, but if you like you could create a pull request to add support for ringing. In the worst case it won't work on macOS (but I doubt that this will be the case).

mre avatar Dec 16 '22 15:12 mre

Ok, I'll see what I can do when I'll have some time :smile:

Zelnes avatar Dec 16 '22 15:12 Zelnes

Thanks, that would be extremely nice. ✌️

mre avatar Dec 16 '22 15:12 mre

I'm back, and I didn't notice the shell script, I thought you were asking for a python PR. Anyway, I can't push my branch to your repo, can you give me the correct rights ?

Zelnes avatar Dec 19 '22 13:12 Zelnes

No worries. You usually fork a project and create a branch on your side and then create a pull request to my repo. 😉

mre avatar Dec 19 '22 14:12 mre