Skip to content

Commit

Permalink
Merge pull request #166 from Dash-Industry-Forum/fix-eccp
Browse files Browse the repository at this point in the history
Fix ECCP
  • Loading branch information
tobbee authored Mar 4, 2024
2 parents 6d87c17 + 2235ce2 commit 195acdc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Correct UTCTiming schemes for http-iso and http-head
- Make urlgen fields for negative test cases easier to fill
- Fix OPTIONS for livesim2/ path
- Fix encryption of segments for representations with previous metadata

## [1.2.0] - 2024-02-16

Expand Down
17 changes: 10 additions & 7 deletions cmd/livesim2/app/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,14 @@ func (r *RepData) readInit(vodFS fs.FS, assetPath string) error {
return fmt.Errorf("getInitBytes: %w", err)
}

if prepareForEncryption(r.Codecs) {
assetName := path.Base(assetPath)
err = r.addEncryption(assetName, data)
if err != nil {
return fmt.Errorf("addEncryption: %w", err)
}
}

if r.MediaTimescale != 0 {
return nil // Already set
}
Expand All @@ -761,13 +769,6 @@ func (r *RepData) readInit(vodFS fs.FS, assetPath string) error {
trex := r.initSeg.Moov.Mvex.Trex
r.DefaultSampleDuration = trex.DefaultSampleDuration

if prepareForEncryption(r.Codecs) {
assetName := path.Base(assetPath)
err = r.addEncryption(assetName, data)
if err != nil {
return fmt.Errorf("addEncryption: %w", err)
}
}
return nil
}

Expand Down Expand Up @@ -800,6 +801,7 @@ func (r *RepData) addEncryption(assetName string, data []byte) error {
if err != nil {
return fmt.Errorf("init protect cbcs: %w", err)
}
slog.Info("Encrypted init segment with cbcs", "asset", assetName, "repID", r.ID)
ed.cbcsPD = ipd
ed.cbcsInitSeg = initSeg
ed.cbcsInitBytes, err = getInitBytes(initSeg)
Expand All @@ -816,6 +818,7 @@ func (r *RepData) addEncryption(assetName string, data []byte) error {
if err != nil {
return fmt.Errorf("init protect cenc: %w", err)
}
slog.Info("Encrypted init segment with cenc", "asset", assetName, "repID", r.ID)
ed.cencPD = ipd
ed.cencInitSeg = initSeg
ed.cencInitBytes, err = getInitBytes(initSeg)
Expand Down
2 changes: 1 addition & 1 deletion cmd/livesim2/app/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func (s *Server) Routes(ctx context.Context) error {
// LiveRouter is mounted at /livesim2
s.LiveRouter.MethodFunc("GET", "/*", s.livesimHandlerFunc)
s.LiveRouter.MethodFunc("HEAD", "/*", s.livesimHandlerFunc)
s.Router.MethodFunc("OPTIONS", "/*", s.optionsHandlerFunc)
s.LiveRouter.MethodFunc("POST", "/*", s.laURLHandlerFunc)
s.LiveRouter.MethodFunc("OPTIONS", "/*", s.optionsHandlerFunc)
// VodRouter is mounted at /vod
s.VodRouter.MethodFunc("GET", "/*", s.vodHandlerFunc)
s.VodRouter.MethodFunc("HEAD", "/*", s.vodHandlerFunc)
Expand Down

0 comments on commit 195acdc

Please sign in to comment.