|  | 
|  | 1 | +using System; | 
|  | 2 | +using System.Net; | 
|  | 3 | +using Microsoft.Extensions.Logging; | 
|  | 4 | +using SIPSorceryMedia.Abstractions; | 
|  | 5 | + | 
|  | 6 | +namespace SIPSorcery.Media | 
|  | 7 | +{ | 
|  | 8 | +    internal static partial class MediaLoggingExtensions | 
|  | 9 | +    { | 
|  | 10 | +        [LoggerMessage( | 
|  | 11 | +            EventId = 0, | 
|  | 12 | +            EventName = "SettingAudioSourceFormat", | 
|  | 13 | +            Level = LogLevel.Debug, | 
|  | 14 | +            Message = "Setting audio source format to {AudioFormatID}:{AudioFormatCodec}.")] | 
|  | 15 | +        public static partial void LogSettingAudioSourceFormat( | 
|  | 16 | +            this ILogger logger, | 
|  | 17 | +            int audioFormatID, | 
|  | 18 | +            AudioCodecsEnum audioFormatCodec); | 
|  | 19 | + | 
|  | 20 | +        [LoggerMessage( | 
|  | 21 | +            EventId = 0, | 
|  | 22 | +            EventName = "MusicFileNotSetOrFound", | 
|  | 23 | +            Level = LogLevel.Warning, | 
|  | 24 | +            Message = "Music file not set or not found, using default music resource.")] | 
|  | 25 | +        public static partial void LogMusicFileNotSetOrFound( | 
|  | 26 | +            this ILogger logger); | 
|  | 27 | + | 
|  | 28 | +        [LoggerMessage( | 
|  | 29 | +            EventId = 0, | 
|  | 30 | +            EventName = "SendingAudioSteamLength", | 
|  | 31 | +            Level = LogLevel.Debug, | 
|  | 32 | +            Message = "Sending audio stream length {AudioStreamLength}.")] | 
|  | 33 | +        public static partial void LogSendingAudioSteamLength( | 
|  | 34 | +            this ILogger logger, | 
|  | 35 | +            long audioStreamLength); | 
|  | 36 | + | 
|  | 37 | +        [LoggerMessage( | 
|  | 38 | +            EventId = 0, | 
|  | 39 | +            EventName = "RtpMediaPacketReceived", | 
|  | 40 | +            Level = LogLevel.Trace, | 
|  | 41 | +            Message = "audio RTP packet received from {RemoteEndPoint} ssrc {SyncSource} seqnum {SequenceNumber} timestamp {Timestamp} payload type {PayloadType}.")] | 
|  | 42 | +        public static partial void LogRtpMediaPacketReceived( | 
|  | 43 | +            this ILogger logger, | 
|  | 44 | +            IPEndPoint remoteEndPoint, | 
|  | 45 | +            uint syncSource, | 
|  | 46 | +            ushort sequenceNumber, | 
|  | 47 | +            uint timestamp, | 
|  | 48 | +            int payloadType); | 
|  | 49 | + | 
|  | 50 | +        [LoggerMessage( | 
|  | 51 | +            EventId = 0, | 
|  | 52 | +            EventName = "SendAudioFromStreamCompleted", | 
|  | 53 | +            Level = LogLevel.Debug, | 
|  | 54 | +            Message = "Send audio from stream completed.")] | 
|  | 55 | +        public static partial void LogSendAudioFromStreamCompleted( | 
|  | 56 | +            this ILogger logger); | 
|  | 57 | + | 
|  | 58 | +        [LoggerMessage( | 
|  | 59 | +            EventId = 0, | 
|  | 60 | +            EventName = "SettingAudioFormat", | 
|  | 61 | +            Level = LogLevel.Debug, | 
|  | 62 | +            Message = "Setting audio source format to {FormatID}:{Codec} {ClockRate} (RTP clock rate {RtpClockRate}).")] | 
|  | 63 | +        public static partial void LogSettingAudioFormat( | 
|  | 64 | +            this ILogger logger, | 
|  | 65 | +            int formatID, | 
|  | 66 | +            AudioCodecsEnum codec, | 
|  | 67 | +            int clockRate, | 
|  | 68 | +            int rtpClockRate); | 
|  | 69 | + | 
|  | 70 | +        [LoggerMessage( | 
|  | 71 | +            EventId = 0, | 
|  | 72 | +            EventName = "SettingVideoFormat", | 
|  | 73 | +            Level = LogLevel.Debug, | 
|  | 74 | +            Message = "Setting video sink and source format to {VideoFormatID}:{VideoCodec}.")] | 
|  | 75 | +        public static partial void LogSettingVideoFormat( | 
|  | 76 | +            this ILogger logger, | 
|  | 77 | +            int videoFormatID, | 
|  | 78 | +            VideoCodecsEnum videoCodec); | 
|  | 79 | + | 
|  | 80 | +        [LoggerMessage( | 
|  | 81 | +            EventId = 0, | 
|  | 82 | +            EventName = "AudioTrackDtmfNegotiated", | 
|  | 83 | +            Level = LogLevel.Debug, | 
|  | 84 | +            Message = "Audio track negotiated DTMF payload ID {AudioStreamNegotiatedRtpEventPayloadID}.")] | 
|  | 85 | +        public static partial void LogAudioTrackDtmfNegotiated( | 
|  | 86 | +            this ILogger logger, | 
|  | 87 | +            int audioStreamNegotiatedRtpEventPayloadID); | 
|  | 88 | + | 
|  | 89 | +        [LoggerMessage( | 
|  | 90 | +            EventId = 0, | 
|  | 91 | +            EventName = "VideoCaptureDeviceFailure", | 
|  | 92 | +            Level = LogLevel.Warning, | 
|  | 93 | +            Message = "Video source for capture device failure. {errorMessage}")] | 
|  | 94 | +        public static partial void LogVideoCaptureDeviceFailure( | 
|  | 95 | +            this ILogger logger, | 
|  | 96 | +            string errorMessage); | 
|  | 97 | + | 
|  | 98 | +        [LoggerMessage( | 
|  | 99 | +            EventId = 0, | 
|  | 100 | +            EventName = "WebcamVideoSourceFailed", | 
|  | 101 | +            Level = LogLevel.Warning, | 
|  | 102 | +            Message = "Webcam video source failed before start, switching to test pattern source.")] | 
|  | 103 | +        public static partial void LogWebcamFailedSwitchingToPattern( | 
|  | 104 | +            this ILogger logger); | 
|  | 105 | + | 
|  | 106 | +        [LoggerMessage( | 
|  | 107 | +            EventId = 0, | 
|  | 108 | +            EventName = "StreamClosedWarning", | 
|  | 109 | +            Level = LogLevel.Warning, | 
|  | 110 | +            Message = "Stream Closed.")] | 
|  | 111 | +        public static partial void LogStreamClosedWarning( | 
|  | 112 | +            this ILogger logger, | 
|  | 113 | +            Exception exception); | 
|  | 114 | + | 
|  | 115 | +        [LoggerMessage( | 
|  | 116 | +            EventId = 0, | 
|  | 117 | +            EventName = "AudioStreamReadError", | 
|  | 118 | +            Level = LogLevel.Warning, | 
|  | 119 | +            Message = "Failed to read from audio stream source.")] | 
|  | 120 | +        public static partial void LogAudioStreamReadError( | 
|  | 121 | +            this ILogger logger); | 
|  | 122 | + | 
|  | 123 | +        [LoggerMessage( | 
|  | 124 | +            EventId = 0, | 
|  | 125 | +            EventName = "AudioStreamNullError", | 
|  | 126 | +            Level = LogLevel.Warning, | 
|  | 127 | +            Message = "Failed to read from audio stream source, stream null or closed.")] | 
|  | 128 | +        public static partial void LogAudioStreamNullError( | 
|  | 129 | +            this ILogger logger); | 
|  | 130 | + | 
|  | 131 | +        [LoggerMessage( | 
|  | 132 | +            EventId = 0, | 
|  | 133 | +            EventName = "UnhandledStreamException", | 
|  | 134 | +            Level = LogLevel.Warning, | 
|  | 135 | +            Message = "Caught unhandled exception")] | 
|  | 136 | +        public static partial void LogUnhandledStreamException( | 
|  | 137 | +            this ILogger logger, | 
|  | 138 | +            Exception exception); | 
|  | 139 | + | 
|  | 140 | +        [LoggerMessage( | 
|  | 141 | +            EventId = 0, | 
|  | 142 | +            EventName = "StreamReaderCloseError", | 
|  | 143 | +            Level = LogLevel.Warning, | 
|  | 144 | +            Message = "Error occurred whilst trying to close the stream source reader.")] | 
|  | 145 | +        public static partial void LogStreamReaderCloseError( | 
|  | 146 | +            this ILogger logger, | 
|  | 147 | +            Exception exception); | 
|  | 148 | + | 
|  | 149 | +        [LoggerMessage( | 
|  | 150 | +            EventId = 0, | 
|  | 151 | +            EventName = "FrameRateError", | 
|  | 152 | +            Level = LogLevel.Warning, | 
|  | 153 | +            Message = "{framesPerSecond} fames per second not in the allowed range of {minimumFramesPerSecond} to {maximumFramesPerSecond}, ignoring.")] | 
|  | 154 | +        public static partial void LogFrameRateError( | 
|  | 155 | +            this ILogger logger, | 
|  | 156 | +            int framesPerSecond, | 
|  | 157 | +            int minimumFramesPerSecond, | 
|  | 158 | +            int maximumFramesPerSecond); | 
|  | 159 | + | 
|  | 160 | +        [LoggerMessage( | 
|  | 161 | +            EventId = 0, | 
|  | 162 | +            EventName = "SilenceSampleError", | 
|  | 163 | +            Level = LogLevel.Error, | 
|  | 164 | +            Message = "Exception sending silence sample")] | 
|  | 165 | +        public static partial void LogSendingSilenceSampleError( | 
|  | 166 | +            this ILogger logger, | 
|  | 167 | +            Exception exception); | 
|  | 168 | + | 
|  | 169 | +        [LoggerMessage( | 
|  | 170 | +            EventId = 0, | 
|  | 171 | +            EventName = "SignalGeneratorError", | 
|  | 172 | +            Level = LogLevel.Error, | 
|  | 173 | +            Message = "Exception sending signal generator sample")] | 
|  | 174 | +        public static partial void LogSignalGeneratorError( | 
|  | 175 | +            this ILogger logger, | 
|  | 176 | +            Exception exception); | 
|  | 177 | + | 
|  | 178 | +        [LoggerMessage( | 
|  | 179 | +            EventId = 0, | 
|  | 180 | +            EventName = "MediaEngineStartError", | 
|  | 181 | +            Level = LogLevel.Error, | 
|  | 182 | +            Message = "Error starting media engine. {ErrorMessage}")] | 
|  | 183 | +        public static partial void LogMediaEngineStartError( | 
|  | 184 | +            this ILogger logger, | 
|  | 185 | +            string errorMessage, | 
|  | 186 | +            Exception ex); | 
|  | 187 | + | 
|  | 188 | +        [LoggerMessage( | 
|  | 189 | +            EventId = 0, | 
|  | 190 | +            EventName = "MediaEngineStop", | 
|  | 191 | +            Level = LogLevel.Debug, | 
|  | 192 | +            Message = "Media engine stopped")] | 
|  | 193 | +        public static partial void LogMediaEngineStop( | 
|  | 194 | +            this ILogger logger); | 
|  | 195 | +    } | 
|  | 196 | +} | 
0 commit comments