Skip to content

Commit

Permalink
会议UI修改
Browse files Browse the repository at this point in the history
  • Loading branch information
heavyrain2012 committed Feb 17, 2021
1 parent c8e57a7 commit 0bbf990
Show file tree
Hide file tree
Showing 6 changed files with 323 additions and 1 deletion.
Binary file modified avenginekit/avenginekit.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public interface MessageContentType {
int ContentType_Call_Add_Participant = 406;
int ContentType_CALL_MUTE_VIDEO = 407;
int ContentType_Conference_Invite = 408;
int ContentType_Conference_Change_Model = 410;
int ContentType_Conference_Kickoff_Member = 411;

int MESSAGE_CONTENT_TYPE_FEED = 501;
int MESSAGE_CONTENT_TYPE_FEED_COMMENT = 502;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package cn.wildfire.chat.kit.voip.conference;

import androidx.lifecycle.ViewModelProviders;

import java.util.List;

import cn.wildfire.chat.kit.viewmodel.MessageViewModel;
import cn.wildfire.chat.kit.voip.conference.message.ConferenceChangeModelContent;
import cn.wildfire.chat.kit.voip.conference.message.ConferenceKickoffMemberContent;
import cn.wildfirechat.avenginekit.AVEngineKit;
import cn.wildfirechat.message.Message;
import cn.wildfirechat.model.Conversation;
import cn.wildfirechat.remote.ChatManager;
import cn.wildfirechat.remote.OnReceiveMessageListener;

public class ConferenceManager implements OnReceiveMessageListener {
public interface ConferenceManagerEventCallback {
void onChangeModeRequest(String conferenceId, boolean audience);
void onKickoffRequest(String conferenceId);
}

private ConferenceManagerEventCallback callback;
public static ConferenceManager managerInstance = null;

public static synchronized ConferenceManager Instance() {
if(managerInstance == null) {
managerInstance = new ConferenceManager();
}
return managerInstance;
}

private ConferenceManager() {
ChatManager.Instance().addOnReceiveMessageListener(this);
}

public void setCallback(ConferenceManagerEventCallback callback) {
this.callback = callback;
}

public void requestChangeModel(String conferenceId, String userId, boolean audience) {
ConferenceChangeModelContent content = new ConferenceChangeModelContent(conferenceId, audience);
Conversation conversation = new Conversation(Conversation.ConversationType.Single, userId);
ChatManager.Instance().sendMessage(conversation, content, null, 0, null);
}

public void requestLeave(String conferenceId, String userId) {
ConferenceKickoffMemberContent content = new ConferenceKickoffMemberContent(conferenceId);
Conversation conversation = new Conversation(Conversation.ConversationType.Single, userId);
ChatManager.Instance().sendMessage(conversation, content, null, 0, null);
}

public void changeModel(String conferenceId, boolean audience) {
if(AVEngineKit.Instance().getCurrentSession() != null
&& AVEngineKit.Instance().getCurrentSession().isConference()
&& AVEngineKit.Instance().getCurrentSession().getCallId().equals(conferenceId))
AVEngineKit.Instance().getCurrentSession().switchAudience(audience);
}

@Override
public void onReceiveMessage(List<Message> messages, boolean hasMore) {
if(AVEngineKit.Instance().getCurrentSession() != null
&& AVEngineKit.Instance().getCurrentSession().isConference()) {
for (Message msg : messages) {
if (msg.content instanceof ConferenceChangeModelContent) {
ConferenceChangeModelContent content = (ConferenceChangeModelContent) msg.content;
if (callback != null) {
callback.onChangeModeRequest(content.getCallId(), content.isAudience());
}
} else if (msg.content instanceof ConferenceKickoffMemberContent) {
ConferenceKickoffMemberContent content = (ConferenceKickoffMemberContent) msg.content;
if (callback != null) {
callback.onKickoffRequest(content.getCallId());
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import cn.wildfirechat.model.UserInfo;
import cn.wildfirechat.remote.ChatManager;

public class ConferenceVideoFragment extends Fragment implements AVEngineKit.CallSessionCallback {
public class ConferenceVideoFragment extends Fragment implements AVEngineKit.CallSessionCallback, ConferenceManager.ConferenceManagerEventCallback {
@BindView(R2.id.rootView)
RelativeLayout rootLinearLayout;
@BindView(R2.id.durationTextView)
Expand Down Expand Up @@ -121,6 +121,8 @@ private void init() {
AudioManager audioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_NORMAL);
audioManager.setSpeakerphoneOn(true);

ConferenceManager.Instance().setCallback(this);
}

private void initParticipantsView(AVEngineKit.CallSession session) {
Expand Down Expand Up @@ -465,4 +467,26 @@ private void updateCallDuration() {
}
handler.postDelayed(this::updateCallDuration, 1000);
}

@Override
public void onChangeModeRequest(String conferenceId, boolean audience) {
if(AVEngineKit.Instance().getCurrentSession() != null
&& AVEngineKit.Instance().getCurrentSession().isConference()
&& AVEngineKit.Instance().getCurrentSession().getCallId().equals(conferenceId)) {
if(audience) {
AVEngineKit.Instance().getCurrentSession().switchAudience(true);
} else {
//Todo 弹出提醒是否切换到发言模式
}
}
}

@Override
public void onKickoffRequest(String conferenceId) {
if(AVEngineKit.Instance().getCurrentSession() != null
&& AVEngineKit.Instance().getCurrentSession().isConference()
&& AVEngineKit.Instance().getCurrentSession().getCallId().equals(conferenceId)) {
AVEngineKit.Instance().getCurrentSession().leaveConference(false);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* Copyright (c) 2020 WildFireChat. All rights reserved.
*/

package cn.wildfire.chat.kit.voip.conference.message;

import android.os.Parcel;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import cn.wildfirechat.message.Message;
import cn.wildfirechat.message.MessageContent;
import cn.wildfirechat.message.core.ContentTag;
import cn.wildfirechat.message.core.MessagePayload;
import cn.wildfirechat.message.core.PersistFlag;

import static cn.wildfirechat.message.core.MessageContentType.ContentType_Call_Start;
import static cn.wildfirechat.message.core.MessageContentType.ContentType_Conference_Change_Model;

/**
* Created by heavyrain lee on 2017/12/6.
*/

@ContentTag(type = ContentType_Conference_Change_Model, flag = PersistFlag.Transparent)
public class ConferenceChangeModelContent extends MessageContent {
private String callId;
private boolean audience;


public ConferenceChangeModelContent() {
}

public ConferenceChangeModelContent(String callId, boolean audience) {
this.callId = callId;
this.audience = audience;
}

public String getCallId() {
return callId;
}

public void setCallId(String callId) {
this.callId = callId;
}

public boolean isAudience() {
return audience;
}

public void setAudience(boolean audience) {
this.audience = audience;
}

@Override
public MessagePayload encode() {
MessagePayload payload = super.encode();
payload.content = callId;

try {
JSONObject objWrite = new JSONObject();
if (audience) {
objWrite.put("a", audience);
}

payload.binaryContent = objWrite.toString().getBytes();
} catch (JSONException e) {
e.printStackTrace();
}
return payload;
}


@Override
public void decode(MessagePayload payload) {
callId = payload.content;

try {
if (payload.binaryContent != null) {
JSONObject jsonObject = new JSONObject(new String(payload.binaryContent));
audience = jsonObject.optBoolean("a", false);
}
} catch (JSONException e) {
e.printStackTrace();
}
}

@Override
public String digest(Message message) {
return "[网络电话]";
}


@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeString(this.callId);
dest.writeInt(this.audience ? 1 : 0);
}

protected ConferenceChangeModelContent(Parcel in) {
super(in);
this.callId = in.readString();
this.audience = in.readInt() == 1;
}

public static final Creator<ConferenceChangeModelContent> CREATOR = new Creator<ConferenceChangeModelContent>() {
@Override
public ConferenceChangeModelContent createFromParcel(Parcel source) {
return new ConferenceChangeModelContent(source);
}

@Override
public ConferenceChangeModelContent[] newArray(int size) {
return new ConferenceChangeModelContent[size];
}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (c) 2020 WildFireChat. All rights reserved.
*/

package cn.wildfire.chat.kit.voip.conference.message;

import android.os.Parcel;

import org.json.JSONException;
import org.json.JSONObject;

import cn.wildfirechat.message.Message;
import cn.wildfirechat.message.MessageContent;
import cn.wildfirechat.message.core.ContentTag;
import cn.wildfirechat.message.core.MessagePayload;
import cn.wildfirechat.message.core.PersistFlag;

import static cn.wildfirechat.message.core.MessageContentType.ContentType_Conference_Change_Model;
import static cn.wildfirechat.message.core.MessageContentType.ContentType_Conference_Kickoff_Member;

/**
* Created by heavyrain lee on 2017/12/6.
*/

@ContentTag(type = ContentType_Conference_Kickoff_Member, flag = PersistFlag.Transparent)
public class ConferenceKickoffMemberContent extends MessageContent {
private String callId;


public ConferenceKickoffMemberContent() {
}

public ConferenceKickoffMemberContent(String callId) {
this.callId = callId;
}

public String getCallId() {
return callId;
}

public void setCallId(String callId) {
this.callId = callId;
}

@Override
public MessagePayload encode() {
MessagePayload payload = super.encode();
payload.content = callId;
return payload;
}


@Override
public void decode(MessagePayload payload) {
callId = payload.content;
}

@Override
public String digest(Message message) {
return "[网络电话]";
}


@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeString(this.callId);
}

protected ConferenceKickoffMemberContent(Parcel in) {
super(in);
this.callId = in.readString();
}

public static final Creator<ConferenceKickoffMemberContent> CREATOR = new Creator<ConferenceKickoffMemberContent>() {
@Override
public ConferenceKickoffMemberContent createFromParcel(Parcel source) {
return new ConferenceKickoffMemberContent(source);
}

@Override
public ConferenceKickoffMemberContent[] newArray(int size) {
return new ConferenceKickoffMemberContent[size];
}
};
}

0 comments on commit 0bbf990

Please sign in to comment.