Skip to content

Commit

Permalink
Added private data specifier descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
asticode committed Dec 17, 2017
1 parent bffd4ea commit 2adccc2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions astits/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ func descriptorToString(d *astits.Descriptor) string {
os = append(os, fmt.Sprintf("country: %s | rating: %d | minimum age: %d", i.CountryCode, i.Rating, i.MinimumAge()))
}
return "[Parental rating] " + strings.Join(os, " - ")
case astits.DescriptorTagPrivateDataSpecifier:
return fmt.Sprintf("[Private data specifier] specifier: %d", d.PrivateDataSpecifier.Specifier)
case astits.DescriptorTagService:
return fmt.Sprintf("[Service] service %s | provider: %s", d.Service.Name, d.Service.Provider)
case astits.DescriptorTagShortEvent:
Expand Down
2 changes: 1 addition & 1 deletion data_psi.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func psiTableType(tableID int) string {
return PSITableTypeTOT
}
// TODO Remove this log
astilog.Debugf("unlisted PSI table ID %d", tableID)
astilog.Debugf("astits: unlisted PSI table ID %d", tableID)
return PSITableTypeUnknown
}

Expand Down
17 changes: 15 additions & 2 deletions descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
DescriptorTagMaximumBitrate = 0xe
DescriptorTagNetworkName = 0x40
DescriptorTagParentalRating = 0x55
DescriptorTagPrivateDataSpecifier = 0x5f
DescriptorTagService = 0x48
DescriptorTagShortEvent = 0x4d
DescriptorTagStreamIdentifier = 0x52
Expand Down Expand Up @@ -88,6 +89,7 @@ type Descriptor struct {
MaximumBitrate *DescriptorMaximumBitrate
NetworkName *DescriptorNetworkName
ParentalRating *DescriptorParentalRating
PrivateDataSpecifier *DescriptorPrivateDataSpecifier
Service *DescriptorService
ShortEvent *DescriptorShortEvent
StreamIdentifier *DescriptorStreamIdentifier
Expand Down Expand Up @@ -427,7 +429,7 @@ func newDescriptorExtension(i []byte) (d *DescriptorExtension) {
d.SupplementaryAudio = newDescriptorExtensionSupplementaryAudio(b)
default:
// TODO Remove this log
astilog.Debugf("unlisted extension tag 0x%x", d.Tag)
astilog.Debugf("astits: unlisted extension tag 0x%x", d.Tag)
}
return
}
Expand Down Expand Up @@ -590,6 +592,15 @@ func newDescriptorParentalRating(i []byte) (d *DescriptorParentalRating) {
return
}

// DescriptorPrivateDataSpecifier represents a private data specifier descriptor
type DescriptorPrivateDataSpecifier struct {
Specifier uint32
}

func newDescriptorPrivateDataSpecifier(i []byte) *DescriptorPrivateDataSpecifier {
return &DescriptorPrivateDataSpecifier{Specifier: uint32(i[0])<<24 | uint32(i[1])<<16 | uint32(i[2])<<8 | uint32(i[3])}
}

// DescriptorService represents a service descriptor
// Page: 96 | Chapter: 6.2.33 | Link: https://www.dvb.org/resources/public/standards/a38_dvb-si_specification.pdf
type DescriptorService struct {
Expand Down Expand Up @@ -811,6 +822,8 @@ func parseDescriptors(i []byte, offset *int) (o []*Descriptor) {
d.NetworkName = newDescriptorNetworkName(b)
case DescriptorTagParentalRating:
d.ParentalRating = newDescriptorParentalRating(b)
case DescriptorTagPrivateDataSpecifier:
d.PrivateDataSpecifier = newDescriptorPrivateDataSpecifier(b)
case DescriptorTagService:
d.Service = newDescriptorService(b)
case DescriptorTagShortEvent:
Expand All @@ -827,7 +840,7 @@ func parseDescriptors(i []byte, offset *int) (o []*Descriptor) {
d.VBITeletext = newDescriptorTeletext(b)
default:
// TODO Remove this log
astilog.Debugf("unlisted descriptor tag 0x%x", d.Tag)
astilog.Debugf("astits: unlisted descriptor tag 0x%x", d.Tag)
}
*offset += int(d.Length)
}
Expand Down
9 changes: 8 additions & 1 deletion descriptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func descriptorsBytes(w *astibinary.Writer) {
func TestParseDescriptor(t *testing.T) {
// Init
w := astibinary.New()
w.Write(uint16(211)) // Descriptors length
w.Write(uint16(217)) // Descriptors length
// AC3
w.Write(uint8(DescriptorTagAC3)) // Tag
w.Write(uint8(9)) // Length
Expand Down Expand Up @@ -191,6 +191,10 @@ func TestParseDescriptor(t *testing.T) {
w.Write("1") // AVC still present
w.Write("1") // AVC 24 hour picture flag
w.Write("000000") // Reserved
// Private data specifier
w.Write(uint8(DescriptorTagPrivateDataSpecifier)) // Tag
w.Write(uint8(4)) // Length
w.Write(uint32(128)) // Private data specifier

// Assert
var offset int
Expand Down Expand Up @@ -334,4 +338,7 @@ func TestParseDescriptor(t *testing.T) {
LevelIDC: 2,
ProfileIDC: 1,
})
assert.Equal(t, *ds[19].PrivateDataSpecifier, DescriptorPrivateDataSpecifier{
Specifier: 128,
})
}

0 comments on commit 2adccc2

Please sign in to comment.