// @flow import * as PAGES from 'constants/pages'; import * as ICONS from 'constants/icons'; import * as PUBLISH_MODES from 'constants/publish_types'; import React from 'react'; import Page from 'component/page'; import Spinner from 'component/spinner'; import Button from 'component/button'; import ChannelSelector from 'component/channelSelector'; import Yrbl from 'component/yrbl'; import { Lbry } from 'lbry-redux'; import { toHex } from 'util/hex'; import { FormField } from 'component/common/form'; import CopyableText from 'component/copyableText'; import Card from 'component/common/card'; import ClaimList from 'component/claimList'; import usePersistedState from 'effects/use-persisted-state'; type Props = { channels: Array, fetchingChannels: boolean, activeChannelClaim: ?ChannelClaim, pendingClaims: Array, }; export default function LivestreamSetupPage(props: Props) { const { channels, fetchingChannels, activeChannelClaim, pendingClaims } = props; const [sigData, setSigData] = React.useState({ signature: undefined, signing_ts: undefined }); const [showHelpTest, setShowHelpTest] = usePersistedState('livestream-help-seen', true); const hasChannels = channels && channels.length > 0; const activeChannelClaimStr = JSON.stringify(activeChannelClaim); const streamKey = createStreamKey(); const helpText = (

{__( `The Go Live process begins by first submitting your Livestream details and waiting for approval confirmation.` )}{' '} {__( `The livestream will not be visible on your channel until you are live, but you can share the URL in advance.` )}{' '} {__( `Once the your livestream is confirmed, configure your streaming software (OBS, Restream, etc) at the server URL above along with the stream key.` )}

{__(`To ensure the best streaming experience with OBS, open settings -> output`)}

{__(`Select advanced mode from the dropdown at the top.`)}

{__(`Ensure the following settings are selected under the streaming tab:`)}

  • {__(`Bitrate: 1000 to 2500 kbps`)}
  • {__(`Keyframes: 1`)}
  • {__(`Profile: High`)}
  • {__(`Tune: Zerolatency`)}

{__(`If not using OBS, make sure the bitrate is below 5Mbps or the stream will not work.`)}

{__( `You'll need to record your own stream through your software if you plan to share it afterward. You can also delete it if you prefer not to upload the copy. In the near future, we'll support a more streamlined process that will let you upload the replay.` )}

{__(`After your livestream: Click the Upload Stream button. This will allow you to edit any final details before uploading and select the saved mp4 file you recorded.`)}

{__(`Click save once you are done.`)}

); React.useEffect(() => { if (activeChannelClaimStr) { const channelClaim = JSON.parse(activeChannelClaimStr); // ensure we have a channel if (channelClaim.claim_id) { Lbry.channel_sign({ channel_id: channelClaim.claim_id, hexdata: toHex(channelClaim.name), }) .then((data) => { setSigData(data); }) .catch((error) => { setSigData({ signature: null, signing_ts: null }); }); } } }, [activeChannelClaimStr, setSigData]); function createStreamKey() { if (!activeChannelClaim || !sigData.signature || !sigData.signing_ts) return null; return `${activeChannelClaim.claim_id}?d=${toHex(activeChannelClaim.name)}&s=${sigData.signature}&t=${ sigData.signing_ts }`; } const [livestreamClaims, setLivestreamClaims] = React.useState([]); const pendingLiveStreamClaims = // $FlowFixMe pendingClaims ? pendingClaims.filter((claim) => !(claim && claim.value && claim.value.source)) : []; const pendingLength = pendingLiveStreamClaims.length; const totalLivestreamClaims = pendingLiveStreamClaims.concat(livestreamClaims); React.useEffect(() => { if (!activeChannelClaimStr) return; const channelClaim = JSON.parse(activeChannelClaimStr); Lbry.claim_search({ channel_ids: [channelClaim.claim_id], has_no_source: true, claim_type: ['stream'], }) .then((res) => { if (res && res.items && res.items.length > 0) { setLivestreamClaims(res.items.reverse()); } else { setLivestreamClaims([]); } }) .catch(() => { setLivestreamClaims([]); }); }, [activeChannelClaimStr, pendingLength, setShowHelpTest]); return ( {fetchingChannels && (
)} {!fetchingChannels && !hasChannels && (