Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue #235 - endNumber in live MPD #236

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet
### Fixed

- endNumber in live MPD (Issue #235)

## [1.6.0] - 2024-12-03

Expand Down
3 changes: 3 additions & 0 deletions cmd/livesim2/app/livempd.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ func LiveMPD(a *asset, mpdName string, cfg *ResponseConfig, drmCfg *drm.DrmConfi
adaptationSets := orderAdaptationSetsByContentType(period.AdaptationSets)
var refSegEntries segEntries
for asIdx, as := range adaptationSets {
if as.SegmentTemplate != nil {
as.SegmentTemplate.EndNumber = nil // Never output endNumber
}
switch as.ContentType {
case "video", "audio":
if cfg.PatchTTL > 0 && as.Id == nil {
Expand Down
24 changes: 24 additions & 0 deletions cmd/livesim2/app/livempd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1013,3 +1013,27 @@ func TestFillContentTypes(t *testing.T) {
assert.Equal(t, m.RFC6838ContentTypeType("video"), p.AdaptationSets[5].ContentType)
assert.Equal(t, m.RFC6838ContentTypeType("audio"), p.AdaptationSets[6].ContentType)
}

func TestEndNumberRemovedFromMPD(t *testing.T) {
vodFS := os.DirFS("testdata/assets")
tmpDir := t.TempDir()
am := newAssetMgr(vodFS, tmpDir, false)
logger := slog.Default()
err := am.discoverAssets(logger)
require.NoError(t, err)
assetName := "testpic_2s"
asset, ok := am.findAsset(assetName)
require.True(t, ok)
require.NoError(t, err)
cfg := NewResponseConfig()
nowMS := 100_000
mpdName := "Manifest_endNumber.mpd"
liveMPD, err := LiveMPD(asset, mpdName, cfg, nil, nowMS)
assert.NoError(t, err)
aSets := liveMPD.Periods[0].AdaptationSets
assert.Len(t, aSets, 2)
for _, as := range aSets {
stl := as.SegmentTemplate
assert.Nil(t, stl.EndNumber)
}
}
20 changes: 20 additions & 0 deletions cmd/livesim2/app/testdata/assets/testpic_2s/Manifest_endNumber.mpd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:mpeg:dash:schema:mpd:2011" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"bprofiles="urn:mpeg:dash:profile:isoff-live:2011,http://dashif.org/guidelines/dash-if-simple" maxSegmentDuration="PT2S" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT8S" id="base">
<ProgramInformation>
<Title>640x360@30 video, 48kHz audio, 2s segments</Title>
</ProgramInformation>
<Period id="one" start="PT0S">
<AdaptationSet contentType="audio" id="1" mimeType="audio/mp4" lang="en" segmentAlignment="true" startWithSAP="1">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
<SegmentTemplate startNumber="1" endNumber="4" initialization="$RepresentationID$/init.mp4" duration="2" media="$RepresentationID$/$Number$.m4s"/>
<Representation id="A48" codecs="mp4a.40.2" bandwidth="48000" audioSamplingRate="48000">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
</Representation>
</AdaptationSet>
<AdaptationSet contentType="video" id="2" mimeType="video/mp4" segmentAlignment="true" startWithSAP="1" par="16:9" minWidth="640" maxWidth="640" minHeight="360" maxHeight="360" maxFrameRate="60/2">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
<SegmentTemplate startNumber="1" endNumber="4" initialization="$RepresentationID$/init.mp4" duration="2" media="$RepresentationID$/$Number$.m4s"/>
<Representation id="V300" codecs="avc1.64001e" bandwidth="300000" width="640" height="360" frameRate="60/2" sar="1:1"/>
</AdaptationSet>
</Period>
</MPD>
Loading