# % macro, P, Device Prefix
# % macro, R, Device Suffix
# % macro, PORT, Asyn Port name
# % gui, $(PORT), edmtab, ffmpegFile.edl, P=$(P),R=$(R)

# # \file 
# # ffmpegFile wraps the ffmpeg compression libraries in an areaDetector plugin.
# # It works in much the same way as the other NDFile plugins. By default, it
# # will try to guess the file format from the file extension, but you can force
# # it to a particular file format with the FileFormat record.
# # \section ffmpegStream_setup Setup
# # - In the database, an instance of NDPluginBase is required, followed by an
# # instance of NDFile, then an instance of this template. 
# # - In the startup scripts, call ffmpegFileConfigure() once per ffmpegStream
# # instance to setup the areadetector plugin
# # - see \ref build_instructions
# # \section ffmpegStream_screenshots Screenshots
# # \htmlinclude flashvideo.html
# # \image html ffmpegFileEdm.png "Edm screen for ffmpegFile"

# All tags starting with gdatag are DLS specific for GDA
# % gdatag, template, ffmpegFile, $(PORT)_ffmpegFile, $(PORT) ffmpegFile class instance

# # File data format 
# % gdatag, mbbinary, rw, $(PORT)_ffmpegFile, FileFormat, Set FileFormat
record(mbbo, "$(P)$(R)FileFormat")
{
    field(ZRST, "Auto")
    field(ZRVL, "0")
}

# # File data format from driver
# % gdatag, mbbinary, ro, $(PORT)_ffmpegFile, FileFormat_RBV, Readback for FileFormat
record(mbbi, "$(P)$(R)FileFormat_RBV")
{
    field(ZRST, "Auto")
    field(ZRVL, "0")
}

record(bo, "$(P)$(R)AutoSave")
{
    field(VAL,  "0")
}

record(mbbo, "$(P)$(R)FileWriteMode")
{
    field(VAL, "2")
}

record(longout, "$(P)$(R)NumCapture")
{
    field(VAL,  "-1")
}

# # FFMPEG Bitrate
# % gdatag, pv, rw, $(PORT)_ffmpegFile, BITRATE, Set BITRATE
record(ao, "$(P)$(R)BITRATE") {
  field(DTYP, "asynInt32")
  field(OUT, "@asyn($(PORT) 0)FFMPEG_BITRATE")
  field(VAL, "10000000")
  field(PINI, "YES")  
}

# # FFMPEG Bitrate from driver
# % gdatag, pv, ro, $(PORT)_ffmpegFile, BITRATE_RBV, Readback for BITRATE
record(ai, "$(P)$(R)BITRATE_RBV") {
  field(SCAN, "I/O Intr")
  field(DTYP, "asynInt32")
  field(INP, "@asyn($(PORT) 0)FFMPEG_BITRATE")
}

# # FFMPEG Frames Per Second
# % gdatag, pv, rw, $(PORT)_ffmpegFile, FPS, Set FPS
record(ao, "$(P)$(R)FPS") {
  field(DTYP, "asynInt32")
  field(OUT, "@asyn($(PORT) 0)FFMPEG_FPS")
  field(VAL, "25")
  field(PINI, "YES")  
}

# # FFMPEG Frames Per Second from driver
# % gdatag, pv, ro, $(PORT)_ffmpegFile, FPS_RBV, Readback for FPS
record(ai, "$(P)$(R)FPS_RBV") {
  field(SCAN, "I/O Intr")
  field(DTYP, "asynInt32")
  field(INP, "@asyn($(PORT) 0)FFMPEG_FPS")
}

# # FFMPEG Width
# % gdatag, pv, rw, $(PORT)_ffmpegFile, WIDTH, Set WIDTH
record(ao, "$(P)$(R)WIDTH") {
  field(DTYP, "asynInt32")
  field(OUT, "@asyn($(PORT) 0)FFMPEG_WIDTH")
  field(VAL, "640")
  field(PINI, "YES")  
}

# # FFMPEG Width from driver
# % gdatag, pv, ro, $(PORT)_ffmpegFile, WIDTH_RBV, Readback for WIDTH
record(ai, "$(P)$(R)WIDTH_RBV") {
  field(SCAN, "I/O Intr")
  field(DTYP, "asynInt32")
  field(INP, "@asyn($(PORT) 0)FFMPEG_WIDTH")
}

# # FFMPEG Height
# % gdatag, pv, rw, $(PORT)_ffmpegFile, HEIGHT, Set HEIGHT
record(ao, "$(P)$(R)HEIGHT") {
  field(DTYP, "asynInt32")
  field(OUT, "@asyn($(PORT) 0)FFMPEG_HEIGHT")
  field(VAL, "480")
  field(PINI, "YES")  
}

# # FFMPEG Height from driver
# % gdatag, pv, ro, $(PORT)_ffmpegFile, HEIGHT_RBV, Readback for HEIGHT
record(ai, "$(P)$(R)HEIGHT_RBV") {
  field(SCAN, "I/O Intr")
  field(DTYP, "asynInt32")
  field(INP, "@asyn($(PORT) 0)FFMPEG_HEIGHT")
}
