/// <summary>
        /// Writes packet from event data to the RTMP connection using the specified stream id.
        /// </summary>
        /// <param name="message">Event data.</param>
        /// <param name="streamId">Stream id.</param>
        private void Write(IRtmpEvent message, int streamId)
        {
            RtmpHeader header = new RtmpHeader();
            RtmpPacket packet = new RtmpPacket(header, message);

            header.ChannelId = _channelId;
            header.Timer     = message.Timestamp;
            header.StreamId  = streamId;
            header.DataType  = message.DataType;
            if (message.Header != null)
            {
                header.IsTimerRelative = message.Header.IsTimerRelative;
            }
            _connection.Write(packet);
        }