gpt4 book ai didi

C,将带有 GhashTable 键的结构体传递给函数

转载 作者:行者123 更新时间:2023-11-30 16:50:38 24 4
gpt4 key购买 nike

所以基本上我想将我的静音/取消静音通话与通话地点隔离。

我做了一个方法:void janus_audiobridge_mute_toggle_participants(janus_audiobridge_participant *participants[], int size, gboolean muted)

我打电话的方式:

// Prepare params for mute toggle participant
janus_audiobridge_participant *participants[] = {&participant};
gboolean muted_state = json_is_true(muted);
int total = sizeof(participants)/sizeof(*participants);
JANUS_LOG(LOG_WARN, "muted - %s \n", muted_state ? "TRUE" : "FALSE");

// Mute participant/participants
janus_audiobridge_mute_toggle_participants(participants, total, muted_state);

janus_audiobridge_mute_toggle_participants内部:

  GHashTable *parts = participants[0]->room->participants;
JANUS_LOG(LOG_WARN, "HOW MANY PARTICIPANTS: %i", g_hash_table_size(parts));

以下是参与者和房间的结构:

  typedef struct janus_audiobridge_room {
guint64 room_id; /* Unique room ID */
gchar *room_name; /* Room description */
gchar *room_secret; /* Secret needed to manipulate (e.g., destroy) this room */
gchar *room_pin; /* Password needed to join this room, if any */
gboolean is_private; /* Whether this room is 'private' (as in hidden) or not */
uint32_t sampling_rate; /* Sampling rate of the mix (e.g., 16000 for wideband; can be 8, 12, 16, 24 or 48kHz) */
gboolean audiolevel_ext; /* Whether the ssrc-audio-level extension must be negotiated or not for new joins */
gboolean record; /* Whether this room has to be recorded or not */
gchar *record_file; /* Path of the recording file */
FILE *recording; /* File to record the room into */
gint64 record_lastupdate; /* Time when we last updated the wav header */
gboolean destroy; /* Value to flag the room for destruction */
GHashTable *participants; /* Map of participants */
GThread *thread; /* Mixer thread for this room */
GThread *radio_thread; /* Thread that watches time a person has been unmuted */
gint64 destroyed; /* When this room has been destroyed */
janus_mutex mutex; /* Mutex to lock this room instance */
/* RTP forwarders for this room's mix */
GHashTable *rtp_forwarders; /* RTP forwarders list (as a hashmap) */
OpusEncoder *rtp_encoder; /* Opus encoder instance to use for all RTP forwarders */
janus_mutex rtp_mutex; /* Mutex to lock the RTP forwarders list */
int rtp_udp_sock; /* UDP socket to use to forward RTP packets */
gboolean is_someone_talking; /* Whereaver someone is talking */
gint64 last_unmute; /* Time when someone last unmuted himself */
gboolean is_conference; /* Default is FALSE, if turned to TRUE everybody can speak at the same time */
} janus_audiobridge_room;


typedef struct janus_audiobridge_participant {
janus_audiobridge_session *session;
janus_audiobridge_room *room; /* Room */
guint64 user_id; /* Unique ID in the room */
gchar *display; /* Display name (just for fun) */
gboolean prebuffering; /* Whether this participant needs pre-buffering of a few packets (just joined) */
gboolean active; /* Whether this participant can receive media at all */
gboolean working; /* Whether this participant is currently encoding/decoding */
gboolean muted; /* Whether this participant is muted */
int volume_gain; /* Gain to apply to the input audio (in percentage) */
gboolean should_receive_audio; /* Whether send audio to this parcipant */
int opus_complexity; /* Complexity to use in the encoder (by default, DEFAULT_COMPLEXITY) */
/* RTP stuff */
GList *inbuf; /* Incoming audio from this participant, as an ordered list of packets */
GAsyncQueue *outbuf; /* Mixed audio for this participant */
gint64 last_drop; /* When we last dropped a packet because the imcoming queue was full */
janus_mutex qmutex; /* Incoming queue mutex */
int opus_pt; /* Opus payload type */
int extmap_id; /* Audio level RTP extension id, if any */
int dBov_level; /* Value in dBov of the audio level (last value from extension) */
janus_audiobridge_rtp_context context; /* Needed in case the participant changes room */
/* Opus stuff */
OpusEncoder *encoder; /* Opus encoder instance */
OpusDecoder *decoder; /* Opus decoder instance */
gboolean reset; /* Whether or not the Opus context must be reset, without re-joining the room */
GThread *thread; /* Encoding thread for this participant */
janus_recorder *arc; /* The Janus recorder instance for this user's audio, if enabled */
janus_mutex rec_mutex; /* Mutex to protect the recorder from race conditions */
gint64 destroyed; /* When this participant has been destroyed */
gboolean is_admin; /* if TRUE - participant is admin */
} janus_audiobridge_participant;

执行上面的代码后我得到:

[WARN] HOW MANY PARTICIPANTS: 0
(process:4960): GLib-CRITICAL **: g_hash_table_size: assertion 'hash_table != NULL' failed

奇怪的是,当我在同一个地方执行相同的代码时,我调用toggle_mute方法,并且它工作正常。

所以我的问题是:为什么这适用于所有其他结构键,但不适用于 ->room->participants?如何解决这个问题?

谢谢

我使用的是开源系统janus-gateway .

最佳答案

“将 {&participant} 更改为 {participant} 解决了我的问题。感谢放松的提示!:)”

关于C,将带有 GhashTable 键的结构体传递给函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42135921/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com