private void createLocalMedia() {
    localMedia = LocalMedia.create(this);

    // Share your microphone
    localAudioTrack = localMedia.addAudioTrack(true);

    // Share your camera
    cameraCapturer = new CameraCapturer(this, CameraSource.FRONT_CAMERA);
    localVideoTrack = localMedia.addVideoTrack(true, cameraCapturer);
    primaryVideoView.setMirror(true);
    localVideoTrack.addRenderer(primaryVideoView);
    localVideoView = primaryVideoView;
  }
  @Override
  protected void onDestroy() {
    /*
     * Release local media when no longer needed
     */
    if (localMedia != null) {
      localMedia.release();
      localMedia = null;
    }

    super.onDestroy();
  }