@Override
 public void onStreamDropped(Session session, Stream stream) {
   Log.v(
       TAG, "Stream dropped for from session " + session.getSessionId() + ": " + stream.getName());
   if (videoInSubscriber != null) {
     getSession().unsubscribe(videoInSubscriber);
   }
 }
 @Override
 public void onStreamReceived(Session session, Stream stream) {
   Log.v(TAG, "Received stream from session " + session.getSessionId() + ": " + stream.getName());
   Log.v(TAG, "Starting to receive video from session " + session.getSessionId());
   videoInSubscriber = new Subscriber(context, stream);
   getSession().subscribe(videoInSubscriber);
   videoInViewGroup.addView(videoInSubscriber.getView());
 }
Пример #3
0
 private void unsubscribeFromStream(Stream stream) {
   mStreams.remove(stream);
   if (mSubscriber.getStream().getStreamId().equals(stream.getStreamId())) {
     mSubscriberViewContainer.removeView(mSubscriber.getView());
     mSubscriber = null;
     if (!mStreams.isEmpty()) {
       subscribeToStream(mStreams.get(0));
     }
   }
 }
  @Override
  protected void onStreamDropped(Stream stream) {
    MySubscriber p = mSubscriberStream.get(stream);
    if (p != null) {
      mSubscribers.remove(p);
      mSubscriberStream.remove(stream);
      mSubscriberConnection.remove(stream.getConnection().getConnectionId());
      mPagerAdapter.notifyDataSetChanged();

      presentText("\n" + p.getName() + " has left the chat");
    }
  }
  @Override
  protected void onStreamReceived(Stream stream) {
    MySubscriber p = new MySubscriber(mContext, stream);

    // we can use connection data to obtain each user id
    p.setUserId(stream.getConnection().getData());

    // Subscribe audio only if we have more than one player
    if (mSubscribers.size() != 0) {
      p.setSubscribeToVideo(false);
    }

    // Subscribe to this player
    this.subscribe(p);

    mSubscribers.add(p);
    mSubscriberStream.put(stream, p);
    mSubscriberConnection.put(stream.getConnection().getConnectionId(), p);
    mPagerAdapter.notifyDataSetChanged();

    presentText("\n" + p.getName() + " has joined the chat");
  }
 @Override
 public void onStreamDestroyed(PublisherKit publisherKit, Stream stream) {
   Log.v(TAG, "Stream destroyed: " + stream.getStreamId());
 }
 @Override
 public void onStreamCreated(PublisherKit publisherKit, Stream stream) {
   Log.v(TAG, "Stream created: " + stream.getStreamId());
 }