コード例 #1
0
    // load agora engine
    public void loadEngine()
    {
        // start sdk
        logAPICall("initializeEngine");
        if (mRtcEngine != null)
        {
            logAPICall("Engine exists. Please unload it first!");
            return;
        }

        // init engine
        mRtcEngine          = IRtcEngine.getEngine(mVendorKey);
        videoRawDataManager = VideoRawDataManager.GetInstance(mRtcEngine);
        mRtcEngine.EnableVideo();
        mRtcEngine.EnableVideoObserver();
        mRtcEngine.SetLogFile("/sdcard/test.agora.zhang/agora_sdk.log");
        mRtcEngine.SetParameters("{\"rtc.log_filter\": 65535}");
        mRtcEngine.SetVideoProfile(VIDEO_PROFILE_TYPE.VIDEO_PROFILE_PORTRAIT_480P_6, true);
        audioPlaybackDeviceManager   = AudioPlaybackDeviceManager.GetInstance(mRtcEngine);
        audioRecordingoDeviceManager = AudioRecordingDeviceManager.GetInstance(mRtcEngine);
        videoDeviceManager           = VideoDeviceManager.GetInstance(mRtcEngine);
        metaDataObserver             = MetadataObserver.GetInstance(mRtcEngine);
        packetObserver      = PacketObserver.GetInstance(mRtcEngine);
        audioRawDataManager = AudioRawDataManager.GetInstance(mRtcEngine);
        videoRawDataManager = VideoRawDataManager.GetInstance(mRtcEngine);
        // enable log
        mRtcEngine.SetLogFilter(LOG_FILTER.DEBUG | LOG_FILTER.INFO | LOG_FILTER.WARNING | LOG_FILTER.ERROR | LOG_FILTER.CRITICAL);
    }
コード例 #2
0
 /// <summary>
 /// Construct an SSH2 channel stream.
 /// </summary>
 /// <param name="enclosingInstance">The channel that owns this stream.</param>
 /// <param name="observer">An observer to filter data messages.</param>
 protected internal SSH2ChannelStream(SSH2Channel enclosingInstance, PacketObserver observer)
     : base(enclosingInstance)
 {
     buffer        = new byte[enclosingInstance.localwindow.available()];
     this.observer = observer;
     this.channel  = (SSH2Channel)enclosingInstance;
 }
コード例 #3
0
        /// <summary>
        /// Get the next packet from the store that matches an id in the filter. If no id exists this
        /// method will block until a suitable message is received or the store is closed.
        /// </summary>
        /// <param name="observer"></param>
        /// <returns></returns>
        public SSHPacket NextMessage(PacketObserver observer)
        {
            try
            {
                SSHPacket msg = manager.NextMessage(channel, observer);

                if (msg != null)
                {
                    lock (header)
                    {
                        if (channel == null || !channel.StickyMessageIDs.WantsNotification(msg))
                        {
                            Remove(msg);
                        }
                        return(msg);
                    }
                }
            }
            catch (System.Threading.ThreadInterruptedException)
            {
                throw new SSHException("The thread was interrupted", SSHException.INTERNAL_ERROR);
            }

            throw new System.IO.EndOfStreamException("The required message could not be found in the message store");
        }
コード例 #4
0
        internal SSHPacket HasMessage(PacketObserver observer)
        {
            lock (header)
            {
                if (observer == null)
                {
                    throw new System.ArgumentException("Message filter cannot be NULL!");
                }

                if (header.Next == null)
                {
                    return(null);
                }

                for (SSHPacket e = header.Next; e != header; e = e.Next)
                {
//#if DEBUG
//					System.Diagnostics.Trace.WriteLine("Checking message id " + e.MessageID );
//#endif

                    if (observer.WantsNotification(e))
                    {
                        return(e);
                    }
                }

                return(null);
            }
        }
コード例 #5
0
        /// <summary>
        /// Process the next available messages in the message store and only returns once
        /// a message matching one of the ids in the filter array has arrived.
        /// </summary>
        /// <param name="observer"></param>
        /// <returns></returns>
        protected internal virtual SSHChannelMessage ProcessMessages(PacketObserver observer)
        {
            SSHChannelMessage msg;

            msg = (SSHChannelMessage)ms.NextMessage(observer);

            switch (msg.MessageID)
            {
            case SSH_MSG_WINDOW_ADJUST:
            {
#if DEBUG
                LogMessage(msg);
#endif
                remotewindow.adjust((int)msg.ReadUINT32());
                break;
            }

            case SSH_MSG_CHANNEL_DATA:
            {
                byte[] data = msg.ReadBinaryString();
                ProcessStandardData(data, 0, data.Length);
                break;
            }

            case SSH_MSG_CHANNEL_EXTENDED_DATA:
            {
                int    type = (int)msg.ReadUINT32();
                byte[] data = msg.ReadBinaryString();
                ProcessExtendedData(type, data, 0, data.Length);
                break;
            }

            case SSH_MSG_CHANNEL_CLOSE:
            {
                remoteClosed = true;
                CheckCloseStatus(true);
                throw new System.IO.EndOfStreamException("The channel is closed");
            }

            case SSH_MSG_CHANNEL_EOF:
            {
                try
                {
                    stream.CloseInput();
                }
                catch (System.IO.IOException)
                {
                }

                throw new System.IO.EndOfStreamException("The channel is EOF");
            }

            default:
                break;
            }

            return(msg);
        }
コード例 #6
0
ファイル: SSHPacketRouter.cs プロジェクト: hst-bridge/BBS
        /// <summary>
        /// Get the next message from the <see cref="Maverick.SSH.Packets.SSHPacketRouter"/> that matches one of the
        /// ids supplied in the message filter and return its index in the channels message store.
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="observer"></param>
        /// <returns></returns>
        protected internal SSHPacket NextMessage(SSHAbstractChannel channel, PacketObserver observer)
        {
            SSHPacketStore store = channel == null? global : channel.MessageStore;

            PacketHolder holder = new PacketHolder();

            while (!store.Closed && holder.msg == null)
            {
                // Check for an error from the buffering thread
                if (buffered)
                {
                    if (!isClosing)
                    {
                        if (lastError != null)
                        {
                            if (lastError is SSHException)
                            {
                                throw lastError;
                            }
                            else
                            {
                                throw new SSHException(lastError);
                            }
                        }
                    }
                }


                if (sync.RequestBlock(store, observer, holder))
                {
                    try
                    {
                        BlockForMessage();
                    }
                    finally
                    {
                        // Release the block so that other threads may block or return with the
                        // newly arrived message
                        sync.ReleaseBlock();
                    }
                }
            }

            return(holder.msg);
        }
コード例 #7
0
ファイル: ThreadSynchronizer.cs プロジェクト: hst-bridge/BBS
        /// <summary>
        /// Request to obtain the real block but check for messages first in the packet store.
        /// </summary>
        /// <param name="store"></param>
        /// <param name="observer"></param>
        /// <param name="holder"></param>
        /// <returns></returns>
        public bool RequestBlock(SSHPacketStore store, PacketObserver observer, PacketHolder holder)
        {
            lock (this)
            {
//#if DEBUG
//				System.Diagnostics.Trace.WriteLine(System.Threading.Thread.CurrentThread.Name + ": Obtained lock on sync");
//#endif

                if ((holder.msg = store.HasMessage(observer)) != null)
                {
//#if DEBUG
//					System.Diagnostics.Trace.WriteLine(System.Threading.Thread.CurrentThread.Name + ": w00t I've found a message");
//#endif
                    return(false);
                }


                bool canBlock = !isBlocking;

                if (canBlock)
                {
//#if DEBUG
//					System.Diagnostics.Trace.WriteLine(System.Threading.Thread.CurrentThread.Name + ": w00t I've got the *real* block");
//#endif
                    isBlocking = true;
                }
                else
                {
//#if DEBUG
//					System.Diagnostics.Trace.WriteLine(System.Threading.Thread.CurrentThread.Name + ": :( Waiting on sync in pseudo block");
//#endif

                    System.Threading.Monitor.Wait(this);
                }

//#if DEBUG
//				System.Diagnostics.Trace.WriteLine(System.Threading.Thread.CurrentThread.Name + ": Exiting RequestBlock");
//#endif
                return(canBlock);
            }
        }