Class RTMPProtocolEncoder

    • Field Detail

      • log

        protected org.slf4j.Logger log
    • Constructor Detail

      • RTMPProtocolEncoder

        public RTMPProtocolEncoder()
    • Method Detail

      • encode

        public org.apache.mina.core.buffer.IoBuffer encode​(Object message)
                                                    throws Exception
        Encodes object with given protocol state to byte buffer
        Parameters:
        message - Object to encode
        Returns:
        IoBuffer with encoded data
        Throws:
        Exception - Any decoding exception
      • encodePacket

        public org.apache.mina.core.buffer.IoBuffer encodePacket​(Packet packet)
        Encode packet.
        Parameters:
        packet - RTMP packet
        Returns:
        Encoded data
      • dropMessage

        protected boolean dropMessage​(int channelId,
                                      IRTMPEvent message)
        Determine if this message should be dropped. If the traffic from server to client is congested, then drop LIVE messages to help alleviate congestion. - determine latency between server and client using ping - ping timestamp is unsigned int (4 bytes) and is set from value on sender 1st drop disposable frames - lowest mark 2nd drop interframes - middle 3rd drop key frames - high mark
        Parameters:
        channelId - the channel ID
        message - the message
        Returns:
        true to drop; false to send
      • encodeHeader

        public org.apache.mina.core.buffer.IoBuffer encodeHeader​(Header header,
                                                                 Header lastHeader)
        Encode RTMP header.
        Parameters:
        header - RTMP message header
        lastHeader - Previous header
        Returns:
        Encoded header data
      • encodeHeader

        public void encodeHeader​(Header header,
                                 Header lastHeader,
                                 org.apache.mina.core.buffer.IoBuffer buf)
        Encode RTMP header into given IoBuffer.
        Parameters:
        header - RTMP message header
        lastHeader - Previous header
        buf - Buffer for writing encoded header into
      • encodeMessage

        public org.apache.mina.core.buffer.IoBuffer encodeMessage​(Header header,
                                                                  IRTMPEvent message)
        Encode message.
        Parameters:
        header - RTMP message header
        message - RTMP message (event)
        Returns:
        Encoded message data
      • encodeChunkSize

        public org.apache.mina.core.buffer.IoBuffer encodeChunkSize​(ChunkSize chunkSize)
        Encodes ChunkSize event to byte buffer.
        Specified by:
        encodeChunkSize in interface IEventEncoder
        Parameters:
        chunkSize - ChunkSize event
        Returns:
        Byte buffer
      • encodeFlexSharedObject

        public org.apache.mina.core.buffer.IoBuffer encodeFlexSharedObject​(ISharedObjectMessage so)
        Encodes SharedObjectMessage event to byte buffer using AMF3 encoding.
        Specified by:
        encodeFlexSharedObject in interface IEventEncoder
        Parameters:
        so - ISharedObjectMessage event
        Returns:
        Byte buffer
      • encodeSharedObject

        public org.apache.mina.core.buffer.IoBuffer encodeSharedObject​(ISharedObjectMessage so)
        Encodes SharedObjectMessage event to byte buffer.
        Specified by:
        encodeSharedObject in interface IEventEncoder
        Parameters:
        so - ISharedObjectMessage event
        Returns:
        Byte buffer
      • encodeNotify

        public org.apache.mina.core.buffer.IoBuffer encodeNotify​(Notify notify)
        Encodes Notify event to byte buffer.
        Specified by:
        encodeNotify in interface IEventEncoder
        Parameters:
        notify - Notify event
        Returns:
        Byte buffer
      • encodeInvoke

        public org.apache.mina.core.buffer.IoBuffer encodeInvoke​(Invoke invoke)
        Encodes Invoke event to byte buffer.
        Specified by:
        encodeInvoke in interface IEventEncoder
        Parameters:
        invoke - Invoke event
        Returns:
        Byte buffer
      • encodeCommand

        protected org.apache.mina.core.buffer.IoBuffer encodeCommand​(Notify invoke)
        Encode notification event.
        Parameters:
        invoke - Notification event
        Returns:
        Encoded event data
      • encodeCommand

        protected void encodeCommand​(org.apache.mina.core.buffer.IoBuffer out,
                                     ICommand command)
        Encode command event and fill given byte buffer.
        Parameters:
        out - Buffer to fill
        command - Command event
      • encodePing

        public org.apache.mina.core.buffer.IoBuffer encodePing​(Ping ping)
        Encodes Ping event to byte buffer.
        Specified by:
        encodePing in interface IEventEncoder
        Parameters:
        ping - Ping event
        Returns:
        Byte buffer
      • encodeBytesRead

        public org.apache.mina.core.buffer.IoBuffer encodeBytesRead​(BytesRead bytesRead)
        Encodes BytesRead event to byte buffer.
        Specified by:
        encodeBytesRead in interface IEventEncoder
        Parameters:
        bytesRead - BytesRead event
        Returns:
        Byte buffer
      • encodeAggregate

        public org.apache.mina.core.buffer.IoBuffer encodeAggregate​(Aggregate aggregate)
        Encodes Aggregate event to byte buffer.
        Specified by:
        encodeAggregate in interface IEventEncoder
        Parameters:
        aggregate - Aggregate event
        Returns:
        Byte buffer
      • encodeAudioData

        public org.apache.mina.core.buffer.IoBuffer encodeAudioData​(AudioData audioData)
        Encodes AudioData event to byte buffer.
        Specified by:
        encodeAudioData in interface IEventEncoder
        Parameters:
        audioData - AudioData event
        Returns:
        Byte buffer
      • encodeVideoData

        public org.apache.mina.core.buffer.IoBuffer encodeVideoData​(VideoData videoData)
        Encodes VideoData event to byte buffer.
        Specified by:
        encodeVideoData in interface IEventEncoder
        Parameters:
        videoData - VideoData event
        Returns:
        Byte buffer
      • encodeUnknown

        public org.apache.mina.core.buffer.IoBuffer encodeUnknown​(Unknown unknown)
        Encodes Unknown event to byte buffer.
        Specified by:
        encodeUnknown in interface IEventEncoder
        Parameters:
        unknown - Unknown event
        Returns:
        Byte buffer
      • encodeStreamMetadata

        public org.apache.mina.core.buffer.IoBuffer encodeStreamMetadata​(Notify metaData)
      • generateErrorResult

        protected StatusObject generateErrorResult​(String code,
                                                   Throwable error)
        Generate error object to return for given exception.
        Parameters:
        code - call
        error - error
        Returns:
        status object
      • encodeFlexMessage

        public org.apache.mina.core.buffer.IoBuffer encodeFlexMessage​(FlexMessage msg)
        Encodes Flex message event.
        Parameters:
        msg - Flex message event
        Returns:
        Encoded data
      • encodeFlexStreamSend

        public org.apache.mina.core.buffer.IoBuffer encodeFlexStreamSend​(FlexStreamSend msg)
      • setBaseTolerance

        public void setBaseTolerance​(long baseTolerance)
      • setDropLiveFuture

        public void setDropLiveFuture​(boolean dropLiveFuture)
        Setter for dropLiveFuture
        Parameters:
        dropLiveFuture - drop live data with future times
      • setDropEncoded

        public void setDropEncoded​(boolean dropEncoded)
      • getBaseTolerance

        public long getBaseTolerance()