diff --git a/main.go b/main.go index fa85ec1a..e9a4141b 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( _ "github.com/NYTimes/video-transcoding-api/provider/encodingcom" _ "github.com/NYTimes/video-transcoding-api/provider/zencoder" "github.com/NYTimes/video-transcoding-api/service" + _ "github.com/bitmovin/video-transcoding-api/provider/bitmovin" "github.com/google/gops/agent" "github.com/knq/sdhook" "github.com/marzagao/logrus-env" diff --git a/provider/bitmovin/bitmovin.go b/provider/bitmovin/bitmovin.go index 62527c02..e8fdc2d5 100644 --- a/provider/bitmovin/bitmovin.go +++ b/provider/bitmovin/bitmovin.go @@ -9,19 +9,26 @@ import ( "strings" "time" + "github.com/NYTimes/video-transcoding-api/config" "github.com/NYTimes/video-transcoding-api/db" "github.com/NYTimes/video-transcoding-api/provider" "github.com/bitmovin/bitmovin-go/bitmovin" "github.com/bitmovin/bitmovin-go/bitmovintypes" "github.com/bitmovin/bitmovin-go/models" "github.com/bitmovin/bitmovin-go/services" - "github.com/bitmovin/video-transcoding-api/config" ) // Name is the name used for registering the bitmovin provider in the // registry of providers. const Name = "bitmovin" +// Just to double check the interface is properly implemented +var _ provider.TranscodingProvider = (*bitmovinProvider)(nil) + +func init() { + provider.Register(Name, bitmovinConductorFactory) +} + var h264Levels = []bitmovintypes.H264Level{ bitmovintypes.H264Level1, bitmovintypes.H264Level1b, @@ -823,6 +830,15 @@ func parseS3URL(input string) (bucketName string, path string, fileName string, return "", "", "", bitmovintypes.AWSCloudRegion(""), errors.New("") } +func bitmovinConductorFactory(cfg *config.Config) (provider.TranscodingProvider, error) { + if cfg.Bitmovin.APIKey == "" || cfg.Bitmovin.AccessKeyID == "" || cfg.Bitmovin.SecretAccessKey == "" { + return nil, errors.New("") + } + client := bitmovin.NewBitmovin(cfg.Bitmovin.APIKey, cfg.Bitmovin.Endpoint, int64(cfg.Bitmovin.Timeout)) + + return &bitmovinProvider{client: client, config: cfg.Bitmovin}, nil +} + func stringToPtr(s string) *string { return &s }