| 26 | ) |
| 27 | |
| 28 | func NewMockParticipant( |
| 29 | identity livekit.ParticipantIdentity, |
| 30 | protocol types.ProtocolVersion, |
| 31 | hidden bool, |
| 32 | publisher bool, |
| 33 | participantListener types.LocalParticipantListener, |
| 34 | ) *typesfakes.FakeLocalParticipant { |
| 35 | p := &typesfakes.FakeLocalParticipant{} |
| 36 | sid := guid.New(utils.ParticipantPrefix) |
| 37 | p.IDReturns(livekit.ParticipantID(sid)) |
| 38 | p.IdentityReturns(identity) |
| 39 | p.StateReturns(livekit.ParticipantInfo_JOINED) |
| 40 | p.ProtocolVersionReturns(protocol) |
| 41 | p.CanSubscribeReturns(true) |
| 42 | p.CanPublishSourceReturns(!hidden) |
| 43 | p.CanPublishDataReturns(!hidden) |
| 44 | p.HiddenReturns(hidden) |
| 45 | p.ToProtoReturns(&livekit.ParticipantInfo{ |
| 46 | Sid: sid, |
| 47 | Identity: string(identity), |
| 48 | State: livekit.ParticipantInfo_JOINED, |
| 49 | IsPublisher: publisher, |
| 50 | }) |
| 51 | p.ToProtoWithVersionReturns(&livekit.ParticipantInfo{ |
| 52 | Sid: sid, |
| 53 | Identity: string(identity), |
| 54 | State: livekit.ParticipantInfo_JOINED, |
| 55 | IsPublisher: publisher, |
| 56 | }, utils.TimedVersion(0)) |
| 57 | |
| 58 | p.SetMetadataCalls(func(m string) { |
| 59 | participantListener.OnParticipantUpdate(p) |
| 60 | }) |
| 61 | updateTrack := func() { |
| 62 | participantListener.OnTrackUpdated(p, NewMockTrack(livekit.TrackType_VIDEO, "testcam")) |
| 63 | } |
| 64 | |
| 65 | p.SetTrackMutedCalls(func(mute *livekit.MuteTrackRequest, fromServer bool) *livekit.TrackInfo { |
| 66 | updateTrack() |
| 67 | return nil |
| 68 | }) |
| 69 | p.AddTrackCalls(func(req *livekit.AddTrackRequest) { |
| 70 | updateTrack() |
| 71 | }) |
| 72 | p.GetLoggerReturns(logger.GetLogger()) |
| 73 | p.GetReporterReturns(roomobs.NewNoopParticipantSessionReporter()) |
| 74 | |
| 75 | return p |
| 76 | } |
| 77 | |
| 78 | func NewMockTrack(kind livekit.TrackType, name string) *typesfakes.FakeMediaTrack { |
| 79 | t := &typesfakes.FakeMediaTrack{} |