0
所以基本上我想從callplace中分離靜音/取消靜音。C,將GhashTable的鍵傳遞給函數
我做了一個方法: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。
好了,明確了結構領域'participants'是'NULL'指針。準備步驟並不完整,很難知道您在那裏做了正確的事情(例如使用&參與者)。 – unwind
是的,但不是null。當我運行 - > room->參與者的方法時,我稱之爲切換,它的工作原理和返回值爲1. – IvRRimUm
將{{參與者}'更改爲{參與者}修復了我的問題。感謝您放鬆提示! :) – IvRRimUm