Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mjh1 committed Oct 23, 2023
1 parent 67f19b1 commit 6122d6a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 18 deletions.
54 changes: 37 additions & 17 deletions task/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,11 @@ func TaskTranscodeFile(tctx *TaskContext) (*TaskHandlerOutput, error) {
getOutputLocations: func() ([]clients.OutputLocation, error) {
_, outputLocation, err := outputLocations(
params.Storage.URL,
out(isEnabled(params.Outputs.HLS.Path), params.Outputs.HLS.Path),
out(isEnabled(params.Outputs.MP4.Path), params.Outputs.MP4.Path),
out(isEnabled(params.Outputs.FMP4.Path), params.Outputs.FMP4.Path),
output{},
outputs{
hls: out(isEnabled(params.Outputs.HLS.Path), params.Outputs.HLS.Path),
mp4: out(isEnabled(params.Outputs.MP4.Path), params.Outputs.MP4.Path),
fmp4: out(isEnabled(params.Outputs.FMP4.Path), params.Outputs.FMP4.Path),
},

Check warning on line 226 in task/upload.go

View check run for this annotation

Codecov / codecov/patch

task/upload.go#L222-L226

Added lines #L222 - L226 were not covered by tests
false,
)
return outputLocation, err
Expand Down Expand Up @@ -679,7 +680,15 @@ func uploadTaskOutputLocations(tctx *TaskContext) ([]OutputName, []clients.Outpu
if tctx.Task.Params.Upload.Thumbnails {
thumbsEnabled = OUTPUT_ENABLED
}
outputNames, outputLocations, err := outputLocations(outURL, out(OUTPUT_ENABLED, playbackId), out(mp4, playbackId), output{}, out(thumbsEnabled, playbackId), !isEncryptionEnabled(*tctx.Task.Params.Upload))
outputNames, outputLocations, err := outputLocations(
outURL,
outputs{
hls: out(OUTPUT_ENABLED, playbackId),
mp4: out(mp4, playbackId),
thumbnails: out(thumbsEnabled, playbackId),
},
!isEncryptionEnabled(*tctx.Task.Params.Upload),
)

Check warning on line 691 in task/upload.go

View check run for this annotation

Codecov / codecov/patch

task/upload.go#L679-L691

Added lines #L679 - L691 were not covered by tests
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -720,7 +729,14 @@ func clipTaskOutputLocations(tctx *TaskContext) ([]OutputName, []clients.OutputL
return nil, nil, fmt.Errorf("error parsing object store URL %w", err)
}

outputNames, outputLocations, err := outputLocations(outURL, out(OUTPUT_ENABLED, playbackId), out(OUTPUT_ENABLED, playbackId), output{}, output{}, false)
outputNames, outputLocations, err := outputLocations(
outURL,
outputs{
hls: out(OUTPUT_ENABLED, playbackId),
mp4: out(OUTPUT_ENABLED, playbackId),
},
false,
)

Check warning on line 739 in task/upload.go

View check run for this annotation

Codecov / codecov/patch

task/upload.go#L732-L739

Added lines #L732 - L739 were not covered by tests

if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -754,12 +770,16 @@ type output struct {
path string
}

type outputs struct {
hls output
mp4 output
fmp4 output
thumbnails output
}

func outputLocations(
outURL string,
hls,
mp4,
fmp4,
thumbnails output,
outs outputs,
sourceCopy bool,
) ([]OutputName, []clients.OutputLocation, error) {
url, err := url.Parse(outURL)
Expand All @@ -769,23 +789,23 @@ func outputLocations(
names, locations :=
[]OutputName{OutputNameOSPlaylistHLS, OutputNameEmpty},
[]clients.OutputLocation{
outputLocation(url, hls.path, &clients.OutputsRequest{HLS: hls.enabled}),
outputLocation(url, mp4.path, &clients.OutputsRequest{MP4: mp4.enabled}),
outputLocation(url, outs.hls.path, &clients.OutputsRequest{HLS: outs.hls.enabled}),
outputLocation(url, outs.mp4.path, &clients.OutputsRequest{MP4: outs.mp4.enabled}),
}
if fmp4.enabled == OUTPUT_ENABLED {
if outs.fmp4.enabled == OUTPUT_ENABLED {
names, locations =
append(names, OutputNameEmpty),
append(locations, outputLocation(url, fmp4.path, &clients.OutputsRequest{FMP4: fmp4.enabled}))
append(locations, outputLocation(url, outs.fmp4.path, &clients.OutputsRequest{FMP4: outs.fmp4.enabled}))

Check warning on line 798 in task/upload.go

View check run for this annotation

Codecov / codecov/patch

task/upload.go#L798

Added line #L798 was not covered by tests
}
if sourceCopy {
names, locations =
append(names, OutputNameOSSourceMP4),
append(locations, outputLocation(url, videoFileName(hls.path), &clients.OutputsRequest{SourceMp4: true}))
append(locations, outputLocation(url, videoFileName(outs.hls.path), &clients.OutputsRequest{SourceMp4: true}))
}
if thumbnails.enabled == OUTPUT_ENABLED {
if outs.thumbnails.enabled == OUTPUT_ENABLED {
names, locations =
append(names, OutputNameEmpty),
append(locations, outputLocation(url, thumbnails.path, &clients.OutputsRequest{Thumbnails: thumbnails.enabled}))
append(locations, outputLocation(url, outs.thumbnails.path, &clients.OutputsRequest{Thumbnails: outs.thumbnails.enabled}))
}
return names, locations, nil
}
Expand Down
10 changes: 9 additions & 1 deletion task/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,15 @@ func TestOutputLocations(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, gotOutputLocations, err := outputLocations(tt.outURL, out(tt.hls, tt.hlsRelPath), out(tt.mp4, tt.mp4RelPath), output{}, out(tt.thumbs, tt.thumbsRelPath), tt.sourceCopy)
_, gotOutputLocations, err := outputLocations(
tt.outURL,
outputs{
hls: out(tt.hls, tt.hlsRelPath),
mp4: out(tt.mp4, tt.mp4RelPath),
thumbnails: out(tt.thumbs, tt.thumbsRelPath),
},
tt.sourceCopy,
)

if tt.hasError {
require.Error(t, err)
Expand Down

0 comments on commit 6122d6a

Please sign in to comment.