コード例 #1
0
        /// <summary>
        /// Disconnects from the source.
        /// </summary>
        /// <remarks>
        /// The state must be <see cref="ScreenMirroringState.Connected"/>,
        /// <see cref="ScreenMirroringState.Playing"/> or <see cref="ScreenMirroringState.Paused"/>.
        /// </remarks>
        /// <privilege>http://tizen.org/privilege/internet</privilege>
        /// <exception cref="InvalidOperationException">
        ///     The current state is not in the valid.<br/>
        ///     -or-<br/>
        ///     An internal error occurs.
        /// </exception>
        /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
        /// <exception cref="UnauthorizedAccessException">Caller does not have required permission.</exception>
        /// <since_tizen> 4 </since_tizen>
        public void Disconnect()
        {
            ValidateState(ScreenMirroringState.Connected, ScreenMirroringState.Playing,
                          ScreenMirroringState.Paused);

            Native.Disconnect(Handle).ThrowIfError("Failed to disconnect.");
        }
コード例 #2
0
        ScreenMirroringErrorCode IDisplayable <ScreenMirroringErrorCode> .ApplyEvasDisplay(DisplayType type,
                                                                                           ElmSharp.EvasObject evasObject)
        {
            Debug.Assert(Enum.IsDefined(typeof(DisplayType), type));

            return(Native.SetDisplay(Handle, (int)type, evasObject));
        }
コード例 #3
0
        /// <summary>
        /// Unprepares the screen mirroring.
        /// </summary>
        /// <remarks>
        /// The state must be <see cref="ScreenMirroringState.Prepared"/>,
        /// or <see cref="ScreenMirroringState.Disconnected"/>.
        /// </remarks>
        /// <exception cref="InvalidOperationException">
        ///     The current state is not in the valid.<br/>
        ///     -or-<br/>
        ///     An internal error occurs.
        /// </exception>
        /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
        /// <since_tizen> 4 </since_tizen>
        public void Unprepare()
        {
            ValidateState(ScreenMirroringState.Prepared, ScreenMirroringState.Disconnected);

            Native.Unprepare(Handle).ThrowIfError("Failed to reset.");

            DetachDisplay();
        }
コード例 #4
0
        /// <summary>
        /// Releases the resources used by the ScreenMirroring.
        /// </summary>
        /// <param name="disposing">
        /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
        /// </param>
        /// <since_tizen> 4 </since_tizen>
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                DetachDisplay();

                if (_handle != IntPtr.Zero)
                {
                    Native.Destroy(_handle);
                    _handle = IntPtr.Zero;
                }

                _disposed = true;
            }
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the ScreenMirroring class.
        /// </summary>
        /// <feature>http://tizen.org/feature/network.wifi.direct.display</feature>
        /// <exception cref="NotSupportedException">The feature is not supported.</exception>
        /// <since_tizen> 4 </since_tizen>
        public ScreenMirroring()
        {
            if (IsSupported() == false)
            {
                throw new PlatformNotSupportedException(
                          $"The feature({Feature}) is not supported on the current device.");
            }

            Native.Create(out _handle).ThrowIfError("Failed to create ScreenMirroring.");

            _state = new AtomicState();

            AudioInfo = new ScreenMirroringAudioInfo(this);
            VideoInfo = new ScreenMirroringVideoInfo(this);

            RegisterStateChangedEvent();
        }
コード例 #6
0
        private void PrepareCore(Display display, ScreenMirroringResolutions resolutions)
        {
            ValidateState(ScreenMirroringState.Idle);

            Native.SetResolution(Handle, resolutions).ThrowIfError("Failed to set resolutions.");

            try
            {
                SetDisplay(display);

                Native.Prepare(Handle).ThrowIfError("Failed to prepare.");
            }
            catch
            {
                DetachDisplay();
                throw;
            }
        }
コード例 #7
0
ファイル: ScreenMirroring.cs プロジェクト: yunmiha/TizenFX
        /// <summary>
        /// Creates the connection and ready for receiving data from a mirroring source.
        /// </summary>
        /// <param name="sourceIp">The source ip address to connect.</param>
        /// <remarks>
        /// The state must be <see cref="ScreenMirroringState.Prepared"/> state by
        /// <see cref="Prepare(Display, ScreenMirroringResolutions)"/>.
        /// </remarks>
        /// <returns>A task that represents the asynchronous operation.</returns>
        /// <privilege>http://tizen.org/privilege/internet</privilege>
        /// <exception cref="ArgumentNullException"><paramref name="sourceIp"/> is null.</exception>
        /// <exception cref="InvalidOperationException">
        ///     The current state is not in the valid.<br/>
        ///     -or-<br/>
        ///     An internal error occurs.
        /// </exception>
        /// <exception cref="ArgumentException"><paramref name="sourceIp"/> is a zero-length string, contains only white space.</exception>
        /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
        /// <exception cref="UnauthorizedAccessException">Caller does not have required permission.</exception>
        /// <since_tizen> 4 </since_tizen>
        public Task ConnectAsync(string sourceIp)
        {
            if (sourceIp == null)
            {
                throw new ArgumentNullException(nameof(sourceIp));
            }

            if (string.IsNullOrWhiteSpace(sourceIp))
            {
                throw new ArgumentException($"{nameof(sourceIp)} is a zero-length string.", nameof(sourceIp));
            }

            ValidateState(ScreenMirroringState.Prepared);

            Native.SetIpAndPort(Handle, sourceIp, Port.ToString()).ThrowIfError("Failed to set ip.");

            return(RunAsync(Native.Connect, "Failed to connect."));
        }
コード例 #8
0
ファイル: ScreenMirroring.cs プロジェクト: wonrst/TizenFX
        /// <summary>
        /// Creates the connection and ready for receiving data from a mirroring source with the given <paramref name="port"/>.
        /// </summary>
        /// <param name="sourceIp">The source ip address to connect.</param>
        /// <param name="port">The port number to connect. The max value is 65535.</param>
        /// <remarks>
        /// The state must be <see cref="ScreenMirroringState.Prepared"/> state by
        /// <see cref="Prepare(Display, ScreenMirroringResolutions)"/>.
        /// </remarks>
        /// <returns>A task that represents the asynchronous operation.</returns>
        /// <privilege>http://tizen.org/privilege/internet</privilege>
        /// <exception cref="ArgumentException"><paramref name="sourceIp"/> is a zero-length string, contains only white space.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="sourceIp"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="port"/> is greater than port max value(65535).</exception>
        /// <exception cref="InvalidOperationException">
        ///     The current state is not in the valid.<br/>
        ///     -or-<br/>
        ///     An internal error occurs.
        /// </exception>
        /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
        /// <exception cref="UnauthorizedAccessException">Caller does not have required permission.</exception>
        /// <since_tizen> 9 </since_tizen>
        public Task ConnectAsync(string sourceIp, uint port)
        {
            if (sourceIp == null)
            {
                throw new ArgumentNullException(nameof(sourceIp));
            }
            if (string.IsNullOrWhiteSpace(sourceIp))
            {
                throw new ArgumentException($"{nameof(sourceIp)} is a zero-length string.", nameof(sourceIp));
            }
            if (port > _portMax)
            {
                throw new ArgumentOutOfRangeException(nameof(port), $"{nameof(port)} is greater than max port value(65535).");
            }

            ValidateState(ScreenMirroringState.Prepared);

            Native.SetIpAndPort(Handle, sourceIp, port.ToString()).ThrowIfError("Failed to set ip.");

            return(RunAsync(Native.Connect, "Failed to connect."));
        }
コード例 #9
0
        private void RegisterStateChangedEvent()
        {
            _stateChangedCallback = (error, state, _) =>
            {
                var prevState = _state.Value;

                _state.Value = state;

                if (prevState != state)
                {
                    StateChanged?.Invoke(this, new ScreenMirroringStateChangedEventArgs(state));
                }

                if (error != ScreenMirroringErrorCode.None)
                {
                    ErrorOccurred?.Invoke(this, new ScreenMirroringErrorOccurredEventArgs(
                                              ScreenMirroringError.InvalidOperation));
                }
            };

            Native.SetStateChangedCb(Handle, _stateChangedCallback).
            ThrowIfError("Failed to initialize StateChanged event.");
        }
コード例 #10
0
 ScreenMirroringErrorCode IDisplayable <ScreenMirroringErrorCode> .ApplyEcoreWindow(IntPtr windowHandle)
 {
     return(Native.SetEcoreDisplay(Handle, windowHandle));
 }