org.webrtc.EglBase Java Examples

The following examples show how to use org.webrtc.EglBase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Camera.java    From mollyim-android with GNU General Public License v3.0 7 votes vote down vote up
public Camera(@NonNull Context             context,
              @NonNull CameraEventListener cameraEventListener,
              @NonNull EglBase             eglBase)
{
  this.context                = context;
  this.cameraEventListener    = cameraEventListener;
  this.eglBase                = eglBase;
  CameraEnumerator enumerator = getCameraEnumerator(context);
  cameraCount                 = enumerator.getDeviceNames().length;

  CameraVideoCapturer capturerCandidate = createVideoCapturer(enumerator, FRONT);
  if (capturerCandidate != null) {
    activeDirection = FRONT;
  } else {
    capturerCandidate = createVideoCapturer(enumerator, BACK);
    if (capturerCandidate != null) {
      activeDirection = BACK;
    } else {
      activeDirection = NONE;
    }
  }
  capturer = capturerCandidate;
}
 
Example #2
Source File: WebRtcClient.java    From imsdk-android with MIT License 7 votes vote down vote up
public void connect(EglBase.Context context, WebRtcIce ice) {
    if (ice != null&&ice.error==0) {
        for (WebRtcIce.IceServers serv : ice.serverses) {
            if(serv == null){
                continue;
            }
            boolean withAuth = !TextUtils.isEmpty(serv.username)&&
                    !TextUtils.isEmpty(serv.password);
            if(serv.uris != null && serv.uris.size() > 0){
                for (String uri:serv.uris) {
                    if(withAuth)
                    {
                        iceServers.add(new PeerConnection.IceServer(uri, serv.username, serv.password));
                    }
                    else {
                        iceServers.add(new PeerConnection.IceServer(uri));
                    }
                }
            }
        }
    }
    peer = new Peer(context);
}
 
Example #3
Source File: CustomWebSocketListener.java    From WebRTCapp with Apache License 2.0 6 votes vote down vote up
private void createVideoView(final RemoteParticipant remoteParticipant) {
    Handler mainHandler = new Handler(videoConferenceActivity.getMainLooper());

    Runnable myRunnable = new Runnable() {
        @Override
        public void run() {
            View rowView = videoConferenceActivity.getLayoutInflater().inflate(R.layout.peer_video, null);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            lp.setMargins(0, 0, 0, 20);
            rowView.setLayoutParams(lp);
            int rowId = View.generateViewId();
            rowView.setId(rowId);
            views_container.addView(rowView);
            SurfaceViewRenderer videoView = (SurfaceViewRenderer)((ViewGroup)rowView).getChildAt(0);
            remoteParticipant.setVideoView(videoView);
            videoView.setMirror(false);
            EglBase rootEglBase = EglBase.create();
            videoView.init(rootEglBase.getEglBaseContext(), null);
            videoView.setZOrderMediaOverlay(true);
            View textView = ((ViewGroup)rowView).getChildAt(1);
            remoteParticipant.setParticipantNameText((TextView) textView);
            remoteParticipant.setView(rowView);
        }
    };
    mainHandler.post(myRunnable);
}
 
Example #4
Source File: MainActivity.java    From owt-client-android with Apache License 2.0 6 votes vote down vote up
private void initP2PClient() {
    rootEglBase = EglBase.create();

    ContextInitialization.create()
            .setApplicationContext(this)
            .setVideoHardwareAccelerationOptions(
                    rootEglBase.getEglBaseContext(),
                    rootEglBase.getEglBaseContext())
            .initialize();

    VideoEncodingParameters h264 = new VideoEncodingParameters(H264);
    VideoEncodingParameters h265 = new VideoEncodingParameters(H265);
    VideoEncodingParameters vp8 = new VideoEncodingParameters(VP8);
    P2PClientConfiguration configuration = P2PClientConfiguration.builder()
            .addVideoParameters(h264)
            .addVideoParameters(vp8)
            .addVideoParameters(h265)
            .build();

    p2PClient = new P2PClient(configuration, new SocketSignalingChannel());
    p2PClient.addObserver(this);
}
 
Example #5
Source File: WebRtcClient.java    From imsdk-android with MIT License 6 votes vote down vote up
public Peer(EglBase.Context context) {
            PeerConnection.RTCConfiguration rtcConfig =
                    new PeerConnection.RTCConfiguration(iceServers);
            if(pcParams.videoCallEnabled) {
                factory.setVideoHwAccelerationOptions(context, context);
            }
//            rtcConfig.iceTransportsType = PeerConnection.IceTransportsType.ALL;
            rtcConfig.iceTransportsType = PeerConnection.IceTransportsType.RELAY;
            //禁用TCP, turn服务器ice协议使用UDP
            rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.ENABLED;
            rtcConfig.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE;
            rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.NEGOTIATE;
            rtcConfig.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY;
            // Use ECDSA encryption.
            rtcConfig.keyType = PeerConnection.KeyType.ECDSA;
            this.pc = factory.createPeerConnection(rtcConfig, pcConstraints, this);
            pc.addStream(localMS);
            if(mListener != null)
                mListener.onStatusChanged(WebRTCStatus.CONNECTING);
        }
 
Example #6
Source File: WebRtcCallService.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
private void initializeVideo() {
    Util.runOnMainSync(() -> {
        eglBase = EglBase.create();
        localRenderer = new SurfaceViewRenderer(WebRtcCallService.this);
        remoteRenderer = new SurfaceViewRenderer(WebRtcCallService.this);

        localRenderer.init(eglBase.getEglBaseContext(), null);
        remoteRenderer.init(eglBase.getEglBaseContext(), null);

        VideoEncoderFactory encoderFactory = new DefaultVideoEncoderFactory(eglBase.getEglBaseContext(), true, true);
        VideoDecoderFactory decoderFactory = new DefaultVideoDecoderFactory(eglBase.getEglBaseContext());

        peerConnectionFactory = PeerConnectionFactory.builder()
                .setOptions(new PeerConnectionFactoryOptions())
                .setVideoEncoderFactory(encoderFactory)
                .setVideoDecoderFactory(decoderFactory)
                .createPeerConnectionFactory();
    });

}
 
Example #7
Source File: Peer.java    From webrtc_android with MIT License 6 votes vote down vote up
public void createRender(EglBase mRootEglBase, Context context, boolean isOverlay) {
    renderer = new SurfaceViewRenderer(context);
    renderer.init(mRootEglBase.getEglBaseContext(), new RendererCommon.RendererEvents() {
        @Override
        public void onFirstFrameRendered() {
            Log.d(TAG, "createRender onFirstFrameRendered");

        }

        @Override
        public void onFrameResolutionChanged(int videoWidth, int videoHeight, int rotation) {
            Log.d(TAG, "createRender onFrameResolutionChanged");
        }
    });
    renderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
    renderer.setMirror(true);
    renderer.setZOrderMediaOverlay(isOverlay);
    sink = new ProxyVideoSink();
    sink.setTarget(renderer);
    if (_remoteStream != null && _remoteStream.videoTracks.size() > 0) {
        _remoteStream.videoTracks.get(0).addSink(sink);
    }

}
 
Example #8
Source File: PeerConnectionClient.java    From janus-gateway-android with MIT License 6 votes vote down vote up
private void createPeerConnectionInternal(EglBase.Context renderEGLContext, BigInteger handleId) {
  if (factory == null || isError) {
    Log.e(TAG, "Peerconnection factory is not created");
    return;
  }

  Log.d(TAG, "PCConstraints: " + pcConstraints.toString());

  Log.d(TAG, "EGLContext: " + renderEGLContext);
  factory.setVideoHwAccelerationOptions(renderEGLContext, renderEGLContext);

  PeerConnection peerConnection = createPeerConnection(handleId, true);

  mediaStream = factory.createLocalMediaStream("ARDAMS");
  mediaStream.addTrack(createVideoTrack(videoCapturer));

  mediaStream.addTrack(createAudioTrack());
  peerConnection.addStream(mediaStream);
  findVideoSender(handleId);
}
 
Example #9
Source File: MainActivity.java    From webrtc-android-tutorial with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // create PeerConnectionFactory
    PeerConnectionFactory.InitializationOptions initializationOptions =
            PeerConnectionFactory.InitializationOptions.builder(this).createInitializationOptions();
    PeerConnectionFactory.initialize(initializationOptions);
    PeerConnectionFactory peerConnectionFactory = PeerConnectionFactory.builder().createPeerConnectionFactory();

    // create AudioSource
    AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints());
    AudioTrack audioTrack = peerConnectionFactory.createAudioTrack("101", audioSource);

    EglBase.Context eglBaseContext = EglBase.create().getEglBaseContext();

    SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("CaptureThread", eglBaseContext);
    // create VideoCapturer
    VideoCapturer videoCapturer = createCameraCapturer();
    VideoSource videoSource = peerConnectionFactory.createVideoSource(videoCapturer.isScreencast());
    videoCapturer.initialize(surfaceTextureHelper, getApplicationContext(), videoSource.getCapturerObserver());
    videoCapturer.startCapture(480, 640, 30);

    SurfaceViewRenderer localView = findViewById(R.id.localView);
    localView.setMirror(true);
    localView.init(eglBaseContext, null);

    // create VideoTrack
    VideoTrack videoTrack = peerConnectionFactory.createVideoTrack("100", videoSource);
    // display in localView
    videoTrack.addSink(localView);
}
 
Example #10
Source File: PeerConnectionClient.java    From voip_android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public PeerConnectionClient(Context appContext, EglBase eglBase,
                            PeerConnectionParameters peerConnectionParameters, PeerConnectionEvents events) {
    this.rootEglBase = eglBase;
    this.appContext = appContext;
    this.events = events;
    this.peerConnectionParameters = peerConnectionParameters;

    Log.d(TAG, "Preferred video codec: " + peerConnectionParameters.videoCodec);

    final String fieldTrials = getFieldTrials(peerConnectionParameters);
    executor.execute(() -> {
        Log.d(TAG, "Initialize WebRTC. Field trials: " + fieldTrials);
        PeerConnectionFactory.initialize(
                PeerConnectionFactory.InitializationOptions.builder(appContext)
                        .setFieldTrials(fieldTrials)
                        .setEnableInternalTracer(true)
                        .createInitializationOptions());
    });
}
 
Example #11
Source File: HwAvcEncoder.java    From VideoCRE with MIT License 5 votes vote down vote up
public void start(final EglBase eglBase) {
    mMediaCodecHandler.post(new Runnable() {
        @Override
        public void run() {
            mVideoEncoder.initEncode(MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_H264,
                    MediaCodecVideoEncoder.H264Profile.CONSTRAINED_BASELINE.getValue(),
                    mVideoConfig.outputWidth(), mVideoConfig.outputHeight(),
                    mVideoConfig.outputBitrate(), mVideoConfig.fps(),
                    eglBase.getEglBaseContext(), HwAvcEncoder.this);
        }
    });
}
 
Example #12
Source File: TextureViewRenderer.java    From VideoCRE with MIT License 5 votes vote down vote up
/**
 * Initialize this class, sharing resources with |sharedContext|. The custom |drawer| will be used
 * for drawing frames on the EGLSurface. This class is responsible for calling release() on
 * |drawer|. It is allowed to call init() to reinitialize the renderer after a previous
 * init()/release() cycle.
 */
public void init(final EglBase.Context sharedContext,
    RendererCommon.RendererEvents rendererEvents, final int[] configAttributes,
    RendererCommon.GlDrawer drawer) {
  ThreadUtils.checkIsOnMainThread();
  this.rendererEvents = rendererEvents;
  synchronized (layoutLock) {
    isFirstFrameRendered = false;
    rotatedFrameWidth = 0;
    rotatedFrameHeight = 0;
    frameRotation = 0;
  }
  eglRenderer.init(sharedContext, configAttributes, drawer);
}
 
Example #13
Source File: TestActivity.java    From owt-client-android with Apache License 2.0 5 votes vote down vote up
private void initConferenceClient() {
    if (!contextHasInitialized) {
        EglBase rootEglBase = EglBase.create();
        ContextInitialization.create().setApplicationContext(this)
                .setVideoHardwareAccelerationOptions(rootEglBase.getEglBaseContext(),
                        rootEglBase.getEglBaseContext())
                .initialize();
        contextHasInitialized = true;
    }
}
 
Example #14
Source File: PeerVideoActivity.java    From nubo-test with Apache License 2.0 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();

    Bundle extras = getIntent().getExtras();
    this.username = extras.getString(Constants.USER_NAME, "");
    Log.i(TAG, "username: " + username);

    EglBase rootEglBase = EglBase.create();
    masterView.init(rootEglBase.getEglBaseContext(), null);
    masterView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
    localView.init(rootEglBase.getEglBaseContext(), null);
    localView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);

    NBMMediaConfiguration peerConnectionParameters = new NBMMediaConfiguration(
            NBMMediaConfiguration.NBMRendererType.OPENGLES,
            NBMMediaConfiguration.NBMAudioCodec.OPUS, 0,
            NBMMediaConfiguration.NBMVideoCodec.VP8, 0,
            new NBMMediaConfiguration.NBMVideoFormat(352, 288, PixelFormat.RGB_888, 20),
            NBMMediaConfiguration.NBMCameraPosition.FRONT);

    videoRequestUserMapping = new HashMap<>();

    nbmWebRTCPeer = new NBMWebRTCPeer(peerConnectionParameters, this, localView, this);
    nbmWebRTCPeer.registerMasterRenderer(masterView);
    Log.i(TAG, "Initializing nbmWebRTCPeer...");
    nbmWebRTCPeer.initialize();
    callState = CallState.PUBLISHING;
    mCallStatus.setText("Publishing...");
}
 
Example #15
Source File: TestActivity.java    From owt-client-android with Apache License 2.0 5 votes vote down vote up
private void createUI() {
    // Initialization work.
    if (!contextHasInitialized) {
        EglBase rootEglBase = EglBase.create();
        ContextInitialization.create().setApplicationContext(this)
                .setVideoHardwareAccelerationOptions(rootEglBase.getEglBaseContext(),
                        rootEglBase.getEglBaseContext())
                .initialize();
        contextHasInitialized = true;
    }
}
 
Example #16
Source File: TestActivity.java    From owt-client-android with Apache License 2.0 5 votes vote down vote up
private void initConferenceClient() {
    EglBase rootEglBase = EglBase.create();
    ContextInitialization.create().setApplicationContext(this)
            .setVideoHardwareAccelerationOptions(rootEglBase.getEglBaseContext(),
                    rootEglBase.getEglBaseContext())
            .initialize();
}
 
Example #17
Source File: MainActivity.java    From owt-client-android with Apache License 2.0 5 votes vote down vote up
private void initConferenceClient() {
    rootEglBase = EglBase.create();

    if (!contextHasInitialized) {
        ContextInitialization.create()
                .setApplicationContext(this)
                .addIgnoreNetworkType(ContextInitialization.NetworkType.LOOPBACK)
                .setVideoHardwareAccelerationOptions(
                        rootEglBase.getEglBaseContext(),
                        rootEglBase.getEglBaseContext())
                .initialize();
        contextHasInitialized = true;
    }

    PeerConnection.IceServer iceServer = PeerConnection.IceServer.builder(
            "turn:example.com?transport=tcp").setUsername("userName").setPassword(
            "passward").createIceServer();
    List<PeerConnection.IceServer> iceServers = new ArrayList<>();
    iceServers.add(iceServer);
    PeerConnection.RTCConfiguration rtcConfiguration = new PeerConnection.RTCConfiguration(
            iceServers);
    HttpUtils.setUpINSECURESSLContext();
    rtcConfiguration.continualGatheringPolicy = GATHER_CONTINUALLY;
    ConferenceClientConfiguration configuration
            = ConferenceClientConfiguration.builder()
            .setHostnameVerifier(HttpUtils.hostnameVerifier)
            .setSSLContext(HttpUtils.sslContext)
            .setRTCConfiguration(rtcConfiguration)
            .build();
    conferenceClient = new ConferenceClient(configuration);
    conferenceClient.addObserver(this);
}
 
Example #18
Source File: WebRTCWrapper.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
synchronized void close() {
    final PeerConnection peerConnection = this.peerConnection;
    final CapturerChoice capturerChoice = this.capturerChoice;
    final AppRTCAudioManager audioManager = this.appRTCAudioManager;
    final EglBase eglBase = this.eglBase;
    if (peerConnection != null) {
        dispose(peerConnection);
        this.peerConnection = null;
    }
    if (audioManager != null) {
        toneManager.setAppRtcAudioManagerHasControl(false);
        mainHandler.post(audioManager::stop);
    }
    this.localVideoTrack = null;
    this.remoteVideoTrack = null;
    if (capturerChoice != null) {
        try {
            capturerChoice.cameraVideoCapturer.stopCapture();
        } catch (InterruptedException e) {
            Log.e(Config.LOGTAG, "unable to stop capturing");
        }
    }
    if (eglBase != null) {
        eglBase.release();
        this.eglBase = null;
    }
}
 
Example #19
Source File: WebRTCWrapper.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
synchronized void close() {
    final PeerConnection peerConnection = this.peerConnection;
    final CapturerChoice capturerChoice = this.capturerChoice;
    final AppRTCAudioManager audioManager = this.appRTCAudioManager;
    final EglBase eglBase = this.eglBase;
    if (peerConnection != null) {
        dispose(peerConnection);
        this.peerConnection = null;
    }
    if (audioManager != null) {
        toneManager.setAppRtcAudioManagerHasControl(false);
        mainHandler.post(audioManager::stop);
    }
    this.localVideoTrack = null;
    this.remoteVideoTrack = null;
    if (capturerChoice != null) {
        try {
            capturerChoice.cameraVideoCapturer.stopCapture();
        } catch (InterruptedException e) {
            Log.e(Config.LOGTAG, "unable to stop capturing");
        }
    }
    if (eglBase != null) {
        eglBase.release();
        this.eglBase = null;
    }
}
 
Example #20
Source File: WebRtcCallService.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private void initializeVideo() {
  Util.runOnMainSync(() -> {

    eglBase        = EglBase.create();
    localRenderer  = new TextureViewRenderer(WebRtcCallService.this);
    remoteRenderer = new TextureViewRenderer(WebRtcCallService.this);

    localRenderer.init(eglBase.getEglBaseContext(), null);
    remoteRenderer.init(eglBase.getEglBaseContext(), null);

    camera           = new Camera(WebRtcCallService.this, WebRtcCallService.this, eglBase);
    localCameraState = camera.getCameraState();

  });
}
 
Example #21
Source File: EglContextHacker.java    From UltraGpuImage with MIT License 5 votes vote down vote up
public static EGLContext getContextFromEglBase(EglBase eglBase) {
    EglBase.Context context = eglBase.getEglBaseContext();
    try {
        Field f = context.getClass().getDeclaredField("egl14Context");
        f.setAccessible(true);
        return (EGLContext) f.get(context);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example #22
Source File: SurfaceTextureEglRenderer.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public void init(@Nullable EglBase.Context sharedContext, @Nullable RendererCommon.RendererEvents rendererEvents, @NonNull int[] configAttributes, @NonNull RendererCommon.GlDrawer drawer) {
  ThreadUtils.checkIsOnMainThread();
  this.rendererEvents = rendererEvents;
  synchronized (this.layoutLock) {
    this.isFirstFrameRendered = false;
    this.rotatedFrameWidth    = 0;
    this.rotatedFrameHeight   = 0;
    this.frameRotation        = 0;
  }

  super.init(sharedContext, configAttributes, drawer);
}
 
Example #23
Source File: VideoFileRenderer.java    From webrtc_android with MIT License 5 votes vote down vote up
public VideoFileRenderer(String outputFile, int outputFileWidth, int outputFileHeight,
                         final EglBase.Context sharedContext) throws IOException {
  if ((outputFileWidth % 2) == 1 || (outputFileHeight % 2) == 1) {
    throw new IllegalArgumentException("Does not support uneven width or height");
  }

  this.outputFileName = outputFile;
  this.outputFileWidth = outputFileWidth;
  this.outputFileHeight = outputFileHeight;

  outputFrameSize = outputFileWidth * outputFileHeight * 3 / 2;
  outputFrameBuffer = ByteBuffer.allocateDirect(outputFrameSize);

  videoOutFile = new FileOutputStream(outputFile);
  videoOutFile.write(
      ("YUV4MPEG2 C420 W" + outputFileWidth + " H" + outputFileHeight + " Ip F30:1 A1:1\n")
          .getBytes(Charset.forName("US-ASCII")));

  renderThread = new HandlerThread(TAG + "RenderThread");
  renderThread.start();
  renderThreadHandler = new Handler(renderThread.getLooper());

  fileThread = new HandlerThread(TAG + "FileThread");
  fileThread.start();
  fileThreadHandler = new Handler(fileThread.getLooper());

  ThreadUtils.invokeAtFrontUninterruptibly(renderThreadHandler, new Runnable() {
    @Override
    public void run() {
      eglBase = EglBase.create(sharedContext, EglBase.CONFIG_PIXEL_BUFFER);
      eglBase.createDummyPbufferSurface();
      eglBase.makeCurrent();
      yuvConverter = new YuvConverter();
    }
  });
}
 
Example #24
Source File: WebRTCEngine.java    From webrtc_android with MIT License 5 votes vote down vote up
@Override
public void init(EngineCallback callback) {
    mCallback = callback;

    if (mRootEglBase == null) {
        mRootEglBase = EglBase.create();
    }
    if (_factory == null) {
        _factory = createConnectionFactory();
    }
    if (_localStream == null) {
        createLocalStream();
    }
}
 
Example #25
Source File: TextureViewRenderer.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public void init(@NonNull EglBase.Context sharedContext, @NonNull RendererCommon.RendererEvents rendererEvents, @NonNull int[] configAttributes, @NonNull RendererCommon.GlDrawer drawer) {
  ThreadUtils.checkIsOnMainThread();

  this.rendererEvents     = rendererEvents;
  this.rotatedFrameWidth  = 0;
  this.rotatedFrameHeight = 0;

  this.eglRenderer.init(sharedContext, this, configAttributes, drawer);
}
 
Example #26
Source File: MainActivity.java    From webrtc-android-tutorial with Apache License 2.0 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EglBase.Context eglBaseContext = EglBase.create().getEglBaseContext();

        // create PeerConnectionFactory
        PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions
                .builder(this)
                .createInitializationOptions());
        PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
        DefaultVideoEncoderFactory defaultVideoEncoderFactory =
                new DefaultVideoEncoderFactory(eglBaseContext, true, true);
        DefaultVideoDecoderFactory defaultVideoDecoderFactory =
                new DefaultVideoDecoderFactory(eglBaseContext);
        peerConnectionFactory = PeerConnectionFactory.builder()
                .setOptions(options)
                .setVideoEncoderFactory(defaultVideoEncoderFactory)
                .setVideoDecoderFactory(defaultVideoDecoderFactory)
                .createPeerConnectionFactory();

        SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("CaptureThread", eglBaseContext);
        // create VideoCapturer
        VideoCapturer videoCapturer = createCameraCapturer(true);
        VideoSource videoSource = peerConnectionFactory.createVideoSource(videoCapturer.isScreencast());
        videoCapturer.initialize(surfaceTextureHelper, getApplicationContext(), videoSource.getCapturerObserver());
        videoCapturer.startCapture(480, 640, 30);

        localView = findViewById(R.id.localView);
        localView.setMirror(true);
        localView.init(eglBaseContext, null);

        // create VideoTrack
        VideoTrack videoTrack = peerConnectionFactory.createVideoTrack("100", videoSource);
//        // display in localView
//        videoTrack.addSink(localView);




        SurfaceTextureHelper remoteSurfaceTextureHelper = SurfaceTextureHelper.create("RemoteCaptureThread", eglBaseContext);
        // create VideoCapturer
        VideoCapturer remoteVideoCapturer = createCameraCapturer(false);
        VideoSource remoteVideoSource = peerConnectionFactory.createVideoSource(remoteVideoCapturer.isScreencast());
        remoteVideoCapturer.initialize(remoteSurfaceTextureHelper, getApplicationContext(), remoteVideoSource.getCapturerObserver());
        remoteVideoCapturer.startCapture(480, 640, 30);

        remoteView = findViewById(R.id.remoteView);
        remoteView.setMirror(false);
        remoteView.init(eglBaseContext, null);

        // create VideoTrack
        VideoTrack remoteVideoTrack = peerConnectionFactory.createVideoTrack("102", remoteVideoSource);
//        // display in remoteView
//        remoteVideoTrack.addSink(remoteView);



        mediaStreamLocal = peerConnectionFactory.createLocalMediaStream("mediaStreamLocal");
        mediaStreamLocal.addTrack(videoTrack);

        mediaStreamRemote = peerConnectionFactory.createLocalMediaStream("mediaStreamRemote");
        mediaStreamRemote.addTrack(remoteVideoTrack);

        call(mediaStreamLocal, mediaStreamRemote);
    }
 
Example #27
Source File: JingleRtpConnection.java    From Conversations with GNU General Public License v3.0 4 votes vote down vote up
public EglBase.Context getEglBaseContext() {
    return webRTCWrapper.getEglBaseContext();
}
 
Example #28
Source File: WebRTCWrapper.java    From Conversations with GNU General Public License v3.0 4 votes vote down vote up
EglBase.Context getEglBaseContext() {
    return this.eglBase.getEglBaseContext();
}
 
Example #29
Source File: PeerConnectionClient.java    From restcomm-android-sdk with GNU Affero General Public License v3.0 4 votes vote down vote up
public EglBase.Context getRenderContext() {
  return rootEglBase.getEglBaseContext();
}
 
Example #30
Source File: PeerConnectionClient.java    From restcomm-android-sdk with GNU Affero General Public License v3.0 4 votes vote down vote up
public PeerConnectionClient() {
  rootEglBase = EglBase.create();
}