headers = [
  'adts.h',
  'amf.h',
  'auth.h',
  'encode.h',
  'bitfields.h',
  'bitstream.h',
  'certificate.h',
  'checksum.h',
  'cmaf.h',
  'comms.h',
  'config.h',
  'defines.h',
  'dtls_srtp_handshake.h',
  'dtsc.h',
  'encryption.h',
  'flv_tag.h',
  'h264.h',
  'h265.h',
  'hls_support.h',
  'http_parser.h',
  'downloader.h',
  'json.h',
  'langcodes.h',
  'mp4_adobe.h',
  'mp4_dash.h',
  'mp4_encryption.h',
  'mp4_generic.h',
  'mp4.h',
  'mp4_ms.h',
  'mpeg.h',
  'nal.h',
  'ogg.h',
  'procs.h',
  'rtmpchunks.h',
  'rtp_fec.h',
  'rtp.h',
  'sdp.h',
  'sdp_media.h',
  'shared_memory.h',
  'socket.h',
  'stream.h',
  'stun.h',
  'theora.h',
  'timing.h',
  'tinythread.h',
  'ts_packet.h',
  'ts_stream.h',
  'util.h',
  'vorbis.h',
  'triggers.h',
  'opus.h',
  'riff.h',
  'ebml.h',
  'ebml_socketglue.h',
  'websocket.h',
  'url.h',
  'urireader.h',
]

if have_srt 
  headers += 'socket_srt.h'
endif

install_headers(headers, subdir: 'mist')

extra_code = []

if usessl
  extra_code += ['dtls_srtp_handshake.cpp', 'stun.cpp', 'certificate.cpp', 'encryption.cpp',]
endif

libmist = library('mist',
  'adts.cpp',
  'amf.cpp',
  'auth.cpp',
  'encode.cpp',
  'bitfields.cpp',
  'bitstream.cpp',
  'cmaf.cpp',
  'comms.cpp',
  'config.cpp',
  'dtsc.cpp',
  'flv_tag.cpp',
  'h264.cpp',
  'h265.cpp',
  'hls_support.cpp',
  'http_parser.cpp',
  'downloader.cpp',
  'json.cpp',
  'langcodes.cpp',
  'mp4_adobe.cpp',
  'mp4.cpp',
  'mp4_dash.cpp',
  'mp4_encryption.cpp',
  'mp4_generic.cpp',
  'mp4_ms.cpp',
  'mpeg.cpp',
  'nal.cpp',
  'ogg.cpp',
  'procs.cpp',
  'rtmpchunks.cpp',
  'rtp_fec.cpp',
  'rtp.cpp',
  'sdp.cpp',
  'sdp_media.cpp',
  'shared_memory.cpp',
  'socket.cpp',
  'stream.cpp',
  'theora.cpp',
  'timing.cpp',
  'tinythread.cpp',
  'ts_packet.cpp',
  'ts_stream.cpp',
  'util.cpp',
  'vorbis.cpp',
  'triggers.cpp',
  'opus.cpp',
  'riff.cpp',
  'ebml.cpp',
  'ebml_socketglue.cpp',
  'url.cpp',
  'urireader.cpp',
  'websocket.cpp',
  extra_code,
  include_directories: incroot,
  dependencies: mist_deps,
  install: true,
)

libmist_dep = declare_dependency(
    link_with: [libmist],
    dependencies: mist_deps,
    include_directories: incroot
)

if have_srt
  libmist_srt = library('mist_srt', 'socket_srt.cpp', dependencies: [libsrt, libmist_dep], install: true)
  libmist_srt_dep = declare_dependency(link_with: [libmist_srt])
endif