github.com/livekit/protocol@v1.39.3/egress/notify_options.go (about)

     1  // Copyright 2025 LiveKit, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package egress
    16  
    17  import (
    18  	"github.com/livekit/protocol/livekit"
    19  	"github.com/livekit/protocol/webhook"
    20  )
    21  
    22  func GetEgressNotifyOptions(egressInfo *livekit.EgressInfo) []webhook.NotifyOption {
    23  	if egressInfo == nil {
    24  		return nil
    25  	}
    26  
    27  	if egressInfo.Request == nil {
    28  		return nil
    29  	}
    30  
    31  	var whs []*livekit.WebhookConfig
    32  
    33  	switch req := egressInfo.Request.(type) {
    34  	case *livekit.EgressInfo_RoomComposite:
    35  		if req.RoomComposite != nil {
    36  			whs = req.RoomComposite.Webhooks
    37  		}
    38  	case *livekit.EgressInfo_Web:
    39  		if req.Web != nil {
    40  			whs = req.Web.Webhooks
    41  		}
    42  	case *livekit.EgressInfo_Participant:
    43  		if req.Participant != nil {
    44  			whs = req.Participant.Webhooks
    45  		}
    46  	case *livekit.EgressInfo_TrackComposite:
    47  		if req.TrackComposite != nil {
    48  			whs = req.TrackComposite.Webhooks
    49  		}
    50  	case *livekit.EgressInfo_Track:
    51  		if req.Track != nil {
    52  			whs = req.Track.Webhooks
    53  		}
    54  	}
    55  
    56  	if len(whs) > 0 {
    57  		return []webhook.NotifyOption{webhook.WithExtraWebhooks(whs)}
    58  	}
    59  
    60  	return nil
    61  }