From 072235f032b97f718f1b952fa85319a80ff4b113 Mon Sep 17 00:00:00 2001 From: Kat Huang Date: Mon, 20 May 2024 21:52:38 -0600 Subject: [PATCH] Create playlist, video generator and video player (#489) Co-authored-by: Ivan Malison Reviewed-on: https://dev.railbird.ai/railbird/railbird-mobile/pulls/489 Reviewed-by: Ivan Malison --- src/index.tsx | 171 +++++++++++++++++++++++++++++++++------ src/operations/shots.gql | 13 ++- src/operations/video.gql | 29 ++++++- src/schema.gql | 13 +-- 4 files changed, 181 insertions(+), 45 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 1f63133..e2d771b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -378,7 +378,7 @@ export type UploadStreamGql = { errors: Array; id: Scalars["ID"]["output"]; isCompleted: Scalars["Boolean"]["output"]; - lastIntendedSegmentBound?: Maybe; + lastIntendedSegmentBound: Scalars["Int"]["output"]; linksRequested: Scalars["Int"]["output"]; lowestUnuploadedSegmentIndex: Scalars["Int"]["output"]; segmentProcessingCursor: Scalars["Int"]["output"]; @@ -425,7 +425,6 @@ export type VideoGql = { __typename?: "VideoGQL"; averageTimeBetweenShots?: Maybe; createdAt?: Maybe; - currentProcessing?: Maybe; elapsedTime?: Maybe; endTime?: Maybe; framesPerSecond: Scalars["Float"]["output"]; @@ -463,18 +462,6 @@ export type VideoMetadataInput = { videoName?: InputMaybe; }; -export type VideoProcessingErrorGql = { - __typename?: "VideoProcessingErrorGQL"; - endSegmentIndex?: Maybe; - message: Scalars["String"]["output"]; - startSegmentIndex?: Maybe; -}; - -export type VideoProcessingGql = { - __typename?: "VideoProcessingGQL"; - errors: Array; -}; - export type VideoTag = { __typename?: "VideoTag"; name: Scalars["String"]["output"]; @@ -589,6 +576,10 @@ export type GetVideoMakePercentageIntervalsQuery = { export type GetShotsQueryVariables = Exact<{ filterInput: FilterInput; + includeCreatedAt?: Scalars["Boolean"]["input"]; + includeUpdatedAt?: Scalars["Boolean"]["input"]; + includeCueObjectFeatures?: Scalars["Boolean"]["input"]; + includePocketingIntentionFeatures?: Scalars["Boolean"]["input"]; includeCueObjectDistance?: Scalars["Boolean"]["input"]; includeCueObjectAngle?: Scalars["Boolean"]["input"]; includeCueBallSpeed?: Scalars["Boolean"]["input"]; @@ -728,7 +719,7 @@ export type GetStreamMonitoringDetailsQuery = { segmentProcessingCursor: number; isCompleted: boolean; uploadCompletionCursor: number; - lastIntendedSegmentBound?: number | null; + lastIntendedSegmentBound: number; } | null; currentProcessing?: { __typename?: "VideoProcessingGQL"; @@ -817,16 +808,50 @@ export type GetVideosQuery = { getVideos: Array<{ __typename?: "VideoGQL"; id: number; - name?: string | null; - framesPerSecond: number; playlist?: { __typename?: "HLSPlaylistGQL"; - m3u8Text: string; segmentDurations: Array; } | null; + stream?: { + __typename?: "UploadStreamGQL"; + id: string; + segments: Array<{ + __typename?: "UploadSegmentGQL"; + uploaded: boolean; + valid: boolean; + segmentIndex: number; + endFrameIndex?: number | null; + framesPerSecond?: number | null; + }>; + } | null; }>; }; +export type GetVideoQueryVariables = Exact<{ + videoId: Scalars["Int"]["input"]; +}>; + +export type GetVideoQuery = { + __typename?: "Query"; + getVideo: { + __typename?: "VideoGQL"; + id: number; + playlist?: { + __typename?: "HLSPlaylistGQL"; + segmentDurations: Array; + } | null; + stream?: { + __typename?: "UploadStreamGQL"; + segments: Array<{ + __typename?: "UploadSegmentGQL"; + segmentIndex: number; + endFrameIndex?: number | null; + framesPerSecond?: number | null; + }>; + } | null; + }; +}; + export type CreateUploadStreamMutationVariables = Exact<{ videoMetadataInput: VideoMetadataInput; }>; @@ -904,7 +929,7 @@ export type GetUploadStreamsWithDetailsQuery = { stream?: { __typename?: "UploadStreamGQL"; isCompleted: boolean; - lastIntendedSegmentBound?: number | null; + lastIntendedSegmentBound: number; uploadCompletionCursor: number; } | null; }>; @@ -1256,6 +1281,10 @@ export type GetVideoMakePercentageIntervalsQueryResult = Apollo.QueryResult< export const GetShotsDocument = gql` query GetShots( $filterInput: FilterInput! + $includeCreatedAt: Boolean! = false + $includeUpdatedAt: Boolean! = false + $includeCueObjectFeatures: Boolean! = false + $includePocketingIntentionFeatures: Boolean! = false $includeCueObjectDistance: Boolean! = false $includeCueObjectAngle: Boolean! = false $includeCueBallSpeed: Boolean! = false @@ -1269,15 +1298,16 @@ export const GetShotsDocument = gql` videoId startFrame endFrame - createdAt - updatedAt - cueObjectFeatures { + createdAt @include(if: $includeCreatedAt) + updatedAt @include(if: $includeUpdatedAt) + cueObjectFeatures @include(if: $includeCueObjectFeatures) { cueObjectDistance @include(if: $includeCueObjectDistance) cueObjectAngle @include(if: $includeCueObjectAngle) cueBallSpeed @include(if: $includeCueBallSpeed) shotDirection @include(if: $includeShotDirection) } - pocketingIntentionFeatures { + pocketingIntentionFeatures + @include(if: $includePocketingIntentionFeatures) { targetPocketDistance @include(if: $includeTargetPocketDistance) make @include(if: $includeMake) intendedPocketType @include(if: $includeIntendedPocketType) @@ -1299,6 +1329,10 @@ export const GetShotsDocument = gql` * const { data, loading, error } = useGetShotsQuery({ * variables: { * filterInput: // value for 'filterInput' + * includeCreatedAt: // value for 'includeCreatedAt' + * includeUpdatedAt: // value for 'includeUpdatedAt' + * includeCueObjectFeatures: // value for 'includeCueObjectFeatures' + * includePocketingIntentionFeatures: // value for 'includePocketingIntentionFeatures' * includeCueObjectDistance: // value for 'includeCueObjectDistance' * includeCueObjectAngle: // value for 'includeCueObjectAngle' * includeCueBallSpeed: // value for 'includeCueBallSpeed' @@ -1979,12 +2013,19 @@ export const GetVideosDocument = gql` query GetVideos($videoIds: [Int!]!) { getVideos(videoIds: $videoIds) { id - name - framesPerSecond playlist { - m3u8Text segmentDurations } + stream { + id + segments { + uploaded + valid + segmentIndex + endFrameIndex + framesPerSecond + } + } } } `; @@ -2049,6 +2090,84 @@ export type GetVideosQueryResult = Apollo.QueryResult< GetVideosQuery, GetVideosQueryVariables >; +export const GetVideoDocument = gql` + query GetVideo($videoId: Int!) { + getVideo(videoId: $videoId) { + id + playlist { + segmentDurations + } + stream { + segments { + segmentIndex + endFrameIndex + framesPerSecond + } + } + } + } +`; + +/** + * __useGetVideoQuery__ + * + * To run a query within a React component, call `useGetVideoQuery` and pass it any options that fit your needs. + * When your component renders, `useGetVideoQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useGetVideoQuery({ + * variables: { + * videoId: // value for 'videoId' + * }, + * }); + */ +export function useGetVideoQuery( + baseOptions: Apollo.QueryHookOptions, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery( + GetVideoDocument, + options, + ); +} +export function useGetVideoLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + GetVideoQuery, + GetVideoQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery( + GetVideoDocument, + options, + ); +} +export function useGetVideoSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetVideoQuery, + GetVideoQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetVideoDocument, + options, + ); +} +export type GetVideoQueryHookResult = ReturnType; +export type GetVideoLazyQueryHookResult = ReturnType< + typeof useGetVideoLazyQuery +>; +export type GetVideoSuspenseQueryHookResult = ReturnType< + typeof useGetVideoSuspenseQuery +>; +export type GetVideoQueryResult = Apollo.QueryResult< + GetVideoQuery, + GetVideoQueryVariables +>; export const CreateUploadStreamDocument = gql` mutation CreateUploadStream($videoMetadataInput: VideoMetadataInput!) { createUploadStream(videoMetadata: $videoMetadataInput) { diff --git a/src/operations/shots.gql b/src/operations/shots.gql index 1fb634a..e03c13c 100644 --- a/src/operations/shots.gql +++ b/src/operations/shots.gql @@ -1,5 +1,9 @@ query GetShots( $filterInput: FilterInput! + $includeCreatedAt: Boolean! = false + $includeUpdatedAt: Boolean! = false + $includeCueObjectFeatures: Boolean! = false + $includePocketingIntentionFeatures: Boolean! = false $includeCueObjectDistance: Boolean! = false $includeCueObjectAngle: Boolean! = false $includeCueBallSpeed: Boolean! = false @@ -13,15 +17,16 @@ query GetShots( videoId startFrame endFrame - createdAt - updatedAt - cueObjectFeatures { + createdAt @include(if: $includeCreatedAt) + updatedAt @include(if: $includeUpdatedAt) + cueObjectFeatures @include(if: $includeCueObjectFeatures) { cueObjectDistance @include(if: $includeCueObjectDistance) cueObjectAngle @include(if: $includeCueObjectAngle) cueBallSpeed @include(if: $includeCueBallSpeed) shotDirection @include(if: $includeShotDirection) } - pocketingIntentionFeatures { + pocketingIntentionFeatures + @include(if: $includePocketingIntentionFeatures) { targetPocketDistance @include(if: $includeTargetPocketDistance) make @include(if: $includeMake) intendedPocketType @include(if: $includeIntendedPocketType) diff --git a/src/operations/video.gql b/src/operations/video.gql index cb640f2..e01b1c0 100644 --- a/src/operations/video.gql +++ b/src/operations/video.gql @@ -117,11 +117,34 @@ query GetVideoDetails($videoId: Int!) { query GetVideos($videoIds: [Int!]!) { getVideos(videoIds: $videoIds) { id - name - framesPerSecond playlist { - m3u8Text segmentDurations } + stream { + id + segments { + uploaded + valid + segmentIndex + endFrameIndex + framesPerSecond + } + } + } +} + +query GetVideo($videoId: Int!) { + getVideo(videoId: $videoId) { + id + playlist { + segmentDurations + } + stream { + segments { + segmentIndex + endFrameIndex + framesPerSecond + } + } } } diff --git a/src/schema.gql b/src/schema.gql index a01cc6b..8b9f97d 100644 --- a/src/schema.gql +++ b/src/schema.gql @@ -217,7 +217,6 @@ type VideoGQL { playlist: HLSPlaylistGQL tags: [VideoTag!]! homographyHistory: [HomographyInfoGQL!]! - currentProcessing: VideoProcessingGQL } type UploadStreamGQL { @@ -225,7 +224,7 @@ type UploadStreamGQL { linksRequested: Int! uploadsCompleted: Int! segmentProcessingCursor: Int! - lastIntendedSegmentBound: Int + lastIntendedSegmentBound: Int! isCompleted: Boolean! lowestUnuploadedSegmentIndex: Int! uploadCompletionCursor: Int! @@ -293,16 +292,6 @@ type IntPoint2D { y: Int! } -type VideoProcessingGQL { - errors: [VideoProcessingErrorGQL!]! -} - -type VideoProcessingErrorGQL { - message: String! - startSegmentIndex: Int - endSegmentIndex: Int -} - type PageInfoGQL { hasNextPage: Boolean! endCursor: String