; This is an example configuration file that illustrates
; how to define service linking

; More information about the usage of the tools is available
; in the guide, which can be found on the
; www.opendigitalradio.org website.
;
general {
    dabmode 1
    nbframes 20000

    syslog false
    tist false
    managementport 12720
}

remotecontrol {
    telnetport 12721
}

; Service linking sets
linking {
    ; Every child section declares one linkage sets according to
    ; TS 103 176 Clause 5.2.3 "Linkage sets". This information will
    ; be encoded in FIG 0/6
    set-fu {
        ; Linkage Set Number is a 12-bit number that identifies the linkage set
        ; in a country (requires coordination between multiplex operators in a country)
        ; (mandatory)
        lsn 0xabc

        ; Hard link means that all services carry the same programme, soft links means
        ; that the programmes are related in some way. (default true)
        hard true

        ; Linkage actuator flag. Set to false to disable a link
        active true

        ; Whether this linkage set affects only one country or several. Linkage sets that
        ; include AMSS or DRM services need to have this set to true. (default false)
        ; Linkage sets whose key service has a different ECC than the ensemble ECC need to
        ; set this to true.
        international false

        ; If the keyservice and list are absent, a FIG with an empty list will be transmitted for
        ; this linkage set. This instructs receivers to delete their corresponding database entry
        ; (Change Event Indicator for FIG0/6)

        ; Every linkage set has to contain a service from the current ensemble. keyservice may be omitted.
        keyservice srv-fu

        ; List of services to be included (mandatory if keyservice given)
        list {
            ; Every service has a uid that can be used as a human-readable description

            ; The first example is a link to a DAB service on another ensemble.
            fu-on-my-friends-mux {
                ; Possible options: dab, fm, drm, amss (mandatory)
                type dab

                ; if type is dab, the id is a DAB service ID (mandatory)
                id 0x8daf

                ; Since this link set has international false, we do not need to specify
                ; the ECC. With internation true, the following would be needed
                ; (mandatory if internation true)
                ;ecc 0xec
            }

            ; The second example is a link to an FM transmission
            fu-on-fm {
                ; Possible options: dab, fm, drm, amss
                type fm

                ; if type is fm, the id is a PI-code
                id 0x1A2B

                ; Also here, ECC declaration is not required
            }
        }
    }

    ; And now an international true to test more options
    set-ri {
        lsn 0xdef
        hard soft
        international true
        keyservice srv-ri

        list {
            ri-on-drm {
                type drm
                id 0x1298
                ecc 0xec
            }

            ri-on-amss {
                type amss
                id 0x1A2B
                ecc 0xea
            }

            ri-on-fm {
                type fm
                id 0x4C5D
                ecc 0x4f
            }
        }
    }
}

; According to ETSI TR 101 496-2 Clause 3.6.10.
; Each entry corresponds to one frequence information
; database entry. The multiplexer then transmits this
; information inside FIG 0/21 defined in
; ETSI EN 300 401 Clause 8.1.8
frequency_information {
    fi_dab_4fff {
        ; The database key comprises oe, range_modulation and
        ; either eid, pi_code, drm_id or amss_id.
        ; The database key must be unique among all the fi entries.
        ; RegionId and signalling FI for data services are not implemented.
        oe false
        range_modulation dab
        eid 0x4fff

        continuity true
        frequencies {
            freq_a {
                signal_mode_1 true
                adjacent true
                frequency 234.208
            }
            freq_b {
                signal_mode_1 true
                adjacent true
                frequency 188.928
            }
            freq_c {
                signal_mode_1 true
                adjacent false
                frequency 230.784
            }
        }
    }
    fi_fm_1234 {
        oe false
        range_modulation fm
        pi_code 0x1234

        continuity true
        frequencies "87.6 105.2"
    }
    fi_dab_4fee {
        oe true
        range_modulation dab
        eid 0x4fee

        continuity true
        frequencies {
            freq_a {
                signal_mode_1 true
                adjacent false
                frequency 230.784
            }
        }
    }
    fi_drm_12ab45 {
        oe false
        range_modulation drm
        drm_id 0x12ab45

        continuity true
        frequencies "15.21 22.4"
    }
    fi_amss_33cc88 {
        range_modulation amss
        amss_id 0x33cc88

        continuity true
        frequencies "14.8"
    }
}

; We can announce the presence of a service in another ensemble using FIG0/24,
; both for services we carry in this ensemble (OE=0) and for services that
; only exist in another ensemble (OE=1)
other-services {
    ; you can freely chose the unique id
    srv-fu {
        ; If this ensemble contains a service with this id, OE will be set to 0.
        ; Otherwise, OE=1
        id 0x8daa

        ; If this service is present in other ensembles, it can be announced
        ; through FIG0/24. other_ensembles is a comma separated list of
        ; ensemble IDs (decimal or hexadecimal with 0x prefix).
        ; Add the current ensemble Id to the list if you carry this service too.
        other_ensembles "0x4ffe,0x4ffd,0x4fff"
    }

    ; For a more efficient usage of the FIC capacity, it is better to first enumerate
    ; the services that we carry in the ensemble (OE=0), followed by the foreign services.
    ; This avoids having to send FIG0 headers every time the OE flag switches.
    srv-foreign {
        id 0x8daf
        other_ensembles "0x4ffd"

        ; Only Audio type services are supported
    }
}

; FIG 0/20 - Adding, changing, removing and modifying services
; Allowable changes are "identity", "addition", "removal", "global_removal"
service-component-information {
    ; Signal a service being added
    new_radio {
        id          0x1234
        change      addition
        programme   true
        active      true
    }

    ; Signal a service being removed globally
    old_radio {
        id          0x5678
        change      global_removal
        active      true
    }

    ; Signal a service changing identity
    rebranded {
        id          0xABCD
        change      identity
        transfer_sid 0xEF01
        active      true
    }

    ; Signal a service moving to another ensemble
    moving_service {
        id          0x1111
        change      identity
        transfer_sid 0x2222
        transfer_eid 0x3333
        active      true
    }
    
    ; Service has ended - send all listeners to the old service (0x1234) to the new service (0xC012)
    service_old_redirect {
        id          0x1234
        change      identity
        transfer_sid 0xC012
        active      true
    }
    
    ; Part-time service with SC description
    part_time_radio {
        id          0x4444
        change      addition
        part_time   true
        scids       0
        sc_description {
            ca      false
            data    false
            scty    0
        }
        active      true
    }
}

; For information about the ensemble, service, subchannels, components and outputs,
; please see doc/example.mux and doc/advanced.mux
ensemble {
    id 0x4fff
    ecc 0xec

    local-time-offset auto
    label "OpenDigitalRadio"
    shortlabel "ODR"
}

services {
    srv-fu {
        id 0x8daa
        label "Funk"
    }
    srv-ri {
        id 0x8dab
        label "Rick"
    }
}

subchannels {
    sub-fu {
        type dabplus
        inputfile "tcp://*:9000"
        bitrate 96
        id 1
        protection 3
        zmq-buffer 40
        zmq-prebuffering 20
    }
    sub-ri {
        type dabplus
        inputfile "tcp://*:9001"
        bitrate 96
        id 2
        protection 3
        zmq-buffer 40
        zmq-prebuffering 20
    }
}

components {
    comp-fu {
        service srv-fu
        subchannel sub-fu
    }

    comp-ri {
        service srv-ri
        subchannel sub-ri
    }
}

outputs {
    file "file://./test.eti?type=raw"
    ;throttle "simul://"
}

