Skip to content

Commit

Permalink
Merge pull request #55 from r3b-fish/feature/exclude-empty-hls-key-in…
Browse files Browse the repository at this point in the history
…fo-file-param

Skip an empty -hls_key_info_file parameter
  • Loading branch information
xfrr committed Jun 24, 2020
2 parents 67dc504 + 644d31a commit fb3f88b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build:
docker:
# specify the version
- image: circleci/golang:1.11
- image: circleci/golang:1.14-buster
environment:
GO111MODULE: "on"

Expand All @@ -12,5 +12,6 @@ jobs:
- checkout

# specify any bash command here prefixed with `run: `
- run: go mod vendor
- run: go test -v ./tests/...
- run: sudo apt-get update && sudo apt-get install ffmpeg
- run: go mod download
- run: go test -failfast -v -run=. ./...
6 changes: 5 additions & 1 deletion models/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,11 @@ func (m *Mediafile) ObtainMapMetadata() []string {
}

func (m *Mediafile) ObtainEncryptionKey() []string {
return []string{"-hls_key_info_file", m.encryptionKey}
if m.encryptionKey != "" {
return []string{"-hls_key_info_file", m.encryptionKey}
}

return nil
}

func (m *Mediafile) ObtainBframe() []string {
Expand Down
21 changes: 21 additions & 0 deletions models/media_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package models

import (
"github.com/stretchr/testify/require"
"testing"
)

func TestMedia(t *testing.T) {
t.Run("#ObtainEncryptionKey", func(t *testing.T) {
t.Run("Should get nil if encryptionKey is not set", func(t *testing.T) {
mediaFile := Mediafile{}

require.Nil(t, mediaFile.ObtainEncryptionKey())
})

t.Run("Should return file.keyinfo if it's set", func(t *testing.T) {
mediaFile := Mediafile{encryptionKey: "file.keyinfo"}
require.Equal(t, []string{"-hls_key_info_file", "file.keyinfo"}, mediaFile.ObtainEncryptionKey())
})
})
}

0 comments on commit fb3f88b

Please sign in to comment.