func (d Device) TxMode() (dvb.TxMode, error) { m, e := d.get(dtvTransmissionMode) if e != 0 { return 0, Error{"get", "transmission mode", e} } return dvb.TxMode(m), nil }
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 }