Documentation ¶
Index ¶
- Constants
- Variables
- func ParseTimestamp(timestamp string) (time.Time, error)
- func SetLogger(l LoggerIF)
- func ToTimestamp(t time.Time) string
- type BlockChWithBaseTimecode
- type BlockReader
- type BlockWithBaseTimecode
- type BlockWithMetadata
- type BlockWriter
- type Client
- type Cluster
- type ClusterWrite
- type Consumer
- type Container
- type EBMLHeader
- type ErrorID
- type Fragment
- type FragmentEvent
- type FragmentEventError
- type FragmentEventType
- type FragmentMetadata
- type FragmentTimecodeType
- type GetMediaBody
- type GetMediaOption
- type GetMediaOptions
- type Info
- type LoggerIF
- type Provider
- type PutMediaOption
- func OnError(onError func(error)) PutMediaOption
- func OnPutMediaNewConn(onNewConn func()) PutMediaOption
- func OnPutMediaSwitchConn(onSwitchConn func(timecode uint64)) PutMediaOption
- func WithConnectionTimeout(timeout time.Duration) PutMediaOption
- func WithFragmentHeadDumpLen(n int) PutMediaOption
- func WithFragmentTimecodeType(fragmentTimecodeType FragmentTimecodeType) PutMediaOption
- func WithHttpClient(client http.Client) PutMediaOption
- func WithProducerStartTimestamp(producerStartTimestamp time.Time) PutMediaOption
- func WithPutMediaBufferLen(n int) PutMediaOption
- func WithPutMediaLogger(logger LoggerIF) PutMediaOption
- func WithPutMediaResponseBufferLen(n int) PutMediaOption
- func WithPutMediaRetry(count int, intervalBase time.Duration) PutMediaOption
- func WithSegmentUID(segmentUID []byte) PutMediaOption
- func WithTags(tags func() []SimpleTag) PutMediaOption
- func WithTitle(title string) PutMediaOption
- type PutMediaOptions
- type Segment
- type SegmentWrite
- type SimpleTag
- type StartSelector
- type StartSelectorType
- type StreamID
- type Tag
- type Tags
- type TrackEntry
- type Tracks
Constants ¶
const ( TagNameFragmentNumber = "AWS_KINESISVIDEO_FRAGMENT_NUMBER" TagNameServerTimestamp = "AWS_KINESISVIDEO_SERVER_TIMESTAMP" TagNameProducerTimestamp = "AWS_KINESISVIDEO_PRODUCER_TIMESTAMP" TagNameExceptionErrorCode = "AWS_KINESISVIDEO_EXCEPTION_ERROR_CODE" TagNameExceptionMessage = "AWS_KINESISVIDEO_EXCEPTION_MESSAGE" )
const TimecodeScale = 1000000
Variables ¶
var ( ErrInvalidTimecode = errors.New("invalid timecode") ErrWriteTimeout = errors.New("write timeout") )
Functions ¶
func ToTimestamp ¶
Types ¶
type BlockChWithBaseTimecode ¶
type BlockReader ¶ added in v1.0.0
type BlockWithBaseTimecode ¶
type BlockWithBaseTimecode struct { Timecode uint64 Block ebml.Block }
func (*BlockWithBaseTimecode) AbsTimecode ¶
func (bt *BlockWithBaseTimecode) AbsTimecode() int64
type BlockWithMetadata ¶
type BlockWithMetadata struct { *BlockWithBaseTimecode *FragmentMetadata }
type BlockWriter ¶ added in v0.9.0
type BlockWriter interface { // Write a block to Kinesis Video Stream. Write(*BlockWithBaseTimecode) error // ReadResponse reads a response from Kinesis Video Stream. ReadResponse() (*FragmentEvent, error) // Close immediately shuts down the client. Close() error // Shutdown gracefully shuts down the client without interrupting on-going PutMedia request. // If Shotdown returned an error, some of the internal resources might not released yet and // caller should call Shutdown or Close again. Shutdown(ctx context.Context) error }
type ClusterWrite ¶
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
func (*Consumer) GetMedia ¶
func (c *Consumer) GetMedia(opts ...GetMediaOption) (BlockReader, error)
GetMedia opens connection to Kinesis Video Stream to get media blocks. This function immediately returns BlockReader. Both BlockWriter.Read() and BlockWriter.ReadTag() must be called until getting io.EOF as error, otherwise Reader will be blocked after the buffer is filled.
type Container ¶
type Container struct { Header EBMLHeader `ebml:"EBML"` Segment Segment `ebml:",size=unknown"` }
type EBMLHeader ¶
type ErrorID ¶ added in v0.6.1
type ErrorID int
ErrorID represents ErrorId enum of PutMedia API. See https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/API_dataplane_PutMedia.html for details.
const ( STREAM_READ_ERROR ErrorID = 4000 MAX_FRAGMENT_SIZE_REACHED ErrorID = 4001 MAX_FRAGMENT_DURATION_REACHED ErrorID = 4002 MAX_CONNECTION_DURATION_REACHED ErrorID = 4003 FRAGMENT_TIMECODE_LESSER_THAN_PREVIOUS ErrorID = 4004 MORE_THAN_ALLOWED_TRACKS_FOUND ErrorID = 4005 INVALID_MKV_DATA ErrorID = 4006 INVALID_PRODUCER_TIMESTAMP ErrorID = 4007 STREAM_NOT_ACTIVE ErrorID = 4008 FRAGMENT_METADATA_LIMIT_REACHED ErrorID = 4009 TRACK_NUMBER_MISMATCH ErrorID = 4010 FRAMES_MISSING_FOR_TRACK ErrorID = 4011 KMS_KEY_ACCESS_DENIED ErrorID = 4500 KMS_KEY_DISABLED ErrorID = 4501 KMS_KEY_VALIDATION_ERROR ErrorID = 4502 KMS_KEY_UNAVAILABLE ErrorID = 4503 KMS_KEY_INVALID_USAGE ErrorID = 4504 KMS_KEY_INVALID_STATE ErrorID = 4505 KMS_KEY_NOT_FOUND ErrorID = 4506 INTERNAL_ERROR ErrorID = 5000 ARCHIVAL_ERROR ErrorID = 5001 )
type Fragment ¶
type Fragment []*BlockWithMetadata
type FragmentEvent ¶
type FragmentEvent struct { EventType FragmentEventType FragmentTimecode uint64 FragmentNumber string // 158-bit number, handle as string ErrorId ErrorID ErrorCode string // contains filtered or unexported fields }
FragmentEvent represents Acknowledgement object of PutMedia API. See https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/API_dataplane_PutMedia.html for details.
func (*FragmentEvent) AsError ¶ added in v1.0.0
func (e *FragmentEvent) AsError() error
func (*FragmentEvent) Dump ¶ added in v0.7.0
func (e *FragmentEvent) Dump() []byte
func (*FragmentEvent) IsError ¶ added in v0.5.4
func (e *FragmentEvent) IsError() bool
type FragmentEventError ¶ added in v1.0.0
type FragmentEventError struct {
FragmentEvent
}
func (FragmentEventError) Error ¶ added in v1.0.0
func (e FragmentEventError) Error() string
type FragmentEventType ¶ added in v1.0.0
type FragmentEventType string
FragmentEventType represents AckEventType enum of PutMedia API. See https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/API_dataplane_PutMedia.html for details.
const ( FRAGMENT_EVENT_BUFFERING FragmentEventType = "BUFFERING" FRAGMENT_EVENT_RECEIVED FragmentEventType = "RECEIVED" FRAGMENT_EVENT_PERSISTED FragmentEventType = "PERSISTED" FRAGMENT_EVENT_ERROR FragmentEventType = "ERROR" FRAGMENT_EVENT_IDLE FragmentEventType = "IDLE" )
type FragmentMetadata ¶
type FragmentTimecodeType ¶
type FragmentTimecodeType string
const ( FragmentTimecodeTypeAbsolute FragmentTimecodeType = "ABSOLUTE" FragmentTimecodeTypeRelative FragmentTimecodeType = "RELATIVE" )
type GetMediaBody ¶
type GetMediaBody struct { StartSelector StartSelector StreamARN *string `json:",omitempty"` StreamName *string `json:",omitempty"` }
type GetMediaOption ¶
type GetMediaOption func(*GetMediaOptions)
func WithGetMediaBufferLen ¶ added in v1.0.0
func WithGetMediaBufferLen(n int) GetMediaOption
func WithGetMediaTagBufferLen ¶ added in v1.0.0
func WithGetMediaTagBufferLen(n int) GetMediaOption
func WithStartSelectorContinuationToken ¶
func WithStartSelectorContinuationToken(token string) GetMediaOption
func WithStartSelectorNow ¶
func WithStartSelectorNow() GetMediaOption
func WithStartSelectorProducerTimestamp ¶
func WithStartSelectorProducerTimestamp(timestamp time.Time) GetMediaOption
type GetMediaOptions ¶
type GetMediaOptions struct {
// contains filtered or unexported fields
}
type LoggerIF ¶
type LoggerIF interface { Debug(args ...interface{}) Debugf(format string, args ...interface{}) Info(args ...interface{}) Infof(format string, args ...interface{}) Warn(args ...interface{}) Warnf(format string, args ...interface{}) Error(args ...interface{}) Errorf(format string, args ...interface{}) }
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
func (*Provider) PutMedia ¶
func (p *Provider) PutMedia(opts ...PutMediaOption) (BlockWriter, error)
PutMedia opens connection to Kinesis Video Stream to put media blocks. This function immediately returns BlockWriter. BlockWriter.ReadResponse() must be called until getting io.EOF as error, otherwise Write() call will be blocked after the buffer is filled.
type PutMediaOption ¶
type PutMediaOption func(*PutMediaOptions)
func OnError ¶
func OnError(onError func(error)) PutMediaOption
func OnPutMediaNewConn ¶ added in v1.1.0
func OnPutMediaNewConn(onNewConn func()) PutMediaOption
OnPutMediaNewConn registers a func that will be called before creating a new PutMedia API connection. Media stream processing is blocked until the func returns.
func OnPutMediaSwitchConn ¶ added in v1.1.0
func OnPutMediaSwitchConn(onSwitchConn func(timecode uint64)) PutMediaOption
OnPutMediaSwitchConn registers a func that will be called before switching a PutMedia API connection. Media stream processing is blocked until the func returns.
func WithConnectionTimeout ¶
func WithConnectionTimeout(timeout time.Duration) PutMediaOption
func WithFragmentHeadDumpLen ¶ added in v0.7.0
func WithFragmentHeadDumpLen(n int) PutMediaOption
WithFragmentHeadDumpLen sets fragment data head dump length embedded to the FragmentEvent error message. Data dump is enabled only if PutMediaRetry is enabled. Set zero to disable.
func WithFragmentTimecodeType ¶
func WithFragmentTimecodeType(fragmentTimecodeType FragmentTimecodeType) PutMediaOption
func WithHttpClient ¶
func WithHttpClient(client http.Client) PutMediaOption
func WithProducerStartTimestamp ¶
func WithProducerStartTimestamp(producerStartTimestamp time.Time) PutMediaOption
func WithPutMediaBufferLen ¶ added in v1.0.0
func WithPutMediaBufferLen(n int) PutMediaOption
func WithPutMediaLogger ¶ added in v0.8.0
func WithPutMediaLogger(logger LoggerIF) PutMediaOption
func WithPutMediaResponseBufferLen ¶ added in v1.0.0
func WithPutMediaResponseBufferLen(n int) PutMediaOption
func WithPutMediaRetry ¶ added in v0.5.0
func WithPutMediaRetry(count int, intervalBase time.Duration) PutMediaOption
func WithSegmentUID ¶
func WithSegmentUID(segmentUID []byte) PutMediaOption
func WithTags ¶
func WithTags(tags func() []SimpleTag) PutMediaOption
func WithTitle ¶
func WithTitle(title string) PutMediaOption
type PutMediaOptions ¶
type PutMediaOptions struct {
// contains filtered or unexported fields
}
type SegmentWrite ¶
type SegmentWrite struct { Info Info Tracks Tracks Cluster ClusterWrite `ebml:",size=unknown"` Tags Tags }
type StartSelector ¶
type StartSelector struct { AfterFragmentNumber string `json:",omitempty"` ContinuationToken string `json:",omitempty"` StartSelectorType StartSelectorType StartTimestamp int `json:",omitempty"` }
type StartSelectorType ¶
type StartSelectorType string
const ( StartSelectorTypeNow StartSelectorType = "NOW" StartSelectorTypeEarliest StartSelectorType = "EARLIEST" StartSelectorTypeFragmentNumber StartSelectorType = "FRAGMENT_NUMBER" StartSelectorTypeProducerTimestamp StartSelectorType = "PRODUCER_TIMESTAMP" StartSelectorTypeServerTimestamp StartSelectorType = "SERVER_TIMESTAMP" StartSelectorTypeContinuationToken StartSelectorType = "CONTINUATION_TOKEN" )
type StreamID ¶
func StreamName ¶
type TrackEntry ¶
type Tracks ¶
type Tracks struct {
TrackEntry []TrackEntry
}