package media import ( "context" "io" "time" "git.netflux.io/rob/clipper/generated/store" signerv4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/google/uuid" youtubev2 "github.com/kkdai/youtube/v2" ) // An int16 has two bytes. const SizeOfInt16 = 2 // MediaSet represents the media and metadata associated with a single media // resource (for example, a YouTube video). type MediaSet struct { Audio Audio Video Video ID uuid.UUID YoutubeID string } // Audio contains the metadata for the audio part of the media set. type Audio struct { ContentLength int64 Channels int // ApproxFrames is used during initial processing when a precise frame count // cannot be determined. Prefer Frames in all other cases. ApproxFrames int64 Frames int64 SampleRate int YoutubeItag int MimeType string } // Video contains the metadata for the video part of the media set. type Video struct { ContentLength int64 Duration time.Duration // not sure if this are needed any more? ThumbnailWidth int ThumbnailHeight int YoutubeItag int MimeType string } // Store wraps a database store. type Store interface { GetMediaSet(context.Context, uuid.UUID) (store.MediaSet, error) GetMediaSetByYoutubeID(context.Context, string) (store.MediaSet, error) CreateMediaSet(context.Context, store.CreateMediaSetParams) (store.MediaSet, error) SetRawAudioUploaded(context.Context, store.SetRawAudioUploadedParams) (store.MediaSet, error) SetEncodedAudioUploaded(context.Context, store.SetEncodedAudioUploadedParams) (store.MediaSet, error) SetVideoUploaded(context.Context, store.SetVideoUploadedParams) (store.MediaSet, error) SetVideoThumbnailUploaded(context.Context, store.SetVideoThumbnailUploadedParams) (store.MediaSet, error) } // S3API provides an API to AWS S3. type S3API struct { S3Client S3PresignClient } // S3Client wraps the AWS S3 service client. type S3Client interface { GetObject(context.Context, *s3.GetObjectInput, ...func(*s3.Options)) (*s3.GetObjectOutput, error) CreateMultipartUpload(context.Context, *s3.CreateMultipartUploadInput, ...func(*s3.Options)) (*s3.CreateMultipartUploadOutput, error) UploadPart(context.Context, *s3.UploadPartInput, ...func(*s3.Options)) (*s3.UploadPartOutput, error) AbortMultipartUpload(context.Context, *s3.AbortMultipartUploadInput, ...func(*s3.Options)) (*s3.AbortMultipartUploadOutput, error) CompleteMultipartUpload(context.Context, *s3.CompleteMultipartUploadInput, ...func(*s3.Options)) (*s3.CompleteMultipartUploadOutput, error) } // S3PresignClient wraps the AWS S3 Presign client. type S3PresignClient interface { PresignGetObject(context.Context, *s3.GetObjectInput, ...func(*s3.PresignOptions)) (*signerv4.PresignedHTTPRequest, error) } // YoutubeClient wraps the youtube.Client client. type YoutubeClient interface { GetVideoContext(context.Context, string) (*youtubev2.Video, error) GetStreamContext(context.Context, *youtubev2.Video, *youtubev2.Format) (io.ReadCloser, int64, error) }