/**
  * Implements OperationSetVideoTelephony#setLocalVideoAllowed(Call, boolean). Modifies the local
  * media setup to reflect the requested setting for the streaming of the local video and then
  * re-invites all CallPeers to re-negotiate the modified media setup.
  *
  * @param call the call where we'd like to allow sending local video.
  * @param allowed <tt>true</tt> if local video transmission is allowed and <tt>false</tt>
  *     otherwise.
  * @throws OperationFailedException if video initialization fails.
  */
 @Override
 public void setLocalVideoAllowed(Call call, boolean allowed) throws OperationFailedException {
   ((CallJabberImpl) call).setLocalVideoAllowed(allowed, MediaUseCase.DESKTOP);
   size =
       (((VideoMediaFormat) ((CallJabberImpl) call).getDefaultDevice(MediaType.VIDEO).getFormat())
           .getSize());
   ((CallJabberImpl) call).modifyVideoContent(allowed);
 }
  /**
   * Check if the remote part supports Jingle video.
   *
   * @param calleeAddress Contact address
   * @param videoDevice <tt>MediaDevice</tt> used
   * @return true if contact support Jingle video, false otherwise
   * @throws OperationFailedException with the corresponding code if we fail to create the video
   *     call.
   */
  protected Call createOutgoingVideoCall(String calleeAddress, MediaDevice videoDevice)
      throws OperationFailedException {
    if (parentProvider.getConnection() == null) {
      throw new OperationFailedException(
          "Failed to create OutgoingJingleSession.\n" + "we don't have a valid XMPPConnection.",
          OperationFailedException.INTERNAL_ERROR);
    }

    CallJabberImpl call = new CallJabberImpl(basicTelephony);
    /* enable video */
    call.setVideoDevice(videoDevice);
    call.setLocalVideoAllowed(true, getMediaUseCase());

    return basicTelephony.createOutgoingCall(call, calleeAddress);
  }
  /**
   * Notifies this instance that a specific <tt>ColibriConferenceIQ</tt> has been received.
   *
   * @param conferenceIQ the <tt>ColibriConferenceIQ</tt> which has been received
   */
  private void processColibriConferenceIQ(ColibriConferenceIQ conferenceIQ) {
    /*
     * The application is not a Jitsi Videobridge server, it is a client.
     * Consequently, the specified ColibriConferenceIQ is sent to it in
     * relation to the part of the application's functionality which makes
     * requests to a Jitsi Videobridge server i.e. CallJabberImpl.
     *
     * Additionally, the method processColibriConferenceIQ is presently tasked
     * with processing ColibriConferenceIQ requests only. They are SET IQs
     * sent by the Jitsi Videobridge server to notify the application about
     * updates in the states of (colibri) conferences organized by the
     * application.
     */
    if (IQ.Type.SET.equals(conferenceIQ.getType()) && conferenceIQ.getID() != null) {
      OperationSetBasicTelephony<?> basicTelephony =
          protocolProvider.getOperationSet(OperationSetBasicTelephony.class);

      if (basicTelephony != null) {
        Iterator<? extends Call> i = basicTelephony.getActiveCalls();

        while (i.hasNext()) {
          Call call = i.next();

          if (call instanceof CallJabberImpl) {
            CallJabberImpl callJabberImpl = (CallJabberImpl) call;
            MediaAwareCallConference conference = callJabberImpl.getConference();

            if ((conference != null) && conference.isJitsiVideobridge()) {
              /*
               * TODO We may want to disallow rogue CallJabberImpl
               * instances which may throw an exception to prevent
               * the conferenceIQ from reaching the CallJabberImpl
               * instance which it was meant for.
               */
              if (callJabberImpl.processColibriConferenceIQ(conferenceIQ)) break;
            }
          }
        }
      }
    }
  }
 /**
  * Sets the indicator which determines whether the streaming of local video in a specific
  * <tt>Call</tt> is allowed. The setting does not reflect the availability of actual video capture
  * devices, it just expresses the desire of the user to have the local video streamed in the case
  * the system is actually able to do so.
  *
  * @param call the <tt>Call</tt> to allow/disallow the streaming of local video for
  * @param mediaDevice the media device to use for the desktop streaming
  * @param allowed <tt>true</tt> to allow the streaming of local video for the specified
  *     <tt>Call</tt>; <tt>false</tt> to disallow it
  * @throws OperationFailedException if initializing local video fails.
  */
 public void setLocalVideoAllowed(Call call, MediaDevice mediaDevice, boolean allowed)
     throws OperationFailedException {
   ((CallJabberImpl) call).setVideoDevice(mediaDevice);
   size = ((VideoMediaFormat) mediaDevice.getFormat()).getSize();
   super.setLocalVideoAllowed(call, allowed);
 }