< Summary

Information
Class: Livekit.Server.Sdk.Dotnet.EgressServiceClient
Assembly: LivekitApi
File(s): /home/runner/work/livekit-server-sdk-dotnet/livekit-server-sdk-dotnet/LivekitApi/EgressServiceClient.cs
Line coverage
100%
Covered lines: 91
Uncovered lines: 0
Coverable lines: 91
Total lines: 187
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
StartRoomCompositeEgress()100%11100%
StartWebEgress()100%11100%
StartParticipantEgress()100%11100%
StartTrackCompositeEgress()100%11100%
StartTrackEgress()100%11100%
StartEgress()100%11100%
UpdateLayout()100%11100%
UpdateStream()100%11100%
ListEgress()100%11100%
StopEgress()100%11100%

File(s)

/home/runner/work/livekit-server-sdk-dotnet/livekit-server-sdk-dotnet/LivekitApi/EgressServiceClient.cs

#LineLine coverage
 1using System.Net.Http;
 2using System.Threading.Tasks;
 3
 4namespace Livekit.Server.Sdk.Dotnet
 5{
 6    /// <summary>
 7    /// Client of the LiveKit Egress service: records or streams rooms, participants, tracks and web pages.
 8    /// See <see href="https://docs.livekit.io/transport/media/ingress-egress/egress/">Egress overview</see>.
 9    /// </summary>
 10    public class EgressServiceClient : BaseService
 11    {
 12        /// <summary>
 13        /// Creates the client.
 14        /// </summary>
 15        /// <param name="host">URL of the LiveKit server, <c>http(s)://</c> or <c>ws(s)://</c>; a subpath such as <c>htt
 16        /// <param name="apiKey">API key; the <c>LIVEKIT_API_KEY</c> environment variable when omitted.</param>
 17        /// <param name="apiSecret">API secret; the <c>LIVEKIT_API_SECRET</c> environment variable when omitted.</param>
 18        /// <param name="client">Optional <see cref="HttpClient"/> to send the requests with. The SDK never modifies it,
 19        public EgressServiceClient(
 20            string host,
 21            string apiKey = null,
 22            string apiSecret = null,
 23            HttpClient client = null
 24        )
 3625            : base(host, apiKey, apiSecret, client) { }
 26
 27        /// <summary>
 28        /// Starts a room composite egress: records or streams the whole room, rendered by a web template.
 29        /// </summary>
 30        /// <param name="request">Room name, layout, template and the file, stream, segment or image outputs.</param>
 31        /// <returns>The started egress, with its ID and status.</returns>
 32        public async Task<EgressInfo> StartRoomCompositeEgress(RoomCompositeEgressRequest request)
 333        {
 334            return await SendAsync(
 335                    Twirp.Routes.Egress.StartRoomCompositeEgress,
 336                    request,
 337                    EgressInfo.Parser,
 338                    AuthHeader(new VideoGrants { RoomRecord = true })
 339                )
 340                .ConfigureAwait(false);
 341        }
 42
 43        /// <summary>
 44        /// Starts a web egress: records or streams an arbitrary web page.
 45        /// </summary>
 46        /// <param name="request">URL to render and the outputs.</param>
 47        /// <returns>The started egress, with its ID and status.</returns>
 48        public async Task<EgressInfo> StartWebEgress(WebEgressRequest request)
 149        {
 150            return await SendAsync(
 151                    Twirp.Routes.Egress.StartWebEgress,
 152                    request,
 153                    EgressInfo.Parser,
 154                    AuthHeader(new VideoGrants { RoomRecord = true })
 155                )
 156                .ConfigureAwait(false);
 157        }
 58
 59        /// <summary>
 60        /// Starts a participant egress: records or streams the tracks of one participant.
 61        /// </summary>
 62        /// <param name="request">Room name, participant identity and the outputs.</param>
 63        /// <returns>The started egress, with its ID and status.</returns>
 64        public async Task<EgressInfo> StartParticipantEgress(ParticipantEgressRequest request)
 165        {
 166            return await SendAsync(
 167                    Twirp.Routes.Egress.StartParticipantEgress,
 168                    request,
 169                    EgressInfo.Parser,
 170                    AuthHeader(new VideoGrants { RoomRecord = true })
 171                )
 172                .ConfigureAwait(false);
 173        }
 74
 75        /// <summary>
 76        /// Starts a track composite egress: records or streams one audio and one video track mixed together.
 77        /// </summary>
 78        /// <param name="request">Room name, the audio and video track SIDs and the outputs.</param>
 79        /// <returns>The started egress, with its ID and status.</returns>
 80        public async Task<EgressInfo> StartTrackCompositeEgress(TrackCompositeEgressRequest request)
 181        {
 182            return await SendAsync(
 183                    Twirp.Routes.Egress.StartTrackCompositeEgress,
 184                    request,
 185                    EgressInfo.Parser,
 186                    AuthHeader(new VideoGrants { RoomRecord = true })
 187                )
 188                .ConfigureAwait(false);
 189        }
 90
 91        /// <summary>
 92        /// Starts a track egress: exports a single track to a file or to a WebSocket.
 93        /// </summary>
 94        /// <param name="request">Room name, track SID and the file or WebSocket output.</param>
 95        /// <returns>The started egress, with its ID and status.</returns>
 96        public async Task<EgressInfo> StartTrackEgress(TrackEgressRequest request)
 197        {
 198            return await SendAsync(
 199                    Twirp.Routes.Egress.StartTrackEgress,
 1100                    request,
 1101                    EgressInfo.Parser,
 1102                    AuthHeader(new VideoGrants { RoomRecord = true })
 1103                )
 1104                .ConfigureAwait(false);
 1105        }
 106
 107        /// <summary>
 108        /// Start any type of egress. The request's source and outputs determine the egress type.
 109        /// </summary>
 110        /// <param name="request">Which kind of egress to start, with its own options.</param>
 111        /// <returns>The started egress, with its ID and status.</returns>
 112        public async Task<EgressInfo> StartEgress(StartEgressRequest request)
 1113        {
 1114            return await SendAsync(
 1115                    Twirp.Routes.Egress.StartEgress,
 1116                    request,
 1117                    EgressInfo.Parser,
 1118                    AuthHeader(new VideoGrants { RoomRecord = true })
 1119                )
 1120                .ConfigureAwait(false);
 1121        }
 122
 123        /// <summary>
 124        /// Changes the layout of a running room composite egress.
 125        /// </summary>
 126        /// <param name="request">Egress ID and the new layout.</param>
 127        /// <returns>The updated egress.</returns>
 128        public async Task<EgressInfo> UpdateLayout(UpdateLayoutRequest request)
 1129        {
 1130            return await SendAsync(
 1131                    Twirp.Routes.Egress.UpdateLayout,
 1132                    request,
 1133                    EgressInfo.Parser,
 1134                    AuthHeader(new VideoGrants { RoomRecord = true })
 1135                )
 1136                .ConfigureAwait(false);
 1137        }
 138
 139        /// <summary>
 140        /// Adds or removes stream destinations (RTMP, SRT) of a running stream egress.
 141        /// </summary>
 142        /// <param name="request">Egress ID and the stream URLs to add or remove.</param>
 143        /// <returns>The updated egress.</returns>
 144        public async Task<EgressInfo> UpdateStream(UpdateStreamRequest request)
 1145        {
 1146            return await SendAsync(
 1147                    Twirp.Routes.Egress.UpdateStream,
 1148                    request,
 1149                    EgressInfo.Parser,
 1150                    AuthHeader(new VideoGrants { RoomRecord = true })
 1151                )
 1152                .ConfigureAwait(false);
 1153        }
 154
 155        /// <summary>
 156        /// Lists the egresses, optionally filtered by room, egress ID or active state.
 157        /// </summary>
 158        /// <param name="request">Optional filters: room name, egress ID, active egresses only.</param>
 159        /// <returns>The matching egresses.</returns>
 160        public async Task<ListEgressResponse> ListEgress(ListEgressRequest request)
 58161        {
 58162            return await SendAsync(
 58163                    Twirp.Routes.Egress.ListEgress,
 58164                    request,
 58165                    ListEgressResponse.Parser,
 58166                    AuthHeader(new VideoGrants { RoomRecord = true })
 58167                )
 58168                .ConfigureAwait(false);
 58169        }
 170
 171        /// <summary>
 172        /// Stops a running egress.
 173        /// </summary>
 174        /// <param name="request">Egress ID.</param>
 175        /// <returns>The stopped egress.</returns>
 176        public async Task<EgressInfo> StopEgress(StopEgressRequest request)
 3177        {
 3178            return await SendAsync(
 3179                    Twirp.Routes.Egress.StopEgress,
 3180                    request,
 3181                    EgressInfo.Parser,
 3182                    AuthHeader(new VideoGrants { RoomRecord = true })
 3183                )
 3184                .ConfigureAwait(false);
 3185        }
 186    }
 187}