-
Notifications
You must be signed in to change notification settings - Fork 2
FCE-2959: Fix MediaStream type #511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MiloszFilimowski
wants to merge
8
commits into
main
Choose a base branch
from
FCE-2959-fix-media-stream-type
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+168
−30
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
730ab8f
update useCamera type to RN
MiloszFilimowski 265f9ff
Merge branch 'main' into FCE-2959-fix-media-stream-type
MiloszFilimowski b6188b9
fix other types
MiloszFilimowski cfe90d3
fix fishjam-chat lint
MiloszFilimowski 6a5e2f7
fix usePeers
MiloszFilimowski 1d6384b
export initialize devices
MiloszFilimowski 3162007
fix docs generation
MiloszFilimowski 363b93e
add copilot change
MiloszFilimowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| module.exports = { | ||
| root: true, | ||
| extends: ['expo'], | ||
| ignorePatterns: [ | ||
| 'dist/*', | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { | ||
| useCamera as useCameraReactClient, | ||
| useCustomSource as useCustomSourceReactClient, | ||
| useInitializeDevices as useInitializeDevicesReactClient, | ||
| useLivestreamStreamer as useLivestreamStreamerReactClient, | ||
| useLivestreamViewer as useLivestreamViewerReactClient, | ||
| useMicrophone as useMicrophoneReactClient, | ||
| usePeers as usePeersReactClient, | ||
| useScreenShare as useScreenShareReactClient, | ||
| } from '@fishjam-cloud/react-client'; | ||
| import type { MediaStream as RNMediaStream } from '@fishjam-cloud/react-native-webrtc'; | ||
| import { useCallback } from 'react'; | ||
|
|
||
| import type { | ||
| ConnectStreamerConfig, | ||
| InitializeDevicesResult, | ||
| PeerWithTracks, | ||
| UseLivestreamStreamerResult, | ||
| UseLivestreamViewerResult, | ||
| } from './types'; | ||
|
|
||
| export const useCamera = useCameraReactClient as () => Omit<ReturnType<typeof useCameraReactClient>, 'cameraStream'> & { | ||
| cameraStream: RNMediaStream | null; | ||
| }; | ||
|
|
||
| export const useMicrophone = useMicrophoneReactClient as () => Omit< | ||
| ReturnType<typeof useMicrophoneReactClient>, | ||
| 'toggleMicrophoneMute' | 'microphoneStream' | ||
| > & { | ||
| microphoneStream: RNMediaStream | null; | ||
| }; | ||
|
|
||
| export const useScreenShare = useScreenShareReactClient as () => Omit< | ||
| ReturnType<typeof useScreenShareReactClient>, | ||
| 'stream' | ||
| > & { | ||
| stream: RNMediaStream | null; | ||
| }; | ||
|
|
||
| export const useCustomSource = useCustomSourceReactClient as <T extends string>( | ||
| sourceId: T, | ||
| ) => Omit<ReturnType<typeof useCustomSourceReactClient>, 'stream' | 'setStream'> & { | ||
| stream: RNMediaStream | undefined; | ||
| setStream: (newStream: RNMediaStream | null) => void; | ||
| }; | ||
|
|
||
| export function useLivestreamStreamer(): UseLivestreamStreamerResult { | ||
| const { connect: reactConnect, ...rest } = useLivestreamStreamerReactClient(); | ||
|
|
||
| const connect = useCallback( | ||
| async (config: ConnectStreamerConfig, urlOverride?: string) => { | ||
| // @ts-expect-error RNMediaStream is MediaStream at runtime via webrtc polyfill | ||
| await reactConnect(config, urlOverride); | ||
MiloszFilimowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
MiloszFilimowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| [reactConnect], | ||
| ); | ||
|
|
||
| return { ...rest, connect }; | ||
| } | ||
|
|
||
| export function useLivestreamViewer(): UseLivestreamViewerResult { | ||
| const { stream, ...rest } = useLivestreamViewerReactClient(); | ||
| return { | ||
| ...rest, | ||
| stream: stream as unknown as RNMediaStream | null, | ||
| }; | ||
| } | ||
|
|
||
| export const useInitializeDevices = useInitializeDevicesReactClient as () => { | ||
| initializeDevices: ( | ||
| ...args: Parameters<ReturnType<typeof useInitializeDevicesReactClient>['initializeDevices']> | ||
| ) => Promise<InitializeDevicesResult>; | ||
| }; | ||
|
|
||
| export function usePeers<P = Record<string, unknown>, S = Record<string, unknown>>() { | ||
| return usePeersReactClient<P, S>() as unknown as { | ||
| localPeer: PeerWithTracks<P, S> | null; | ||
| remotePeers: PeerWithTracks<P, S>[]; | ||
| peers: PeerWithTracks<P, S>[]; | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import type { | ||
| CustomSource as ReactClientCustomSource, | ||
| InitializeDevicesResult as ReactClientInitializeDevicesResult, | ||
| PeerWithTracks as ReactClientPeerWithTracks, | ||
| Track as ReactClientTrack, | ||
| UseLivestreamStreamerResult as ReactClientUseLivestreamStreamerResult, | ||
| UseLivestreamViewerResult as ReactClientUseLivestreamViewerResult, | ||
| } from '@fishjam-cloud/react-client'; | ||
| import type { MediaStream as RNMediaStream } from '@fishjam-cloud/react-native-webrtc'; | ||
|
|
||
| export type StreamerInputs = | ||
| | { video: RNMediaStream; audio?: RNMediaStream | null } | ||
| | { video?: null; audio: RNMediaStream }; | ||
|
|
||
| export type ConnectStreamerConfig = { | ||
| inputs: StreamerInputs; | ||
| token: string; | ||
| }; | ||
|
|
||
| export type UseLivestreamStreamerResult = Omit<ReactClientUseLivestreamStreamerResult, 'connect'> & { | ||
| connect: (config: ConnectStreamerConfig, urlOverride?: string) => Promise<void>; | ||
| }; | ||
|
|
||
| export type UseLivestreamViewerResult = Omit<ReactClientUseLivestreamViewerResult, 'stream'> & { | ||
| stream: RNMediaStream | null; | ||
| }; | ||
|
|
||
| export type Track = Omit<ReactClientTrack, 'stream'> & { stream: RNMediaStream | null }; | ||
|
|
||
| export type CustomSource<T extends string> = Omit<ReactClientCustomSource<T>, 'stream'> & { stream?: RNMediaStream }; | ||
|
|
||
| export type InitializeDevicesResult = Omit<ReactClientInitializeDevicesResult, 'stream'> & { | ||
| stream: RNMediaStream | null; | ||
| }; | ||
|
|
||
| export type TrackFields = | ||
| | 'tracks' | ||
| | 'cameraTrack' | ||
| | 'microphoneTrack' | ||
| | 'screenShareVideoTrack' | ||
| | 'screenShareAudioTrack' | ||
| | 'customVideoTracks' | ||
| | 'customAudioTracks'; | ||
|
|
||
| export type PeerWithTracks<P, S> = Omit<ReactClientPeerWithTracks<P, S>, TrackFields> & { | ||
| tracks: Track[]; | ||
| cameraTrack?: Track; | ||
| microphoneTrack?: Track; | ||
| screenShareVideoTrack?: Track; | ||
| screenShareAudioTrack?: Track; | ||
| customVideoTracks: Track[]; | ||
| customAudioTracks: Track[]; | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.