0

所以基本上我想将我的静音/取消静音呼叫与呼叫场所隔离开来。

我做了一个方法: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

4

1 回答 1

0

“更改{&participant}{participant}解决我的问题。感谢 unwind 的提示!:)”

于 2017-02-09T12:06:07.417 回答