Skip to content

Commit

Permalink
Merge pull request #206 from Dash-Industry-Forum/cmaf-ingest
Browse files Browse the repository at this point in the history
CMAF Ingest
  • Loading branch information
tobbee authored Aug 14, 2024
2 parents ca3ec3f + ca0bb0c commit 7c3505d
Show file tree
Hide file tree
Showing 52 changed files with 3,315 additions and 125 deletions.
22 changes: 22 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,23 @@
"autodetected",
"autoplay",
"beevik",
"bmdt",
"btrt",
"caddyserver",
"cbcs",
"cenc",
"certmagic",
"certpath",
"cfhd",
"chunkdur",
"chunkparser",
"cmaf",
"cmfm",
"commandline",
"configprocessor",
"confmap",
"curr",
"danielgtaylor",
"dashif",
"ebuttm",
"ebutts",
Expand All @@ -46,16 +52,21 @@
"genurl",
"golangci",
"gzipped",
"Hdlr",
"healthz",
"htmpl",
"htmx",
"httpiso",
"httpisoms",
"httpxsdatems",
"huma",
"humachi",
"IDURI",
"IFECCP",
"imsc",
"Inband",
"ingester",
"ingesters",
"insertad",
"isoff",
"Itvl",
Expand All @@ -67,10 +78,12 @@
"Konf",
"laurl",
"livesim",
"lmsg",
"logfile",
"logformat",
"loglevel",
"ltgt",
"maxbuffer",
"maxrequests",
"mdat",
"Mdhd",
Expand All @@ -84,6 +97,9 @@
"mpds",
"multiperiod",
"Mvex",
"Mvhd",
"NALU",
"Nalus",
"outdir",
"Payl",
"peroff",
Expand All @@ -92,6 +108,7 @@
"posflag",
"pprof",
"prettylog",
"prft",
"promhttp",
"proxied",
"proxying",
Expand All @@ -115,6 +132,7 @@
"stppd",
"stpptime",
"stretchr",
"strm",
"stsd",
"Sttg",
"Sttp",
Expand All @@ -139,17 +157,21 @@
"tmpl",
"Traf",
"Trak",
"Traks",
"Trun",
"tsbd",
"TTML",
"ttmpl",
"udta",
"urlgen",
"urlprefix",
"UTCMS",
"vals",
"vatm",
"vodroot",
"vttc",
"vtte",
"waitgroup",
"WEBVTT",
"writerepdata",
"WVTT",
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added functions and constants for CMAF file extensions in pkg/cmaf
- Short HEVC + AC-3 test content
- Generation of CMAF ingest streams with a REST-based API
- New program `cmaf-ingest-receiver` that can receive one or more CMAF ingest streams

### Fixed

- Will now set contentType from mimeType on AdaptationSet or Representation level.
- If contentType and mimedType is not present, contentType will be set from codecs string.
- Issue with audio resegmentation.

### Changed

- Go version changed to 1.22

## [1.4.1] - 2024-05-28

### Fixed
Expand Down
70 changes: 70 additions & 0 deletions cmd/cmaf-ingest-receiver/app/basicauth_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package app

import (
"bytes"
"context"
"fmt"
"net/http"
"net/http/httptest"
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestBasicAuth(t *testing.T) {

config := Config{
Channels: []ChannelConfig{
{Name: "clear"},
{Name: "protected", AuthUser: "user", AuthPswd: "secret"},
{Name: "onlyuser", AuthUser: "user", AuthPswd: ""},
},
}
cases := []struct {
desc string
url string
user string
password string
expectedResponseCode int
}{
{desc: "No password", url: "clear/video/init.cmfv", expectedResponseCode: http.StatusOK},
{desc: "Valid password", url: "protected/video/init.cmfv", user: "user", password: "secret",
expectedResponseCode: http.StatusOK},
{desc: "Invalid password", url: "protected/video/init.cmfv", user: "user", password: "wrong",
expectedResponseCode: http.StatusUnauthorized},
{desc: "Only user specified", url: "onlyuser/video/init.cmfv", user: "user", password: "",
expectedResponseCode: http.StatusOK},
}

tmpDir, err := os.MkdirTemp("", "ew-cmaf-ingest-test")
defer os.RemoveAll(tmpDir)
assert.NoError(t, err)
opts := Options{
prefix: "/upload",
timeShiftBufferDepthS: 30,
storage: tmpDir,
}

data, err := os.ReadFile("testdata/video/init.cmfv")
assert.NoError(t, err)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
receiver, err := NewReceiver(ctx, &opts, &config)
require.NoError(t, err)
router := setupRouter(receiver)
server := httptest.NewServer(router)
defer server.Close()
for _, c := range cases {
buf := bytes.NewBuffer(data)
url := fmt.Sprintf("%s%s/%s", server.URL, opts.prefix, c.url)
req, err := http.NewRequest(http.MethodPut, url, buf)
require.NoError(t, err)
req.SetBasicAuth(c.user, c.password)
resp, err := http.DefaultClient.Do(req)
require.NoError(t, err)
assert.Equal(t, c.expectedResponseCode, resp.StatusCode)
}
}
Loading

0 comments on commit 7c3505d

Please sign in to comment.