Android WebRTC - 创建1-N呼叫

时间:2017-06-30 14:30:10

标签: android webrtc

我有一个项目https://github.com/njovy/AppRTCDemo。这个项目可以进行1 -1次调用。我修改了PeerConnectionClient.class:

private static final PeerConnectionClient instance = new PeerConnectionClient();
    // private final PCObserver pcObserver = new PCObserver();
    private final PCObserver[] pcObservers = new PCObserver[MAX_CONNECTIONS];
    // private final SDPObserver sdpObserver = new SDPObserver();
    private final SDPObserver[] sdpObservers = new SDPObserver[MAX_CONNECTIONS];
    private final LooperExecutor executor;

    private static final int MAX_CONNECTIONS = 3;

    private PeerConnectionFactory factory;
    private PeerConnection[] peerConnections = new PeerConnection[MAX_CONNECTIONS];
    PeerConnectionFactory.Options options = null;
    private VideoSource videoSource;
    private boolean videoCallEnabled;
    private boolean audioCallEnabled;
    private boolean preferIsac;
    private boolean preferH264;
    private boolean videoSourceStopped;
    private boolean isError;
    private Timer statsTimer;
    private VideoRenderer.Callbacks localRender;   
    private VideoRenderer.Callbacks[] remoteRenders;
    private SignalingParameters signalingParameters;
    private MediaConstraints pcConstraints;
    private MediaConstraints videoConstraints;
    private MediaConstraints audioConstraints;
    private MediaConstraints sdpMediaConstraints;
    private PeerConnectionParameters peerConnectionParameters;
    // Queued remote ICE candidates are consumed only after both local and
    // remote descriptions are set. Similarly local ICE candidates are sent to
    // remote peer after both local and remote description are set.
    private LinkedList<IceCandidate>[] queuedRemoteCandidateLists = new LinkedList[MAX_CONNECTIONS];
    private PeerConnectionEvents events;
    private boolean[] isConnectionInitiator = new boolean[MAX_CONNECTIONS];
    private SessionDescription[] localSdps = new SessionDescription[MAX_CONNECTIONS]; // either offer or answer SDP
    private MediaStream mediaStream;
    private int numberOfCameras;
    private VideoCapturerAndroid videoCapturer;
    // enableVideo is set to true if video should be rendered and sent.
    private boolean renderVideo;
    private VideoTrack localVideoTrack;
    private VideoTrack[] remoteVideoTracks = new VideoTrack[MAX_CONNECTIONS];

在这里https://pastebin.com/c0YCHS6g。我的通话活动:https://pastebin.com/8RVwVZRq

1 个答案:

答案 0 :(得分:0)

Android WebRTC - 创建1-N来电此处N的价值是多少?

如果N > 4您需要使用媒体中继服务器(SFU / SVC)服务器,否则移动设备将会死!!! 对于N个远程参与者,WebRTC将进行N次编码(它将耗费CPU和电池N次)并将流中继到N个参与者它将消耗N倍带宽(您无法想象它在3G / 4G中)。

根据您的使用案例从Janus / Jitsi / Kurento / Licode / red5 / switchrtc / wowza等选择媒体服务器。

如果N <= 4
你需要将peerConnectionClinet重构成两部分 1. Singleton Factory:主要peerConnectionFactory&amp; MediaStream / MediaTracks
2. PC实例:从Singleton Factory创建一个peerConnection,并将相同的流添加到所有实例。该pc实例负责每个端点的提供/回答/候选交换。