internal override int Init(string appId, string channelId)
        {
            int ret = -1;

            app_id_     = appId;
            channel_id_ = channelId.Split(';').GetValue(0).ToString();

            if (null == rtc_engine_)
            {
                rtc_engine_ = AgoraRtcEngine.CreateAgoraRtcEngine();
            }
            LogConfig        log_config     = new LogConfig(agora_sdk_log_file_path_);
            RtcEngineContext rtc_engine_ctx = new RtcEngineContext(app_id_, AREA_CODE.AREA_CODE_GLOB, log_config);

            ret = rtc_engine_.Initialize(rtc_engine_ctx);
            CSharpForm.dump_handler_("Initialize", ret);
            event_handler_ = new ScreenShareEventHandler(this);
            rtc_engine_.InitEventHandler(event_handler_);

            if (null == screen_share_engine_)
            {
                screen_share_engine_ = AgoraRtcEngine.CreateAgoraRtcEngine(AgoraEngineType.SubProcess);
            }
            ret = screen_share_engine_.Initialize(rtc_engine_ctx);
            CSharpForm.dump_handler_(ScreenShare_TAG + "Initialize", ret);

            //screen_share_event_handler_ = new ScreenShareEventHandler(this);
            //screen_share_engine_.InitEventHandler(screen_share_event_handler_);

            return(ret);
        }
        internal override int Init(string appId, string channelId)
        {
            int ret = -1;

            app_id_     = appId;
            channel_id_ = channelId.Split(';').GetValue(0).ToString();

            if (null == rtc_engine_)
            {
                rtc_engine_ = AgoraRtcEngine.CreateAgoraRtcEngine();
            }

            LogConfig        log_config     = new LogConfig(agora_sdk_log_file_path_);
            RtcEngineContext rtc_engine_ctx = new RtcEngineContext(app_id_, AREA_CODE.AREA_CODE_GLOB, log_config);

            ret = rtc_engine_.Initialize(rtc_engine_ctx);
            CSharpForm.dump_handler_(JoinChannelVideo_TAG + "Initialize", ret);
            // second way to set logfile
            //ret = rtc_engine_.SetLogFile(log_file_path);
            //CSharpForm.dump_handler_(JoinChannelVideo_TAG + "SetLogFile", ret);

            event_handler_ = new JoinChannelVideoEventHandler(this);
            rtc_engine_.InitEventHandler(event_handler_);

            return(ret);
        }
Exemple #3
0
        internal override int UnInit()
        {
            int ret = -1;

            if (null != first_channel_)
            {
                first_channel_.Unpublish();
                ret = first_channel_.LeaveChannel();
                first_channel_.Dispose();
                CSharpForm.dump_handler_(JoinMultipleChannel_TAG + "LeaveChannel", ret);
            }

            if (null != second_channel_)
            {
                second_channel_.Unpublish();
                ret = second_channel_.LeaveChannel();
                second_channel_.Dispose();
                CSharpForm.dump_handler_(JoinMultipleChannel_TAG + "LeaveChannel", ret);
            }

            if (null != rtc_engine_)
            {
                rtc_engine_.Dispose(true);
                rtc_engine_ = null;
            }

            return(ret);
        }
Exemple #4
0
        internal override int Init(string appId, string channelId)
        {
            int ret = -1;

            app_id_     = appId;
            channel_id_ = channelId.Split(';').GetValue(0).ToString();

            if (null == rtc_engine_)
            {
                rtc_engine_ = AgoraRtcEngine.CreateAgoraRtcEngine();
            }
            LogConfig        log_config     = new LogConfig(agora_sdk_log_file_path_);
            RtcEngineContext rtc_engine_ctx = new RtcEngineContext(app_id_, AREA_CODE.AREA_CODE_GLOB, log_config);

            ret = rtc_engine_.Initialize(rtc_engine_ctx);
            CSharpForm.dump_handler_(ProcessRawData_TAG + "Initialize", ret);

            event_handler_ = new ProcessRawDataEventHandler(this);
            rtc_engine_.InitEventHandler(event_handler_);

            audio_frame_observer = new ProcessRawDataAudioFrameObserver();
            rtc_engine_.RegisterAudioFrameObserver(audio_frame_observer);

            video_frame_observer = new ProcessRawDataVideoFrameObserver();
            rtc_engine_.RegisterVideoFrameObserver(video_frame_observer);

            return(ret);
        }
        public static AgoraWindowInfo[] GetWindowInfos(this IAgoraRtcEngine agoraRtcEngine)
        {
#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
            var windowCollectionPtr = AgoraRtcNative.EnumerateWindows();
            var windowCollection    =
                (IrisWindowCollection)(Marshal.PtrToStructure(windowCollectionPtr, typeof(IrisWindowCollection)));
            var windowInfos = new AgoraWindowInfo[windowCollection.length];
            for (var i = 0; i < windowCollection.length; i++)
            {
#if NET_2_0_SUBSET
                var window =
                    (IrisWindow)(Marshal.PtrToStructure(
                                     (IntPtr)((long)windowCollection.windows + Marshal.SizeOf(typeof(IrisWindow)) * i),
                                     typeof(IrisWindow)) ?? new IrisWindow());
                windowInfos[i] = new AgoraWindowInfo(window.id, window.name, window.owner_name, window.bounds,
                                                     window.work_area);
#else
                var window =
                    (IrisWindow)(Marshal.PtrToStructure(
                                     windowCollection.windows + Marshal.SizeOf(typeof(IrisWindow)) * i,
                                     typeof(IrisWindow)) ??
                                 new IrisWindow());
                windowInfos[i] = new AgoraWindowInfo(window.id, window.name, window.owner_name, window.bounds,
                                                     window.work_area);
#endif
            }

            AgoraRtcNative.FreeIrisWindowCollection(windowCollectionPtr);

            return(windowInfos);
#else
            throw new PlatformNotSupportedException();
#endif
        }
        public static AgoraDisplayInfo[] GetDisplayInfos(this IAgoraRtcEngine agoraRtcEngine)
        {
#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || NET40_OR_GREATER || NETCOREAPP2_0_OR_GREATER
            var displayCollectionPtr = AgoraRtcNative.EnumerateDisplays();
            var displayCollection    =
                (IrisDisplayCollection)(Marshal.PtrToStructure(displayCollectionPtr, typeof(IrisDisplayCollection)) ??
                                        new IrisDisplayCollection());
            var displayInfos = new AgoraDisplayInfo[displayCollection.length];
            for (var i = 0; i < displayCollection.length; i++)
            {
#if NET_2_0_SUBSET
                var display =
                    (IrisDisplay)(Marshal.PtrToStructure(
                                      (IntPtr)((long)displayCollection.displays + Marshal.SizeOf(typeof(IrisDisplay)) * i),
                                      typeof(IrisDisplay)) ?? new IrisDisplay());
                displayInfos[i] = new AgoraDisplayInfo(display.id, display.bounds, display.work_area);
#else
                var display =
                    (IrisDisplay)(Marshal.PtrToStructure(
                                      displayCollection.displays + Marshal.SizeOf(typeof(IrisDisplay)) * i,
                                      typeof(IrisDisplay)) ?? new IrisDisplay());
                displayInfos[i] = new AgoraDisplayInfo(display.id, display.bounds, display.work_area);
#endif
            }

            AgoraRtcNative.FreeIrisDisplayCollection(displayCollectionPtr);

            return(displayInfos);
#else
            throw new PlatformNotSupportedException();
#endif
        }
        internal override int UnInit()
        {
            int ret = -1;

            if (null != rtc_engine_)
            {
                rtc_engine_.Dispose();
                rtc_engine_ = null;
            }
            return(ret);
        }
        internal void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _agoraRtcEngine = null;
                _disposed       = true;
            }
        }
        internal override int UnInit()
        {
            int ret = -1;

            if (null != rtc_engine_)
            {
                ret = rtc_engine_.LeaveChannel();
                CSharpForm.dump_handler_(JoinChannelVideo_TAG + "LeaveChannel", ret);

                rtc_engine_.Dispose();
                rtc_engine_ = null;
            }
            return(ret);
        }
Exemple #10
0
        internal override int Init(string appId, string channelId)
        {
            int ret = -1;

            app_id_ = appId;
            var channels = channelId.Split(';');

            if (channels.Length < 2)
            {
                return(-1);
            }
            first_channel_id_  = channelId.Split(';').GetValue(0).ToString();
            second_channel_id_ = channelId.Split(';').GetValue(1).ToString();

            if (null == rtc_engine_)
            {
                rtc_engine_ = AgoraRtcEngine.CreateAgoraRtcEngine();
            }
            LogConfig        log_config     = new LogConfig(agora_sdk_log_file_path_);
            RtcEngineContext rtc_engine_ctx = new RtcEngineContext(app_id_, AREA_CODE.AREA_CODE_GLOB, log_config);

            ret = rtc_engine_.Initialize(rtc_engine_ctx);
            CSharpForm.dump_handler_(JoinMultipleChannel_TAG + "Initialize", ret);
            //event_handler_ = new JoinMultipleChannelEventHandler(this);
            //rtc_engine_.InitEventHandler(event_handler_);
            rtc_engine_.SetChannelProfile(CHANNEL_PROFILE_TYPE.CHANNEL_PROFILE_LIVE_BROADCASTING);

            first_channel_ = rtc_engine_.CreateChannel(first_channel_id_);
            ret            = first_channel_.SetClientRole(CLIENT_ROLE_TYPE.CLIENT_ROLE_BROADCASTER);
            CSharpForm.dump_handler_(JoinMultipleChannel_TAG + "SetClientRole(ch1)", ret);
            first_channel_event_handler_ = new JoinMultipleChannelChannelEventHandler(this);
            first_channel_.InitEventHandler(first_channel_event_handler_);

            second_channel_ = rtc_engine_.CreateChannel(second_channel_id_);
            ret             = second_channel_.SetClientRole(CLIENT_ROLE_TYPE.CLIENT_ROLE_AUDIENCE);
            CSharpForm.dump_handler_(JoinMultipleChannel_TAG + "SetClientRole(ch2)", ret);
            second_channel_event_handler_ = new JoinMultipleChannelChannelEventHandler(this);
            second_channel_.InitEventHandler(second_channel_event_handler_);

            return(ret);
        }
        internal override int UnInit()
        {
            int ret = -1;

            if (null != screen_share_engine_)
            {
                ret = screen_share_engine_.LeaveChannel();
                CSharpForm.dump_handler_(ScreenShare_TAG + "LeaveChannel", ret);

                screen_share_engine_.Dispose();
                screen_share_engine_ = null;
            }

            if (null != rtc_engine_)
            {
                ret = rtc_engine_.LeaveChannel();
                CSharpForm.dump_handler_("LeaveChannel", ret);

                rtc_engine_.Dispose();
                rtc_engine_ = null;
            }
            return(ret);
        }
 public VideoStreamManager(IAgoraRtcEngine agoraRtcEngine)
 {
     this._agoraRtcEngine = agoraRtcEngine;
 }