| | | 1 | | using System.Net.Http; |
| | | 2 | | using System.Threading.Tasks; |
| | | 3 | | |
| | | 4 | | namespace Livekit.Server.Sdk.Dotnet |
| | | 5 | | { |
| | | 6 | | /// <summary> |
| | | 7 | | /// Client of the LiveKit Ingress service: brings RTMP, WHIP or URL media into rooms. |
| | | 8 | | /// See <see href="https://docs.livekit.io/transport/media/ingress-egress/ingress/">Ingress overview</see>. |
| | | 9 | | /// </summary> |
| | | 10 | | public class IngressServiceClient : 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 IngressServiceClient( |
| | | 20 | | string host, |
| | | 21 | | string apiKey = null, |
| | | 22 | | string apiSecret = null, |
| | | 23 | | HttpClient client = null |
| | | 24 | | ) |
| | 24 | 25 | | : base(host, apiKey, apiSecret, client) { } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Creates a new ingress. Default audio and video options will be used if none is provided. |
| | | 29 | | /// </summary> |
| | | 30 | | /// <param name="request">Input type (RTMP, WHIP or URL), name, the room and participant to publish as, and the |
| | | 31 | | /// <returns>The created ingress, including the URL and stream key to push media to.</returns> |
| | | 32 | | public async Task<IngressInfo> CreateIngress(CreateIngressRequest request) |
| | 5 | 33 | | { |
| | 5 | 34 | | return await SendAsync( |
| | 5 | 35 | | Twirp.Routes.Ingress.CreateIngress, |
| | 5 | 36 | | request, |
| | 5 | 37 | | IngressInfo.Parser, |
| | 5 | 38 | | AuthHeader(new VideoGrants { IngressAdmin = true }) |
| | 5 | 39 | | ) |
| | 5 | 40 | | .ConfigureAwait(false); |
| | 5 | 41 | | } |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Updates the existing ingress with the given ingressID. Only inactive ingress can be updated. |
| | | 45 | | /// </summary> |
| | | 46 | | /// <param name="request">Ingress ID and the fields to change.</param> |
| | | 47 | | /// <returns>The updated ingress.</returns> |
| | | 48 | | public async Task<IngressInfo> UpdateIngress(UpdateIngressRequest request) |
| | 1 | 49 | | { |
| | 1 | 50 | | return await SendAsync( |
| | 1 | 51 | | Twirp.Routes.Ingress.UpdateIngress, |
| | 1 | 52 | | request, |
| | 1 | 53 | | IngressInfo.Parser, |
| | 1 | 54 | | AuthHeader(new VideoGrants { IngressAdmin = true }) |
| | 1 | 55 | | ) |
| | 1 | 56 | | .ConfigureAwait(false); |
| | 1 | 57 | | } |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// Lists the ingresses, optionally filtered by room or ingress ID. |
| | | 61 | | /// </summary> |
| | | 62 | | /// <param name="request">Optional filters: room name, ingress ID.</param> |
| | | 63 | | /// <returns>The matching ingresses.</returns> |
| | | 64 | | public async Task<ListIngressResponse> ListIngress(ListIngressRequest request) |
| | 14 | 65 | | { |
| | 14 | 66 | | return await SendAsync( |
| | 14 | 67 | | Twirp.Routes.Ingress.ListIngress, |
| | 14 | 68 | | request, |
| | 14 | 69 | | ListIngressResponse.Parser, |
| | 14 | 70 | | AuthHeader(new VideoGrants { IngressAdmin = true }) |
| | 14 | 71 | | ) |
| | 14 | 72 | | .ConfigureAwait(false); |
| | 14 | 73 | | } |
| | | 74 | | |
| | | 75 | | /// <summary> |
| | | 76 | | /// Deletes an ingress. |
| | | 77 | | /// </summary> |
| | | 78 | | /// <param name="request">Ingress ID.</param> |
| | | 79 | | /// <returns>The deleted ingress.</returns> |
| | | 80 | | public async Task<IngressInfo> DeleteIngress(DeleteIngressRequest request) |
| | 5 | 81 | | { |
| | 5 | 82 | | return await SendAsync( |
| | 5 | 83 | | Twirp.Routes.Ingress.DeleteIngress, |
| | 5 | 84 | | request, |
| | 5 | 85 | | IngressInfo.Parser, |
| | 5 | 86 | | AuthHeader(new VideoGrants { IngressAdmin = true }) |
| | 5 | 87 | | ) |
| | 5 | 88 | | .ConfigureAwait(false); |
| | 5 | 89 | | } |
| | | 90 | | } |
| | | 91 | | } |