diff --git a/clientsession.go b/clientsession.go index 2d1b476..a68d707 100644 --- a/clientsession.go +++ b/clientsession.go @@ -895,6 +895,8 @@ func (s *ClientSession) GetOrCreatePublisher(ctx context.Context, mcu Mcu, strea s.publishers[streamType] = publisher } log.Printf("Publishing %s as %s for session %s", streamType, publisher.Id(), s.PublicId()) + } else { + publisher.SetMedia(mediaTypes) } return publisher, nil diff --git a/mcu_common.go b/mcu_common.go index b1d99bc..8959b42 100644 --- a/mcu_common.go +++ b/mcu_common.go @@ -90,6 +90,7 @@ type McuPublisher interface { McuClient HasMedia(MediaType) bool + SetMedia(MediaType) } type McuSubscriber interface { diff --git a/mcu_janus.go b/mcu_janus.go index f4b6f45..3b7d345 100644 --- a/mcu_janus.go +++ b/mcu_janus.go @@ -883,6 +883,10 @@ func (p *mcuJanusPublisher) HasMedia(mt MediaType) bool { return (p.mediaTypes & mt) == mt } +func (p *mcuJanusPublisher) SetMedia(mt MediaType) { + p.mediaTypes = mt +} + func (p *mcuJanusPublisher) NotifyReconnected() { ctx := context.TODO() handle, session, roomId, err := p.mcu.getOrCreatePublisherHandle(ctx, p.id, p.streamType, p.bitrate) diff --git a/mcu_proxy.go b/mcu_proxy.go index 1d12272..38995ba 100644 --- a/mcu_proxy.go +++ b/mcu_proxy.go @@ -144,6 +144,11 @@ func (p *mcuProxyPublisher) HasMedia(mt MediaType) bool { return (p.mediaTypes & mt) == mt } +func (p *mcuProxyPublisher) SetMedia(mt MediaType) { + // TODO: Also update mediaTypes on proxy. + p.mediaTypes = mt +} + func (p *mcuProxyPublisher) NotifyClosed() { p.listener.PublisherClosed(p) p.conn.removePublisher(p) diff --git a/mcu_test.go b/mcu_test.go index 605f0a9..061ec6e 100644 --- a/mcu_test.go +++ b/mcu_test.go @@ -153,6 +153,10 @@ func (p *TestMCUPublisher) HasMedia(mt MediaType) bool { return (p.mediaTypes & mt) == mt } +func (p *TestMCUPublisher) SetMedia(mt MediaType) { + p.mediaTypes = mt +} + func (p *TestMCUPublisher) SendMessage(ctx context.Context, message *MessageClientMessage, data *MessageClientMessageData, callback func(error, map[string]interface{})) { go func() { if p.isClosed() {