rsked/source.cc
/// Read: encoding, medium, location.  All must be present and valid.
///
encoding, medium, location.  All must be present and valid.
encoding medium location . All must be present and valid .
void Source::extract_required_props( const Json::Value &slot )
{
    const Json::Value &medstr = slot["medium"];
    if (medstr.isNull()) {
        LOG_ERROR(Lgr) << "Source {" << m_name << "} does not specify medium";
        throw Schedule_error();
    }
    m_medium = strtomedium( medstr.asString() );
    const Json::Value &encstr = slot["encoding"];
    if (encstr.isNull()) {
        LOG_ERROR(Lgr) << "Source {" << m_name << "} does not specify encoding";
        throw Schedule_error();
    }
    m_encoding = strtoencoding( encstr.asString() );
    const Json::Value &lstr = slot["location"];
    if (lstr.isNull()) {
        LOG_ERROR(Lgr) << "Source {" << m_name << "} is missing a location";
        throw Schedule_error();
    }
    if (Medium::radio == m_medium) {
        constexpr const unsigned HZ_PER_MHZ = 1'000'000;
        double mhz = lstr.asDouble();
        if ((mhz < MinRadioFreqMHz) or (mhz > MaxRadioFreqMHz)) {
            LOG_ERROR(Lgr) << "Source {" << m_name
                           << "} invalid frequency: " << mhz;
            throw Schedule_error();
        }
        m_freq_hz = unsigned(HZ_PER_MHZ * mhz);
    }
    else if (Medium::stream == m_medium) {
        m_resource = lstr.asString();
    }
    else if ((Medium::file == m_medium) or (Medium::playlist == m_medium)
             or (Medium::directory == m_medium)) {
        extract_local_resource(slot);
    }
}
void Source :: extract_required_props ( const Json :: Value & slot ) { const Json :: Value & medstr = slot [ " " ] ; if ( medstr . isNull ( ) ) { LOG_ERROR ( Lgr ) << " " << m_name << " " ; throw Schedule_error ( ) ; } m_medium = strtomedium ( medstr . asString ( ) ) ; const Json :: Value & encstr = slot [ " " ] ; if ( encstr . isNull ( ) ) { LOG_ERROR ( Lgr ) << " " << m_name << " " ; throw Schedule_error ( ) ; } m_encoding = strtoencoding ( encstr . asString ( ) ) ; const Json :: Value & lstr = slot [ " " ] ; if ( lstr . isNull ( ) ) { LOG_ERROR ( Lgr ) << " " << m_name << " " ; throw Schedule_error ( ) ; } if ( Medium :: radio == m_medium ) { constexpr const unsigned HZ_PER_MHZ = 1'000'000 ; double mhz = lstr . asDouble ( ) ; if ( ( mhz < MinRadioFreqMHz ) or ( mhz > MaxRadioFreqMHz ) ) { LOG_ERROR ( Lgr ) << " " << m_name << " " << mhz ; throw Schedule_error ( ) ; } m_freq_hz = unsigned ( HZ_PER_MHZ * mhz ) ; } else if ( Medium :: stream == m_medium ) { m_resource = lstr . asString ( ) ; } else if ( ( Medium :: file == m_medium ) or ( Medium :: playlist == m_medium ) or ( Medium :: directory == m_medium ) ) { extract_local_resource ( slot ) ; } }
Read: encoding, medium, location.
Read : encoding medium location .
// //