Skip to content

Commit

Permalink
remove hls.js from the repository and restore plain MIT license (#3008)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Feb 11, 2024
1 parent fcf649c commit 9eb97ad
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 12 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/binaries
/coverage*.txt
/apidocs/*.html
**/hls.min.js
5 changes: 3 additions & 2 deletions .github/workflows/bump_hls_js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ jobs:
&& ((git checkout deps/hlsjs && git rebase ${GITHUB_REF_NAME}) || git checkout -b deps/hlsjs)
- run: >
curl -o internal/servers/hls/hls.min.js https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.min.js
&& echo VERSION=$(cat internal/servers/hls/hls.min.js | grep -o '"version",get:function(){return".*"}' | sed 's/"version",get:function(){return"\(.*\)"}/\1/') >> $GITHUB_ENV
VERSION=$(curl -s https://api.github.com/repos/video-dev/hls.js/releases?per_page=1 | grep tag_name | sed 's/\s\+"tag_name": "\(.\+\)",/\1/')
&& echo $VERSION > internal/servers/hls/hlsjsdownloader/VERSION
&& echo VERSION=$VERSION >> $GITHUB_ENV
- id: check_repo
run: >
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/binaries
/coverage*.txt
/apidocs/*.html
**/hls.min.js
5 changes: 0 additions & 5 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

internal/core/hls.min.js is Copyright (c) Dailymotion and is protected by
its own license (Apache License, Version 2.0) available at

https://github.com/video-dev/hls.js/blob/master/LICENSE
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ _rtsp-simple-server_ has been rebranded as _MediaMTX_. The reason is pretty obvi
* [OpenWrt](#openwrt-1)
* [Cross compile](#cross-compile)
* [Compile for all supported platforms](#compile-for-all-supported-platforms)
* [License](#license)
* [Specifications](#specifications)
* [Related projects](#related-projects)

Expand Down Expand Up @@ -1805,6 +1806,7 @@ Install git and Go ≥ 1.21. Clone the repository, enter into the folder and st
```sh
git clone https://github.com/bluenviron/mediamtx
cd mediamtx
go generate ./...
CGO_ENABLED=0 go build .
```

Expand All @@ -1825,6 +1827,7 @@ Download the repository, open a terminal in it and run:
cd internal/protocols/rpicamera/exe
make
cd ../../../../
go generate ./...
go build -tags rpicamera .
```

Expand All @@ -1844,6 +1847,7 @@ Clone the repository, enter into the folder and start the building process:
```sh
git clone https://github.com/bluenviron/mediamtx
cd mediamtx
go generate ./...
CGO_ENABLED=0 go build .
```

Expand All @@ -1860,6 +1864,7 @@ On the machine you want to use to compile, install git and Go ≥ 1.21. Clone t
```sh
git clone https://github.com/bluenviron/mediamtx
cd mediamtx
go generate ./...
CGO_ENABLED=0 GOOS=my_os GOARCH=my_arch go build .
```

Expand Down Expand Up @@ -1899,6 +1904,13 @@ make binaries

The command will produce tarballs in folder `binaries/`.

## License

All the code in this repository is released under the [MIT License](LICENSE). Compiled binaries make use of some third-party dependencies:

* hls.js, released under the [Apache License 2.0](https://github.com/video-dev/hls.js/blob/master/LICENSE)
* all the dependencies listed into the [go.mod file](go.mod), which are all released under either the MIT license, BSD-3-Clause license or Apache License 2.0

## Specifications

|name|area|
Expand Down
2 changes: 0 additions & 2 deletions internal/servers/hls/hls.min.js

This file was deleted.

1 change: 1 addition & 0 deletions internal/servers/hls/hlsjsdownloader/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.5.4
51 changes: 51 additions & 0 deletions internal/servers/hls/hlsjsdownloader/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Package main contains an utility to download hls.js
package main

import (
"fmt"
"io"
"log"
"net/http"
"os"
)

func do() error {
log.Println("downloading hls.js...")

buf, err := os.ReadFile("./hlsjsdownloader/VERSION")
if err != nil {
return err
}
version := string(buf[:len(buf)-1])

res, err := http.Get("https://cdn.jsdelivr.net/npm/hls.js@" + version + "/dist/hls.min.js")
if err != nil {
return err
}
defer res.Body.Close()

if res.StatusCode != http.StatusOK {
return fmt.Errorf("bad status code: %v", res.StatusCode)
}

buf, err = io.ReadAll(res.Body)
if err != nil {
return err
}

err = os.WriteFile("hls.min.js", buf, 0o644)
if err != nil {
return err
}

log.Println("ok")
return nil
}

func main() {
err := do()
if err != nil {
log.Printf("ERR: %v", err)
os.Exit(1)
}
}
3 changes: 3 additions & 0 deletions internal/servers/hls/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ const (
pauseAfterAuthError = 2 * time.Second
)

//go:generate go run ./hlsjsdownloader

//go:embed index.html
var hlsIndex []byte

//nolint:typecheck
//go:embed hls.min.js
var hlsMinJS []byte

Expand Down
1 change: 1 addition & 0 deletions scripts/binaries.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ENV CGO_ENABLED 0
RUN rm -rf tmp binaries
RUN mkdir tmp binaries
RUN cp mediamtx.yml LICENSE tmp/
RUN go generate ./...

FROM build-base AS build-windows-amd64
RUN GOOS=windows GOARCH=amd64 go build -ldflags "-X github.com/bluenviron/mediamtx/internal/core.version=$$VERSION" -o tmp/$(BINARY_NAME).exe
Expand Down
1 change: 1 addition & 0 deletions scripts/test-highlevel.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test-highlevel-nodocker:
go generate ./...
go test -v -race -tags enable_highlevel_tests ./internal/highleveltests

define DOCKERFILE_HIGHLEVEL_TEST
Expand Down
6 changes: 3 additions & 3 deletions scripts/test.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
LBITS := $(shell getconf LONG_BIT)
ifeq ($(LBITS),64)
RACE=-race
ifeq ($(shell getconf LONG_BIT),64)
RACE=-race
endif

test-internal:
go generate ./...
go test -v $(RACE) -coverprofile=coverage-internal.txt \
$$(go list ./internal/... | grep -v /core)

Expand Down

0 comments on commit 9eb97ad

Please sign in to comment.