< Summary

Information
Class: LiveKit.Rtc.FrameProcessor<T>
Assembly: LivekitRtc
File(s): /home/runner/work/livekit-server-sdk-dotnet/livekit-server-sdk-dotnet/LivekitRtc/FrameProcessor.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
Total lines: 91
Line coverage: 0%
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
OnStreamInfoUpdated(...)100%210%
OnCredentialsUpdated(...)100%210%

File(s)

/home/runner/work/livekit-server-sdk-dotnet/livekit-server-sdk-dotnet/LivekitRtc/FrameProcessor.cs

#LineLine coverage
 1// author: https://github.com/pabloFuente
 2
 3using System;
 4
 5namespace LiveKit.Rtc
 6{
 7    /// <summary>
 8    /// Information about the stream being processed.
 9    /// </summary>
 10    public class FrameProcessorStreamInfo
 11    {
 12        /// <summary>
 13        /// Gets or sets the room name.
 14        /// </summary>
 15        public string RoomName { get; set; } = string.Empty;
 16
 17        /// <summary>
 18        /// Gets or sets the participant identity.
 19        /// </summary>
 20        public string ParticipantIdentity { get; set; } = string.Empty;
 21
 22        /// <summary>
 23        /// Gets or sets the publication SID.
 24        /// </summary>
 25        public string PublicationSid { get; set; } = string.Empty;
 26    }
 27
 28    /// <summary>
 29    /// Credentials for the stream being processed.
 30    /// </summary>
 31    public class FrameProcessorCredentials
 32    {
 33        /// <summary>
 34        /// Gets or sets the access token.
 35        /// </summary>
 36        public string Token { get; set; } = string.Empty;
 37
 38        /// <summary>
 39        /// Gets or sets the LiveKit server URL.
 40        /// </summary>
 41        public string Url { get; set; } = string.Empty;
 42    }
 43
 44    /// <summary>
 45    /// Abstract base class for processing audio or video frames.
 46    /// </summary>
 47    /// <typeparam name="TFrame">The type of frame to process (AudioFrame or VideoFrame).</typeparam>
 48    public abstract class FrameProcessor<TFrame>
 49        where TFrame : class
 50    {
 51        /// <summary>
 52        /// Gets whether the frame processor is enabled.
 53        /// </summary>
 54        public abstract bool IsEnabled { get; set; }
 55
 56        /// <summary>
 57        /// Hook for the room, participant and publication of the processed stream. This version of the SDK
 58        /// never calls it.
 59        /// </summary>
 60        /// <param name="info">The updated stream information.</param>
 61        public virtual void OnStreamInfoUpdated(FrameProcessorStreamInfo info)
 062        {
 63            // Default implementation does nothing
 064        }
 65
 66        /// <summary>
 67        /// Hook for the server URL and access token of the room, for processors that call LiveKit
 68        /// services. This version of the SDK never calls it.
 69        /// </summary>
 70        /// <param name="credentials">The updated credentials.</param>
 71        public virtual void OnCredentialsUpdated(FrameProcessorCredentials credentials)
 072        {
 73            // Default implementation does nothing
 074        }
 75
 76        /// <summary>
 77        /// Process a frame and return the processed frame. An <see cref="AudioStream"/> calls it for
 78        /// each frame in order, one call at a time, on a thread pool thread, so a slow implementation
 79        /// only delays the frames of its own stream. If it throws or returns null, the stream
 80        /// delivers the original frame.
 81        /// </summary>
 82        /// <param name="frame">The frame to process.</param>
 83        /// <returns>The processed frame.</returns>
 84        public abstract TFrame Process(TFrame frame);
 85
 86        /// <summary>
 87        /// Close and clean up the frame processor.
 88        /// </summary>
 89        public abstract void Close();
 90    }
 91}