public static AmfMessage GetInvokeCloseStream(uint channelId, uint streamId) { //Variant closeStream= Variant.CreateMap(); //closeStream[0] =new Variant(); return(GenericMessageFactory.GetInvoke(channelId, streamId, 0, false, 1, Defines.RM_INVOKE_FUNCTION_CLOSESTREAM, Variant.GetList(Variant.Get()))); }
public static AmfMessage GetNotifyOnMetaData(uint channelId, uint streamId, double timeStamp, bool isAbsolute, Variant metadata) { metadata[Defines.HTTP_HEADERS_SERVER] = "C# Rtmp Server"; return(GenericMessageFactory.GetNotify(channelId, streamId, timeStamp, isAbsolute, "onMetaData", Variant.GetList(metadata))); }
public static AmfMessage GetInvokeCreateStream() { //var createStream = Variant.CreateMap(); //createStream[0] = new Variant(); return(GenericMessageFactory.GetInvoke(3, 0, 0, false, 1, Defines.RM_INVOKE_FUNCTION_CREATESTREAM, Variant.GetList(Variant.Get()))); }
public static AmfMessage GetNotifyOnStatusDataStart(uint channelId, uint streamId, double timeStamp, bool isAbsolute) { return(GenericMessageFactory.GetNotify(channelId, streamId, timeStamp, isAbsolute, "onStatus", Variant.GetList(Variant.GetMap(new VariantMapHelper { { "code", "NetStream.Data.Start" } })))); }
public static AmfMessage GetInvokeReleaseStreamErrorNotFound(AmfMessage request) { return(GenericMessageFactory.GetInvokeError(request.ChannelId, request.StreamId, request.InvokeId, Variant.Get(), Variant.GetMap(new VariantMapHelper { { Defines.RM_INVOKE_PARAMS_RESULT_LEVEL, Defines.RM_INVOKE_PARAMS_RESULT_LEVEL_ERROR }, { Defines.RM_INVOKE_PARAMS_RESULT_CODE, "NetConnection.Call.Failed" }, { Defines.RM_INVOKE_PARAMS_RESULT_DESCRIPTION, "Specified stream not found in call to releaseStream" } }))); }
public static AmfMessage GetInvokeConnectError(uint channelId, uint streamId, uint requestId, string level, string code, string decription) { return(GenericMessageFactory.GetInvokeError(channelId, streamId, requestId, Variant.Get(), Variant.GetMap(new VariantMapHelper { { Defines.RM_INVOKE_PARAMS_RESULT_LEVEL, level }, { Defines.RM_INVOKE_PARAMS_RESULT_CODE, code }, { Defines.RM_INVOKE_PARAMS_RESULT_DESCRIPTION, decription } }))); }
public static AmfMessage GetNotifyOnPlayStatusPlayComplete(uint channelId, uint streamId, double timeStamp, bool isAbsolute, double bytes, double duration) { return(GenericMessageFactory.GetNotify(channelId, streamId, timeStamp, isAbsolute, "onPlayStatus", Variant.GetList(Variant.GetMap(new VariantMapHelper { { "bytes", bytes }, { "duration", duration }, { "level", "status" }, { "code", "NetStream.Play.Complete" } })))); }
public static AmfMessage GetInvokeOnFCPublish(uint channelId, uint streamId, double timeStamp, bool isAbsolute, double requestId, string code, string description) { return(GenericMessageFactory.GetInvoke(channelId, streamId, timeStamp, isAbsolute, requestId, "onFCPublish", Variant.GetList( Variant.Get(), Variant.GetMap(new VariantMapHelper { { Defines.RM_INVOKE_PARAMS_ONSTATUS_CODE, code }, { Defines.RM_INVOKE_PARAMS_ONSTATUS_DESCRIPTION, description } }) ))); }
public static AmfMessage GetInvokeOnStatusStreamPlayFailed(uint channelId, uint streamId, double requestId, string streamName) { return(GenericMessageFactory.GetInvokeOnStatus(channelId, streamId, 0, false, requestId, Variant.GetMap(new VariantMapHelper { { Defines.RM_INVOKE_PARAMS_ONSTATUS_LEVEL, Defines.RM_INVOKE_PARAMS_RESULT_LEVEL_ERROR }, { Defines.RM_INVOKE_PARAMS_ONSTATUS_CODE, "NetStream.Play.Failed" }, { Defines.RM_INVOKE_PARAMS_ONSTATUS_DESCRIPTION, "Fail to play " + streamName }, { Defines.RM_INVOKE_PARAMS_ONSTATUS_DETAILS, streamName }, { Defines.RM_INVOKE_PARAMS_ONSTATUS_CLIENTID, "" } }))); }
public static AmfMessage GetInvokeOnStatusStreamPlayUnpublishNotify(uint channelId, uint streamId, double timeStamp, bool isAbsolute, double requestId, string description, string clientId) { return(GenericMessageFactory.GetInvokeOnStatus(channelId, streamId, timeStamp, isAbsolute, requestId, Variant.GetMap(new VariantMapHelper { { Defines.RM_INVOKE_PARAMS_ONSTATUS_LEVEL, Defines.RM_INVOKE_PARAMS_ONSTATUS_LEVEL_STATUS }, { Defines.RM_INVOKE_PARAMS_ONSTATUS_CODE, "NetStream.Play.UnpublishNotify" }, { Defines.RM_INVOKE_PARAMS_ONSTATUS_DESCRIPTION, description }, { Defines.RM_INVOKE_PARAMS_ONSTATUS_CLIENTID, clientId } }))); }
public static AmfMessage GetInvokeOnStatusStreamPlayReset(uint channelId, uint streamId, double timeStamp, bool isAbsolute, double requestId, string description, string details, string clientId) { return(GenericMessageFactory.GetInvokeOnStatus(channelId, streamId, timeStamp, isAbsolute, requestId, Variant.GetMap(new VariantMapHelper { { Defines.RM_INVOKE_PARAMS_ONSTATUS_LEVEL, Defines.RM_INVOKE_PARAMS_ONSTATUS_LEVEL_STATUS }, { Defines.RM_INVOKE_PARAMS_ONSTATUS_CODE, Defines.RM_INVOKE_PARAMS_ONSTATUS_CODE_NETSTREAMPLAYRESET }, { Defines.RM_INVOKE_PARAMS_ONSTATUS_DESCRIPTION, description }, { Defines.RM_INVOKE_PARAMS_ONSTATUS_DETAILS, details }, { Defines.RM_INVOKE_PARAMS_ONSTATUS_CLIENTID, clientId } }))); }
protected override bool FeedMetaData(MediaFile pFile, MediaFrame mediaFrame) { //1. Seek into the data file at the correct position if (!pFile.SeekTo(mediaFrame.Start)) { FATAL("Unable to seek to position {0}", mediaFrame.Start); return(false); } var endPosition = pFile.Position + (long)mediaFrame.Length; //2. Read the data //_metadataBuffer.IgnoreAll(); //if (!_metadataBuffer.ReadFromFs(pFile, (int) mediaFrame.Length)) { // Logger.FATAL("Unable to read {0} bytes from offset {1}", mediaFrame.Length, mediaFrame.Start); // return false; //} //3. Parse the metadata _metadataName = ""; _metadataParameters.SetValue(); var _tempVariant = _amf0Reader.ReadVariant(); //if (!_amfSerializer.Read(_metadataBuffer, _tempVariant)) { // Logger.WARN("Unable to read metadata"); // return true; //} if (_tempVariant != VariantType.String) { WARN("Unable to read metadata"); return(true); } _metadataName = _tempVariant; while (pFile.Position < endPosition) { _metadataParameters.Add(_amf0Reader.ReadVariant()); } var message = GenericMessageFactory.GetNotify( ((BaseOutNetRTMPStream )OutStreams.Last()).CommandsChannelId, ((BaseOutNetRTMPStream )OutStreams.Last()).RTMPStreamId, mediaFrame.AbsoluteTime, true, _metadataName, _metadataParameters); //5. Send it return(((BaseRTMPProtocol )Protocol).SendMessage(message, true)); }
public static AmfMessage GetPong() { var ts = (uint)(DateTime.Now.MilliSecondsFrom1970()); AmfMessage result; result.Header = GenericMessageFactory.VH(HeaderType.HT_FULL, 2, 0, 0, Defines.RM_HEADER_MESSAGETYPE_USRCTRL, 0, true); result.Body = Variant.GetMap(new VariantMapHelper { { Defines.RM_USRCTRL, Variant.GetMap(new VariantMapHelper { { Defines.RM_USRCTRL_TYPE, (ushort)Defines.RM_USRCTRL_TYPE_PING_RESPONSE }, { Defines.RM_USRCTRL_TYPE_STRING, RTMPProtocolSerializer.GetUserCtrlTypeString(Defines.RM_USRCTRL_TYPE_PING_RESPONSE) }, { Defines.RM_USRCTRL_PONG, ts } }) } }); return(result); }
public static AmfMessage GetFlexStreamSend(uint channelId, uint streamId, double timeStamp, bool isAbsolute, string function, Variant parameters) { AmfMessage result; result.Header = GenericMessageFactory.VH(HeaderType.HT_FULL, channelId, (uint)timeStamp, 0, Defines.RM_HEADER_MESSAGETYPE_FLEXSTREAMSEND, streamId, isAbsolute); result.Body = Variant.Get(); result.Body[Defines.RM_FLEXSTREAMSEND, Defines.RM_FLEXSTREAMSEND_UNKNOWNBYTE] = (byte)0; result.Body[Defines.RM_FLEXSTREAMSEND, Defines.RM_FLEXSTREAMSEND_PARAMS].Add(function); foreach (var parameter in parameters.Children.Values) { result.Body[Defines.RM_FLEXSTREAMSEND, Defines.RM_FLEXSTREAMSEND_PARAMS].Add(parameter); } return(result); }
private static AmfMessage GetInvokeConnectResult(uint channelId, uint streamId, uint requestId, string level, string code, string decription, double objectEncoding) { var firstParams = Variant.GetMap(new VariantMapHelper { { "fmsVer", "FMS/3,0,1,123" }, { "capabilities", 31.0 } }); var secordParams = Variant.GetMap(new VariantMapHelper { { Defines.RM_INVOKE_PARAMS_RESULT_LEVEL, level }, { Defines.RM_INVOKE_PARAMS_RESULT_CODE, code }, { Defines.RM_INVOKE_PARAMS_RESULT_DESCRIPTION, decription }, { Defines.RM_INVOKE_PARAMS_RESULT_OBJECTENCODING, objectEncoding } }); return(GenericMessageFactory.GetInvokeResult(channelId, streamId, requestId, firstParams, secordParams)); }
public static AmfMessage GetInvokeConnect(string appName, string tcUrl, double audioCodecs, double capabilities, string flashVer, bool fPad, string pageUrl, string swfUrl, double videoCodecs, double videoFunction, double objectEncoding) { var connectRequest0 = Variant.Get(); connectRequest0[Defines.RM_INVOKE_PARAMS_CONNECT_APP] = appName; connectRequest0[Defines.RM_INVOKE_PARAMS_CONNECT_AUDIOCODECS] = audioCodecs; connectRequest0[Defines.RM_INVOKE_PARAMS_CONNECT_FLASHVER] = flashVer; connectRequest0[Defines.RM_INVOKE_PARAMS_CONNECT_FPAD] = (bool)fPad; connectRequest0[Defines.RM_INVOKE_PARAMS_CONNECT_PAGEURL] = pageUrl ?? ""; connectRequest0[Defines.RM_INVOKE_PARAMS_CONNECT_SWFURL] = swfUrl ?? ""; connectRequest0[Defines.RM_INVOKE_PARAMS_CONNECT_TCURL] = tcUrl ?? ""; connectRequest0[Defines.RM_INVOKE_PARAMS_CONNECT_VIDEOCODECS] = videoCodecs; connectRequest0[Defines.RM_INVOKE_PARAMS_CONNECT_VIDEOFUNCTION] = videoFunction; connectRequest0["objectEncoding"] = objectEncoding; return(GenericMessageFactory.GetInvoke(3, 0, 0, false, 1, Defines.RM_INVOKE_FUNCTION_CONNECT, Variant.GetList(connectRequest0))); }
public static AmfMessage GetUserControlStream(ushort operation, uint streamId) { AmfMessage result; result.Header = GenericMessageFactory.VH(HeaderType.HT_FULL, 2, 0, 0, Defines.RM_HEADER_MESSAGETYPE_USRCTRL, 0, true); result.Body = Variant.GetMap(new VariantMapHelper { { Defines.RM_USRCTRL, Variant.GetMap(new VariantMapHelper { { Defines.RM_USRCTRL_TYPE, operation }, { Defines.RM_USRCTRL_TYPE_STRING, RTMPProtocolSerializer.GetUserCtrlTypeString(operation) }, { Defines.RM_USRCTRL_STREAMID, streamId } }) } }); return(result); }
public override void SignalAttachedToInStream() { if (OutputStream == null) { OutputStream = Utils.Rms.GetStream(); } //1. Store the attached stream type to know how we should proceed on detach _attachedStreamType = InStream.Type == StreamTypes.ST_IN_NET_CLUSTER ? (InStream as InClusterStream).ContentStreamType : InStream.Type; //2. Mirror the feeder chunk size FeederChunkSize = InStream.ChunkSize; if (FeederChunkSize == 0) { FeederChunkSize = 0xffffffff; } if (FeederChunkSize != ChunkSize) { if (_audioBucket == null) { _audioBucket = Utils.Rms.GetStream(); } if (_videoBucket == null) { _videoBucket = Utils.Rms.GetStream(); } } //3. Fix the time base FixTimeBase(); //4. Store the metadata if (_attachedStreamType.TagKindOf(StreamTypes.ST_IN_FILE_RTMP)) { _completeMetadata = (InStream as InFileRTMPStream).CompleteMetadata; } AmfMessage message; //5. Send abort messages on audio/video channels if (_pChannelAudio.lastOutProcBytes != 0) { message = GenericMessageFactory.GetAbortMessage(_pChannelAudio.id); if (!Protocol.SendMessage(message)) { Protocol.EnqueueForDelete(); return; } _pChannelAudio.Reset(); } if (_pChannelVideo.lastOutProcBytes != 0) { message = GenericMessageFactory.GetAbortMessage(_pChannelVideo.id); if (!Protocol.SendMessage(message)) { Protocol.EnqueueForDelete(); return; } _pChannelVideo.Reset(); } //6. Stream is recorded if (_attachedStreamType.TagKindOf(StreamTypes.ST_IN_FILE_RTMP)) { message = GetUserControlStreamIsRecorded(RTMPStreamId); if (!Protocol.SendMessage(message)) { Protocol.EnqueueForDelete(); return; } } //7. Stream begin message = GetUserControlStreamBegin(RTMPStreamId); if (!Protocol.SendMessage(message)) { Protocol.EnqueueForDelete(); return; } if (SendOnStatusPlayMessages) { //8. Send NetStream.Play.Reset message = GetInvokeOnStatusStreamPlayReset( _pChannelAudio.id, RTMPStreamId, 0, true, 0, "reset...", Name, _clientId); if (!Protocol.SendMessage(message)) { Protocol.EnqueueForDelete(); return; } //9. NetStream.Play.Start message = GetInvokeOnStatusStreamPlayStart( _pChannelAudio.id, RTMPStreamId, 0, true, 0, "start...", Name, _clientId); if (!Protocol.SendMessage(message)) { Protocol.EnqueueForDelete(); return; } //10. notify |RtmpSampleAccess message = GetNotifyRtmpSampleAccess( _pChannelAudio.id, RTMPStreamId, 0, true, true, true); if (!Protocol.SendMessage(message)) { Protocol.EnqueueForDelete(); return; } } else { this.Log().Info("Skip sending NetStream.Play.Reset, NetStream.Play.Start and notify |RtmpSampleAcces"); } if (_attachedStreamType.TagKindOf(StreamTypes.ST_IN_FILE_RTMP)) { //11. notify onStatus code="NetStream.Data.Start" message = GetNotifyOnStatusDataStart( _pChannelAudio.id, RTMPStreamId, 0, true); if (!Protocol.SendMessage(message)) { Protocol.EnqueueForDelete(); return; } //12. notify onMetaData //message = GetNotifyOnMetaData( // _pChannelAudio.id, RTMPStreamId, 0, true, _completeMetadata[Defines.META_RTMP_META]); //if (!Protocol.SendMessage( message,false,false)) //{ // Protocol.EnqueueForDelete(); //} } else { var pCapabilities = Capabilities; if (pCapabilities == null || pCapabilities.VideoCodecId != VideoCodec.H264) { //Protocol.SendMessagesBlock.TriggerBatch(); Protocol.EnqueueForOutbound(Protocol.OutputBuffer); return; } var meta = Variant.Get(); if ((pCapabilities.Avc._widthOverride != 0) && (pCapabilities.Avc._heightOverride != 0)) { meta["width"] = pCapabilities.Avc._widthOverride; meta["height"] = pCapabilities.Avc._heightOverride; } else if ((pCapabilities.Avc.Width != 0) && (pCapabilities.Avc.Height != 0)) { meta["width"] = pCapabilities.Avc.Width; meta["height"] = pCapabilities.Avc.Height; } if (pCapabilities.BandwidthHint != 0) { meta["bandwidth"] = pCapabilities.BandwidthHint; } message = GetNotifyOnMetaData(_pChannelAudio.id, RTMPStreamId, 0, false, meta); if (!Protocol.SendMessage(message)) { Protocol.EnqueueForDelete(); } } //Protocol.SendMessagesBlock.TriggerBatch(); Protocol.EnqueueForOutbound(Protocol.OutputBuffer); }
public static AmfMessage GetInvokeReleaseStreamResult(uint channelId, uint streamId, uint requestId, double releasedStreamId) { return(GenericMessageFactory.GetInvokeResult(channelId, streamId, requestId, Variant.Get(), streamId != 0 ? Variant.Get(streamId) : Variant.Get())); }
internal static AmfMessage GetInvokeClose() { return(GenericMessageFactory.GetInvoke(3, 0, 0, false, 0, Defines.RM_INVOKE_FUNCTION_CLOSE, Variant.GetList(Variant.Get()))); }
public static AmfMessage GetInvokeFCSubscribe(string streamName) { return(GenericMessageFactory.GetInvoke(3, 0, 0, false, 1, Defines.RM_INVOKE_FUNCTION_FCSUBSCRIBE, Variant.GetList(Variant.Get(), streamName))); }
public static AmfMessage GetInvokePlay(uint channelId, uint streamId, string streamName, double start, double length) { return(GenericMessageFactory.GetInvoke(channelId, streamId, 0, false, 1, Defines.RM_INVOKE_FUNCTION_PLAY, Variant.GetList(Variant.Get(), streamName, start, length))); }
public static AmfMessage GetInvokePublish(uint channelId, uint streamId, string streamName, string mode) { return(GenericMessageFactory.GetInvoke(channelId, streamId, 0, false, 1, Defines.RM_INVOKE_FUNCTION_PUBLISH, Variant.GetList(Variant.Get(), streamName, mode))); }
public static AmfMessage GetInvokeDeleteStream(uint channelId, uint streamId) { return(GenericMessageFactory.GetInvoke(channelId, streamId, 0, false, 1, Defines.RM_INVOKE_FUNCTION_DELETESTREAM, Variant.GetList(Variant.Get()))); }
public static AmfMessage GetNotifyRtmpSampleAccess(uint channelId, uint streamId, double timeStamp, bool isAbsolute, bool audioAccess, bool videoAccess) { return(GenericMessageFactory.GetNotify(channelId, streamId, timeStamp, isAbsolute, "|RtmpSampleAccess", Variant.GetList(audioAccess, videoAccess))); }
public static AmfMessage GetInvokeCreateStreamResult(uint channelId, uint streamId, uint requestId, double createdStreamId) { return(GenericMessageFactory.GetInvokeResult(channelId, streamId, requestId, Variant.Get(), Variant.Get(createdStreamId))); }