Skip to content

Calling setOnVideo/AudioFrameCallback outside of the onTrackSubscribed handler never starts a frame thread handler #235

Description

@Soralsei

LiveKit C++ SDK Version

v1.2.0

Platform

Linux x86_64

OS Version

OpenSUSE 15.6 LEAP

Compiler & Version

gcc 15.2

CMake Version

3.28.3

How are you using the SDK?

Vendoring the SDK and building from source as a CMake subdirectory

Issue Description

Calling setOnAudio/VideoFrameCallback correctly adds the frame handler to the relevant video/audio_callbacks, but doing so outside of the onTrackSubscribed delegate callback never starts a reader thread, resulting in the corresponding frame callback never being called.

This happens because SubscriberThreadDispatcher::handleTrackSubscribed only gets called synchronously right after the delegate callback from the Room event handler @ room.cpp:703, which no-ops if the frame callback key has not been added to the callback map yet.

A potential fix could be to call SubscriberThreadDispatcher::handleTrackSubscribed if setOnAudio/VideoFrameCallback is called when the mappings are empty.

Steps to Reproduce

  1. Handle the onTrackSubscribed room delegate event
  2. Call Room::setOnVideoFrameCallback from the context of another thread (ex: in a Qt GUI thread) that can run after the event handler returns
  3. Notice no audio/video frame callbacks being called

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions