#ifndef APP_STATE_H
#define APP_STATE_H

#include <glib.h>
#include <gst/gst.h>

typedef struct {
  GMainLoop *loop;
  struct lws_context *lws_ctx;
  struct lws *wsi;

  gchar *dev_room;
  gchar *member_id;
  gchar *video_device;
  gboolean prefer_mpp;

  gboolean enable_audio;
  gchar *audio_alsa_device; /* NULL = alsasrc 默认；字符串 "test" = audiotestsrc */

  /* TRUE=index.html 设备端主动发 Offer；FALSE=等手机 client.html 发 Offer 再 Answer */
  gboolean device_offerer;
  gboolean call_enable;

  GstElement *pipeline;
  GstElement *webrtc;
  gpointer rtc_client; /* libdatachannel native sender (WEBRTCPUSH_USE_MPP=1) */

  gboolean offer_received;
  gboolean remote_description_set;
  gboolean payloader_linked;
  gboolean audio_linked;

  gboolean verbose;

  GMutex lock;
} AppState;

void app_state_lock(AppState *app);
void app_state_unlock(AppState *app);

#endif
