The application that i m developing is mixture of both multiparty and broadcasting. There will be a single particular admin/host who's stream is subscribed by all the subscribers(Broadcasting). Both the host/publisher as well as all the subscribers will be able to see all the participants in the session(sort of multiparty). On event from the host/publisher such as button click etc, the publisher will now stop publishing his/her stream and all the subscriber will view the stream from a particular subscriber in the session that the host selects. Since my application uses android SDK and does not have moderator token. How can i succeed creating the application i desire.( (note: I have already completed Basic audio,video chat ) Can you provide me with necessary methods and sample code to pull it off.
I used the following codes:
private HashMap<String, Stream> mStringStreams = new HashMap<String, Stream>();
@Override
public void onStreamReceived(Session session, final Stream stream) {
Log.d(LOG_TAG, "onStreamReceived: New Stream Received " + stream.getStreamId() + " in session: " + session.getSessionId()+" Stream name: "+stream.getName());
if(stream.getName().equalsIgnoreCase("Main_stream"))
{
mSubscriber = new Subscriber.Builder(SuscriberActivity.this, stream).build();
mSession.subscribe(mSubscriber);
mSubscriberViewContainer.addView(mSubscriber.getView());
}
if (mSubscribers.size() + 1 > MAX_NUM_SUBSCRIBERS ) {
Toast.makeText(this, "New subscriber ignored. MAX_NUM_SUBSCRIBERS limit reached.", Toast.LENGTH_LONG).show();
return;
}
if(stream.getName().compareTo("Main_stream")!=0)
{
final Subscriber subscriber = new Subscriber.Builder(SuscriberActivity.this, stream).build();
mStringStreams.put(stream.getStreamId().toString(), stream);
mSession.subscribe(subscriber);
mSubscribers.add(subscriber);
mSubscriberStreams.put(stream,subscriber);
int position = mSubscribers.size() - 1;
final int id = getResources().getIdentifier("subscriberview" + (new Integer(position)).toString(), "id", SuscriberActivity.this.getPackageName());
FrameLayout subscriberViewContainer = (FrameLayout) findViewById(id);
subscriber.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
subscriberViewContainer.addView(subscriber.getView());
}
@Override
public void onSignalReceived(Session session, String s, String s1, Connection connection) {
stream = mSubscriberStreams.get(s1).getStream();
Stream stream= mStringStreams.get(s1);
Subscriber mSubscriber1 = new Subscriber.Builder(SuscriberActivity.this, stream).build();
mSubscriber1.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
mSubscriberViewContainer.removeView(mPublisher.getView());
mSubscriberViewContainer.addView(mSubscriber1.getView().getRootView());
}
}