ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.23k stars 619 forks source link

Screen share feature with react-native sdk #6505

Open pp1137 opened 2 months ago

pp1137 commented 2 months ago

How to add screen share feature with react-native webrtc sdk

Environment

React-native MacOS

"@antmedia/react-native-ant-media": "^1.0.8", "react-native-webrtc": "111.0.0" "react-native": "0.74.2",

My code :

const adaptor = useAntMedia({ url: webSocketUrl, mediaConstraints: { audio: true, video: { width: 640, height: 480, frameRate: 30, // facingMode: 'front', }, onlyDataChannel: true, }, callback(command, data) })

const startScreenShare = useCallback(async () => {

if (screenShareWebRtcAdaptor) { if (isScreenSharing) { stopScreenShare(); } else { try { const stream = await mediaDevices.getDisplayMedia({ video: true, audio: false, });

    console.log("STREAM : ", stream);
    let videoTrack = stream.getVideoTracks()[0];
    console.log("STREAM  1: ", videoTrack);
    var metaData = {
          isMicMuted: false,
          isCameraOn: true,
          isScreenShared: true,
          playOnly: false
        }
      screenShareStreamId = publishStreamId + "_presentation"
    adaptor.localStream.current = stream;  
    adaptor.play(screenShareStreamId,undefined,roomId, stream,undefined,undefined,metaData);
      console.log("STREAM  2: ", videoTrack);
    let notEvent = {
     streamId: screenShareStreamId,
     eventType: "SCREEN_SHARED_ON"
    };
    console.log("STREAM  3: ", videoTrack);

   // console.info("send notification event", notEvent);
   adaptor?.sendData(publishStreamId, JSON.stringify(notEvent));  
   setIsScreenSharing(true);  
    console.log("STREAM  21: ", videoTrack);
    // rtc_view(videoTrack, styles.localPlayer);
  } catch (error) {
    console.error('Screen share error', error);
  }
 }

} }, [adaptor])

How to share screen share stream with current conference room in react-native. We have created conference call with antmedia react-native sdk conference is working and need to add screen share feature with this so how can we do it please suggest. Can you please share suggestion or example for that also we have discussed with support team of antmedia for that.

mekya commented 1 month ago

Hi @pp1137

As far as I see, you have some issues and would like to resolve the issues. What about turning this collaboration into a more win-win way?

Currently, you have some issues and we're doing our best effort to resolve them if we have some bandwidth beyond our commitments. If we build a win-win collaboration, we'll have commitments to resolve your issues faster.

Generally, it works in two ways.

Reach out to contact@antmedia.io by mentioning this message to talk about building win-win collaboration.

Cheers Oguz