Ejemplo n.º 1
0
  /**
   * Return the video encoding (eg. H.264)
   *
   * @return Encoding
   * @throws RemoteException
   */
  public String getVideoEncoding() throws RemoteException {
    try {
      final VideoStreamingSession session = mRichcallService.getVideoSharingSession(mSharingId);
      if (session == null) {
        return mPersistentStorage.getVideoEncoding();
      }
      IVideoPlayer player = session.getPlayer();
      if (player == null) {
        throw new ServerApiGenericException(
            "Cannot get video encoding for session with sharing ID:".concat(mSharingId));
      }
      VideoCodec codec = player.getCodec();
      if (codec == null) {
        throw new ServerApiGenericException(
            "Cannot get video codec for session with sharing ID:".concat(mSharingId));
      }
      return codec.getEncoding();

    } catch (ServerApiBaseException e) {
      if (!e.shouldNotBeLogged()) {
        sLogger.error(ExceptionUtil.getFullStackTrace(e));
      }
      throw e;

    } catch (Exception e) {
      sLogger.error(ExceptionUtil.getFullStackTrace(e));
      throw new ServerApiGenericException(e);
    }
  }
Ejemplo n.º 2
0
  /**
   * Returns the video descriptor
   *
   * @return Video descriptor
   * @throws RemoteException
   * @see VideoDescriptor
   */
  public VideoDescriptor getVideoDescriptor() throws RemoteException {
    try {
      final VideoStreamingSession session = mRichcallService.getVideoSharingSession(mSharingId);
      if (session == null) {
        return mPersistentStorage.getVideoDescriptor();
      }
      IVideoPlayer player = session.getPlayer();
      if (player != null) {
        VideoCodec codec = player.getCodec();
        return new VideoDescriptor(codec.getWidth(), codec.getHeight());
      }
      VideoContent content = (VideoContent) session.getContent();
      return new VideoDescriptor(content.getWidth(), content.getHeight());

    } catch (ServerApiBaseException e) {
      if (!e.shouldNotBeLogged()) {
        sLogger.error(ExceptionUtil.getFullStackTrace(e));
      }
      throw e;

    } catch (Exception e) {
      sLogger.error(ExceptionUtil.getFullStackTrace(e));
      throw new ServerApiGenericException(e);
    }
  }
Ejemplo n.º 3
0
  /**
   * Returns the state of the sharing
   *
   * @return State
   * @throws RemoteException
   * @see State
   */
  public int getState() throws RemoteException {
    try {
      VideoStreamingSession session = mRichcallService.getVideoSharingSession(mSharingId);
      if (session == null) {
        return mPersistentStorage.getState().toInt();
      }
      SipDialogPath dialogPath = session.getDialogPath();
      if (dialogPath != null && dialogPath.isSessionEstablished()) {
        return State.STARTED.toInt();

      } else if (session.isInitiatedByRemote()) {
        if (session.isSessionAccepted()) {
          return State.ACCEPTING.toInt();
        }
        return State.INVITED.toInt();
      }
      return State.INITIATING.toInt();

    } catch (ServerApiBaseException e) {
      if (!e.shouldNotBeLogged()) {
        sLogger.error(ExceptionUtil.getFullStackTrace(e));
      }
      throw e;

    } catch (Exception e) {
      sLogger.error(ExceptionUtil.getFullStackTrace(e));
      throw new ServerApiGenericException(e);
    }
  }
Ejemplo n.º 4
0
 @Override
 public void onInvitationReceived(ContactId contact, MmContent content, long timestamp) {
   if (sLogger.isActivated()) {
     sLogger.debug("Invited to video sharing session");
   }
   synchronized (mLock) {
     mPersistentStorage.addVideoSharing(
         contact,
         Direction.INCOMING,
         (VideoContent) content,
         State.INVITED,
         ReasonCode.UNSPECIFIED,
         timestamp);
   }
   mBroadcaster.broadcastInvitation(mSharingId);
 }
Ejemplo n.º 5
0
  /**
   * Returns the duration of the video sharing
   *
   * @return Duration in milliseconds
   * @throws RemoteException
   */
  public long getDuration() throws RemoteException {
    try {
      final VideoStreamingSession session = mRichcallService.getVideoSharingSession(mSharingId);
      if (session == null) {
        return mPersistentStorage.getDuration();
      }
      return mStartTime > 0 ? System.currentTimeMillis() - mStartTime : 0;

    } catch (ServerApiBaseException e) {
      if (!e.shouldNotBeLogged()) {
        sLogger.error(ExceptionUtil.getFullStackTrace(e));
      }
      throw e;

    } catch (Exception e) {
      sLogger.error(ExceptionUtil.getFullStackTrace(e));
      throw new ServerApiGenericException(e);
    }
  }
Ejemplo n.º 6
0
  /**
   * Returns the reason code of the state of the video sharing
   *
   * @return ReasonCode
   * @throws RemoteException
   * @see ReasonCode
   */
  public int getReasonCode() throws RemoteException {
    try {
      VideoStreamingSession session = mRichcallService.getVideoSharingSession(mSharingId);
      if (session == null) {
        return mPersistentStorage.getReasonCode().toInt();
      }
      return ReasonCode.UNSPECIFIED.toInt();

    } catch (ServerApiBaseException e) {
      if (!e.shouldNotBeLogged()) {
        sLogger.error(ExceptionUtil.getFullStackTrace(e));
      }
      throw e;

    } catch (Exception e) {
      sLogger.error(ExceptionUtil.getFullStackTrace(e));
      throw new ServerApiGenericException(e);
    }
  }
Ejemplo n.º 7
0
  private void setStateAndReasonCode(ContactId contact, State state, ReasonCode reasonCode) {
    long duration = 0;

    switch (state) {
      case STARTED:
        mStartTime = System.currentTimeMillis();
        break;
      case ABORTED:
      case FAILED:
        duration = mStartTime > 0 ? System.currentTimeMillis() - mStartTime : 0;
        // $FALL-THROUGH$
      default:
        break;
    }

    if (mPersistentStorage.setStateReasonCodeAndDuration(state, reasonCode, duration)) {
      mBroadcaster.broadcastStateChanged(contact, mSharingId, state, reasonCode);
    }
  }
Ejemplo n.º 8
0
  /**
   * Returns the direction of the sharing (incoming or outgoing)
   *
   * @return Direction
   * @throws RemoteException
   * @see Direction
   */
  public int getDirection() throws RemoteException {
    try {
      VideoStreamingSession session = mRichcallService.getVideoSharingSession(mSharingId);
      if (session == null) {
        return mPersistentStorage.getDirection().toInt();
      }
      if (session.isInitiatedByRemote()) {
        return Direction.INCOMING.toInt();
      }
      return Direction.OUTGOING.toInt();

    } catch (ServerApiBaseException e) {
      if (!e.shouldNotBeLogged()) {
        sLogger.error(ExceptionUtil.getFullStackTrace(e));
      }
      throw e;

    } catch (Exception e) {
      sLogger.error(ExceptionUtil.getFullStackTrace(e));
      throw new ServerApiGenericException(e);
    }
  }