Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
encoders: start HLS integration
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioribeiro committed Nov 28, 2016
1 parent 09b8387 commit 578c4fa
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -26,3 +26,5 @@ _testmain.go
*.coverprofile
coverage.txt
.DS_Store

snickers
6 changes: 4 additions & 2 deletions Makefile
Expand Up @@ -12,9 +12,11 @@ build:
go get gopkg.in/mgo.v2
go get github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega
cd $$GOPATH/src/github.com/snickers/hls && make clean && make dep;
go build

run:
go run main.go
run: build
DYLD_LIBRARY_PATH=$$GOPATH/src/github.com/snickers/hls/build ./snickers

test:
@go vet ./...
Expand Down
20 changes: 20 additions & 0 deletions encoders/encoder.go
@@ -0,0 +1,20 @@
package encoders

import (
"code.cloudfoundry.org/lager"
"github.com/snickers/snickers/db"
"github.com/snickers/snickers/types"
)

// EncodeFunc is a function type for the multiple
// possible ways to encode the job
type EncodeFunc func(logger lager.Logger, dbInstance db.Storage, jobID string) error

// GetEncodeFunc returns the encode function
// based on the job source.
func GetEncodeFunc(job types.Job) EncodeFunc {
if job.ABR {
return HLSEncode
}
return FFMPEGEncode
}
19 changes: 19 additions & 0 deletions encoders/hls.go
@@ -0,0 +1,19 @@
package encoders

import (
"code.cloudfoundry.org/lager"
"github.com/snickers/hls/segmenter"
"github.com/snickers/snickers/db"
)

// HLSEncode function is responsible for encoding adaptive bitrate outputs
func HLSEncode(logger lager.Logger, dbInstance db.Storage, jobID string) error {
log := logger.Session("hls-encode")
log.Info("started", lager.Data{"job": jobID})
defer log.Info("finished")
var cfg segmenter.HLSConfig
if cfg.SourceFile == "" {
return nil
}
return nil
}
3 changes: 2 additions & 1 deletion pipeline/pipeline.go
Expand Up @@ -33,7 +33,8 @@ func StartJob(logger lager.Logger, config gonfig.Gonfig, dbInstance db.Storage,
}

log.Info("encoding")
if err := encoders.FFMPEGEncode(logger, dbInstance, job.ID); err != nil {
encodeFunc := encoders.GetEncodeFunc(job)
if err := encodeFunc(logger, dbInstance, job.ID); err != nil {
log.Error("encode failed", err)
job.Status = types.JobError
job.Details = err.Error()
Expand Down
1 change: 1 addition & 0 deletions types/job.go
Expand Up @@ -23,6 +23,7 @@ type Job struct {
Details string `json:"progress"`
LocalSource string `json:"-"`
LocalDestination string `json:"-"`
ABR bool `json:"abr"`
}

// JobInput stores the information passed from the
Expand Down

0 comments on commit 578c4fa

Please sign in to comment.