Skip to content

Commit

Permalink
Merge pull request #136 from Dash-Industry-Forum/fix-subtitle-content…
Browse files Browse the repository at this point in the history
…-type

fix: correct contentType for subtitles to text
  • Loading branch information
tobbee authored Nov 15, 2023
2 parents 5b0fada + c757d50 commit b41dd0c
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cmd/livesim2/app/handler_livesim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestFetches(t *testing.T) {
},
{
desc: "imsc1 image subtitle",
url: "testpic_2s_imsc1/imsc1_img_en/300.cmft?nowMS=610000",
url: "testpic_2s_imsc1/imsc1_img_en/300.m4s?nowMS=610000",
params: "",
wantedStatusCode: http.StatusOK,
wantedContentType: `application/mp4`,
Expand Down
2 changes: 1 addition & 1 deletion cmd/livesim2/app/livempd.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func LiveMPD(a *asset, mpdName string, cfg *ResponseConfig, nowMS int) (*m.MPD,
se = refSegEntries
} else {
switch as.ContentType {
case "video", "subtitle", "image":
case "video", "text", "image":
se = a.generateTimelineEntries(as.Representations[0].Id, wTimes, atoMS)
case "audio":
se = a.generateTimelineEntriesFromRef(refSegEntries, as.Representations[0].Id, wTimes, atoMS)
Expand Down
29 changes: 19 additions & 10 deletions cmd/livesim2/app/livempd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ func TestLiveMPDStart(t *testing.T) {
timescale: 1,
startNr: 7,
},
{
asset: "testpic_2s",
mpdName: "Manifest_imsc1.mpd",
nrMedia: "$RepresentationID$/$Number$.m4s",
timeMedia: "$RepresentationID$/$Time$.m4s",
timescale: 1,
startNr: 7,
},
}
for _, tc := range cases {
asset, ok := am.findAsset(tc.asset)
Expand All @@ -76,13 +84,11 @@ func TestLiveMPDStart(t *testing.T) {
stl := as.SegmentTemplate
assert.Nil(t, stl.SegmentTimeline)
assert.Equal(t, uint32(tc.startNr), *stl.StartNumber)
if as.ContentType != "image" {
assert.Equal(t, tc.nrMedia, stl.Media)
} else {
tcMedia := strings.Replace(tc.nrMedia, ".m4s", ".jpg", 1)
assert.Equal(t, tcMedia, stl.Media)
tcMedia := tc.nrMedia
if as.ContentType == "image" {
tcMedia = strings.Replace(tc.nrMedia, ".m4s", ".jpg", 1)
}

assert.Equal(t, tcMedia, stl.Media)
require.NotNil(t, stl.Duration)
require.Equal(t, tc.timescale, int(stl.GetTimescale()))
assert.Equal(t, 2, int(*stl.Duration)/int(stl.GetTimescale()))
Expand All @@ -95,16 +101,19 @@ func TestLiveMPDStart(t *testing.T) {
assert.Equal(t, m.DateTime("1970-01-01T00:00:00Z"), liveMPD.AvailabilityStartTime)
for _, as := range liveMPD.Periods[0].AdaptationSets {
stl := as.SegmentTemplate
if as.ContentType == "video" {
switch as.ContentType {
case "video":
require.Greater(t, stl.SegmentTimeline.S[0].R, 0)
}
if as.ContentType != "image" {
fallthrough
case "audio", "text":
assert.Nil(t, stl.StartNumber)
assert.Equal(t, tc.timeMedia, stl.Media)
} else {
case "image":
tcMedia := strings.Replace(tc.nrMedia, ".m4s", ".jpg", 1)
assert.Equal(t, tcMedia, stl.Media)
assert.Equal(t, tc.startNr, int(*stl.StartNumber))
default:
t.Errorf("unknown content type %s", as.ContentType)
}
}
assert.Equal(t, 1, len(liveMPD.UTCTimings))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</AdaptationSet>
<AdaptationSet contentType="text" mimeType="application/mp4" segmentAlignment="true" lang="en">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
<SegmentTemplate startNumber="1" initialization="$RepresentationID$/init.cmft" duration="2" media="$RepresentationID$/$Number$.cmft"/>
<SegmentTemplate startNumber="1" initialization="$RepresentationID$/init.mp4" duration="2" media="$RepresentationID$/$Number$.m4s"/>
<Representation id="imsc1_img_en" codecs="stpp.ttml.im1i" bandwidth="40000"/>
</AdaptationSet>
<AdaptationSet contentType="text" mimeType="application/mp4" segmentAlignment="true" lang="sv">
Expand Down

0 comments on commit b41dd0c

Please sign in to comment.