mirror of
https://github.com/bluenviron/mediamtx
synced 2025-03-25 04:18:48 +00:00
parent
1133c734ab
commit
1e15d4995c
64
.github/workflows/bump-hls-js.yml
vendored
Normal file
64
.github/workflows/bump-hls-js.yml
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
name: bump-hls-js
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '4 5 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
bump-hls-js:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- run: >
|
||||
git config user.name mediamtx-bot
|
||||
&& git config user.email bot@mediamtx
|
||||
&& ((git checkout deps/hlsjs && git rebase ${GITHUB_REF_NAME}) || git checkout -b deps/hlsjs)
|
||||
|
||||
- run: >
|
||||
curl -o internal/core/hls.min.js https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.min.js
|
||||
&& echo VERSION=$(cat internal/core/hls.min.js | grep -o '"version",get:function(){return".*"}' | sed 's/"version",get:function(){return"\(.*\)"}/\1/') >> $GITHUB_ENV
|
||||
|
||||
- id: check_repo
|
||||
run: >
|
||||
echo "clean=$(git status --porcelain)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- if: ${{ steps.check_repo.outputs.clean != '' }}
|
||||
run: >
|
||||
&& git reset ${GITHUB_REF_NAME}
|
||||
&& git add .
|
||||
&& git commit -m "bump hls-js to v${VERSION}"
|
||||
&& git push --set-upstream origin deps/hlsjs --force
|
||||
|
||||
- if: ${{ steps.check_repo.outputs.clean != '' }}
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const prs = await github.rest.pulls.list({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
head: 'deps/hlsjs',
|
||||
state: 'open',
|
||||
});
|
||||
|
||||
if (prs.data.length == 0) {
|
||||
await github.rest.pulls.create({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
head: 'deps/hlsjs',
|
||||
base: context.ref.slice('refs/heads/'.length),
|
||||
title: `bump hls-js to v${process.env.VERSION}`,
|
||||
});
|
||||
} else {
|
||||
github.rest.pulls.update({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: prs.data[0].number,
|
||||
title: `bump hls-js to v${process.env.VERSION}`,
|
||||
});
|
||||
}
|
5
LICENSE
5
LICENSE
@ -19,3 +19,8 @@ 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.
|
||||
|
||||
src/internal/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
|
||||
|
@ -1551,3 +1551,4 @@ The command will produce tarballs in folder `binaries/`.
|
||||
* [notedit/rtmp (RTMP library used internally)](https://github.com/notedit/rtmp)
|
||||
* [go-astits (MPEG-TS library used internally)](https://github.com/asticode/go-astits)
|
||||
* [go-mp4 (MP4 library used internally)](https://github.com/abema/go-mp4)
|
||||
* [hls.js (browser-side HLS library used internally)](https://github.com/video-dev/hls.js)
|
||||
|
2
internal/core/hls.min.js
vendored
Normal file
2
internal/core/hls.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -23,6 +23,9 @@ const (
|
||||
//go:embed hls_index.html
|
||||
var hlsIndex []byte
|
||||
|
||||
//go:embed hls.min.js
|
||||
var hlsMinJS []byte
|
||||
|
||||
type hlsHTTPServerParent interface {
|
||||
logger.Writer
|
||||
handleRequest(req hlsMuxerHandleRequestReq)
|
||||
@ -118,6 +121,13 @@ func (s *hlsHTTPServer) onRequest(ctx *gin.Context) {
|
||||
var fname string
|
||||
|
||||
switch {
|
||||
case strings.HasSuffix(pa, "/hls.min.js"):
|
||||
ctx.Writer.Header().Set("Cache-Control", "max-age=3600")
|
||||
ctx.Writer.Header().Set("Content-Type", "application/javascript")
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Writer.Write(hlsMinJS)
|
||||
return
|
||||
|
||||
case pa == "", pa == "favicon.ico":
|
||||
return
|
||||
|
||||
@ -190,6 +200,7 @@ func (s *hlsHTTPServer) onRequest(ctx *gin.Context) {
|
||||
|
||||
switch fname {
|
||||
case "":
|
||||
ctx.Writer.Header().Set("Cache-Control", "max-age=3600")
|
||||
ctx.Writer.Header().Set("Content-Type", "text/html")
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Writer.Write(hlsIndex)
|
||||
|
@ -19,7 +19,7 @@ html, body {
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.4.10"></script>
|
||||
<script src="hls.min.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
|
@ -205,11 +205,13 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) {
|
||||
|
||||
switch fname {
|
||||
case "":
|
||||
ctx.Writer.Header().Set("Cache-Control", "max-age=3600")
|
||||
ctx.Writer.Header().Set("Content-Type", "text/html")
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Writer.Write(webrtcReadIndex)
|
||||
|
||||
case "publish":
|
||||
ctx.Writer.Header().Set("Cache-Control", "max-age=3600")
|
||||
ctx.Writer.Header().Set("Content-Type", "text/html")
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Writer.Write(webrtcPublishIndex)
|
||||
|
Loading…
Reference in New Issue
Block a user