Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream: added metadata support #1088

Merged
merged 2 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/1088.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
stream: added metadata support
```
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