public IMessage PullMessage(IPipe pipe) { lock (_syncLock) { if (_pipe != pipe) { return(null); } if (_reader == null) { Init(); } if (!_reader.HasMoreTags()) { // TODO send OOBCM to notify EOF // Do not unsubscribe as this kills VOD seek while in buffer // this.pipe.unsubscribe(this); return(null); } ITag tag = _reader.ReadTag(); IRtmpEvent msg = null; int timestamp = tag.Timestamp; switch (tag.DataType) { case Constants.TypeAudioData: msg = new AudioData(tag.Body); break; case Constants.TypeVideoData: msg = new VideoData(tag.Body); break; case Constants.TypeInvoke: msg = new Invoke(tag.Body); break; case Constants.TypeNotify: msg = new Notify(tag.Body); break; case Constants.TypeFlexStreamEnd: msg = new FlexStreamSend(tag.Body); break; default: log.Warn("Unexpected type " + tag.DataType); msg = new Unknown(tag.DataType, tag.Body); break; } msg.Timestamp = timestamp; RtmpMessage rtmpMsg = new RtmpMessage(); rtmpMsg.body = msg; return(rtmpMsg); } }
public void PushMessage(IPipe pipe, IMessage message) { if (message is ResetMessage) { _timeStamper.Reset(); } else if (message is StatusMessage) { StatusMessage statusMsg = message as StatusMessage; _data.SendStatus(statusMsg.body as StatusASO); } else if (message is RtmpMessage) { // Make sure chunk size has been sent if (!_chunkSizeSent) { SendChunkSize(); } RtmpMessage rtmpMsg = message as RtmpMessage; IRtmpEvent msg = rtmpMsg.body; int eventTime = msg.Timestamp; #if !SILVERLIGHT if (log.IsDebugEnabled) { log.Debug(string.Format("Message timestamp: {0}", eventTime)); } #endif if (eventTime < 0) { #if !SILVERLIGHT if (log.IsDebugEnabled) { log.Debug(string.Format("Message has negative timestamp: {0}", eventTime)); } #endif return; } byte dataType = msg.DataType; // Create a new header for the consumer RtmpHeader header = _timeStamper.GetTimeStamp(dataType, eventTime); switch (msg.DataType) { case Constants.TypeStreamMetadata: Notify notify = new Notify((msg as Notify).Data); notify.Header = header; notify.Timestamp = header.Timer; _data.Write(notify); break; case Constants.TypeFlexStreamEnd: // TODO: okay to send this also to AMF0 clients? FlexStreamSend send = new FlexStreamSend((msg as Notify).Data); send.Header = header; send.Timestamp = header.Timer; _data.Write(send); break; case Constants.TypeVideoData: VideoData videoData = new VideoData((msg as VideoData).Data); videoData.Header = header; videoData.Timestamp = header.Timer; _video.Write(videoData); break; case Constants.TypeAudioData: AudioData audioData = new AudioData((msg as AudioData).Data); audioData.Header = header; audioData.Timestamp = header.Timer; _audio.Write(audioData); break; case Constants.TypePing: Ping ping = new Ping((msg as Ping).PingType, (msg as Ping).Value2, (msg as Ping).Value3, (msg as Ping).Value4); ping.Header = header; _connection.Ping(ping); break; case Constants.TypeBytesRead: BytesRead bytesRead = new BytesRead((msg as BytesRead).Bytes); bytesRead.Header = header; bytesRead.Timestamp = header.Timer; _connection.GetChannel((byte)2).Write(bytesRead); break; default: _data.Write(msg); break; } } }
static ByteBuffer EncodeFlexStreamSend(RtmpContext context, FlexStreamSend msg) { ByteBuffer output = msg.Data; return(output); }
private static ByteBuffer EncodeFlexStreamSend(RtmpContext context, FlexStreamSend msg) { return(msg.Data); }
public void PushMessage(IPipe pipe, IMessage message) { if (message is ResetMessage) { this._streamTracker.Reset(); } else if (message is StatusMessage) { StatusMessage message2 = message as StatusMessage; this._data.SendStatus(message2.body as StatusASO); } else if (message is RtmpMessage) { RtmpMessage message3 = message as RtmpMessage; IRtmpEvent body = message3.body; RtmpHeader header = new RtmpHeader(); int num = this._streamTracker.Add(body); if (num < 0) { log.Warn("Skipping message with negative timestamp."); } else { header.IsTimerRelative = this._streamTracker.IsRelative; header.Timer = num; switch (body.DataType) { case 3: { BytesRead read = new BytesRead((body as BytesRead).Bytes); header.IsTimerRelative = false; header.Timer = 0; read.Header = header; read.Timestamp = header.Timer; this._connection.GetChannel(2).Write(read); return; } case 4: { Ping ping = new Ping((body as Ping).Value1, (body as Ping).Value2, (body as Ping).Value3, (body as Ping).Value4); header.IsTimerRelative = false; header.Timer = 0; ping.Header = header; ping.Timestamp = header.Timer; this._connection.Ping(ping); return; } case 8: { AudioData data2 = new AudioData((body as AudioData).Data) { Header = header, Timestamp = header.Timer }; this._audio.Write(data2); return; } case 9: { VideoData data = new VideoData((body as VideoData).Data) { Header = header, Timestamp = header.Timer }; this._video.Write(data); return; } case 15: { FlexStreamSend send = new FlexStreamSend((body as Notify).Data) { Header = header, Timestamp = header.Timer }; this._data.Write(send); return; } case 0x12: { Notify notify = new Notify((body as Notify).Data) { Header = header, Timestamp = header.Timer }; this._data.Write(notify); return; } } this._data.Write(body); } } }