public bool CanHandleData(ByteBuffer data) { if (data.Limit == 0) return false;// Empty buffer byte first = data.Get(); bool result = ((first & 0x0f) == VideoCodec.AVC.Id); data.Rewind(); return result; }
public bool AddData(ByteBuffer data) { if (data.Limit == 0) return true; if (!CanHandleData(data)) return false; data.Rewind(); byte frameType = data.Get(); data.Rewind(); if ((frameType & 0xf0) != VideoCodec.FLV_FRAME_KEY) return true;// Not a keyframe //If we don't have the AVCDecoderConfigurationRecord stored... if (_blockDataAVCDCR == null) { data.Get();//FT data.Get();//CODECID byte AVCPacketType = data.Get(); //Sequence Header / here comes a AVCDecoderConfigurationRecord if (log.IsDebugEnabled) log.Debug(string.Format("AVCPacketType: {0}", AVCPacketType)); if (AVCPacketType == 0) { data.Rewind(); // Store AVCDecoderConfigurationRecord data _dataCountAVCDCR = data.Limit; if (_blockSizeAVCDCR < _dataCountAVCDCR) { _blockSizeAVCDCR = _dataCountAVCDCR; _blockDataAVCDCR = new byte[_blockSizeAVCDCR]; } data.Read(_blockDataAVCDCR, 0, _dataCountAVCDCR); } } data.Rewind(); // Store last keyframe _dataCountLKF = data.Limit; if (_blockSizeLKF < _dataCountLKF) { _blockSizeLKF = _dataCountLKF; _blockDataLKF = new byte[_blockSizeLKF]; } data.Read(_blockDataLKF, 0, _dataCountLKF); data.Rewind(); return true; }
public static ByteBuffer ReturnMessage(byte pollingDelay, ByteBuffer data, RtmptRequest request) { ByteBuffer buffer = ByteBuffer.Allocate((int)data.Length + 30); StreamWriter sw = new StreamWriter(buffer); int contentLength = data.Limit + 1; if (request.HttpVersion == 1) { sw.Write("HTTP/1.1 200 OK\r\n"); sw.Write("Cache-Control: no-cache\r\n"); } else { sw.Write("HTTP/1.0 200 OK\r\n"); sw.Write("Pragma: no-cache\r\n"); } sw.Write(string.Format("Content-Length: {0}\r\n", contentLength)); sw.Write("Connection: Keep-Alive\r\n"); sw.Write(string.Format("Content-Type: {0}\r\n", ContentType.RTMPT)); sw.Write("\r\n"); sw.Write((char)pollingDelay); sw.Flush(); BinaryWriter bw = new BinaryWriter(buffer); byte[] buf = data.ToArray(); bw.Write(buf); bw.Flush(); return buffer; }
public BufferStreamReader(ByteBuffer buffer) { _buffer = buffer; }
public Unknown(byte dataType, ByteBuffer data) : base(EventType.SYSTEM) { _dataType = dataType; _data = data; }
public Unknown(ByteBuffer data) : base(EventType.SYSTEM) { _dataType = Constants.TypeUnknown; _data = data; }
internal FlexStreamSend(ByteBuffer data) : this() { _data = data; }