Example #1
0
File: api5.go Project: ziutek/dvb
func (d Device) Hierarchy() (dvb.Hierarchy, error) {
	h, e := d.get(dtvHierarchy)
	if e != 0 {
		return 0, Error{"get", "hierarchy", e}
	}
	return dvb.Hierarchy(h), nil
}
Example #2
0
func ParseTerrestrialDeliverySystemDescriptor(d Descriptor) (tds TerrestrialDeliverySystemDescriptor, ok bool) {
	if d.Tag() != TerrestrialDeliverySystemTag {
		return
	}
	data := d.Data()
	if len(data) < 11 {
		return
	}
	tds.Freq = int64(decodeU32(data[0:4])) * 10
	switch data[4] >> 5 {
	case 0:
		tds.Bandwidth = 8e6
	case 1:
		tds.Bandwidth = 7e6
	case 2:
		tds.Bandwidth = 6e6
	case 3:
		tds.Bandwidth = 5e6
	default:
		return
	}
	tds.HighPrio = data[4]&0x10 != 0
	tds.TimeSlicing = data[4]&0x08 == 0
	tds.MPEFEC = data[4]&0x04 == 0
	switch data[5] >> 6 {
	case 0:
		tds.Constellation = dvb.QPSK
	case 1:
		tds.Constellation = dvb.QAM16
	case 2:
		tds.Constellation = dvb.QAM64
	default:
		return
	}
	tds.Hierarchy = dvb.Hierarchy((data[5] >> 3) & 0x07)
	if tds.Hierarchy > dvb.Hierarchy4 {
		return
	}
	tds.CodeRateHP = decodeCodeRate(data[5] & 0x07)
	if tds.CodeRateHP == dvb.FECAuto || tds.CodeRateHP == dvb.FECNone {
		return
	}
	tds.CodeRateLP = decodeCodeRate(data[6] >> 5)
	if tds.CodeRateLP == dvb.FECAuto {
		return
	}
	tds.Guard = dvb.Guard((data[6] >> 3) & 0x03)
	tds.TxMode = dvb.TxMode((data[6] >> 1) & 0x03)
	if tds.TxMode > dvb.TxMode8k {
		return
	}
	tds.OtherFreq = data[6]&0x01 != 0
	ok = true
	return
}