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 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 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" }
     }))));
 }
Exemple #4
0
        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 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)));
 }