Exemple #1
0
        /// <summary>
        /// <see cref="IRtspConnection.WriteMessage(RtspMessage)"/>
        /// </summary>
        public bool WriteMessage(RtspMessage msg)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("Cannot send null message");
            }

            var message = msg.ToString();

            if (LOG.IsDebugEnabled)
            {
                LOG.Debug($"Sending RTSP message\n {message}");
            }

            try
            {
                var data = Encoding.UTF8.GetBytes(message);
                Write(data, 0, data.Length);
            }
            catch (Exception e)
            {
                LOG.Error($"Unable to send RTSP message to '{Endpoint}', reason: {e.Message}");
                return(false);
            }

            return(true);
        }