Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/livekit/room.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
#include <memory>
#include <mutex>

#include "livekit/audio_stream.h"
#include "livekit/data_stream.h"
#include "livekit/e2ee.h"
#include "livekit/ffi_handle.h"
#include "livekit/room_callbacks.h"
#include "livekit/room_event_types.h"
#include "livekit/stats.h"
#include "livekit/subscription_thread_dispatcher.h"
#include "livekit/video_stream.h"
#include "livekit/visibility.h"

namespace livekit {
Expand All @@ -42,6 +44,7 @@ struct E2EEOptions;
class E2EEManager;
class LocalParticipant;
class RemoteParticipant;
class SubscriptionThreadDispatcher;

/// Represents a single ICE server configuration.
struct IceServer {
Expand Down
46 changes: 46 additions & 0 deletions include/livekit/room_callbacks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2026 LiveKit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <cstdint>
#include <functional>
#include <optional>
#include <vector>

namespace livekit {

class AudioFrame;
class VideoFrame;
struct VideoFrameEvent;

/// @brief Callback for incoming audio frames on a subscription reader thread.
using AudioFrameCallback = std::function<void(const AudioFrame&)>;
Comment thread
stephen-derosa marked this conversation as resolved.

/// @brief Callback for incoming video frames on a subscription reader thread.
using VideoFrameCallback = std::function<void(const VideoFrame& frame, std::int64_t timestamp_us)>;

/// @brief Callback for incoming video frame events on a subscription reader thread.
using VideoFrameEventCallback = std::function<void(const VideoFrameEvent&)>;

/// @brief Callback for incoming data frames on a subscription reader thread.
using DataFrameCallback =
std::function<void(const std::vector<std::uint8_t>& payload, std::optional<std::uint64_t> user_timestamp)>;

/// @brief Identifier for a data frame callback registration.
using DataFrameCallbackId = std::uint64_t;

} // namespace livekit
1 change: 1 addition & 0 deletions src/room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "lk_log.h"
#include "room.pb.h"
#include "room_proto_converter.h"
#include "subscription_thread_dispatcher.h"
#include "trace/trace_event.h"
#include "track.pb.h"
#include "track_proto_converter.h"
Expand Down
2 changes: 1 addition & 1 deletion src/subscription_thread_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "livekit/subscription_thread_dispatcher.h"
#include "subscription_thread_dispatcher.h"

#include <exception>
#include <utility>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <vector>

#include "livekit/audio_stream.h"
#include "livekit/room_callbacks.h"
#include "livekit/video_stream.h"
#include "livekit/visibility.h"

Expand All @@ -38,29 +39,6 @@ class RemoteDataTrack;
class Track;
class VideoFrame;

/// Callback type for incoming audio frames.
/// Invoked on a dedicated reader thread per (participant, track_name) pair.
using AudioFrameCallback = std::function<void(const AudioFrame&)>;

/// Callback type for incoming video frames.
/// Invoked on a dedicated reader thread per (participant, track_name) pair.
using VideoFrameCallback = std::function<void(const VideoFrame& frame, std::int64_t timestamp_us)>;

/// Callback type for incoming video frame events.
/// Invoked on a dedicated reader thread per (participant, track_name) pair.
using VideoFrameEventCallback = std::function<void(const VideoFrameEvent&)>;

/// Callback type for incoming data track frames.
/// Invoked on a dedicated reader thread per subscription.
/// @param payload Raw binary data received.
/// @param user_timestamp Optional application-defined timestamp from sender.
using DataFrameCallback =
std::function<void(const std::vector<std::uint8_t>& payload, std::optional<std::uint64_t> user_timestamp)>;

/// Opaque identifier returned by addOnDataFrameCallback, used to remove an
/// individual subscription via removeOnDataFrameCallback.
using DataFrameCallbackId = std::uint64_t;

/// Owns subscription callback registration and per-subscription reader threads.
///
/// `SubscriptionThreadDispatcher` is the low-level companion to @ref Room's
Expand All @@ -81,7 +59,7 @@ using DataFrameCallbackId = std::uint64_t;
/// The design keeps track-type-specific startup isolated so additional track
/// kinds can be added later without pushing more thread state back into
/// @ref Room.
class LIVEKIT_API SubscriptionThreadDispatcher {
class LIVEKIT_INTERNAL_API SubscriptionThreadDispatcher {
Comment thread
stephen-derosa marked this conversation as resolved.
public:
/// Constructs an empty dispatcher with no registered callbacks or readers.
SubscriptionThreadDispatcher();
Expand Down
2 changes: 2 additions & 0 deletions src/tests/unit/test_subscription_thread_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <unordered_map>
#include <vector>

#include "subscription_thread_dispatcher.h"

namespace livekit {

class SubscriptionThreadDispatcherTest : public ::testing::Test {
Expand Down
Loading