Skip to content

Commit

Permalink
Merge pull request #66 from seqsense/use-bufio
Browse files Browse the repository at this point in the history
Use buffered writer for marshalling
  • Loading branch information
kamatama41 authored Jun 19, 2020
2 parents 79e3b0f + e6970d9 commit dfe813e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package kinesisvideomanager

import (
"bufio"
"bytes"
"fmt"
"io"
Expand All @@ -12,7 +13,7 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/client"
"github.com/aws/aws-sdk-go/aws/signer/v4"
v4 "github.com/aws/aws-sdk-go/aws/signer/v4"
"github.com/aws/aws-sdk-go/service/kinesisvideo"

"github.com/at-wat/ebml-go"
Expand Down Expand Up @@ -287,11 +288,20 @@ func (p *Provider) putMedia(baseTimecode chan uint64, ch chan ebml.Block, chTag
r, w := io.Pipe()
chErr := make(chan error)
go func() {
if err := ebml.Marshal(&data, w); err != nil {
defer func() {
close(chErr)
w.CloseWithError(io.EOF)
}()

buf := bufio.NewWriter(w)
if err := ebml.Marshal(&data, buf); err != nil {
chErr <- err
return
}
if err := buf.Flush(); err != nil {
chErr <- err
return
}
close(chErr)
w.CloseWithError(io.EOF)
}()

req, err := http.NewRequest("POST", p.endpoint, r)
Expand Down

0 comments on commit dfe813e

Please sign in to comment.