Skip to content

Commit

Permalink
stream: added metadata support
Browse files Browse the repository at this point in the history
  • Loading branch information
Venoox committed Sep 18, 2022
1 parent bb37d69 commit c70c4a5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ type StreamUploadFromURLParameters struct {
AllowedOrigins []string `json:"allowedOrigins,omitempty"`
RequiredSignedURLs bool `json:"requiredSignedURLs,omitempty"`
Watermark UploadVideoURLWatermark `json:"watermark,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
}

// StreamCreateVideoParameters are parameters used when creating a video.
Expand All @@ -115,6 +116,7 @@ type StreamCreateVideoParameters struct {
AllowedOrigins []string `json:"allowedOrigins,omitempty"`
RequiredSignedURLs bool `json:"requiredSignedURLs,omitempty"`
Watermark UploadVideoURLWatermark `json:"watermark,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
}

// UploadVideoURLWatermark represents UID of an existing watermark.
Expand Down
19 changes: 15 additions & 4 deletions stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const (
"width": 1920
},
"maxDurationSeconds": 300,
"meta": {},
"meta": {
"name": "My First Stream Video"
},
"modified": "2014-01-02T02:20:00Z",
"uploadExpiry": "2014-01-02T02:20:00Z",
"playback": {
Expand Down Expand Up @@ -121,7 +123,9 @@ func createTestVideo() StreamVideo {
Scale: 0.1,
Position: "center",
},
Meta: map[string]interface{}{},
Meta: map[string]interface{}{
"name": "My First Stream Video",
},
NFT: StreamVideoNFTParameters{
Token: 5,
Contract: "0x57f1887a8bf19b14fc0d912b9b2acc9af147ea85",
Expand Down Expand Up @@ -155,6 +159,9 @@ func TestStream_StreamUploadFromURL(t *testing.T) {
input := StreamUploadFromURLParameters{
AccountID: testAccountID,
URL: "https://example.com/myvideo.mp4",
Meta: map[string]interface{}{
"name": "My First Stream Video",
},
}

out, err := client.StreamUploadFromURL(context.Background(), input)
Expand Down Expand Up @@ -241,7 +248,9 @@ func TestStream_CreateVideoDirectURL(t *testing.T) {
assert.Equal(t, ErrMissingMaxDuration, err)
}

input := StreamCreateVideoParameters{AccountID: testAccountID, MaxDurationSeconds: 300}
input := StreamCreateVideoParameters{AccountID: testAccountID, MaxDurationSeconds: 300, Meta: map[string]interface{}{
"name": "My First Stream Video",
}}
out, err := client.StreamCreateVideoDirectURL(context.Background(), input)

created, _ := time.Parse(time.RFC3339, "2014-01-02T02:20:00Z")
Expand Down Expand Up @@ -291,7 +300,9 @@ func TestStream_ListVideos(t *testing.T) {
"width": 1920
},
"maxDurationSeconds": 300,
"meta": {},
"meta": {
"name": "My First Stream Video"
},
"modified": "2014-01-02T02:20:00Z",
"uploadExpiry": "2014-01-02T02:20:00Z",
"playback": {
Expand Down

0 comments on commit c70c4a5

Please sign in to comment.