Skip to content

Commit

Permalink
feat: enable HLS support on host end
Browse files Browse the repository at this point in the history
  • Loading branch information
khushal87 committed Oct 10, 2023
1 parent 8db1024 commit 353b3e2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export type HostLiveStreamProps = HostLiveStreamTopViewProps &
* Component to customize the bottom view controls at the host's live stream.
*/
HostLiveStreamControls?: React.ComponentType<HostLiveStreamControlsProps> | null;
/**
* Enable HTTP live streaming
*/
hls?: boolean;
};

/**
Expand All @@ -48,6 +52,7 @@ export const HostLiveStream = ({
LiveStreamMediaControls,
onEndStreamHandler,
onStartStreamHandler,
hls = false,
}: HostLiveStreamProps) => {
const {
theme: { colors, hostLiveStream },
Expand Down Expand Up @@ -80,6 +85,7 @@ export const HostLiveStream = ({
onStartStreamHandler={onStartStreamHandler}
HostStartStreamButton={HostStartStreamButton}
LiveStreamMediaControls={LiveStreamMediaControls}
hls={hls}
/>
)}
</SafeAreaView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export type HostLiveStreamControlsProps = HostStartStreamButtonProps & {
* Component to customize the host's media control(audio/video) buttons.
*/
LiveStreamMediaControls?: React.ComponentType<LiveStreamMediaControlsProps> | null;
/**
* Enable HTTP live streaming
*/
hls?: boolean;
};

/**
Expand All @@ -32,6 +36,7 @@ export const HostLiveStreamControls = ({
LiveStreamMediaControls = DefaultLiveStreamMediaControls,
onEndStreamHandler,
onStartStreamHandler,
hls = false,
}: HostLiveStreamControlsProps) => {
const {
theme: { colors, hostLiveStreamControls },
Expand All @@ -49,6 +54,7 @@ export const HostLiveStreamControls = ({
<HostStartStreamButton
onEndStreamHandler={onEndStreamHandler}
onStartStreamHandler={onStartStreamHandler}
hls={hls}
/>
)}
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export type HostStartStreamButtonProps = {
* @returns void
*/
onEndStreamHandler?: () => void;
/**
* Enable HTTP live streaming
*/
hls?: boolean;
};

/**
Expand All @@ -36,6 +40,7 @@ export type HostStartStreamButtonProps = {
export const HostStartStreamButton = ({
onEndStreamHandler,
onStartStreamHandler,
hls,
}: HostStartStreamButtonProps) => {
const [isAwaitingResponse, setIsAwaitingResponse] = useState(false);
const { useIsCallLive } = useCallStateHooks();
Expand All @@ -59,6 +64,9 @@ export const HostStartStreamButton = ({
try {
setIsAwaitingResponse(true);
await call?.goLive();
if (hls) {
await call?.startHLS();
}
setIsAwaitingResponse(false);
} catch (error) {
console.error('Error starting livestream', error);
Expand All @@ -71,7 +79,12 @@ export const HostStartStreamButton = ({
}
try {
setIsAwaitingResponse(true);
await call?.stopLive();
if (hls) {
await call?.stopHLS();
} else {
await call?.stopLive();
}

setIsAwaitingResponse(false);
} catch (error) {
console.error('Error stopping livestream', error);
Expand Down

0 comments on commit 353b3e2

Please sign in to comment.