syntax = "proto3";
package rtc;
option go_package = "./rtc";

message ParticipantMetaData{
  GroupInfo groupInfo = 1;
  GroupMemberFullInfo groupMemberInfo = 2;
  PublicUserInfo userInfo = 3;
}

message GroupInfo {
  string groupID = 1;
  string groupName = 2;
  string notification = 3;
  string introduction = 4;
  string faceURL = 5;
  string ownerUserID = 6;
  int64 createTime = 7;
  uint32 memberCount = 8;
  string ex = 9;
  int32 status = 10;
  string creatorUserID = 11;
  int32 groupType = 12;
  int32 needVerification = 13;
  int32 lookMemberInfo = 14;
  int32 applyMemberFriend = 15;
  int64 notificationUpdateTime = 16;
  string notificationUserID = 17;
  bool displayIsRead = 18;
}

message GroupMemberFullInfo {
  string groupID = 1;
  string userID = 2;
  int32 roleLevel = 3;
  int64 joinTime = 4;
  string nickname = 5;
  string faceURL = 6;
  int32 appMangerLevel = 7; //if >0
  int32 joinSource = 8;
  string operatorUserID = 9;
  string ex = 10;
  int64 muteEndTime = 11;
  string inviterUserID = 12;
}

message PublicUserInfo {
  string userID = 1;
  string nickname = 2;
  string faceURL = 3;
  string ex = 4;
}

message GetJoinTokenReq{
  string room = 1;
  string identity = 2;
  ParticipantMetaData metaData = 3;
}

message GetJoinTokenResp{
  string jwt = 1;
  string liveURL = 2;
}


message SignalReq {
  oneof payload {
    SignalInviteReq invite = 1;
    SignalInviteInGroupReq inviteInGroup= 2;
    SignalCancelReq cancel = 3;
    SignalAcceptReq accept = 4;
    SignalHungUpReq hungUp = 5;
    SignalRejectReq reject = 6;
    SignalGetTokenByRoomIDReq getTokenByRoomID = 7;
  }
}

message SignalSendCustomSignalReq {
  string roomID = 1;
  string customInfo = 2;
}

message SignalSendCustomSignalResp {
}


message SignalGetMeetingsReq {
  string userID = 1;
}

message SignalGetMeetingsResp {
  repeated MeetingInfo meetingInfoList = 1;
}

message SignalOperateStreamReq {
  string streamType = 1;
  string roomID = 2;
  string userID = 3;
  bool mute = 4;
  bool muteAll = 5;
}


message SignalOperateStreamResp {
}

message SignalOnStreamChangeReq {
  string roomID = 1;
  string streamType = 2;
  bool mute = 3;
}

message  SignalCreateMeetingReq{
  int64 meetingDuration = 1;
  string roomID = 2;
  string meetingName = 3;
  string meetingHostUserID = 4;
  ParticipantMetaData participant = 5;
  repeated string inviteeUserIDList = 6;
  int64 startTime = 7;
  string ex = 8;
}

message  SignalCreateMeetingResp{
  string token = 1;
  string roomID = 2;
  string liveURL = 3;
}

message  SignalJoinMeetingReq{
  string roomID = 1;
  string userID = 2;
  ParticipantMetaData participant = 3;
}

message SignalJoinMeetingResp{
  string token = 1;
  string roomID = 2;
  string liveURL = 3;
}

message SignalResp {
  oneof payload {
    SignalInviteResp invite = 1;
    SignalInviteInGroupResp inviteInGroup= 2;
    SignalCancelResp cancel = 3;
    SignalAcceptResp accept = 4;
    SignalHungUpResp hungUp = 5;
    SignalRejectResp reject = 6;
    SignalGetTokenByRoomIDResp getTokenByRoomID = 7;
  }
}

message InvitationInfo  {
  string inviterUserID = 1;
  repeated string inviteeUserIDList = 2;
  string customData = 3;
  string  groupID = 4;
  string roomID = 5;
  int32 timeout = 6;
  string mediaType = 7;
  int32 platformID = 8;
  int32 sessionType = 9;
  int64 initiateTime = 10;
  repeated string busyLineUserIDList = 11;
}

message MeetingInfo {
  string roomID = 1;
  string meetingName = 2;
  string ex = 3;
  string hostUserID = 4;
  repeated string inviteeUserIDList = 5; //邀请列表
  int64 createTime = 6;
  int64 startTime = 7;
  int64 endTime = 8;
  bool participantCanUnmuteSelf = 9; //成员是否能自己解除禁言
  bool participantCanEnableVideo = 10; //成员是否能开启视频
  bool onlyHostInviteUser = 11; //仅主持人可邀请用户
  bool onlyHostShareScreen = 12; //仅主持人可共享屏幕
  bool joinDisableMicrophone = 13; //加入是否默认关麦克风
  bool joinDisableVideo = 14; //加入是否默认关视频
  bool isMuteAllVideo = 15; // 是否全员禁用视频
  bool isMuteAllMicrophone = 16; // 是否全员禁用麦克风
  repeated string canScreenUserIDList = 17; // 可共享屏幕的ID列表
  repeated string disableMicrophoneUserIDList = 18; // 当前被禁言麦克风的id列表
  repeated string disableVideoUserIDList = 19; // 当前禁用视频流的ID列表
  repeated string pinedUserIDList = 20; // 置顶ID列表
  repeated string beWatchedUserIDList = 21; // 正在被观看用户列表
}

message SignalInviteReq {
  InvitationInfo invitation = 1;
  OfflinePushInfo offlinePushInfo  = 2;
  ParticipantMetaData participant = 3;
  string userID = 4;
}

message SignalInviteResp {
  string token = 1;
  string roomID = 2;
  string liveURL = 3;
  repeated string busyLineUserIDList = 4;
}

message SignalInviteInGroupReq {
  InvitationInfo invitation = 1;
  OfflinePushInfo offlinePushInfo  = 2;
  ParticipantMetaData participant = 3;
  string userID = 4;
}

message SignalInviteInGroupResp {
  string token = 1;
  string roomID = 2;
  string liveURL = 3;
  repeated string busyLineUserIDList = 4;
}

message SignalCancelReq {
  InvitationInfo invitation = 1;
  OfflinePushInfo offlinePushInfo  = 2;
  ParticipantMetaData participant = 3;
  string userID = 4;
}

message SignalCancelResp {

}

message SignalAcceptReq {
  InvitationInfo invitation = 1;
  OfflinePushInfo offlinePushInfo  = 2;
  ParticipantMetaData participant = 3;
  int32 opUserPlatformID = 4;
  string userID = 5;
}

message SignalAcceptResp {
  string token = 1;
  string roomID = 2;
  string liveURL = 3;
}

message SignalHungUpReq {
  InvitationInfo invitation = 1;
  OfflinePushInfo offlinePushInfo  = 2;
  string userID = 3;
}

message SignalHungUpResp {

}


message SignalRejectReq {
  InvitationInfo invitation = 1;
  OfflinePushInfo offlinePushInfo  = 2;
  ParticipantMetaData participant = 3;
  int32 opUserPlatformID = 4;
  string userID = 5;
}

message SignalRejectResp {

}

message SignalGetRoomByGroupIDReq {
  string groupID = 1;
}

message SignalGetRoomByGroupIDResp {
  InvitationInfo invitation = 1;
  repeated ParticipantMetaData participant = 2;
  string roomID = 3;
}

message SignalOnRoomParticipantConnectedReq {
  InvitationInfo invitation = 1;
  repeated ParticipantMetaData participant = 2;
  string groupID = 3;
}

message SignalOnRoomParticipantDisconnectedReq {
  InvitationInfo invitation = 1;
  repeated ParticipantMetaData participant = 2;
  string groupID = 3;
}

message SignalGetTokenByRoomIDReq {
  string roomID = 1;
  ParticipantMetaData participant = 2;
  string userID = 3;
}

message SignalGetTokenByRoomIDResp {
  string token = 1;
  string liveURL = 2;
}

message SignalUpdateMeetingInfoReq {
  string roomID = 1;
  StringValue meetingName = 2;
  StringValue ex = 3;
  repeated string inviteeUserIDList = 4;
  Int64Value startTime = 5;
  Int64Value endTime = 6;
  BoolValue participantCanUnmuteSelf = 7;
  BoolValue participantCanEnableVideo = 8;
  BoolValue onlyHostInviteUser = 9;
  BoolValue onlyHostShareScreen = 10;
  BoolValue joinDisableMicrophone = 11;
  BoolValue joinDisableVideo = 12;
  BoolValue isMuteAllVideo = 13;
  BoolValue isMuteAllMicrophone = 14;

  repeated string addCanScreenUserIDList = 15;
  repeated string reduceCanScreenUserIDList = 16;
  repeated string canScreenUserIDList = 17;

  repeated string addDisableMicrophoneUserIDList = 18;
  repeated string reduceDisableMicrophoneUserIDList = 19;
  repeated string disableMicrophoneUserIDList = 20;

  repeated string addDisableVideoUserIDList = 21;
  repeated string reduceDisableVideoUserIDList = 22;
  repeated string disableVideoUserIDList = 23;

  repeated string addPinedUserIDList = 24;
  repeated string reducePinedUserIDList = 25;
  repeated string pinedUserIDList = 26;

  repeated string addBeWatchedUserIDList = 27;
  repeated string reduceBeWatchedUserIDList = 28;
  repeated string beWatchedUserIDList = 29;
}

message SignalUpdateMeetingInfoResp {
}

message SignalCloseRoomReq {
  string roomID = 1;
}

message SignalCloseRoomResp {
}


message SignalMessageAssembleReq {
  SignalReq signalReq = 1;
}

message SignalMessageAssembleResp {
  SignalResp signalResp = 1;
}

message SignalGetRoomsReq {
  repeated string roomIDs = 1;
}

message SignalGetRoomsResp {
  repeated SignalGetRoomByGroupIDResp roomList = 1;
}


message GetSignalInvitationInfoReq {
  string roomID = 1;
}

message GetSignalInvitationInfoResp {
  InvitationInfo invitationInfo = 1;
  OfflinePushInfo offlinePushInfo = 2;
}

message GetSignalInvitationInfoStartAppReq {
  string userID = 1;
}

message GetSignalInvitationInfoStartAppResp {
  InvitationInfo invitation = 1;
  OfflinePushInfo offlinePushInfo = 2;
}

message OfflinePushInfo {
  string title = 1;
  string desc = 2;
  string ex = 3;
  string iOSPushSound = 4;
  bool iOSBadgeCount = 5;
  string signalInfo = 6;
}

message SignalUser {
  string userID = 1;
  string nickname = 2;
  int32 status = 3;
}

message SignalRecord {
  string roomID = 1;
  string sID = 2;
  string fileName = 3;
  string mediaType = 4;
  int32 sessionType = 5;
  string inviterUserID = 6;
  string inviterUserNickname = 7;
  string groupID = 8;
  string groupName = 9;
  repeated SignalUser inviterUsers = 10;
  int64 createTime = 11;
  int64 endTime = 12;
  string size = 13;
  string fileURL = 14;
}

message MeetingUser {
  string userID = 1;
  string nickname = 2;
}

message FileRecord {
  string size = 1;
  string fileURL = 2;
}

message MeetingRecord {
  string roomID = 1;
  string meetingName = 2;
  string ex = 3;
  string hostUserID = 4;
  string hostUserNickname = 5;
  int64 createTime = 6;
  int64 startTime = 7;
  int64 endTime = 8;
  repeated MeetingUser joinedUsers = 9;
  int32 status = 10;
  repeated FileRecord fileRecords = 11;
}

message GetSignalInvitationRecordsReq {
  RequestPagination pagination = 1;
  int32 sessionType = 2;
  string sendID = 3;
  string recvID = 4;
  int64 startTime = 5;
  int64 endTime = 6;
  repeated UserInfo JoinedUsers = 7;
}

message RequestPagination {
  int32 pageNumber = 1;
  int32 showNumber = 2;
}

message UserInfo {
  string userID = 1;
  string nickname = 2;
  string faceURL = 3;
  string ex = 4;
  int64 createTime = 5;
  int32 appMangerLevel = 6;
  int32 globalRecvMsgOpt = 7;
  int32 status = 8;
}

message GetSignalInvitationRecordsResp {
  int32 total = 1;
  repeated SignalRecord signalRecords = 2;
}

message DeleteSignalRecordsReq {
  repeated string sIDs = 1;
}

message DeleteSignalRecordsResp {
}

message GetMeetingRecordsReq {
  string hostUserID = 1;
  string joinedUserID = 2;
  int64 startTime = 3;
  int64 endTime = 4;
  RequestPagination pagination = 5;
}

message GetMeetingRecordsResp {
  int32 total = 1;
  repeated MeetingRecord meetingRecords = 2;
}

message DeleteMeetingRecordsReq {
  repeated string roomIDs = 1;
}

message DeleteMeetingRecordsResp {
}

service RtcService {
  rpc SignalMessageAssemble(SignalMessageAssembleReq) returns(SignalMessageAssembleResp);
  rpc SignalGetRoomByGroupID(SignalGetRoomByGroupIDReq) returns(SignalGetRoomByGroupIDResp);
  rpc SignalGetTokenByRoomID(SignalGetTokenByRoomIDReq) returns(SignalGetTokenByRoomIDResp);
  rpc SignalGetRooms(SignalGetRoomsReq) returns(SignalGetRoomsResp);

  rpc GetSignalInvitationInfo(GetSignalInvitationInfoReq) returns(GetSignalInvitationInfoResp);
  rpc GetSignalInvitationInfoStartApp(GetSignalInvitationInfoStartAppReq) returns(GetSignalInvitationInfoStartAppResp);
  // meeting
  rpc SignalCreateMeeting(SignalCreateMeetingReq) returns(SignalCreateMeetingResp);
  rpc SignalJoinMeeting(SignalJoinMeetingReq) returns(SignalJoinMeetingResp);
  rpc SignalUpdateMeetingInfo(SignalUpdateMeetingInfoReq) returns(SignalUpdateMeetingInfoResp);
  rpc SignalCloseRoom(SignalCloseRoomReq) returns(SignalCloseRoomResp);
  rpc SignalGetMeetings(SignalGetMeetingsReq) returns(SignalGetMeetingsResp);
  rpc SignalOperateStream(SignalOperateStreamReq) returns(SignalOperateStreamResp);

  // custom signal
  rpc SignalSendCustomSignal(SignalSendCustomSignalReq) returns(SignalSendCustomSignalResp);

  // rtc cms
  rpc GetSignalInvitationRecords(GetSignalInvitationRecordsReq) returns(GetSignalInvitationRecordsResp);
  rpc DeleteSignalRecords(DeleteSignalRecordsReq) returns(DeleteSignalRecordsResp);
  rpc GetMeetingRecords(GetMeetingRecordsReq) returns(GetMeetingRecordsResp);
  rpc DeleteMeetingRecords(DeleteMeetingRecordsReq) returns(DeleteMeetingRecordsResp);
}


// Wrapper message for `double`.
//
// The JSON representation for `DoubleValue` is JSON number.
message DoubleValue {
  // The double value.
  double value = 1;
}

// Wrapper message for `float`.
//
// The JSON representation for `FloatValue` is JSON number.
message FloatValue {
  // The float value.
  float value = 1;
}

// Wrapper message for `int64`.
//
// The JSON representation for `Int64Value` is JSON string.
message Int64Value {
  // The int64 value.
  int64 value = 1;
}

// Wrapper message for `uint64`.
//
// The JSON representation for `UInt64Value` is JSON string.
message UInt64Value {
  // The uint64 value.
  uint64 value = 1;
}

// Wrapper message for `int32`.
//
// The JSON representation for `Int32Value` is JSON number.
message Int32Value {
  // The int32 value.
  int32 value = 1;
}

// Wrapper message for `uint32`.
//
// The JSON representation for `UInt32Value` is JSON number.
message UInt32Value {
  // The uint32 value.
  uint32 value = 1;
}

// Wrapper message for `bool`.
//
// The JSON representation for `BoolValue` is JSON `true` and `false`.
message BoolValue {
  // The bool value.
  bool value = 1;
}

// Wrapper message for `string`.
//
// The JSON representation for `StringValue` is JSON string.
message StringValue {
  // The string value.
  string value = 1;
}

// Wrapper message for `bytes`.
//
// The JSON representation for `BytesValue` is JSON string.
message BytesValue {
  // The bytes value.
  bytes value = 1;
}