Java Code Examples for org.webrtc.EglBase#create()

The following examples show how to use org.webrtc.EglBase#create() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
Source File: CallActivity.java    From RTCStartupDemo with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_call);

    mLogcatView = findViewById(R.id.LogcatView);
    mStartCallBtn = findViewById(R.id.StartCallButton);
    mEndCallBtn = findViewById(R.id.EndCallButton);

    RTCSignalClient.getInstance().setSignalEventListener(mOnSignalEventListener);

    String serverAddr = getIntent().getStringExtra("ServerAddr");
    String roomName = getIntent().getStringExtra("RoomName");
    RTCSignalClient.getInstance().joinRoom(serverAddr, UUID.randomUUID().toString(), roomName);

    mRootEglBase = EglBase.create();

    mLocalSurfaceView = findViewById(R.id.LocalSurfaceView);
    mRemoteSurfaceView = findViewById(R.id.RemoteSurfaceView);

    mLocalSurfaceView.init(mRootEglBase.getEglBaseContext(), null);
    mLocalSurfaceView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
    mLocalSurfaceView.setMirror(true);
    mLocalSurfaceView.setEnableHardwareScaler(false /* enabled */);

    mRemoteSurfaceView.init(mRootEglBase.getEglBaseContext(), null);
    mRemoteSurfaceView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
    mRemoteSurfaceView.setMirror(true);
    mRemoteSurfaceView.setEnableHardwareScaler(true /* enabled */);
    mRemoteSurfaceView.setZOrderMediaOverlay(true);

    ProxyVideoSink videoSink = new ProxyVideoSink();
    videoSink.setTarget(mLocalSurfaceView);

    mPeerConnectionFactory = createPeerConnectionFactory(this);

    // NOTE: this _must_ happen while PeerConnectionFactory is alive!
    Logging.enableLogToDebugOutput(Logging.Severity.LS_VERBOSE);

    mVideoCapturer = createVideoCapturer();

    mSurfaceTextureHelper = SurfaceTextureHelper.create("CaptureThread", mRootEglBase.getEglBaseContext());
    VideoSource videoSource = mPeerConnectionFactory.createVideoSource(false);
    mVideoCapturer.initialize(mSurfaceTextureHelper, getApplicationContext(), videoSource.getCapturerObserver());

    mVideoTrack = mPeerConnectionFactory.createVideoTrack(VIDEO_TRACK_ID, videoSource);
    mVideoTrack.setEnabled(true);
    mVideoTrack.addSink(videoSink);

    AudioSource audioSource = mPeerConnectionFactory.createAudioSource(new MediaConstraints());
    mAudioTrack = mPeerConnectionFactory.createAudioTrack(AUDIO_TRACK_ID, audioSource);
    mAudioTrack.setEnabled(true);
}
 
Example 10
Source File: VideoConferenceActivity.java    From WebRTCapp with Apache License 2.0 4 votes vote down vote up
public void initViews() {
    localVideoView.setMirror(true);
    EglBase rootEglBase = EglBase.create();
    localVideoView.init(rootEglBase.getEglBaseContext(), null);
    localVideoView.setZOrderMediaOverlay(true);
}
 
Example 11
Source File: PeerConnectionClient.java    From sample-videoRTC with Apache License 2.0 4 votes vote down vote up
public PeerConnectionClient() {
  rootEglBase = EglBase.create();
}
 
Example 12
Source File: MainActivity.java    From janus-gateway-android with MIT License 4 votes vote down vote up
private void createLocalRender() {
    localRender = (SurfaceViewRenderer) findViewById(R.id.local_video_view);
    rootEglBase = EglBase.create();
    localRender.init(rootEglBase.getEglBaseContext(), null);
    localRender.setEnableHardwareScaler(true);
}
 
Example 13
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();
}