Documentation
¶
Index ¶
- Variables
- func ExtractFrameFromVideo(videoPath string, timestamp time.Duration) (image.Image, error)
- type BaseRecorder
- func (r *BaseRecorder) Close() error
- func (r *BaseRecorder) GetInfo() RecordingInfo
- func (r *BaseRecorder) GetSegments() []SegmentInfo
- func (r *BaseRecorder) Pause(ctx context.Context) error
- func (r *BaseRecorder) Resume(ctx context.Context) error
- func (r *BaseRecorder) SetOnError(callback func(error))
- func (r *BaseRecorder) SetOnSegmentComplete(callback func(SegmentInfo))
- func (r *BaseRecorder) SetOnThumbnail(callback func(ThumbnailInfo))
- func (r *BaseRecorder) Start(ctx context.Context) error
- func (r *BaseRecorder) Stop(ctx context.Context) error
- type FileMetadataStore
- func (s *FileMetadataStore) Close() error
- func (s *FileMetadataStore) Delete(ctx context.Context, recordingID string) error
- func (s *FileMetadataStore) Get(ctx context.Context, recordingID string) (*RecordingMetadata, error)
- func (s *FileMetadataStore) IncrementViews(ctx context.Context, recordingID string) error
- func (s *FileMetadataStore) Query(ctx context.Context, query MetadataQuery) ([]*RecordingMetadata, error)
- func (s *FileMetadataStore) Save(ctx context.Context, metadata *RecordingMetadata) error
- func (s *FileMetadataStore) Update(ctx context.Context, metadata *RecordingMetadata) error
- type InMemoryMetadataStore
- func (s *InMemoryMetadataStore) Close() error
- func (s *InMemoryMetadataStore) Delete(ctx context.Context, recordingID string) error
- func (s *InMemoryMetadataStore) Get(ctx context.Context, recordingID string) (*RecordingMetadata, error)
- func (s *InMemoryMetadataStore) IncrementViews(ctx context.Context, recordingID string) error
- func (s *InMemoryMetadataStore) Query(ctx context.Context, query MetadataQuery) ([]*RecordingMetadata, error)
- func (s *InMemoryMetadataStore) Save(ctx context.Context, metadata *RecordingMetadata) error
- func (s *InMemoryMetadataStore) Update(ctx context.Context, metadata *RecordingMetadata) error
- type LocalStorage
- func (s *LocalStorage) Close() error
- func (s *LocalStorage) Copy(ctx context.Context, srcKey, dstKey string) error
- func (s *LocalStorage) Delete(ctx context.Context, key string) error
- func (s *LocalStorage) Download(ctx context.Context, key string) (io.ReadCloser, error)
- func (s *LocalStorage) Exists(ctx context.Context, key string) (bool, error)
- func (s *LocalStorage) GetMetadata(ctx context.Context, key string) (map[string]string, error)
- func (s *LocalStorage) GetURL(ctx context.Context, key string, expires time.Duration) (string, error)
- func (s *LocalStorage) List(ctx context.Context, prefix string, maxKeys int) ([]StorageObject, error)
- func (s *LocalStorage) SetMetadata(ctx context.Context, key string, metadata map[string]string) error
- func (s *LocalStorage) Upload(ctx context.Context, key string, data io.Reader, size int64, ...) error
- type MetadataQuery
- type MetadataStore
- type Recorder
- type RecordingConfig
- type RecordingFormat
- type RecordingInfo
- type RecordingMetadata
- type RecordingState
- type S3Storage
- func (s *S3Storage) Close() error
- func (s *S3Storage) Copy(ctx context.Context, srcKey, dstKey string) error
- func (s *S3Storage) Delete(ctx context.Context, key string) error
- func (s *S3Storage) Download(ctx context.Context, key string) (io.ReadCloser, error)
- func (s *S3Storage) Exists(ctx context.Context, key string) (bool, error)
- func (s *S3Storage) GetMetadata(ctx context.Context, key string) (map[string]string, error)
- func (s *S3Storage) GetURL(ctx context.Context, key string, expires time.Duration) (string, error)
- func (s *S3Storage) List(ctx context.Context, prefix string, maxKeys int) ([]StorageObject, error)
- func (s *S3Storage) SetMetadata(ctx context.Context, key string, metadata map[string]string) error
- func (s *S3Storage) Upload(ctx context.Context, key string, data io.Reader, size int64, ...) error
- type SegmentInfo
- type Storage
- type StorageConfig
- type StorageObject
- type StorageType
- type ThumbnailConfig
- type ThumbnailGenerator
- func (g *ThumbnailGenerator) Close() error
- func (g *ThumbnailGenerator) GenerateThumbnail(ctx context.Context, recordingID string, frame image.Image, ...) ([]ThumbnailInfo, error)
- func (g *ThumbnailGenerator) GetThumbnails(recordingID string) []ThumbnailInfo
- func (g *ThumbnailGenerator) GetThumbnailsBySize(recordingID, sizeName string) []ThumbnailInfo
- func (g *ThumbnailGenerator) ShouldCaptureThumbnail() bool
- type ThumbnailInfo
- type ThumbnailSize
Constants ¶
This section is empty.
Variables ¶
var ( ErrRecordingNotStarted = errors.New("recording not started") ErrRecordingAlreadyStarted = errors.New("recording already started") ErrRecordingPaused = errors.New("recording is paused") ErrInvalidFormat = errors.New("invalid recording format") ErrInvalidSegment = errors.New("invalid segment") ErrStorageNotConfigured = errors.New("storage not configured") ErrObjectNotFound = errors.New("object not found") ErrInvalidObjectKey = errors.New("invalid object key") ErrUploadFailed = errors.New("upload failed") ErrDownloadFailed = errors.New("download failed") )
Common errors
Functions ¶
Types ¶
type BaseRecorder ¶
type BaseRecorder struct {
// contains filtered or unexported fields
}
BaseRecorder provides a base implementation for recording livestreams
func NewBaseRecorder ¶
func NewBaseRecorder(config RecordingConfig, log logger.Logger) *BaseRecorder
NewBaseRecorder creates a new base recorder
func (*BaseRecorder) Close ¶
func (r *BaseRecorder) Close() error
Close closes the recorder and releases resources
func (*BaseRecorder) GetInfo ¶
func (r *BaseRecorder) GetInfo() RecordingInfo
GetInfo returns current recording information
func (*BaseRecorder) GetSegments ¶
func (r *BaseRecorder) GetSegments() []SegmentInfo
GetSegments returns all recorded segments
func (*BaseRecorder) Pause ¶
func (r *BaseRecorder) Pause(ctx context.Context) error
Pause temporarily pauses recording
func (*BaseRecorder) Resume ¶
func (r *BaseRecorder) Resume(ctx context.Context) error
Resume resumes a paused recording
func (*BaseRecorder) SetOnError ¶
func (r *BaseRecorder) SetOnError(callback func(error))
SetOnError sets the callback for errors
func (*BaseRecorder) SetOnSegmentComplete ¶
func (r *BaseRecorder) SetOnSegmentComplete(callback func(SegmentInfo))
SetOnSegmentComplete sets the callback for segment completion
func (*BaseRecorder) SetOnThumbnail ¶
func (r *BaseRecorder) SetOnThumbnail(callback func(ThumbnailInfo))
SetOnThumbnail sets the callback for thumbnail generation
type FileMetadataStore ¶
type FileMetadataStore struct {
// contains filtered or unexported fields
}
FileMetadataStore implements a file-based metadata store
func NewFileMetadataStore ¶
func NewFileMetadataStore(basePath string, log logger.Logger) (*FileMetadataStore, error)
NewFileMetadataStore creates a new file-based metadata store
func (*FileMetadataStore) Close ¶
func (s *FileMetadataStore) Close() error
Close closes the metadata store
func (*FileMetadataStore) Delete ¶
func (s *FileMetadataStore) Delete(ctx context.Context, recordingID string) error
Delete deletes recording metadata file
func (*FileMetadataStore) Get ¶
func (s *FileMetadataStore) Get(ctx context.Context, recordingID string) (*RecordingMetadata, error)
Get retrieves recording metadata from file
func (*FileMetadataStore) IncrementViews ¶
func (s *FileMetadataStore) IncrementViews(ctx context.Context, recordingID string) error
IncrementViews increments the view count for a recording
func (*FileMetadataStore) Query ¶
func (s *FileMetadataStore) Query(ctx context.Context, query MetadataQuery) ([]*RecordingMetadata, error)
Query queries recording metadata from files
func (*FileMetadataStore) Save ¶
func (s *FileMetadataStore) Save(ctx context.Context, metadata *RecordingMetadata) error
Save saves recording metadata to file
func (*FileMetadataStore) Update ¶
func (s *FileMetadataStore) Update(ctx context.Context, metadata *RecordingMetadata) error
Update updates existing recording metadata in file
type InMemoryMetadataStore ¶
type InMemoryMetadataStore struct {
// contains filtered or unexported fields
}
InMemoryMetadataStore implements an in-memory metadata store
func NewInMemoryMetadataStore ¶
func NewInMemoryMetadataStore(log logger.Logger) *InMemoryMetadataStore
NewInMemoryMetadataStore creates a new in-memory metadata store
func (*InMemoryMetadataStore) Close ¶
func (s *InMemoryMetadataStore) Close() error
Close closes the metadata store
func (*InMemoryMetadataStore) Delete ¶
func (s *InMemoryMetadataStore) Delete(ctx context.Context, recordingID string) error
Delete deletes recording metadata
func (*InMemoryMetadataStore) Get ¶
func (s *InMemoryMetadataStore) Get(ctx context.Context, recordingID string) (*RecordingMetadata, error)
Get retrieves recording metadata by ID
func (*InMemoryMetadataStore) IncrementViews ¶
func (s *InMemoryMetadataStore) IncrementViews(ctx context.Context, recordingID string) error
IncrementViews increments the view count for a recording
func (*InMemoryMetadataStore) Query ¶
func (s *InMemoryMetadataStore) Query(ctx context.Context, query MetadataQuery) ([]*RecordingMetadata, error)
Query queries recording metadata with filters
func (*InMemoryMetadataStore) Save ¶
func (s *InMemoryMetadataStore) Save(ctx context.Context, metadata *RecordingMetadata) error
Save saves recording metadata
func (*InMemoryMetadataStore) Update ¶
func (s *InMemoryMetadataStore) Update(ctx context.Context, metadata *RecordingMetadata) error
Update updates existing recording metadata
type LocalStorage ¶
type LocalStorage struct {
// contains filtered or unexported fields
}
LocalStorage implements local filesystem storage
func NewLocalStorage ¶
func NewLocalStorage(config StorageConfig, log logger.Logger) (*LocalStorage, error)
NewLocalStorage creates a new local storage backend
func (*LocalStorage) Copy ¶
func (s *LocalStorage) Copy(ctx context.Context, srcKey, dstKey string) error
Copy copies a file to a new location
func (*LocalStorage) Delete ¶
func (s *LocalStorage) Delete(ctx context.Context, key string) error
Delete removes a file from local filesystem
func (*LocalStorage) Download ¶
func (s *LocalStorage) Download(ctx context.Context, key string) (io.ReadCloser, error)
Download downloads data from local filesystem
func (*LocalStorage) GetMetadata ¶
GetMetadata retrieves metadata for a file
func (*LocalStorage) GetURL ¶
func (s *LocalStorage) GetURL(ctx context.Context, key string, expires time.Duration) (string, error)
GetURL returns a file:// URL for the file
func (*LocalStorage) List ¶
func (s *LocalStorage) List(ctx context.Context, prefix string, maxKeys int) ([]StorageObject, error)
List lists files with the given prefix
func (*LocalStorage) SetMetadata ¶
func (s *LocalStorage) SetMetadata(ctx context.Context, key string, metadata map[string]string) error
SetMetadata sets metadata for a file
type MetadataQuery ¶
type MetadataQuery struct {
StreamID string
UserID string
Tags []string
StartDate time.Time
EndDate time.Time
MinDuration time.Duration
MaxDuration time.Duration
SortBy string
SortOrder string
Offset int
Limit int
}
MetadataQuery contains parameters for querying recording metadata
type MetadataStore ¶
type MetadataStore interface {
Save(ctx context.Context, metadata *RecordingMetadata) error
Get(ctx context.Context, recordingID string) (*RecordingMetadata, error)
Update(ctx context.Context, metadata *RecordingMetadata) error
Delete(ctx context.Context, recordingID string) error
Query(ctx context.Context, query MetadataQuery) ([]*RecordingMetadata, error)
IncrementViews(ctx context.Context, recordingID string) error
Close() error
}
MetadataStore defines the interface for storing and querying recording metadata
type Recorder ¶
type Recorder interface {
Start(ctx context.Context) error
Stop(ctx context.Context) error
Pause(ctx context.Context) error
Resume(ctx context.Context) error
GetInfo() RecordingInfo
GetSegments() []SegmentInfo
Close() error
}
Recorder defines the interface for recording livestreams
type RecordingConfig ¶
type RecordingConfig struct {
StreamID string
Format RecordingFormat
OutputPath string
SegmentDuration time.Duration
MaxSegmentSize int64
Storage Storage
AutoUpload bool
Metadata map[string]string
}
RecordingConfig contains configuration for a recording session
func DefaultRecordingConfig ¶
func DefaultRecordingConfig() RecordingConfig
DefaultRecordingConfig returns a default recording configuration
type RecordingFormat ¶
type RecordingFormat string
RecordingFormat represents the format of the recording
const ( FormatMP4 RecordingFormat = "mp4" FormatFLV RecordingFormat = "flv" FormatHLS RecordingFormat = "hls" )
Recording formats supported by the SDK
type RecordingInfo ¶
type RecordingInfo struct {
ID string
StreamID string
State RecordingState
Format RecordingFormat
StartTime time.Time
EndTime time.Time
Duration time.Duration
Size int64
SegmentCount int
CurrentFile string
Error error
Metadata map[string]string
}
RecordingInfo contains information about a recording session
type RecordingMetadata ¶
type RecordingMetadata struct {
RecordingID string
StreamID string
UserID string
Title string
Description string
StartTime time.Time
EndTime time.Time
Duration time.Duration
FileSize int64
Format RecordingFormat
SegmentCount int
ThumbnailCount int
ViewCount int64
Tags []string
CustomMetadata map[string]string
CreatedAt time.Time
UpdatedAt time.Time
}
RecordingMetadata contains metadata about a recording
type RecordingState ¶
type RecordingState string
RecordingState represents the current state of a recording
const ( StateIdle RecordingState = "idle" StateRecording RecordingState = "recording" StatePaused RecordingState = "paused" StateStopped RecordingState = "stopped" StateError RecordingState = "error" )
Recording states
type S3Storage ¶
type S3Storage struct {
// contains filtered or unexported fields
}
S3Storage implements AWS S3 storage backend
func NewS3Storage ¶
func NewS3Storage(cfg StorageConfig, log logger.Logger) (*S3Storage, error)
NewS3Storage creates a new S3 storage backend
func (*S3Storage) GetMetadata ¶
GetMetadata retrieves metadata for an S3 object
func (*S3Storage) SetMetadata ¶
SetMetadata sets metadata for an S3 object
type SegmentInfo ¶
type SegmentInfo struct {
Index int
Path string
RemotePath string
Size int64
Duration time.Duration
StartTime time.Time
EndTime time.Time
Uploaded bool
}
SegmentInfo contains information about a recording segment
type Storage ¶
type Storage interface {
Upload(ctx context.Context, key string, data io.Reader, size int64, contentType string) error
Download(ctx context.Context, key string) (io.ReadCloser, error)
Delete(ctx context.Context, key string) error
Exists(ctx context.Context, key string) (bool, error)
List(ctx context.Context, prefix string, maxKeys int) ([]StorageObject, error)
GetMetadata(ctx context.Context, key string) (map[string]string, error)
SetMetadata(ctx context.Context, key string, metadata map[string]string) error
Copy(ctx context.Context, srcKey, dstKey string) error
GetURL(ctx context.Context, key string, expires time.Duration) (string, error)
Close() error
}
Storage defines the interface for storage backends
type StorageConfig ¶
type StorageConfig struct {
Type StorageType
BasePath string
Endpoint string
Region string
Bucket string
AccessKeyID string
SecretAccessKey string
UseSSL bool
MaxRetries int
RetryDelay time.Duration
Timeout time.Duration
}
StorageConfig contains configuration for storage backends
func DefaultStorageConfig ¶
func DefaultStorageConfig() StorageConfig
DefaultStorageConfig returns a default storage configuration
type StorageObject ¶
type StorageObject struct {
Key string
Size int64
LastModified time.Time
ContentType string
Metadata map[string]string
}
StorageObject represents an object in storage
type StorageType ¶
type StorageType string
StorageType represents the type of storage backend
const ( StorageTypeLocal StorageType = "local" StorageTypeS3 StorageType = "s3" )
type ThumbnailConfig ¶
type ThumbnailConfig struct {
Enabled bool
Sizes []ThumbnailSize
Interval time.Duration
Format string
Storage Storage
AutoUpload bool
}
ThumbnailConfig contains configuration for thumbnail generation
func DefaultThumbnailConfig ¶
func DefaultThumbnailConfig() ThumbnailConfig
DefaultThumbnailConfig returns a default thumbnail configuration
type ThumbnailGenerator ¶
type ThumbnailGenerator struct {
// contains filtered or unexported fields
}
ThumbnailGenerator generates thumbnails from video frames
func NewThumbnailGenerator ¶
func NewThumbnailGenerator(config ThumbnailConfig, log logger.Logger) *ThumbnailGenerator
NewThumbnailGenerator creates a new thumbnail generator
func (*ThumbnailGenerator) Close ¶
func (g *ThumbnailGenerator) Close() error
Close closes the thumbnail generator
func (*ThumbnailGenerator) GenerateThumbnail ¶
func (g *ThumbnailGenerator) GenerateThumbnail(ctx context.Context, recordingID string, frame image.Image, timestamp time.Time) ([]ThumbnailInfo, error)
GenerateThumbnail generates thumbnails from a video frame
func (*ThumbnailGenerator) GetThumbnails ¶
func (g *ThumbnailGenerator) GetThumbnails(recordingID string) []ThumbnailInfo
GetThumbnails returns all thumbnails for a recording
func (*ThumbnailGenerator) GetThumbnailsBySize ¶
func (g *ThumbnailGenerator) GetThumbnailsBySize(recordingID, sizeName string) []ThumbnailInfo
GetThumbnailsBySize returns thumbnails for a specific size
func (*ThumbnailGenerator) ShouldCaptureThumbnail ¶
func (g *ThumbnailGenerator) ShouldCaptureThumbnail() bool
ShouldCaptureThumbnail checks if a thumbnail should be captured based on interval
type ThumbnailInfo ¶
type ThumbnailInfo struct {
RecordingID string
Timestamp time.Time
Size string
Width int
Height int
Path string
RemotePath string
FileSize int64
Uploaded bool
}
ThumbnailInfo contains information about a generated thumbnail
func BatchGenerateThumbnails ¶
func BatchGenerateThumbnails(ctx context.Context, recordingID, videoPath string, interval time.Duration, config ThumbnailConfig) ([]ThumbnailInfo, error)
BatchGenerateThumbnails generates thumbnails at regular intervals from a video file
func GenerateThumbnailFromFile ¶
func GenerateThumbnailFromFile(videoPath string, timestamp time.Duration, config ThumbnailConfig) ([]ThumbnailInfo, error)
GenerateThumbnailFromFile generates thumbnails from a video file This is a placeholder - actual implementation requires video decoding