diff --git a/README.md b/README.md index 31025991..00dc34da 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ The Video Transcoding API provides an agnostic API to transcode media assets across different cloud services. Currently, it supports the following providers: -- [Amazon Elastic Transcoder](https://aws.amazon.com/elastictranscoder/) - [Bitmovin](http://bitmovin.com) - [Elemental Conductor](http://www.elementaltechnologies.com/products/elemental-conductor) - [Encoding.com](http://encoding.com) @@ -25,19 +24,6 @@ environment variables: ### Providers configuration -#### For [Amazon Elastic Transcoder](https://aws.amazon.com/elastictranscoder/) - -``` -export AWS_ACCESS_KEY_ID=your.access.key.id -export AWS_SECRET_ACCESS_KEY=your.secret.access.key -export AWS_REGION="us-east-1" -export ELASTICTRANSCODER_PIPELINE_ID="yourpipeline-id" -``` - -Please notice that for Elastic Transcoder you don't specify the destination -bucket, as it is [defined in the Elastic Transcoder -Pipeline](https://docs.aws.amazon.com/elastictranscoder/latest/developerguide/pipeline-settings.html#pipeline-settings-configure-transcoded-bucket). - #### For [Bitmovin](http://bitmovin.com) ``` diff --git a/config/config.go b/config/config.go index 84bfcf29..8d448e57 100644 --- a/config/config.go +++ b/config/config.go @@ -15,7 +15,6 @@ type Config struct { DefaultSegmentDuration uint `envconfig:"DEFAULT_SEGMENT_DURATION" default:"5"` Redis *storage.Config EncodingCom *EncodingCom - ElasticTranscoder *ElasticTranscoder ElementalConductor *ElementalConductor Hybrik *Hybrik Zencoder *Zencoder @@ -41,15 +40,6 @@ type Zencoder struct { Destination string `envconfig:"ZENCODER_DESTINATION"` } -// ElasticTranscoder represents the set of configurations for the Elastic -// Transcoder provider. -type ElasticTranscoder struct { - AccessKeyID string `envconfig:"AWS_ACCESS_KEY_ID"` - SecretAccessKey string `envconfig:"AWS_SECRET_ACCESS_KEY"` - Region string `envconfig:"AWS_REGION"` - PipelineID string `envconfig:"ELASTICTRANSCODER_PIPELINE_ID"` -} - // ElementalConductor represents the set of configurations for the Elemental // Conductor provider. type ElementalConductor struct { diff --git a/config/config_test.go b/config/config_test.go index 675cbd96..dbc08475 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -29,7 +29,6 @@ func TestLoadConfigFromEnv(t *testing.T) { "AWS_ACCESS_KEY_ID": "AKIANOTREALLY", "AWS_SECRET_ACCESS_KEY": "secret-key", "AWS_REGION": "us-east-1", - "ELASTICTRANSCODER_PIPELINE_ID": "mypipeline", "ELEMENTALCONDUCTOR_HOST": "elemental-server", "ELEMENTALCONDUCTOR_USER_LOGIN": "myuser", "ELEMENTALCONDUCTOR_API_KEY": "secret-key", @@ -83,12 +82,6 @@ func TestLoadConfigFromEnv(t *testing.T) { PresetPath: "transcoding-api-presets", }, Zencoder: &Zencoder{}, - ElasticTranscoder: &ElasticTranscoder{ - AccessKeyID: "AKIANOTREALLY", - SecretAccessKey: "secret-key", - Region: "us-east-1", - PipelineID: "mypipeline", - }, ElementalConductor: &ElementalConductor{ Host: "elemental-server", UserLogin: "myuser", @@ -151,7 +144,6 @@ func TestLoadConfigFromEnvWithDefaults(t *testing.T) { "AWS_ACCESS_KEY_ID": "AKIANOTREALLY", "AWS_SECRET_ACCESS_KEY": "secret-key", "AWS_REGION": "us-east-1", - "ELASTICTRANSCODER_PIPELINE_ID": "mypipeline", "ELEMENTALCONDUCTOR_HOST": "elemental-server", "ELEMENTALCONDUCTOR_USER_LOGIN": "myuser", "ELEMENTALCONDUCTOR_API_KEY": "secret-key", @@ -187,12 +179,6 @@ func TestLoadConfigFromEnvWithDefaults(t *testing.T) { Destination: "https://safe-stuff", StatusEndpoint: "http://status.encoding.com", }, - ElasticTranscoder: &ElasticTranscoder{ - AccessKeyID: "AKIANOTREALLY", - SecretAccessKey: "secret-key", - Region: "us-east-1", - PipelineID: "mypipeline", - }, ElementalConductor: &ElementalConductor{ Host: "elemental-server", UserLogin: "myuser", diff --git a/go.mod b/go.mod index 7266efa9..1907dcc4 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/video-dev/video-transcoding-api/v2 require ( github.com/NYTimes/gizmo v1.2.14 github.com/NYTimes/gziphandler v1.1.1 - github.com/aws/aws-sdk-go v1.22.1 github.com/aws/aws-sdk-go-v2 v0.10.0 github.com/bitmovin/bitmovin-go v1.29.0 github.com/fsouza/ctxlogger v1.5.8 diff --git a/go.sum b/go.sum index c0adf95c..d204745a 100644 --- a/go.sum +++ b/go.sum @@ -1,33 +1,23 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.30.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0 h1:ROfEUZz+Gh5pa62DJWXSaonyu3StP6EA6lPEXPI6mCo= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -contrib.go.opencensus.io/exporter/ocagent v0.6.0/go.mod h1:zmKjrJcdo0aYcVS7bmEeSEBLPA9YJp5bjrofdU3pIXs= contrib.go.opencensus.io/exporter/stackdriver v0.12.2/go.mod h1:iwB6wGarfphGGe/e5CWqyUk/cLzKnWsOKPVW3no6OTw= contrib.go.opencensus.io/resource v0.1.1/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/zstd v1.3.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Gurpartap/logrus-stack v0.0.0-20170710170904-89c00d8a28f4 h1:vdT7QwBhJJEVNFMBNhRSFDRCB6O16T28VhvqRgqFyn8= github.com/Gurpartap/logrus-stack v0.0.0-20170710170904-89c00d8a28f4/go.mod h1:SvXOG8ElV28oAiG9zv91SDe5+9PfIr7PPccpr8YyXNs= -github.com/NYTimes/gizmo v1.2.13 h1:E8N8UXlOiRFD7jmpbR2q+ODxs8TlRf4yNTl1b6YVqto= -github.com/NYTimes/gizmo v1.2.13/go.mod h1:EVueweNcfm9LqrtNwpJE0VtnrQjkKKeCzVhEcrT1+pM= github.com/NYTimes/gizmo v1.2.14 h1:JvS7HxJI8QRgifnxPyCDof8tGYy0nz6eO93UWqZ2ypo= github.com/NYTimes/gizmo v1.2.14/go.mod h1:gb8iDOhy/u7Go0HsGgc7rQ9m3tA7bgbUndgeX4my1Ns= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/NYTimes/logrotate v1.0.0 h1:6jFGbon6jOtpy3t3kwZZKS4Gdmf1C/Wv5J4ll4Xn5yk= github.com/NYTimes/logrotate v1.0.0/go.mod h1:GxNz1cSw1c6t99PXoZlw+nm90H6cyQyrH66pjVv7x88= -github.com/Shopify/sarama v1.20.1/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/sarama v1.23.1/go.mod h1:XLH1GYJnLVE0XCr6KdJGVJRTwY30moWNJ4sERjXX6fs= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v0.0.0-20170410192909-ea383cf3ba6e/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/aws/aws-sdk-go v1.19.18/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.22.0 h1:e88V6+dSEyBibUy0ekOydtTfNWzqG3hrtCR8SF6UqqY= -github.com/aws/aws-sdk-go v1.22.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.22.1 h1://WJvJi9iq/i5TWHuK3hIC23xCZYH7Qv7SIN2vZVqxY= -github.com/aws/aws-sdk-go v1.22.1/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go-v2 v0.10.0 h1:qxZ7TyWFEIucMPQR2qymRx7JZ+hWF0N8HyCWh0XKh6Q= github.com/aws/aws-sdk-go-v2 v0.10.0/go.mod h1:cpXCmy3BB+lqwGweJjdawczHW3a+g8QgcFHcoOVoHao= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= @@ -38,7 +28,6 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4Yn github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60= github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -52,15 +41,10 @@ github.com/fluent/fluent-logger-golang v1.4.0 h1:uT1Lzz5yFV16YvDwWbjX6s3AYngnJz8 github.com/fluent/fluent-logger-golang v1.4.0/go.mod h1:2/HCT/jTy78yGyeNGQLGQsjF3zzzAuy6Xlk6FCMV5eU= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsouza/ctxlogger v1.5.7 h1:DhyLAfmgDpaUp/3aa71NHFcUs13/uu8GKyvHC9pH0IU= -github.com/fsouza/ctxlogger v1.5.7/go.mod h1:kzKQDXb9zfDx4l7s1FWTE37Oee9krkOnV6os+T2RC08= github.com/fsouza/ctxlogger v1.5.8 h1:WeCzJZNkXx2QbQn4ae3tVU58zBcPGMA+o7ykYqhU74o= github.com/fsouza/ctxlogger v1.5.8/go.mod h1:lZ2fh22JdnuMCgYmJOZqq32peZgwhEL+R6X3+MILHvc= -github.com/fsouza/gizmo-stackdriver-logging v1.3.0 h1:9Oj6+VWGSHRG6mDRGhwNRKxtwqb15I4kAXlIlpwY92k= -github.com/fsouza/gizmo-stackdriver-logging v1.3.0/go.mod h1:aa9jncdWMsq4dOoOlyueqBaovtSeg1tVUiaoMVzbjt4= github.com/fsouza/gizmo-stackdriver-logging v1.3.1 h1:/Ly7X0CWRN+VwLOctlewtt9Bvg+OwtFd/76VPEAyj/M= github.com/fsouza/gizmo-stackdriver-logging v1.3.1/go.mod h1:cvIA5UbpvKN+pZir82dMhwPouAmytECQHrCDfdXbpow= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA= @@ -80,7 +64,6 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= @@ -94,7 +77,6 @@ github.com/google/gops v0.3.6/go.mod h1:RZ1rH95wsAGX4vMWKmqBOIWynmWisBf4QFdgT/k/ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.4.0 h1:XulKRWSQK5uChr4pEgSE4Tc/OcmnU9GJuSwdog/tZsA= @@ -104,7 +86,6 @@ github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/ github.com/gorilla/mux v1.7.0 h1:tOSd0UKHQd6urX6ApfOn4XdBMY6Sh1MfxV3kmaazO+U= github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/grpc-gateway v1.9.4/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= @@ -117,7 +98,6 @@ github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03/go.mod h1:MK8+TM0 github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 h1:PJPDf8OUfOK1bb/NeTKd4f1QXZItOX389VN3B6qC8ro= github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/kelseyhightower/envconfig v1.3.0 h1:IvRS4f2VcIQy6j4ORGIf9145T/AsUB+oY8LyvN8BXNM= @@ -128,17 +108,13 @@ github.com/keybase/go-ps v0.0.0-20161005175911-668c8856d999 h1:2d+FLQbz4xRTi36DO github.com/keybase/go-ps v0.0.0-20161005175911-668c8856d999/go.mod h1:hY+WOq6m2FpbvyrI93sMaypsttvaIL5nhVR92dTMUcQ= github.com/knq/jwt v0.0.0-20180925223530-fc44a4704737 h1:1xIW/VaRuKqTia61AXVrIFt2wDeIgXyVmSFU6wX1cx4= github.com/knq/jwt v0.0.0-20180925223530-fc44a4704737/go.mod h1:H6bRgq8JMACag/WS+QyO3B00Hx9JZTF/zUHxNhzkxqo= -github.com/knq/pemutil v0.0.0-20180607233853-a6a7785bc45a h1:IPa47OrAMfRqw3RENZIMQF4rwU7doG3rNmvdzeeVYYQ= -github.com/knq/pemutil v0.0.0-20180607233853-a6a7785bc45a/go.mod h1:2VjBu5gkjU1wG99pRhJ+zm/P4bHnjdRY0CIMP9Gvn7Q= github.com/knq/pemutil v0.0.0-20181215144041-fb6fad722528 h1:W50e/aaqE/OF4zTsWRfLtkHzX44jNgIz8w1rKNV0dfg= github.com/knq/pemutil v0.0.0-20181215144041-fb6fad722528/go.mod h1:2VjBu5gkjU1wG99pRhJ+zm/P4bHnjdRY0CIMP9Gvn7Q= -github.com/knq/sdhook v0.0.0-20190114230312-41b9ccbff0b5 h1:K/XIPlDNzUOLjG4qPhSatnVlmma7kfB8tpUiQukjkJ0= -github.com/knq/sdhook v0.0.0-20190114230312-41b9ccbff0b5/go.mod h1:xneOdR9bxZt/0EInYiWOz9U07+AimqnjxFxRyndR8/0= github.com/knq/sdhook v0.0.0-20190801142816-0b7fa827d09a h1:ISpJvNQW7atuiFtuI4eYn+7OR6LkebeEg66toOw+0tM= github.com/knq/sdhook v0.0.0-20190801142816-0b7fa827d09a/go.mod h1:YActjSMTbqNCLzYRAgL+4cP6LHj46roJGtFl/iIKBRI= -github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -161,7 +137,6 @@ github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v0.0.0-20190327172049-315a67e90e41/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= -github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -174,24 +149,17 @@ github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 h1:PnBWHBf+6L0jOqq0gIVUe6Yk0/QMZ640k6NvkxcBf+8= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.0.0-20181218105931-67670fe90761 h1:z6tvbDJ5OLJ48FFmnksv04a78maSTRBUIhkdHYV5Y98= -github.com/prometheus/common v0.0.0-20181218105931-67670fe90761/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7 h1:80VN+vGkqM773Br/uNNTSheo3KatTgV8IpjIKjvVLng= github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= -github.com/sirupsen/logrus v1.1.1/go.mod h1:zrgwTnHtNr00buQ1vSptGe8m1f/BbgsPukg8qsT7A+A= github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME= github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa/go.mod h1:2RVY1rIf+2J2o/IM9+vPq9RzmHDSseB7FoXiSNIUsoU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= @@ -214,7 +182,6 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -226,9 +193,7 @@ golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181017193950-04a2e542c03f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -240,7 +205,6 @@ golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8 golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= @@ -257,8 +221,6 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181019160139-8e24a49d80f8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= @@ -268,8 +230,6 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b h1:ag/x1USPSsqHud38I9BAC88qd golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 h1:rM0ROo5vb9AdYJi1110yjWGMej9ITfKddS89P3Fkhug= golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 h1:LepdCS8Gf/MVejFIt8lsiexZATdoGVyp5bcyS+rYoUI= -golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To= @@ -284,7 +244,6 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -google.golang.org/api v0.0.0-20181021000519-a2651947f503/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.5.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0 h1:9sdfJOzWlkqPltHAuzT2Cp+yrBeY1KRVYgms8soxMwM= @@ -308,9 +267,8 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.22.0 h1:J0UbZOIrCAl+fpTOf8YLs4dJo8L/owV4LYVtAXQoPkw= google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/jcmturner/aescts.v1 v1.0.1/go.mod h1:nsR8qBOg+OucoIW+WMhB3GspUQXq9XorLnQb9XtvcOo= @@ -318,10 +276,8 @@ gopkg.in/jcmturner/dnsutils.v1 v1.0.1/go.mod h1:m3v+5svpVOhtFAP/wSz+yzh4Mc0Fg7eR gopkg.in/jcmturner/goidentity.v3 v3.0.0/go.mod h1:oG2kH0IvSYNIu80dVAyu/yoefjq1mNfM5bm88whjWx4= gopkg.in/jcmturner/gokrb5.v7 v7.2.3/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuvyavf11/WM= gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/main.go b/main.go index b4d18545..19107d56 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,6 @@ import ( "github.com/google/gops/agent" "github.com/video-dev/video-transcoding-api/v2/config" _ "github.com/video-dev/video-transcoding-api/v2/provider/bitmovin" - _ "github.com/video-dev/video-transcoding-api/v2/provider/elastictranscoder" _ "github.com/video-dev/video-transcoding-api/v2/provider/elementalconductor" _ "github.com/video-dev/video-transcoding-api/v2/provider/encodingcom" _ "github.com/video-dev/video-transcoding-api/v2/provider/hybrik" diff --git a/provider/elastictranscoder/aws.go b/provider/elastictranscoder/aws.go deleted file mode 100644 index aa37ba34..00000000 --- a/provider/elastictranscoder/aws.go +++ /dev/null @@ -1,419 +0,0 @@ -// Package elastictranscoder provides a implementation of the provider that -// uses AWS Elastic Transcoder for transcoding media files. -// -// It doesn't expose any public type. In order to use the provider, one must - -// -// import ( -// "github.com/video-dev/video-transcoding-api/v2/provider" -// "github.com/video-dev/video-transcoding-api/v2/provider/elastictranscoder" -// ) -// -// func UseProvider() { -// factory, err := provider.GetProviderFactory(elastictranscoder.Name) -// // handle err and use factory to get an instance of the provider. -// } -package elastictranscoder - -import ( - "errors" - "fmt" - "path/filepath" - "regexp" - "strconv" - "strings" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/elastictranscoder" - "github.com/aws/aws-sdk-go/service/elastictranscoder/elastictranscoderiface" - "github.com/video-dev/video-transcoding-api/v2/config" - "github.com/video-dev/video-transcoding-api/v2/db" - "github.com/video-dev/video-transcoding-api/v2/provider" -) - -const ( - // Name is the name used for registering the Elastic Transcoder - // provider in the registry of providers. - Name = "elastictranscoder" - - defaultAWSRegion = "us-east-1" - hlsPlayList = "HLSv3" -) - -var ( - errAWSInvalidConfig = errors.New("invalid Elastic Transcoder config. Please define the configuration entries in the config file or environment variables") - s3Pattern = regexp.MustCompile(`^s3://`) -) - -func init() { - provider.Register(Name, elasticTranscoderFactory) -} - -type awsProvider struct { - c elastictranscoderiface.ElasticTranscoderAPI - config *config.ElasticTranscoder -} - -func (p *awsProvider) Transcode(job *db.Job) (*provider.JobStatus, error) { - var adaptiveStreamingOutputs []db.TranscodeOutput - source := p.normalizeSource(job.SourceMedia) - params := elastictranscoder.CreateJobInput{ - PipelineId: aws.String(p.config.PipelineID), - Input: &elastictranscoder.JobInput{Key: aws.String(source)}, - } - params.Outputs = make([]*elastictranscoder.CreateJobOutput, len(job.Outputs)) - for i, output := range job.Outputs { - presetID, ok := output.Preset.ProviderMapping[Name] - if !ok { - return nil, provider.ErrPresetMapNotFound - } - presetQuery := &elastictranscoder.ReadPresetInput{ - Id: aws.String(presetID), - } - presetOutput, err := p.c.ReadPreset(presetQuery) - if err != nil { - return nil, err - } - if presetOutput.Preset == nil || presetOutput.Preset.Container == nil { - return nil, fmt.Errorf("misconfigured preset: %s", presetID) - } - var isAdaptiveStreamingPreset bool - if *presetOutput.Preset.Container == "ts" { - isAdaptiveStreamingPreset = true - adaptiveStreamingOutputs = append(adaptiveStreamingOutputs, output) - } - params.Outputs[i] = &elastictranscoder.CreateJobOutput{ - PresetId: aws.String(presetID), - Key: p.outputKey(job, output.FileName, isAdaptiveStreamingPreset), - } - if isAdaptiveStreamingPreset { - params.Outputs[i].SegmentDuration = aws.String(strconv.Itoa(int(job.StreamingParams.SegmentDuration))) - } - } - - if len(adaptiveStreamingOutputs) > 0 { - playlistFileName := job.StreamingParams.PlaylistFileName - playlistFileName = strings.TrimRight(playlistFileName, filepath.Ext(playlistFileName)) - jobPlaylist := elastictranscoder.CreateJobPlaylist{ - Format: aws.String(hlsPlayList), - Name: aws.String(job.ID + "/" + playlistFileName), - } - - jobPlaylist.OutputKeys = make([]*string, len(adaptiveStreamingOutputs)) - for i, output := range adaptiveStreamingOutputs { - jobPlaylist.OutputKeys[i] = p.outputKey(job, output.FileName, true) - } - - params.Playlists = []*elastictranscoder.CreateJobPlaylist{&jobPlaylist} - } - resp, err := p.c.CreateJob(¶ms) - if err != nil { - return nil, err - } - return &provider.JobStatus{ - ProviderName: Name, - ProviderJobID: aws.StringValue(resp.Job.Id), - Status: provider.StatusQueued, - }, nil -} - -func (p *awsProvider) normalizeSource(source string) string { - if s3Pattern.MatchString(source) { - source = strings.Replace(source, "s3://", "", 1) - parts := strings.SplitN(source, "/", 2) - return parts[len(parts)-1] - } - return source -} - -func (p *awsProvider) outputKey(job *db.Job, fileName string, adaptive bool) *string { - if adaptive { - fileName = strings.TrimRight(fileName, filepath.Ext(fileName)) - } - return aws.String(job.ID + "/" + fileName) -} - -func (p *awsProvider) createVideoPreset(preset db.Preset) *elastictranscoder.VideoParameters { - videoPreset := elastictranscoder.VideoParameters{ - DisplayAspectRatio: aws.String("auto"), - FrameRate: aws.String("auto"), - SizingPolicy: aws.String("Fill"), - PaddingPolicy: aws.String("Pad"), - Codec: &preset.Video.Codec, - KeyframesMaxDist: &preset.Video.GopSize, - CodecOptions: map[string]*string{ - "Profile": aws.String(strings.ToLower(preset.Video.Profile)), - "Level": &preset.Video.ProfileLevel, - "MaxReferenceFrames": aws.String("2"), - }, - } - if preset.Video.Width != "" { - videoPreset.MaxWidth = &preset.Video.Width - } else { - videoPreset.MaxWidth = aws.String("auto") - } - if preset.Video.Height != "" { - videoPreset.MaxHeight = &preset.Video.Height - } else { - videoPreset.MaxHeight = aws.String("auto") - } - normalizedVideoBitRate, _ := strconv.Atoi(preset.Video.Bitrate) - videoBitrate := strconv.Itoa(normalizedVideoBitRate / 1000) - videoPreset.BitRate = &videoBitrate - switch preset.Video.Codec { - case "h264": - videoPreset.Codec = aws.String("H.264") - case "vp8", "vp9": - videoPreset.Codec = aws.String(preset.Video.Codec) - delete(videoPreset.CodecOptions, "MaxReferenceFrames") - delete(videoPreset.CodecOptions, "Level") - // Recommended profile value is zero, based on: - // http://www.webmproject.org/docs/encoder-parameters/ - videoPreset.CodecOptions["Profile"] = aws.String("0") - } - if preset.Video.GopMode == "fixed" { - videoPreset.FixedGOP = aws.String("true") - } - return &videoPreset -} - -func (p *awsProvider) createThumbsPreset() *elastictranscoder.Thumbnails { - thumbsPreset := &elastictranscoder.Thumbnails{ - PaddingPolicy: aws.String("Pad"), - Format: aws.String("png"), - Interval: aws.String("1"), - SizingPolicy: aws.String("Fill"), - MaxWidth: aws.String("auto"), - MaxHeight: aws.String("auto"), - } - return thumbsPreset -} - -func (p *awsProvider) createAudioPreset(preset db.Preset) *elastictranscoder.AudioParameters { - audioPreset := &elastictranscoder.AudioParameters{ - Codec: &preset.Audio.Codec, - Channels: aws.String("auto"), - SampleRate: aws.String("auto"), - } - - normalizedAudioBitRate, _ := strconv.Atoi(preset.Audio.Bitrate) - audioBitrate := strconv.Itoa(normalizedAudioBitRate / 1000) - audioPreset.BitRate = &audioBitrate - - switch preset.Audio.Codec { - case "aac": - audioPreset.Codec = aws.String("AAC") - case "libvorbis": - audioPreset.Codec = aws.String("vorbis") - } - - return audioPreset -} - -func (p *awsProvider) CreatePreset(preset db.Preset) (string, error) { - presetInput := elastictranscoder.CreatePresetInput{ - Name: &preset.Name, - Description: &preset.Description, - } - if preset.Container == "m3u8" { - presetInput.Container = aws.String("ts") - } else { - presetInput.Container = &preset.Container - } - presetInput.Video = p.createVideoPreset(preset) - presetInput.Audio = p.createAudioPreset(preset) - presetInput.Thumbnails = p.createThumbsPreset() - presetOutput, err := p.c.CreatePreset(&presetInput) - if err != nil { - return "", err - } - return *presetOutput.Preset.Id, nil -} - -func (p *awsProvider) GetPreset(presetID string) (interface{}, error) { - readPresetInput := &elastictranscoder.ReadPresetInput{ - Id: aws.String(presetID), - } - readPresetOutput, err := p.c.ReadPreset(readPresetInput) - if err != nil { - return nil, err - } - return readPresetOutput, err -} - -func (p *awsProvider) DeletePreset(presetID string) error { - presetInput := elastictranscoder.DeletePresetInput{ - Id: &presetID, - } - _, err := p.c.DeletePreset(&presetInput) - return err -} - -func (p *awsProvider) JobStatus(job *db.Job) (*provider.JobStatus, error) { - id := job.ProviderJobID - resp, err := p.c.ReadJob(&elastictranscoder.ReadJobInput{Id: aws.String(id)}) - if err != nil { - return nil, err - } - totalJobs := len(resp.Job.Outputs) - completedJobs := float64(0) - outputs := make(map[string]interface{}, totalJobs) - for _, output := range resp.Job.Outputs { - outputStatus := p.statusMap(aws.StringValue(output.Status)) - switch outputStatus { - case provider.StatusFinished, provider.StatusCanceled, provider.StatusFailed: - completedJobs++ - } - outputs[aws.StringValue(output.Key)] = aws.StringValue(output.StatusDetail) - } - outputDestination, err := p.getOutputDestination(job, resp.Job) - if err != nil { - outputDestination = err.Error() - } - outputFiles, err := p.getOutputFiles(resp.Job) - if err != nil { - return nil, err - } - var sourceInfo provider.SourceInfo - if resp.Job.Input.DetectedProperties != nil { - sourceInfo = provider.SourceInfo{ - Duration: time.Duration(aws.Int64Value(resp.Job.Input.DetectedProperties.DurationMillis)) * time.Millisecond, - Height: aws.Int64Value(resp.Job.Input.DetectedProperties.Height), - Width: aws.Int64Value(resp.Job.Input.DetectedProperties.Width), - } - } - statusMessage := "" - if len(resp.Job.Outputs) > 0 { - statusMessage = aws.StringValue(resp.Job.Outputs[0].StatusDetail) - if strings.Contains(statusMessage, ":") { - errorMessage := strings.SplitN(statusMessage, ":", 2)[1] - statusMessage = strings.TrimSpace(errorMessage) - } - } - return &provider.JobStatus{ - ProviderJobID: aws.StringValue(resp.Job.Id), - Status: p.statusMap(aws.StringValue(resp.Job.Status)), - StatusMessage: statusMessage, - Progress: completedJobs / float64(totalJobs) * 100, - ProviderStatus: map[string]interface{}{"outputs": outputs}, - SourceInfo: sourceInfo, - Output: provider.JobOutput{ - Destination: outputDestination, - Files: outputFiles, - }, - }, nil -} - -func (p *awsProvider) getOutputDestination(job *db.Job, awsJob *elastictranscoder.Job) (string, error) { - readPipelineOutput, err := p.c.ReadPipeline(&elastictranscoder.ReadPipelineInput{ - Id: awsJob.PipelineId, - }) - if err != nil { - return "", err - } - return fmt.Sprintf("s3://%s/%s", - aws.StringValue(readPipelineOutput.Pipeline.OutputBucket), - job.ID, - ), nil -} - -func (p *awsProvider) getOutputFiles(job *elastictranscoder.Job) ([]provider.OutputFile, error) { - pipeline, err := p.c.ReadPipeline(&elastictranscoder.ReadPipelineInput{ - Id: job.PipelineId, - }) - if err != nil { - return nil, err - } - files := make([]provider.OutputFile, 0, len(job.Outputs)+len(job.Playlists)) - for _, output := range job.Outputs { - preset, err := p.c.ReadPreset(&elastictranscoder.ReadPresetInput{ - Id: output.PresetId, - }) - if err != nil { - return nil, err - } - filePath := fmt.Sprintf("s3://%s/%s%s", - aws.StringValue(pipeline.Pipeline.OutputBucket), - aws.StringValue(job.OutputKeyPrefix), - aws.StringValue(output.Key), - ) - container := aws.StringValue(preset.Preset.Container) - if container == "ts" { - continue - } - file := provider.OutputFile{ - Path: filePath, - Container: container, - VideoCodec: aws.StringValue(preset.Preset.Video.Codec), - Width: aws.Int64Value(output.Width), - Height: aws.Int64Value(output.Height), - } - files = append(files, file) - } - for _, playlist := range job.Playlists { - filePath := fmt.Sprintf("s3://%s/%s%s", - aws.StringValue(pipeline.Pipeline.OutputBucket), - aws.StringValue(job.OutputKeyPrefix), - aws.StringValue(playlist.Name)+".m3u8", - ) - files = append(files, provider.OutputFile{Path: filePath, Container: "m3u8"}) - } - return files, nil -} - -func (p *awsProvider) statusMap(awsStatus string) provider.Status { - switch awsStatus { - case "Submitted": - return provider.StatusQueued - case "Progressing": - return provider.StatusStarted - case "Complete": - return provider.StatusFinished - case "Canceled": - return provider.StatusCanceled - default: - return provider.StatusFailed - } -} - -func (p *awsProvider) CancelJob(id string) error { - _, err := p.c.CancelJob(&elastictranscoder.CancelJobInput{Id: aws.String(id)}) - return err -} - -func (p *awsProvider) Healthcheck() error { - _, err := p.c.ReadPipeline(&elastictranscoder.ReadPipelineInput{ - Id: aws.String(p.config.PipelineID), - }) - return err -} - -func (p *awsProvider) Capabilities() provider.Capabilities { - return provider.Capabilities{ - InputFormats: []string{"h264"}, - OutputFormats: []string{"mp4", "hls", "webm"}, - Destinations: []string{"s3"}, - } -} - -func elasticTranscoderFactory(cfg *config.Config) (provider.TranscodingProvider, error) { - if cfg.ElasticTranscoder.AccessKeyID == "" || cfg.ElasticTranscoder.SecretAccessKey == "" || cfg.ElasticTranscoder.PipelineID == "" { - return nil, errAWSInvalidConfig - } - creds := credentials.NewStaticCredentials(cfg.ElasticTranscoder.AccessKeyID, cfg.ElasticTranscoder.SecretAccessKey, "") - region := cfg.ElasticTranscoder.Region - if region == "" { - region = defaultAWSRegion - } - awsSession, err := session.NewSession(aws.NewConfig().WithCredentials(creds).WithRegion(region)) - if err != nil { - return nil, err - } - return &awsProvider{ - c: elastictranscoder.New(awsSession), - config: cfg.ElasticTranscoder, - }, nil -} diff --git a/provider/elastictranscoder/aws_fake_transcode_test.go b/provider/elastictranscoder/aws_fake_transcode_test.go deleted file mode 100644 index 54f57f47..00000000 --- a/provider/elastictranscoder/aws_fake_transcode_test.go +++ /dev/null @@ -1,170 +0,0 @@ -package elastictranscoder - -import ( - "crypto/rand" - "errors" - "fmt" - "strings" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/elastictranscoder" -) - -type failure struct { - op string - err error -} - -type fakeElasticTranscoder struct { - *elastictranscoder.ElasticTranscoder - jobs map[string]*elastictranscoder.CreateJobInput - canceledJobs []elastictranscoder.CancelJobInput - failures chan failure -} - -func newFakeElasticTranscoder() *fakeElasticTranscoder { - return &fakeElasticTranscoder{ - ElasticTranscoder: &elastictranscoder.ElasticTranscoder{}, - failures: make(chan failure, 1), - jobs: make(map[string]*elastictranscoder.CreateJobInput), - } -} - -func (c *fakeElasticTranscoder) CreateJob(input *elastictranscoder.CreateJobInput) (*elastictranscoder.CreateJobResponse, error) { - if err := c.getError("CreateJob"); err != nil { - return nil, err - } - input.Input.DetectedProperties = &elastictranscoder.DetectedProperties{ - DurationMillis: aws.Int64(120e3), - FileSize: aws.Int64(60356779), - Width: aws.Int64(1920), - Height: aws.Int64(1080), - } - id := fmt.Sprintf("job-%x", generateID()) - c.jobs[id] = input - return &elastictranscoder.CreateJobResponse{ - Job: &elastictranscoder.Job{ - Id: aws.String(id), - Input: input.Input, - PipelineId: input.PipelineId, - Status: aws.String("Submitted"), - }, - }, nil -} - -func (c *fakeElasticTranscoder) CreatePreset(input *elastictranscoder.CreatePresetInput) (*elastictranscoder.CreatePresetOutput, error) { - presetID := *input.Name + "-abc123" - return &elastictranscoder.CreatePresetOutput{ - Preset: &elastictranscoder.Preset{ - Audio: input.Audio, - Container: input.Container, - Description: input.Description, - Name: input.Name, - Id: &presetID, - Thumbnails: input.Thumbnails, - Video: input.Video, - }, - }, nil -} - -func (c *fakeElasticTranscoder) ReadPreset(input *elastictranscoder.ReadPresetInput) (*elastictranscoder.ReadPresetOutput, error) { - container := "mp4" - codec := "H.264" - if strings.Contains(*input.Id, "hls") { - container = "ts" - } - if strings.Contains(*input.Id, "webm") { - container = "webm" - codec = "VP8" - } - return &elastictranscoder.ReadPresetOutput{ - Preset: &elastictranscoder.Preset{ - Id: input.Id, - Name: input.Id, - Container: aws.String(container), - Video: &elastictranscoder.VideoParameters{Codec: aws.String(codec)}, - }, - }, nil -} - -func (c *fakeElasticTranscoder) ReadJob(input *elastictranscoder.ReadJobInput) (*elastictranscoder.ReadJobOutput, error) { - if err := c.getError("ReadJob"); err != nil { - return nil, err - } - createJobInput, ok := c.jobs[*input.Id] - if !ok { - return nil, errors.New("job not found") - } - outputs := make([]*elastictranscoder.JobOutput, len(createJobInput.Outputs)) - for i, createJobOutput := range createJobInput.Outputs { - outputs[i] = &elastictranscoder.JobOutput{ - Key: createJobOutput.Key, - Status: aws.String("Complete"), - StatusDetail: aws.String("it's finished!"), - PresetId: aws.String(fmt.Sprintf("preset-%s", aws.StringValue(createJobOutput.Key))), - Width: aws.Int64(0), - Height: aws.Int64(720), - } - } - playlists := make([]*elastictranscoder.Playlist, len(createJobInput.Playlists)) - for i, createJobPlaylist := range createJobInput.Playlists { - playlists[i] = &elastictranscoder.Playlist{ - Name: createJobPlaylist.Name, - Format: createJobPlaylist.Format, - OutputKeys: createJobPlaylist.OutputKeys, - } - } - return &elastictranscoder.ReadJobOutput{ - Job: &elastictranscoder.Job{ - Id: input.Id, - Input: createJobInput.Input, - PipelineId: createJobInput.PipelineId, - Status: aws.String("Complete"), - Outputs: outputs, - Playlists: playlists, - }, - }, nil -} - -func (c *fakeElasticTranscoder) ReadPipeline(input *elastictranscoder.ReadPipelineInput) (*elastictranscoder.ReadPipelineOutput, error) { - if err := c.getError("ReadPipeline"); err != nil { - return nil, err - } - return &elastictranscoder.ReadPipelineOutput{ - Pipeline: &elastictranscoder.Pipeline{ - Id: input.Id, - Name: aws.String("nice pipeline"), - OutputBucket: aws.String("some bucket"), - }, - }, nil -} - -func (c *fakeElasticTranscoder) CancelJob(input *elastictranscoder.CancelJobInput) (*elastictranscoder.CancelJobOutput, error) { - if err := c.getError("CancelJob"); err != nil { - return nil, err - } - c.canceledJobs = append(c.canceledJobs, *input) - return &elastictranscoder.CancelJobOutput{}, nil -} - -func (c *fakeElasticTranscoder) prepareFailure(op string, err error) { - c.failures <- failure{op: op, err: err} -} - -func (c *fakeElasticTranscoder) getError(op string) error { - select { - case prepFailure := <-c.failures: - if prepFailure.op == op { - return prepFailure.err - } - c.failures <- prepFailure - default: - } - return nil -} - -func generateID() []byte { - var b [4]byte - rand.Read(b[:]) - return b[:] -} diff --git a/provider/elastictranscoder/aws_test.go b/provider/elastictranscoder/aws_test.go deleted file mode 100644 index a54eac9a..00000000 --- a/provider/elastictranscoder/aws_test.go +++ /dev/null @@ -1,1165 +0,0 @@ -package elastictranscoder - -import ( - "errors" - "os" - "reflect" - "regexp" - "testing" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/aws/aws-sdk-go/service/elastictranscoder" - "github.com/kr/pretty" - "github.com/video-dev/video-transcoding-api/v2/config" - "github.com/video-dev/video-transcoding-api/v2/db" - "github.com/video-dev/video-transcoding-api/v2/provider" -) - -func TestFactoryIsRegistered(t *testing.T) { - _, err := provider.GetProviderFactory(Name) - if err != nil { - t.Fatal(err) - } -} - -func TestElasticTranscoderProvider(t *testing.T) { - cfg := config.Config{ - ElasticTranscoder: &config.ElasticTranscoder{ - AccessKeyID: "AKIANOTREALLY", - SecretAccessKey: "really-secret", - PipelineID: "mypipeline", - Region: "sa-east-1", - }, - } - provider, err := elasticTranscoderFactory(&cfg) - if err != nil { - t.Fatal(err) - } - elasticProvider := provider.(*awsProvider) - if !reflect.DeepEqual(*elasticProvider.config, *cfg.ElasticTranscoder) { - t.Errorf("ElasticTranscoderProvider: did not store the proper config. Want %#v. Got %#v.", cfg.ElasticTranscoder, elasticProvider.config) - } - expectedCreds := credentials.Value{AccessKeyID: "AKIANOTREALLY", SecretAccessKey: "really-secret"} - creds, err := elasticProvider.c.(*elastictranscoder.ElasticTranscoder).Config.Credentials.Get() - if err != nil { - t.Fatal(err) - } - - // provider is not relevant - creds.ProviderName = expectedCreds.ProviderName - if !reflect.DeepEqual(creds, expectedCreds) { - t.Errorf("ElasticTranscoderProvider: wrogn credentials. Want %#v. Got %#v.", expectedCreds, creds) - } - - region := *elasticProvider.c.(*elastictranscoder.ElasticTranscoder).Config.Region - if region != cfg.ElasticTranscoder.Region { - t.Errorf("ElasticTranscoderProvider: wrong region. Want %q. Got %q.", cfg.ElasticTranscoder.Region, region) - } -} - -func TestElasticTranscoderProviderDefaultRegion(t *testing.T) { - cfg := config.Config{ - ElasticTranscoder: &config.ElasticTranscoder{ - AccessKeyID: "AKIANOTREALLY", - SecretAccessKey: "really-secret", - PipelineID: "mypipeline", - }, - } - provider, err := elasticTranscoderFactory(&cfg) - if err != nil { - t.Fatal(err) - } - elasticProvider := provider.(*awsProvider) - if !reflect.DeepEqual(*elasticProvider.config, *cfg.ElasticTranscoder) { - t.Errorf("ElasticTranscoderProvider: did not store the proper config. Want %#v. Got %#v.", cfg.ElasticTranscoder, elasticProvider.config) - } - expectedCreds := credentials.Value{AccessKeyID: "AKIANOTREALLY", SecretAccessKey: "really-secret"} - creds, err := elasticProvider.c.(*elastictranscoder.ElasticTranscoder).Config.Credentials.Get() - if err != nil { - t.Fatal(err) - } - - // provider is not relevant - creds.ProviderName = expectedCreds.ProviderName - if !reflect.DeepEqual(creds, expectedCreds) { - t.Errorf("ElasticTranscoderProvider: wrogn credentials. Want %#v. Got %#v.", expectedCreds, creds) - } - - region := *elasticProvider.c.(*elastictranscoder.ElasticTranscoder).Config.Region - if region != "us-east-1" { - t.Errorf("ElasticTranscoderProvider: wrong region. Want %q. Got %q.", "us-east-1", region) - } -} - -func TestElasticTranscoderProviderValidation(t *testing.T) { - tests := []struct { - accessKeyID string - secretAccessKey string - pipelineID string - }{ - {"", "", ""}, - {"AKIANOTREALLY", "", ""}, - {"", "very-secret", ""}, - {"", "", "superpipeline"}, - {"AKIANOTREALLY", "very-secret", ""}, - } - for _, test := range tests { - cfg := config.Config{ - ElasticTranscoder: &config.ElasticTranscoder{ - AccessKeyID: test.accessKeyID, - SecretAccessKey: test.secretAccessKey, - PipelineID: test.pipelineID, - }, - } - provider, err := elasticTranscoderFactory(&cfg) - if provider != nil { - t.Errorf("Got unexpected non-nil provider: %#v", provider) - } - if err != errAWSInvalidConfig { - t.Errorf("Wrong error returned. Want errAWSInvalidConfig. Got %#v", err) - } - } -} - -func TestAWSTranscode(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - prov := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - source := "dir/file.mov" - outputs := []db.TranscodeOutput{ - { - FileName: "output-720p.mp4", - Preset: db.PresetMap{ - Name: "mp4_720p", - ProviderMapping: map[string]string{ - Name: "93239832-0001", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "mp4"}, - }, - }, - { - FileName: "output-720p.webm", - Preset: db.PresetMap{ - Name: "webm_720p", - ProviderMapping: map[string]string{ - Name: "93239832-0002", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "webm"}, - }, - }, - { - FileName: "output-1080p.mov", - Preset: db.PresetMap{ - Name: "mov_1080p", - ProviderMapping: map[string]string{ - Name: "93239832-0003", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "mov"}, - }, - }, - } - - jobStatus, err := prov.Transcode(&db.Job{ - ID: "job-123", - SourceMedia: source, - Outputs: outputs, - StreamingParams: db.StreamingParams{}, - }) - if err != nil { - t.Fatal(err) - } - if m, _ := regexp.MatchString(`^job-[a-f0-9]{8}$`, jobStatus.ProviderJobID); !m { - t.Errorf("Elastic Transcoder: invalid id returned - %q", jobStatus.ProviderJobID) - } - if jobStatus.Status != provider.StatusQueued { - t.Errorf("Elastic Transcoder: wrong status returned. Want queued. Got %v", jobStatus.Status) - } - if jobStatus.ProviderName != Name { - t.Errorf("Elastic Transcoder: wrong provider name returned. Want %q. Got %q", Name, jobStatus.ProviderName) - } - - if len(fakeTranscoder.jobs) != 1 { - t.Fatal("Did not send any job request to the server.") - } - jobInput := fakeTranscoder.jobs[jobStatus.ProviderJobID] - - expectedJobInput := elastictranscoder.CreateJobInput{ - PipelineId: aws.String("mypipeline"), - Input: &elastictranscoder.JobInput{ - Key: aws.String(source), - DetectedProperties: &elastictranscoder.DetectedProperties{ - DurationMillis: aws.Int64(120e3), - FileSize: aws.Int64(60356779), - Height: aws.Int64(1080), - Width: aws.Int64(1920), - }, - }, - Outputs: []*elastictranscoder.CreateJobOutput{ - {PresetId: aws.String("93239832-0001"), Key: aws.String("job-123/output-720p.mp4")}, - {PresetId: aws.String("93239832-0002"), Key: aws.String("job-123/output-720p.webm")}, - {PresetId: aws.String("93239832-0003"), Key: aws.String("job-123/output-1080p.mov")}, - }, - } - if !reflect.DeepEqual(*jobInput, expectedJobInput) { - t.Errorf("Elastic Transcoder: wrong input\nWant %#v\nGot %#v", expectedJobInput, *jobInput) - } -} - -func TestAWSTranscodeAdaptiveStreaming(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - prov := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - source := "dir/file.mov" - outputs := []db.TranscodeOutput{ - { - FileName: "output_360p_hls/video.m3u8", - Preset: db.PresetMap{ - Name: "hls_360p", - ProviderMapping: map[string]string{ - Name: "93239832-0001-hls", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "hls"}, - }, - }, - { - FileName: "output_480p_hls/video.m3u8", - Preset: db.PresetMap{ - Name: "hls_480p", - ProviderMapping: map[string]string{ - Name: "93239832-0002-hls", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "hls"}, - }, - }, - { - FileName: "output_720p_hls/video.m3u8", - Preset: db.PresetMap{ - Name: "hls_720p", - ProviderMapping: map[string]string{ - Name: "93239832-0003-hls", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "hls"}, - }, - }, - } - - jobStatus, err := prov.Transcode(&db.Job{ - ID: "job-123", - SourceMedia: source, - Outputs: outputs, - StreamingParams: db.StreamingParams{ - PlaylistFileName: "video.m3u8", - Protocol: "asdf", - SegmentDuration: 3, - }, - }) - if err != nil { - t.Fatal(err) - } - if m, _ := regexp.MatchString(`^job-[a-f0-9]{8}$`, jobStatus.ProviderJobID); !m { - t.Errorf("Elastic Transcoder: invalid id returned - %q", jobStatus.ProviderJobID) - } - if jobStatus.Status != provider.StatusQueued { - t.Errorf("Elastic Transcoder: wrong status returned. Want queued. Got %v", jobStatus.Status) - } - if jobStatus.ProviderName != Name { - t.Errorf("Elastic Transcoder: wrong provider name returned. Want %q. Got %q", Name, jobStatus.ProviderName) - } - - if len(fakeTranscoder.jobs) != 1 { - t.Fatal("Did not send any job request to the server.") - } - jobInput := fakeTranscoder.jobs[jobStatus.ProviderJobID] - - expectedJobInput := elastictranscoder.CreateJobInput{ - PipelineId: aws.String("mypipeline"), - Input: &elastictranscoder.JobInput{ - Key: aws.String(source), - DetectedProperties: &elastictranscoder.DetectedProperties{ - DurationMillis: aws.Int64(120e3), - FileSize: aws.Int64(60356779), - Height: aws.Int64(1080), - Width: aws.Int64(1920), - }, - }, - Outputs: []*elastictranscoder.CreateJobOutput{ - {PresetId: aws.String("93239832-0001-hls"), Key: aws.String("job-123/output_360p_hls/video"), SegmentDuration: aws.String("3")}, - {PresetId: aws.String("93239832-0002-hls"), Key: aws.String("job-123/output_480p_hls/video"), SegmentDuration: aws.String("3")}, - {PresetId: aws.String("93239832-0003-hls"), Key: aws.String("job-123/output_720p_hls/video"), SegmentDuration: aws.String("3")}, - }, - Playlists: []*elastictranscoder.CreateJobPlaylist{ - { - Format: aws.String("HLSv3"), - Name: aws.String("job-123/video"), - OutputKeys: []*string{ - aws.String("job-123/output_360p_hls/video"), - aws.String("job-123/output_480p_hls/video"), - aws.String("job-123/output_720p_hls/video"), - }, - }, - }, - } - if !reflect.DeepEqual(*jobInput, expectedJobInput) { - t.Errorf("Elastic Transcoder: wrong input\nWant %#v\nGot %#v", expectedJobInput, *jobInput) - } -} - -func TestAWSTranscodeAdaptiveAndNonAdaptiveStreaming(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - prov := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - source := "dir/file.mov" - outputs := []db.TranscodeOutput{ - { - FileName: "hls/output_hls_360p/video.m3u8", - Preset: db.PresetMap{ - Name: "hls_360p", - ProviderMapping: map[string]string{ - Name: "93239832-0001-hls", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "hls"}, - }, - }, - { - FileName: "hls/output_hls_480p/video.m3u8", - Preset: db.PresetMap{ - Name: "hls_480p", - ProviderMapping: map[string]string{ - Name: "93239832-0002-hls", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "hls"}, - }, - }, - { - FileName: "hls/output_hls_720p/video.m3u8", - Preset: db.PresetMap{ - Name: "hls_720p", - ProviderMapping: map[string]string{ - Name: "93239832-0003-hls", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "hls"}, - }, - }, - { - FileName: "output_720p.mp4", - Preset: db.PresetMap{ - Name: "mp4_720p", - ProviderMapping: map[string]string{ - Name: "93239832-0004", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "mp4"}, - }, - }, - } - - jobStatus, err := prov.Transcode(&db.Job{ - ID: "job-123", - SourceMedia: source, - Outputs: outputs, - StreamingParams: db.StreamingParams{ - PlaylistFileName: "hls/video.m3u8", - Protocol: "asdf", - SegmentDuration: 3, - }, - }) - if err != nil { - t.Fatal(err) - } - if m, _ := regexp.MatchString(`^job-[a-f0-9]{8}$`, jobStatus.ProviderJobID); !m { - t.Errorf("Elastic Transcoder: invalid id returned - %q", jobStatus.ProviderJobID) - } - if jobStatus.Status != provider.StatusQueued { - t.Errorf("Elastic Transcoder: wrong status returned. Want queued. Got %v", jobStatus.Status) - } - if jobStatus.ProviderName != Name { - t.Errorf("Elastic Transcoder: wrong provider name returned. Want %q. Got %q", Name, jobStatus.ProviderName) - } - - if len(fakeTranscoder.jobs) != 1 { - t.Fatal("Did not send any job request to the server.") - } - jobInput := fakeTranscoder.jobs[jobStatus.ProviderJobID] - - expectedJobInput := elastictranscoder.CreateJobInput{ - PipelineId: aws.String("mypipeline"), - Input: &elastictranscoder.JobInput{ - Key: aws.String(source), - DetectedProperties: &elastictranscoder.DetectedProperties{ - DurationMillis: aws.Int64(120e3), - FileSize: aws.Int64(60356779), - Height: aws.Int64(1080), - Width: aws.Int64(1920), - }, - }, - Outputs: []*elastictranscoder.CreateJobOutput{ - {PresetId: aws.String("93239832-0001-hls"), Key: aws.String("job-123/hls/output_hls_360p/video"), SegmentDuration: aws.String("3")}, - {PresetId: aws.String("93239832-0002-hls"), Key: aws.String("job-123/hls/output_hls_480p/video"), SegmentDuration: aws.String("3")}, - {PresetId: aws.String("93239832-0003-hls"), Key: aws.String("job-123/hls/output_hls_720p/video"), SegmentDuration: aws.String("3")}, - {PresetId: aws.String("93239832-0004"), Key: aws.String("job-123/output_720p.mp4")}, - }, - Playlists: []*elastictranscoder.CreateJobPlaylist{ - { - Format: aws.String("HLSv3"), - Name: aws.String("job-123/hls/video"), - OutputKeys: []*string{ - aws.String("job-123/hls/output_hls_360p/video"), - aws.String("job-123/hls/output_hls_480p/video"), - aws.String("job-123/hls/output_hls_720p/video"), - }, - }, - }, - } - if !reflect.DeepEqual(*jobInput, expectedJobInput) { - t.Errorf("Elastic Transcoder: wrong input\nWant %#v\nGot %#v", expectedJobInput, *jobInput) - } -} - -func TestAWSTranscodeNormalizedSource(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - prov := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - source := "s3://bucketname/some/dir/with/subdir/file.mov" - outputs := []db.TranscodeOutput{ - { - FileName: "output_720p.mp4", - Preset: db.PresetMap{ - Name: "mp4_720p", - ProviderMapping: map[string]string{ - Name: "93239832-0001", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "mp4"}, - }, - }, - { - FileName: "output_1080p.webm", - Preset: db.PresetMap{ - Name: "webm_1080p", - ProviderMapping: map[string]string{ - Name: "93239832-0002", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "webm"}, - }, - }, - } - jobStatus, err := prov.Transcode(&db.Job{ - ID: "job-1", - SourceMedia: source, - Outputs: outputs, - StreamingParams: db.StreamingParams{}, - }) - if err != nil { - t.Fatal(err) - } - if m, _ := regexp.MatchString(`^job-[a-f0-9]{8}$`, jobStatus.ProviderJobID); !m { - t.Errorf("Elastic Transcoder: invalid id returned - %q", jobStatus.ProviderJobID) - } - if jobStatus.Status != provider.StatusQueued { - t.Errorf("Elastic Transcoder: wrong status returned. Want queued. Got %v", jobStatus.Status) - } - if jobStatus.ProviderName != Name { - t.Errorf("Elastic Transcoder: wrong provider name returned. Want %q. Got %q", Name, jobStatus.ProviderName) - } - - if len(fakeTranscoder.jobs) != 1 { - t.Fatal("Did not send any job request to the server.") - } - jobInput := fakeTranscoder.jobs[jobStatus.ProviderJobID] - - expectedJobInput := elastictranscoder.CreateJobInput{ - PipelineId: aws.String("mypipeline"), - Input: &elastictranscoder.JobInput{ - Key: aws.String("some/dir/with/subdir/file.mov"), - DetectedProperties: &elastictranscoder.DetectedProperties{ - DurationMillis: aws.Int64(120e3), - FileSize: aws.Int64(60356779), - Height: aws.Int64(1080), - Width: aws.Int64(1920), - }, - }, - Outputs: []*elastictranscoder.CreateJobOutput{ - {PresetId: aws.String("93239832-0001"), Key: aws.String("job-1/output_720p.mp4")}, - {PresetId: aws.String("93239832-0002"), Key: aws.String("job-1/output_1080p.webm")}, - }, - } - if !reflect.DeepEqual(*jobInput, expectedJobInput) { - t.Errorf("Elastic Transcoder: wrong input\nWant %#v\nGot %#v", expectedJobInput, *jobInput) - } -} - -func TestAWSTranscodePresetNotFound(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - prov := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - source := "s3://bucketname/some/dir/with/subdir/file.mov" - outputs := []db.TranscodeOutput{ - { - FileName: "output_720p.mp4", - Preset: db.PresetMap{ - Name: "mp4_720p", - ProviderMapping: map[string]string{"other": "irrelevant"}, - OutputOpts: db.OutputOptions{Extension: "mp4"}, - }, - }, - } - jobStatus, err := prov.Transcode(&db.Job{ - ID: "job-123", - SourceMedia: source, - Outputs: outputs, - StreamingParams: db.StreamingParams{}, - }) - if err != provider.ErrPresetMapNotFound { - t.Errorf("Wrong error returned. Want %#v. Got %#v", provider.ErrPresetMapNotFound, err) - } - if jobStatus != nil { - t.Errorf("Got unexpected non-nil JobStatus: %#v", jobStatus) - } -} - -func TestAWSTranscodeAWSFailureInAmazon(t *testing.T) { - prepErr := errors.New("something went wrong") - fakeTranscoder := newFakeElasticTranscoder() - fakeTranscoder.prepareFailure("CreateJob", prepErr) - prov := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - source := "dir/file.mp4" - jobStatus, err := prov.Transcode(&db.Job{ - ID: "job-123", - SourceMedia: source, - StreamingParams: db.StreamingParams{}, - }) - if jobStatus != nil { - t.Errorf("Got unexpected non-nil status: %#v", jobStatus) - } - if err != prepErr { - t.Errorf("Got wrong error. Want %q. Got %q", prepErr.Error(), err.Error()) - } -} - -func TestAWSJobStatus(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - prov := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - outputs := []db.TranscodeOutput{ - { - FileName: "output_720p.mp4", - Preset: db.PresetMap{ - Name: "mp4_720p", - ProviderMapping: map[string]string{ - Name: "93239832-0001", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "mp4"}, - }, - }, - { - FileName: "output_720p.webm", - Preset: db.PresetMap{ - Name: "webm_720p", - ProviderMapping: map[string]string{ - Name: "93239832-0002", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "webm"}, - }, - }, - { - FileName: "hls/output_720p.m3u8", - Preset: db.PresetMap{ - Name: "hls_720p", - ProviderMapping: map[string]string{ - Name: "hls-93239832-0003", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "m3u8"}, - }, - }, - } - source := "dir/file.mov" - jobStatus, err := prov.Transcode(&db.Job{ - ID: "job-123", - SourceMedia: source, - Outputs: outputs, - StreamingParams: db.StreamingParams{ - PlaylistFileName: "hls/index.m3u8", - SegmentDuration: 3, - Protocol: "hls", - }, - }) - if err != nil { - t.Fatal(err) - } - jobStatus, err = prov.JobStatus(&db.Job{ID: "job-123", ProviderJobID: jobStatus.ProviderJobID}) - if err != nil { - t.Fatal(err) - } - expectedJobStatus := provider.JobStatus{ - ProviderJobID: jobStatus.ProviderJobID, - Status: provider.StatusFinished, - StatusMessage: "it's finished!", - Progress: 100, - ProviderStatus: map[string]interface{}{ - "outputs": map[string]interface{}{ - "job-123/output_720p.mp4": "it's finished!", - "job-123/output_720p.webm": "it's finished!", - "job-123/hls/output_720p": "it's finished!", - }, - }, - SourceInfo: provider.SourceInfo{ - Duration: 120 * time.Second, - Width: 1920, - Height: 1080, - }, - Output: provider.JobOutput{ - Destination: "s3://some bucket/job-123", - Files: []provider.OutputFile{ - { - Path: "s3://some bucket/job-123/output_720p.mp4", - Container: "mp4", - VideoCodec: "H.264", - Width: 0, - Height: 720, - }, - { - Path: "s3://some bucket/job-123/output_720p.webm", - Container: "webm", - VideoCodec: "VP8", - Width: 0, - Height: 720, - }, - { - Path: "s3://some bucket/job-123/hls/index.m3u8", - Container: "m3u8", - }, - }, - }, - } - if !reflect.DeepEqual(*jobStatus, expectedJobStatus) { - t.Errorf("Wrong JobStatus\nWant %#v\nGot %#v", expectedJobStatus, *jobStatus) - } -} - -func TestAWSJobStatusNoDetectedProperties(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - prov := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - outputs := []db.TranscodeOutput{ - { - FileName: "output_720p.mp4", - Preset: db.PresetMap{ - Name: "mp4_720p", - ProviderMapping: map[string]string{ - Name: "93239832-0001", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "mp4"}, - }, - }, - { - FileName: "output_720p.webm", - Preset: db.PresetMap{ - Name: "webm_720p", - ProviderMapping: map[string]string{ - Name: "93239832-0002", - "other": "irrelevant", - }, - OutputOpts: db.OutputOptions{Extension: "webm"}, - }, - }, - } - jobStatus, err := prov.Transcode(&db.Job{ - ID: "job-123", - SourceMedia: "dir/file.mov", - Outputs: outputs, - StreamingParams: db.StreamingParams{}, - }) - if err != nil { - t.Fatal(err) - } - fakeTranscoder.jobs[jobStatus.ProviderJobID].Input.DetectedProperties = nil - jobStatus, err = prov.JobStatus(&db.Job{ID: "job-123", ProviderJobID: jobStatus.ProviderJobID}) - if err != nil { - t.Fatal(err) - } - expectedJobStatus := provider.JobStatus{ - ProviderJobID: jobStatus.ProviderJobID, - Status: provider.StatusFinished, - StatusMessage: "it's finished!", - Progress: 100, - ProviderStatus: map[string]interface{}{ - "outputs": map[string]interface{}{ - "job-123/output_720p.mp4": "it's finished!", - "job-123/output_720p.webm": "it's finished!", - }, - }, - Output: provider.JobOutput{ - Destination: "s3://some bucket/job-123", - Files: []provider.OutputFile{ - { - Path: "s3://some bucket/job-123/output_720p.mp4", - Container: "mp4", - VideoCodec: "H.264", - Width: 0, - Height: 720, - }, - { - Path: "s3://some bucket/job-123/output_720p.webm", - Container: "webm", - VideoCodec: "VP8", - Width: 0, - Height: 720, - }, - }, - }, - } - if !reflect.DeepEqual(*jobStatus, expectedJobStatus) { - t.Errorf("Wrong JobStatus\nWant %#v\nGot %#v", expectedJobStatus, *jobStatus) - } -} - -func TestAWSCreatePreset(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - prov := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - - inputPreset := db.Preset{ - Name: "preset_name", - Description: "description here", - Container: "mp4", - RateControl: "VBR", - Video: db.VideoPreset{ - Profile: "Main", - ProfileLevel: "3.1", - Height: "720", - Codec: "h264", - Bitrate: "2500000", - GopSize: "90", - GopMode: "fixed", - InterlaceMode: "progressive", - }, - Audio: db.AudioPreset{ - Codec: "aac", - Bitrate: "64000", - }, - } - - presetID, _ := prov.CreatePreset(inputPreset) - - if !reflect.DeepEqual(presetID, "preset_name-abc123") { - t.Errorf("CreatePreset: want %s. Got %s", presetID, "preset_name-abc123") - } -} - -func TestCreateVideoPreset(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - prov := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - tests := []struct { - givenTestCase string - givenPreset db.Preset - expectedVideoParams *elastictranscoder.VideoParameters - }{ - { - "H.264 preset", - db.Preset{ - Container: "m3u8", - Video: db.VideoPreset{ - Profile: "Main", - ProfileLevel: "3.1", - Codec: "h264", - }, - }, - &elastictranscoder.VideoParameters{ - BitRate: aws.String("0"), - Codec: aws.String("H.264"), - CodecOptions: map[string]*string{ - "MaxReferenceFrames": aws.String("2"), - "Profile": aws.String("main"), - "Level": aws.String("3.1"), - }, - DisplayAspectRatio: aws.String("auto"), - FrameRate: aws.String("auto"), - KeyframesMaxDist: aws.String(""), - MaxHeight: aws.String("auto"), - MaxWidth: aws.String("auto"), - PaddingPolicy: aws.String("Pad"), - SizingPolicy: aws.String("Fill"), - }, - }, - { - "WEBM vp8 preset", - db.Preset{ - Container: "webm", - Video: db.VideoPreset{ - Codec: "vp8", - GopSize: "90", - }, - }, - &elastictranscoder.VideoParameters{ - BitRate: aws.String("0"), - Codec: aws.String("vp8"), - CodecOptions: map[string]*string{ - "Profile": aws.String("0"), - }, - DisplayAspectRatio: aws.String("auto"), - FrameRate: aws.String("auto"), - KeyframesMaxDist: aws.String("90"), - MaxHeight: aws.String("auto"), - MaxWidth: aws.String("auto"), - PaddingPolicy: aws.String("Pad"), - SizingPolicy: aws.String("Fill"), - }, - }, - { - "WEBM vp9 preset", - db.Preset{ - Container: "webm", - Video: db.VideoPreset{ - Codec: "vp9", - GopSize: "90", - }, - }, - &elastictranscoder.VideoParameters{ - BitRate: aws.String("0"), - Codec: aws.String("vp9"), - CodecOptions: map[string]*string{ - "Profile": aws.String("0"), - }, - DisplayAspectRatio: aws.String("auto"), - FrameRate: aws.String("auto"), - KeyframesMaxDist: aws.String("90"), - MaxHeight: aws.String("auto"), - MaxWidth: aws.String("auto"), - PaddingPolicy: aws.String("Pad"), - SizingPolicy: aws.String("Fill"), - }, - }, - { - "MP4 preset", - db.Preset{ - Container: "mp4", - Video: db.VideoPreset{ - Profile: "Main", - ProfileLevel: "3.1", - Codec: "h264", - GopSize: "90", - }, - }, - &elastictranscoder.VideoParameters{ - BitRate: aws.String("0"), - Codec: aws.String("H.264"), - CodecOptions: map[string]*string{ - "MaxReferenceFrames": aws.String("2"), - "Profile": aws.String("main"), - "Level": aws.String("3.1"), - }, - DisplayAspectRatio: aws.String("auto"), - FrameRate: aws.String("auto"), - KeyframesMaxDist: aws.String("90"), - MaxHeight: aws.String("auto"), - MaxWidth: aws.String("auto"), - PaddingPolicy: aws.String("Pad"), - SizingPolicy: aws.String("Fill"), - }, - }, - } - for _, test := range tests { - videoParams := prov.createVideoPreset(test.givenPreset) - if !reflect.DeepEqual(test.expectedVideoParams, videoParams) { - t.Errorf("%s: CreateVideoPreset: want %s. Got %s", test.givenTestCase, test.expectedVideoParams, videoParams) - pretty.Fdiff(os.Stderr, videoParams, test.expectedVideoParams) - } - } -} - -func TestCreateAudioPreset(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - prov := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - tests := []struct { - givenTestCase string - givenPreset db.Preset - expectedAudioParams *elastictranscoder.AudioParameters - }{ - { - "AAC preset", - db.Preset{ - Audio: db.AudioPreset{ - Codec: "aac", - }, - }, - &elastictranscoder.AudioParameters{ - BitRate: aws.String("0"), - Channels: aws.String("auto"), - Codec: aws.String("AAC"), - SampleRate: aws.String("auto"), - }, - }, - { - "libvorbis preset", - db.Preset{ - Audio: db.AudioPreset{ - Codec: "libvorbis", - }, - }, - &elastictranscoder.AudioParameters{ - BitRate: aws.String("0"), - Channels: aws.String("auto"), - Codec: aws.String("vorbis"), - SampleRate: aws.String("auto"), - }, - }, - } - for _, test := range tests { - audioParams := prov.createAudioPreset(test.givenPreset) - if !reflect.DeepEqual(test.expectedAudioParams, audioParams) { - t.Errorf("%s: CreateAudioPreset: want %s. Got %s", test.givenTestCase, test.expectedAudioParams, audioParams) - pretty.Fdiff(os.Stderr, audioParams, test.expectedAudioParams) - } - } -} - -func TestAWSJobStatusNotFound(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - provider := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - jobStatus, err := provider.JobStatus(&db.Job{ProviderJobID: "idk"}) - if err == nil { - t.Fatal("Got unexpected error") - } - expectedErrMsg := "job not found" - if err.Error() != expectedErrMsg { - t.Errorf("Got wrong error message. Want %q. Got %q", expectedErrMsg, err.Error()) - } - if jobStatus != nil { - t.Errorf("Got unexpected non-nil JobStatus: %#v", jobStatus) - } -} - -func TestAWSJobStatusInternalError(t *testing.T) { - prepErr := errors.New("failed to get job status") - fakeTranscoder := newFakeElasticTranscoder() - fakeTranscoder.prepareFailure("ReadJob", prepErr) - provider := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - jobStatus, err := provider.JobStatus(&db.Job{ProviderJobID: "idk"}) - if jobStatus != nil { - t.Errorf("Got unexpected non-nil JobStatus: %#v", jobStatus) - } - if err != prepErr { - t.Errorf("Got wrong error. Want %q. Got %q", prepErr.Error(), err.Error()) - } -} - -func TestAWSStatusMap(t *testing.T) { - tests := []struct { - input string - output provider.Status - }{ - {"Submitted", provider.StatusQueued}, - {"Progressing", provider.StatusStarted}, - {"Canceled", provider.StatusCanceled}, - {"Error", provider.StatusFailed}, - {"Complete", provider.StatusFinished}, - {"unknown", provider.StatusFailed}, - } - var prov awsProvider - for _, test := range tests { - result := prov.statusMap(test.input) - if result != test.output { - t.Errorf("statusMap(%q): wrong result. Want %q. Got %q", test.input, test.output, result) - } - } -} - -func TestCancelJob(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - prov := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - err := prov.CancelJob("idk") - if err != nil { - t.Fatal(err) - } - if id := aws.StringValue(fakeTranscoder.canceledJobs[0].Id); id != "idk" { - t.Errorf("wrong job canceled. Want %q. Got %q", "idk", id) - } -} - -func TestCancelJobInternalError(t *testing.T) { - prepErr := errors.New("failed to cancel job") - fakeTranscoder := newFakeElasticTranscoder() - fakeTranscoder.prepareFailure("CancelJob", prepErr) - provider := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - err := provider.CancelJob("idk") - if err != prepErr { - t.Errorf("wrong error returned.\nWant %#v\nGot %#v", prepErr, err) - } -} - -func TestHealthcheck(t *testing.T) { - fakeTranscoder := newFakeElasticTranscoder() - provider := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - err := provider.Healthcheck() - if err != nil { - t.Fatal(err) - } -} - -func TestHealthcheckFailure(t *testing.T) { - prepErr := errors.New("something went wrong") - fakeTranscoder := newFakeElasticTranscoder() - fakeTranscoder.prepareFailure("ReadPipeline", prepErr) - provider := &awsProvider{ - c: fakeTranscoder, - config: &config.ElasticTranscoder{ - AccessKeyID: "AKIA", - SecretAccessKey: "secret", - Region: "sa-east-1", - PipelineID: "mypipeline", - }, - } - err := provider.Healthcheck() - if err != prepErr { - t.Errorf("Wrong error returned. Want %#v.Got %#v", prepErr, err) - } -} - -func TestCapabilities(t *testing.T) { - var prov awsProvider - expected := provider.Capabilities{ - InputFormats: []string{"h264"}, - OutputFormats: []string{"mp4", "hls", "webm"}, - Destinations: []string{"s3"}, - } - cap := prov.Capabilities() - if !reflect.DeepEqual(cap, expected) { - t.Errorf("Capabilities: want %#v. Got %#v", expected, cap) - } -}