コード例 #1
0
ファイル: RtmpHandler.cs プロジェクト: GodLesZ/svn-dump
		/*
		FlexInvoke flexInvoke = new FlexInvoke();
		flexInvoke.Cmd = "onstatus";
		flexInvoke.DataType = DataType.TypeUnknown;
		StatusASO statusASO = StatusASO.GetStatusObject(StatusASO.NC_CONNECT_CLOSED, connection.ObjectEncoding);
		flexInvoke.Parameters = new object[]{ statusASO };
		RtmpChannel channel = connection.GetChannel(3);
		channel.Write(flexInvoke);
		*/


		protected override void OnChunkSize(RtmpConnection connection, RtmpChannel channel, RtmpHeader source, ChunkSize chunkSize) {
			if (connection is IStreamCapableConnection) {
				IStreamCapableConnection streamCapableConnection = connection as IStreamCapableConnection;
				{
					foreach (IClientStream stream in streamCapableConnection.GetStreams()) {
						if (stream is IClientBroadcastStream) {
							IClientBroadcastStream bs = stream as IClientBroadcastStream;
							IBroadcastScope scope = bs.Scope.GetBasicScope(Constants.BroadcastScopeType, bs.PublishedName) as IBroadcastScope;
							if (scope == null)
								continue;

							OOBControlMessage setChunkSize = new OOBControlMessage();
							setChunkSize.Target = "ClientBroadcastStream";
							setChunkSize.ServiceName = "chunkSize";
							setChunkSize.ServiceParameterMap.Add("chunkSize", chunkSize.Size);
							scope.SendOOBControlMessage((IConsumer)null, setChunkSize);
							if (log.IsDebugEnabled) {
								log.Debug("Sending chunksize " + chunkSize + " to " + bs.Provider);
							}
						}
					}
				}
			}
		}
コード例 #2
0
 public void SendOOBControlMessage(IConsumer consumer, OOBControlMessage oobCtrlMsg)
 {
     _pipe.SendOOBControlMessage(consumer, oobCtrlMsg);
 }
コード例 #3
0
 /// <summary>
 /// Out-of-band control message handler.
 /// </summary>
 /// <param name="source">OOB message source.</param>
 /// <param name="pipe">Pipe that used to send OOB message.</param>
 /// <param name="oobCtrlMsg">Out-of-band control message.</param>
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
     if (!"ClientBroadcastStream".Equals(oobCtrlMsg.Target))
         return;
     if ("chunkSize".Equals(oobCtrlMsg.ServiceName))
     {
         _chunkSize = (int)oobCtrlMsg.ServiceParameterMap["chunkSize"];
         NotifyChunkSize();
     }
 }
コード例 #4
0
 /// <summary>
 /// Send OOB control message with chunk size.
 /// </summary>
 private void NotifyChunkSize()
 {
     if (_chunkSize > 0 && _livePipe != null)
     {
         OOBControlMessage setChunkSize = new OOBControlMessage();
         setChunkSize.Target = "ConnectionConsumer";
         setChunkSize.ServiceName = "chunkSize";
         setChunkSize.ServiceParameterMap["chunkSize"] = _chunkSize;
         _livePipe.SendOOBControlMessage(this.Provider, setChunkSize);
     }
 }
コード例 #5
0
ファイル: FileProvider.cs プロジェクト: apakian/fluorinefx
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
     if(typeof(IPassive).Name.Equals(oobCtrlMsg.Target))
     {
         if (oobCtrlMsg.ServiceName.Equals("init"))
         {
             _start = System.Convert.ToInt32(oobCtrlMsg.ServiceParameterMap["startTS"]);
         }
     }
     else if (typeof(ISeekableProvider).Name.Equals(oobCtrlMsg.Target))
     {
         if (oobCtrlMsg.ServiceName.Equals("seek"))
         {
             int position = System.Convert.ToInt32(oobCtrlMsg.ServiceParameterMap["position"]);
             int seekPos = Seek(position);
             // Return position we seeked to
             oobCtrlMsg.Result = seekPos;
         }
     }
     else if (typeof(IStreamTypeAwareProvider).Name.Equals(oobCtrlMsg.Target))
     {
         if (oobCtrlMsg.ServiceName.Equals("hasVideo"))
         {
             oobCtrlMsg.Result = this.HasVideo();
         }
     }
 }
コード例 #6
0
ファイル: PlayEngine.cs プロジェクト: ByteSempai/Ubiquitous
 /// <summary>
 /// Get informations about bytes send and number of bytes the client reports to have received.
 /// </summary>
 /// <returns>Written bytes and number of bytes the client received</returns>
 private long[] GetWriteDelta()
 {
     OOBControlMessage pendingRequest = new OOBControlMessage();
     pendingRequest.Target = "ConnectionConsumer";
     pendingRequest.ServiceName = "writeDelta";
     _msgOut.SendOOBControlMessage(this, pendingRequest);
     if (pendingRequest.Result != null)
     {
         return pendingRequest.Result as long[];
     }
     else
     {
         return new long[] { 0, 0 };
     }
 }
コード例 #7
0
ファイル: BroadcastScope.cs プロジェクト: jfarre20/Ubiquitous
 public void SendOOBControlMessage(IProvider provider, OOBControlMessage oobCtrlMsg)
 {
     _pipe.SendOOBControlMessage(provider, oobCtrlMsg);
 }
コード例 #8
0
        public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
        {
            if (!"ConnectionConsumer".Equals(oobCtrlMsg.Target))
                return;

            if ("pendingCount".Equals(oobCtrlMsg.ServiceName))
            {
                oobCtrlMsg.Result = _connection.PendingMessages;
            }
            else if ("pendingVideoCount".Equals(oobCtrlMsg.ServiceName))
            {
                IClientStream stream = null;
                if (_connection is IStreamCapableConnection)
                    stream = (_connection as IStreamCapableConnection).GetStreamByChannelId(_video.ChannelId);
                if (stream != null)
                {
                    oobCtrlMsg.Result = _connection.GetPendingVideoMessages(stream.StreamId);
                }
                else
                {
                    oobCtrlMsg.Result = (long)0;
                }
            }
            else if ("writeDelta".Equals(oobCtrlMsg.ServiceName))
            {
                long maxStream = 0;
                IBWControllable bwControllable = _connection as IBWControllable;
                // Search FC containing valid BWC
                while (bwControllable != null && bwControllable.BandwidthConfiguration == null)
                {
                    bwControllable = bwControllable.GetParentBWControllable();
                }
                if (bwControllable != null && bwControllable.BandwidthConfiguration != null)
                {
                    IBandwidthConfigure bwc = bwControllable.BandwidthConfiguration;
                    if (bwc is IConnectionBWConfig)
                    {
                        maxStream = (bwc as IConnectionBWConfig).DownstreamBandwidth / 8;
                    }
                }
                if (maxStream <= 0)
                {
                    // Use default value
                    // TODO: this should be configured somewhere and sent to the client when connecting
                    maxStream = 120 * 1024;
                }
                // Return the current delta between sent bytes and bytes the client
                // reported to have received, and the interval the client should use
                // for generating BytesRead messages (half of the allowed bandwidth).
                oobCtrlMsg.Result = new long[] { _connection.WrittenBytes - _connection.ClientBytesRead, maxStream / 2 };
            }
            else if ("chunkSize".Equals(oobCtrlMsg.ServiceName))
            {
                int newSize = (int)oobCtrlMsg.ServiceParameterMap["chunkSize"];
                if (newSize != _chunkSize)
                {
                    _chunkSize = newSize;
                    SendChunkSize();
                }
            }
        }
コード例 #9
0
ファイル: PlayEngine.cs プロジェクト: ByteSempai/Ubiquitous
 /// <summary>
 /// Send VOD seek control message
 /// </summary>
 /// <param name="msgIn"></param>
 /// <param name="position"></param>
 /// <returns></returns>            
 private int SendVODSeekCM(IMessageInput msgIn, int position)
 {
     OOBControlMessage oobCtrlMsg = new OOBControlMessage();
     oobCtrlMsg.Target = typeof(ISeekableProvider).Name;
     oobCtrlMsg.ServiceName = "seek";
     oobCtrlMsg.ServiceParameterMap.Add("position", position);
     msgIn.SendOOBControlMessage(this, oobCtrlMsg);
     if (oobCtrlMsg.Result is int)
     {
         return (int)oobCtrlMsg.Result;
     }
     else
     {
         return -1;
     }
 }
コード例 #10
0
ファイル: PlayEngine.cs プロジェクト: ByteSempai/Ubiquitous
 /// <summary>
 /// Send VOD init control message
 /// </summary>
 /// <param name="msgIn"></param>
 /// <param name="item"></param>
 private void SendVODInitCM(IMessageInput msgIn, IPlayItem item)
 {
     OOBControlMessage oobCtrlMsg = new OOBControlMessage();
     oobCtrlMsg.Target = typeof(IPassive).Name;
     oobCtrlMsg.ServiceName = "init";
     oobCtrlMsg.ServiceParameterMap.Add("startTS", item.Start);
     _msgIn.SendOOBControlMessage(this, oobCtrlMsg);
 }
コード例 #11
0
ファイル: PlayEngine.cs プロジェクト: ByteSempai/Ubiquitous
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
     if ("ConnectionConsumer".Equals(oobCtrlMsg.Target))
     {
         if (source is IProvider)
         {
             _msgOut.SendOOBControlMessage((IProvider)source, oobCtrlMsg);
         }
     }
 }
コード例 #12
0
        public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
        {
            if (!"ConnectionConsumer".Equals(oobCtrlMsg.Target))
            {
                return;
            }

            if ("pendingCount".Equals(oobCtrlMsg.ServiceName))
            {
                oobCtrlMsg.Result = _connection.PendingMessages;
            }
            else if ("pendingVideoCount".Equals(oobCtrlMsg.ServiceName))
            {
                IClientStream stream = null;
                if (_connection is IStreamCapableConnection)
                {
                    stream = (_connection as IStreamCapableConnection).GetStreamByChannelId(_video.ChannelId);
                }
                if (stream != null)
                {
                    oobCtrlMsg.Result = _connection.GetPendingVideoMessages(stream.StreamId);
                }
                else
                {
                    oobCtrlMsg.Result = (long)0;
                }
            }
            else if ("writeDelta".Equals(oobCtrlMsg.ServiceName))
            {
                long            maxStream      = 0;
                IBWControllable bwControllable = _connection as IBWControllable;
                // Search FC containing valid BWC
                while (bwControllable != null && bwControllable.BandwidthConfiguration == null)
                {
                    bwControllable = bwControllable.GetParentBWControllable();
                }
                if (bwControllable != null && bwControllable.BandwidthConfiguration != null)
                {
                    IBandwidthConfigure bwc = bwControllable.BandwidthConfiguration;
                    if (bwc is IConnectionBWConfig)
                    {
                        maxStream = (bwc as IConnectionBWConfig).DownstreamBandwidth / 8;
                    }
                }
                if (maxStream <= 0)
                {
                    // Use default value
                    // TODO: this should be configured somewhere and sent to the client when connecting
                    maxStream = 120 * 1024;
                }
                // Return the current delta between sent bytes and bytes the client
                // reported to have received, and the interval the client should use
                // for generating BytesRead messages (half of the allowed bandwidth).
                oobCtrlMsg.Result = new long[] { _connection.WrittenBytes - _connection.ClientBytesRead, maxStream / 2 };
            }
            else if ("chunkSize".Equals(oobCtrlMsg.ServiceName))
            {
                int newSize = (int)oobCtrlMsg.ServiceParameterMap["chunkSize"];
                if (newSize != _chunkSize)
                {
                    _chunkSize = newSize;
                    SendChunkSize();
                }
            }
        }
コード例 #13
0
 /// <summary>
 /// Handles out-of-band control message.
 /// </summary>
 /// <param name="source">Message component source.</param>
 /// <param name="pipe">Connection pipe.</param>
 /// <param name="oobCtrlMsg">Out-of-band control message</param>
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
 }
コード例 #14
0
        /// <summary>
        /// Send VOD seek control message
        /// </summary>
        /// <param name="msgIn">Message input</param>
        /// <param name="position">New timestamp to play from</param>
        private void SendVODSeekCM(IMessageInput msgIn, int position)
        {
            OOBControlMessage oobCtrlMsg = new OOBControlMessage();
            oobCtrlMsg.Target = typeof(ISeekableProvider).Name;
            oobCtrlMsg.ServiceName = "seek";
            oobCtrlMsg.ServiceParameterMap.Add("position", position);
            msgIn.SendOOBControlMessage(this, oobCtrlMsg);

            lock (this.SyncRoot)
            {
                // Reset properties
                _vodStartTS = 0;
                _serverStartTS = System.Environment.TickCount;
                if (_nextRTMPMessage != null)
                {
                    try
                    {
                        PushMessage(_nextRTMPMessage);
                    }
                    catch (IOException ex)
                    {
                        log.Error("Error while sending message.", ex);
                    }
                    _nextRTMPMessage = null;
                }
                ResetMessage reset = new ResetMessage();
                try
                {
                    PushMessage(reset);
                }
                catch (IOException ex)
                {
                    log.Error("Error while sending message.", ex);
                }
                ScheduleNextMessage();
            }
        }
コード例 #15
0
 public void SendOOBControlMessage(IProvider provider, OOBControlMessage oobCtrlMsg)
 {
     _pipe.SendOOBControlMessage(provider, oobCtrlMsg);
 }
コード例 #16
0
ファイル: PlayEngine.cs プロジェクト: ByteSempai/Ubiquitous
 /// <summary>
 /// Send VOD check video control message
 /// </summary>
 /// <param name="msgIn"></param>
 /// <returns></returns>
 private bool SendCheckVideoCM(IMessageInput msgIn)
 {
     OOBControlMessage oobCtrlMsg = new OOBControlMessage();
     oobCtrlMsg.Target = typeof(IStreamTypeAwareProvider).Name;
     oobCtrlMsg.ServiceName = "hasVideo";
     msgIn.SendOOBControlMessage(this, oobCtrlMsg);
     if (oobCtrlMsg.Result is Boolean)
     {
         return (Boolean)oobCtrlMsg.Result;
     }
     else
     {
         return false;
     }
 }
コード例 #17
0
        /// <summary>
        /// Sends out-of-band ("special") control message to all consumers.
        /// </summary>
        /// <param name="provider">Provider, may be used in concrete implementations.</param>
        /// <param name="oobCtrlMsg">Out-of-band control message.</param>
        public void SendOOBControlMessage(IProvider provider, OOBControlMessage oobCtrlMsg)
        {
		    foreach(IConsumer consumer in _consumers) 
            {
			    try 
                {
				    consumer.OnOOBControlMessage(provider, this, oobCtrlMsg);
			    } 
                catch(Exception ex)
                {
				    log.Error("Exception when passing OOBCM from provider to consumers", ex);
			    }
		    }
        }
コード例 #18
0
ファイル: PlayEngine.cs プロジェクト: ByteSempai/Ubiquitous
 /// <summary>
 /// Get number of pending video messages
 /// </summary>
 /// <returns></returns>
 private long GetPendingVideoMessageCount()
 {
     OOBControlMessage pendingRequest = new OOBControlMessage();
     pendingRequest.Target = "ConnectionConsumer";
     pendingRequest.ServiceName = "pendingVideoCount";
     _msgOut.SendOOBControlMessage(this, pendingRequest);
     if (pendingRequest.Result != null)
     {
         return (long)pendingRequest.Result;
     }
     else
     {
         return 0;
     }
 }
コード例 #19
0
ファイル: BroadcastStream.cs プロジェクト: Boreeas/LoLNotes
 /// <summary>
 /// Handles out-of-band control message.
 /// </summary>
 /// <param name="source">Message component source.</param>
 /// <param name="pipe">Connection pipe.</param>
 /// <param name="oobCtrlMsg">Out-of-band control message</param>
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
 }
コード例 #20
0
ファイル: BroadcastScope.cs プロジェクト: jfarre20/Ubiquitous
 public void SendOOBControlMessage(IConsumer consumer, OOBControlMessage oobCtrlMsg)
 {
     _pipe.SendOOBControlMessage(consumer, oobCtrlMsg);
 }