Skip to content

Commit

Permalink
DATA-764 allow properties from media source (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
bazile-clyde authored Nov 18, 2022
1 parent c35fbf3 commit 047e05a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions media.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gostream
import (
"context"
"errors"
"github.com/pion/mediadevices/pkg/prop"
"sync"
"sync/atomic"

Expand Down Expand Up @@ -116,6 +117,15 @@ type producerConsumer[T any, U any] struct {
// for error handling logic based on consecutively retrieved errors).
type ErrorHandler func(ctx context.Context, mediaErr error)

func PropertiesFromMediaSource[T, U any](src MediaSource[T]) []prop.Media {
if asMedia, ok := src.(*mediaSource[T, U]); ok {
if asMedia.driver != nil {
return asMedia.driver.Properties()
}
}
return nil
}

// newMediaSource instantiates a new media read closer and possibly references the given driver.
func newMediaSource[T, U any](d driver.Driver, r MediaReader[T], p U) MediaSource[T] {
if d != nil {
Expand Down

0 comments on commit 047e05a

Please sign in to comment.