Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.
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
26 changes: 19 additions & 7 deletions include/libdavec.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ typedef struct DaveCommitProcessingResult {
void *roster_update;
} DaveCommitProcessingResult;

typedef void (*DaveMlsFailureCallback)(const char*, const char*);

typedef void (*DaveProtocolVersionChangedCallback)(void);

LIBDAVEC_EXPORT extern const int DAVE_INIT_TRANSITION_ID;

LIBDAVEC_EXPORT extern const int DAVE_DISABLED_VERSION;
typedef enum DaveLoggingSeverity {
VERBOSE,
INFO,
WARNING,
ERROR,
NONE,
} DaveLoggingSeverity;

typedef enum DaveMediaType : uint8_t {
AUDIO,
Expand All @@ -47,6 +47,18 @@ typedef enum DaveCodec : uint8_t {
AV1
} DaveCodec;

typedef void (*DaveLogSink)(DaveLoggingSeverity severity, const char *file, int line, const char *message);

typedef void (*DaveMlsFailureCallback)(const char*, const char*);

typedef void (*DaveProtocolVersionChangedCallback)(void);

LIBDAVEC_EXPORT extern const int DAVE_INIT_TRANSITION_ID;

LIBDAVEC_EXPORT extern const int DAVE_DISABLED_VERSION;

LIBDAVEC_EXPORT void dave_set_log_sink(DaveLogSink sink);

LIBDAVEC_EXPORT uint16_t dave_max_supported_protocol_version(void);

LIBDAVEC_EXPORT void* dave_session_create(const char *context, const char *auth_session_id, DaveMlsFailureCallback mls_failure_callback);
Expand Down
15 changes: 15 additions & 0 deletions src/libdavec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ const int DAVE_INIT_TRANSITION_ID = discord::dave::kInitTransitionId;

const int DAVE_DISABLED_VERSION = discord::dave::kDisabledVersion;

void dave_set_log_sink(DaveLogSink sink) {
static std::atomic<DaveLogSink> log_sink = nullptr;

log_sink.store(sink);

if (sink) {
discord::dave::SetLogSink([](discord::dave::LoggingSeverity severity, const char *file, int line, const std::string &message) {
auto stored = log_sink.load();
if (stored)
stored((DaveLoggingSeverity)severity, file, line, message.c_str());
});
} else
discord::dave::SetLogSink(nullptr);
}

uint16_t dave_max_supported_protocol_version(void) {
return discord::dave::MaxSupportedProtocolVersion();
}
Expand Down
Loading