--- /dev/null
+Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
--- /dev/null
+[general]\r
+profile = profile.device\r
+\r
+[profile.device]\r
+\r
+obs = obs.tizen5.0\r
+user = obs_viewer\r
+passwdx = obs_viewer\r
+repos = repo.base_arm, repo.target_unified\r
+buildroot = ~/GBS-ROOT\r
+\r
+[obs.tizen5.0]\r
+url = https://api.tizen.org\r
+\r
+[repo.base_arm]\r
+url = http://download.tizen.org/snapshots/tizen/base/latest/repos/standard/packages/\r
+\r
+[repo.target_unified]\r
+url = http://download.tizen.org/snapshots/tizen/unified/latest/repos/standard/packages/\r
--- /dev/null
+Name: org.tizen.ScreenMirroringSink
+Summary: org.tizen.ScreenMirroringSink
+Version: 1.0.0
+Release: 1
+Group: N/A
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+
+ExclusiveArch: i586 x86 i486 i686 i386 armv7l arm aarch64
+
+
+BuildRequires: pkgconfig(libtzplatform-config)
+Requires(post): /usr/bin/tpk-backend
+
+%define internal_name org.tizen.ScreenMirroringSink
+%define preload_tpk_path %{TZ_SYS_RO_APP}/.preload-tpk
+
+%description
+profile/iot/apps/native/screen-mirroring
+This is a container package which have preload TPK/WGT files
+
+%prep
+%setup -q
+
+%build
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/%{preload_tpk_path}
+install packaging/%{internal_name}-%{version}.tpk %{buildroot}/%{preload_tpk_path}/
+
+%post
+
+%files
+%defattr(-,root,root,-)
+%{preload_tpk_path}/*
+
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace ScreenMirrorSink\r
+{\r
+ class AppConstants\r
+ {\r
+ // LogTag\r
+ public const string LogTag = "SCREEN_MIRRORING_SINK";\r
+\r
+ // KeyCodes\r
+ public const string BackKeyCode = "XF86Back";\r
+ public const string EscapeKeyCode = "Escape";\r
+\r
+ // string literals\r
+ public const string LightPlatformThemeId = "org.tizen.default-light-theme";\r
+ public const string DarkPlatformThemeId = "org.tizen.default-dark-theme";\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using Tizen.Multimedia;\r
+using Tizen.NUI;\r
+\r
+namespace ScreenMirrorSink\r
+{\r
+ class MirroringDisplay\r
+ {\r
+ public MirroringDisplay(Window window)\r
+ {\r
+ Display = new Display(window);\r
+ }\r
+\r
+ private Display display;\r
+\r
+ public Display Display\r
+ {\r
+ get => display;\r
+ private set => display = value;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using Tizen.Multimedia.Remoting;\r
+using Tizen.NUI;\r
+\r
+namespace ScreenMirrorSink\r
+{\r
+ class MirroringManager\r
+ {\r
+ private WifiDirectController controller;\r
+ private MirroringDisplay mirroringDisplay;\r
+ private MirroringSink sink;\r
+\r
+ public MirroringManager()\r
+ {\r
+ controller = new WifiDirectController();\r
+ controller.DeviceConnected += OnDeviceConnected;\r
+ }\r
+\r
+ private void OnDeviceConnected(object sender, EventArgs e)\r
+ {\r
+ Tizen.Log.Debug(AppConstants.LogTag, "device conneted");\r
+ mirroringDisplay = new MirroringDisplay(Window.Instance);\r
+ sink = new MirroringSink();\r
+ sink.SourceConnected += OnSourceConnected;\r
+ StartMirroring();\r
+ }\r
+\r
+ private void Start()\r
+ {\r
+ if (sink.CurrentState == ScreenMirroringState.Connected)\r
+ {\r
+ sink.Start();\r
+ }\r
+ else\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Sink is not in connected state, Current State: " + sink.CurrentState.ToString());\r
+ }\r
+ }\r
+\r
+ private void StartMirroring()\r
+ {\r
+ SetUpConnection();\r
+ }\r
+\r
+ public void Pause()\r
+ {\r
+ if(sink?.CurrentState == ScreenMirroringState.Playing)\r
+ {\r
+ sink.Pause();\r
+ }\r
+ else\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Sink is not in playing state, Current State: " + sink?.CurrentState.ToString());\r
+ }\r
+ }\r
+\r
+ public void Resume()\r
+ {\r
+ if(sink?.CurrentState == ScreenMirroringState.Paused)\r
+ {\r
+ sink.Resume();\r
+ }\r
+ }\r
+\r
+ public void Stop()\r
+ {\r
+ if(sink.CurrentState == ScreenMirroringState.Connected || sink.CurrentState == ScreenMirroringState.Playing || sink.CurrentState == ScreenMirroringState.Paused)\r
+ {\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Disconnecting sink");\r
+ sink.Disconnect();\r
+ }\r
+\r
+ if(sink.CurrentState == ScreenMirroringState.Disconnected || sink.CurrentState == ScreenMirroringState.Prepared)\r
+ {\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Unpreparing sink");\r
+ sink.Unprepare();\r
+ }\r
+ }\r
+\r
+ public void Terminate()\r
+ {\r
+ Stop();\r
+ controller.StopWifiDirect();\r
+ }\r
+\r
+ private void OnSourceConnected(object sender, EventArgs e)\r
+ {\r
+ Tizen.Log.Info(AppConstants.LogTag, "Screen Mirroring source connected, now start screen mirroring");\r
+ PermissionPopup permissionPopup = new PermissionPopup(controller.ConnectedDeviceName);\r
+ permissionPopup.PermissionRequest += OnPermissionRequest;\r
+ }\r
+\r
+ private void OnPermissionRequest(object sender, PermissionEventHandlerArgs e)\r
+ {\r
+ ((PermissionPopup)sender).Dispose();\r
+ if (e.Permission == RequestPermission.Allow)\r
+ {\r
+ Start();\r
+ }\r
+ else if(e.Permission == RequestPermission.Deny)\r
+ {\r
+ Tizen.Applications.Application.Current.Exit();\r
+ }\r
+ }\r
+\r
+ private void SetUpConnection()\r
+ {\r
+ if(sink.CurrentState == ScreenMirroringState.Connected)\r
+ {\r
+ Tizen.Log.Info(AppConstants.LogTag, "Sink is already in connected state");\r
+ return;\r
+ }\r
+\r
+ if(sink.CurrentState == ScreenMirroringState.Idle)\r
+ {\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Preparing Sink");\r
+ sink.Prepare(mirroringDisplay.Display);\r
+ }\r
+ if(sink.CurrentState == ScreenMirroringState.Prepared)\r
+ {\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Connecting to Source");\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Source Ip: " + controller.ConnectedDeviceIp+":"+controller.ConnectedDevicePort+ ", Name: " + controller.ConnectedDeviceName);\r
+ sink.Connect(controller.ConnectedDeviceIp, (uint)controller.ConnectedDevicePort);\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using Tizen.Multimedia.Remoting;\r
+using Tizen.Multimedia;\r
+\r
+namespace ScreenMirrorSink\r
+{\r
+ class MirroringSink\r
+ {\r
+ private readonly ScreenMirroring screenMirroring = new ScreenMirroring();\r
+\r
+ public event EventHandler<EventArgs> SourceConnected;\r
+\r
+ public MirroringSink()\r
+ {\r
+ currentState = ScreenMirroringState.Idle;\r
+ screenMirroring.StateChanged += OnScreenMirroringStateChange;\r
+ screenMirroring.ErrorOccurred += OnScreenMirroringErrorOccured;\r
+ }\r
+\r
+ private void OnScreenMirroringErrorOccured(object sender, ScreenMirroringErrorOccurredEventArgs e)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Screen Mirroring error occurred: " + e.Error.ToString());\r
+ }\r
+\r
+ private void OnScreenMirroringStateChange(object sender, ScreenMirroringStateChangedEventArgs e)\r
+ {\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Screen Mirror State changed: " + e.State.ToString());\r
+ currentState = e.State;\r
+ if (e.State == ScreenMirroringState.Connected)\r
+ {\r
+ SourceConnected?.Invoke(this, new EventArgs());\r
+ }\r
+ }\r
+\r
+ private ScreenMirroringState currentState;\r
+\r
+ public ScreenMirroringState CurrentState\r
+ {\r
+ get => currentState;\r
+ }\r
+\r
+ public void Prepare(Display display)\r
+ {\r
+ try\r
+ {\r
+ screenMirroring.Prepare(display, ScreenMirroringResolutions.R640x360P30);\r
+ }\r
+ catch (ArgumentNullException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Argument null: " + ex.ParamName);\r
+ }\r
+ catch (ObjectDisposedException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Object disposed : " + ex.Message);\r
+ }\r
+ catch (InvalidOperationException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Invalid operation null: " + ex.Message);\r
+ }\r
+ catch (ArgumentException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Argument exception: " + ex.ParamName + ", " + ex.Message);\r
+ }\r
+ }\r
+\r
+ public async void Connect(string sourceIp, uint port)\r
+ {\r
+ try\r
+ {\r
+ await screenMirroring.ConnectAsync(sourceIp, port);\r
+ }\r
+ catch(UnauthorizedAccessException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Unauthorized access: " + ex.Message);\r
+ }\r
+ catch(ArgumentNullException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Argument null: " + ex.ParamName);\r
+ }\r
+ catch (ObjectDisposedException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Object disposed : " + ex.Message);\r
+ }\r
+ catch (InvalidOperationException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Invalid operation null: " + ex.Message);\r
+ }\r
+ catch(ArgumentException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Argument exception: " + ex.ParamName+", "+ex.Message);\r
+ }\r
+ }\r
+\r
+ public async void Start()\r
+ {\r
+ try\r
+ {\r
+ await screenMirroring.StartAsync();\r
+ }\r
+ catch (UnauthorizedAccessException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Unauthorized access: " + ex.Message);\r
+ }\r
+ catch (ObjectDisposedException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Object disposed : " + ex.Message);\r
+ }\r
+ catch (InvalidOperationException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Invalid operation null: " + ex.Message);\r
+ }\r
+ }\r
+\r
+ public async void Pause()\r
+ {\r
+ try\r
+ {\r
+ await screenMirroring.PauseAsync();\r
+ }\r
+ catch (UnauthorizedAccessException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Unauthorized access: " + ex.Message);\r
+ }\r
+ catch (ObjectDisposedException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Object disposed : " + ex.Message);\r
+ }\r
+ catch (InvalidOperationException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Invalid operation null: " + ex.Message);\r
+ }\r
+ }\r
+\r
+ public async void Resume()\r
+ {\r
+ try\r
+ {\r
+ await screenMirroring.ResumeAsync();\r
+ }\r
+ catch (UnauthorizedAccessException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Unauthorized access: " + ex.Message);\r
+ }\r
+ catch (ObjectDisposedException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Object disposed : " + ex.Message);\r
+ }\r
+ catch (InvalidOperationException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Invalid operation null: " + ex.Message);\r
+ }\r
+ }\r
+\r
+ public void Disconnect()\r
+ {\r
+ try\r
+ {\r
+ screenMirroring.Disconnect();\r
+ }\r
+ catch (UnauthorizedAccessException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Unauthorized access: " + ex.Message);\r
+ }\r
+ catch (ObjectDisposedException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Object disposed : " + ex.Message);\r
+ }\r
+ catch (InvalidOperationException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Invalid operation null: " + ex.Message);\r
+ }\r
+ }\r
+\r
+ public void Unprepare()\r
+ {\r
+ try\r
+ {\r
+ screenMirroring.Unprepare();\r
+ }\r
+ catch (ObjectDisposedException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Object disposed : " + ex.Message);\r
+ }\r
+ catch (InvalidOperationException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Invalid operation null: " + ex.Message);\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace ScreenMirrorSink\r
+{\r
+\r
+ public enum RequestPermission\r
+ {\r
+ Allow,\r
+ Deny\r
+ };\r
+ class PermissionEventHandlerArgs : EventArgs\r
+ {\r
+ internal PermissionEventHandlerArgs(RequestPermission requestPermission)\r
+ {\r
+ Permission = requestPermission;\r
+ }\r
+\r
+ public RequestPermission Permission { get; private set; }\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using Tizen.NUI;\r
+using Tizen.NUI.Components;\r
+using Tizen.NUI.BaseComponents;\r
+\r
+namespace ScreenMirrorSink\r
+{\r
+ class PermissionPopup : IDisposable\r
+ {\r
+ private AlertDialog alertDialog;\r
+ private TextLabel titleLabel;\r
+ private TextLabel contentLabel;\r
+ private Button cancelbutton;\r
+ private Button allowButton;\r
+ private bool disposedValue;\r
+\r
+ public event EventHandler<PermissionEventHandlerArgs> PermissionRequest;\r
+ public PermissionPopup(string name)\r
+ {\r
+ titleLabel = new TextLabel("LabelText")\r
+ {\r
+ ThemeChangeSensitive = true,\r
+ PixelSize = 40,\r
+ FontFamily = "BreezeSans",\r
+ FontStyle = UIConstants.AllNormal,\r
+ Text = "Screen Mirroring",\r
+ };\r
+\r
+ View contentArea = new View()\r
+ {\r
+ SizeHeight = 144,\r
+ WidthResizePolicy = ResizePolicyType.FillToParent,\r
+ BackgroundColor = Color.Transparent,\r
+ };\r
+\r
+ contentLabel = new TextLabel("LabelText")\r
+ {\r
+ ThemeChangeSensitive = true,\r
+ PixelSize = 32,\r
+ FontFamily = "BreezeSans",\r
+ FontStyle = UIConstants.NormalLight,\r
+ Text = "Allow [" + name + "] to mirror on this device",\r
+ WidthResizePolicy = ResizePolicyType.FillToParent,\r
+ HorizontalAlignment = HorizontalAlignment.Begin,\r
+ PositionY = 40,\r
+ };\r
+ contentArea.Add(contentLabel);\r
+\r
+ cancelbutton = new Button("CancelButton")\r
+ {\r
+ ThemeChangeSensitive = true,\r
+ };\r
+ cancelbutton.TextLabel.FontStyle = UIConstants.AllNormal;\r
+ cancelbutton.Clicked += OnCanelClicked;\r
+\r
+ allowButton = new Button()\r
+ {\r
+ Text = "Allow",\r
+ };\r
+ allowButton.Clicked += OnAllowClicked;\r
+\r
+ alertDialog = new AlertDialog()\r
+ {\r
+ TitleContent = titleLabel,\r
+ Content = contentArea,\r
+ Actions = new List<View> { cancelbutton, allowButton },\r
+ };\r
+ Window.Instance.Add(alertDialog);\r
+ }\r
+\r
+ private void OnAllowClicked(object sender, ClickedEventArgs e)\r
+ {\r
+ PermissionRequest?.Invoke(this, new PermissionEventHandlerArgs(RequestPermission.Allow));\r
+ }\r
+\r
+ private void OnCanelClicked(object sender, ClickedEventArgs e)\r
+ {\r
+ PermissionRequest?.Invoke(this, new PermissionEventHandlerArgs(RequestPermission.Deny));\r
+ }\r
+\r
+ private void RemoveAlertDialog()\r
+ {\r
+ Window.Instance.Remove(alertDialog);\r
+ alertDialog.Dispose();\r
+ alertDialog = null;\r
+ }\r
+\r
+ protected virtual void Dispose(bool disposing)\r
+ {\r
+ if (!disposedValue)\r
+ {\r
+ if (disposing)\r
+ {\r
+ // TODO: dispose managed state (managed objects)\r
+ }\r
+\r
+ RemoveAlertDialog();\r
+ disposedValue = true;\r
+ }\r
+ }\r
+\r
+ // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources\r
+ ~PermissionPopup()\r
+ {\r
+ // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method\r
+ Dispose(disposing: false);\r
+ }\r
+\r
+ public void Dispose()\r
+ {\r
+ // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method\r
+ Dispose(disposing: true);\r
+ GC.SuppressFinalize(this);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace ScreenMirrorSink\r
+{\r
+ public class Resources\r
+ {\r
+ public static string GetImagePath()\r
+ {\r
+ return Tizen.Applications.Application.Current.DirectoryInfo.Resource + "images/";\r
+ }\r
+\r
+ public static string GetThemePath()\r
+ {\r
+ return Tizen.Applications.Application.Current.DirectoryInfo.Resource + "themes/";\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.IO;\r
+using Tizen.NUI;\r
+using Tizen.NUI.Xaml;\r
+\r
+namespace ScreenMirrorSink\r
+{\r
+ class Application : NUIApplication\r
+ {\r
+ private MirroringManager manager;\r
+\r
+ public Application() : base(ThemeOptions.PlatformThemeEnabled)\r
+ {\r
+\r
+ }\r
+\r
+ protected override void OnCreate()\r
+ {\r
+ base.OnCreate();\r
+ Initialize();\r
+ }\r
+\r
+ protected override void OnPause()\r
+ {\r
+ base.OnPause();\r
+ manager?.Pause();\r
+ }\r
+\r
+ protected override void OnResume()\r
+ {\r
+ base.OnResume();\r
+ manager?.Resume();\r
+ }\r
+\r
+ protected override void OnTerminate()\r
+ {\r
+ base.OnTerminate();\r
+ manager?.Terminate();\r
+ }\r
+\r
+ void Initialize()\r
+ {\r
+ Window.Instance.BackgroundColor = Color.Transparent;\r
+ Window.Instance.KeyEvent += OnKeyEvent;\r
+\r
+ UpdateTheme(ThemeManager.PlatformThemeId);\r
+ RegisterThemeChanges();\r
+\r
+ TitleBarView titleBarView = new TitleBarView();\r
+ Window.Instance.GetDefaultLayer().Add(titleBarView);\r
+\r
+ manager = new MirroringManager();\r
+ }\r
+\r
+ public void OnKeyEvent(object sender, Window.KeyEventArgs e)\r
+ {\r
+ if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == AppConstants.BackKeyCode || e.Key.KeyPressedName == AppConstants.EscapeKeyCode))\r
+ {\r
+ Exit();\r
+ }\r
+ }\r
+\r
+ private void RegisterThemeChanges()\r
+ {\r
+ ThemeManager.ThemeChanged += (object sender, ThemeChangedEventArgs e) =>\r
+ {\r
+ if (e.IsPlatformThemeChanged)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Theme Changed: " + e.ThemeId);\r
+ UpdateTheme(e.PlatformThemeId);\r
+ }\r
+ };\r
+ }\r
+\r
+ private void SetTheme(string path)\r
+ {\r
+ try\r
+ {\r
+ Theme lightTheme = new Theme(path);\r
+ ThemeManager.ApplyTheme(lightTheme);\r
+ }\r
+ catch (ArgumentNullException e)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "ArgumentNullException: " + e.ParamName);\r
+ }\r
+ catch (IOException e)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "IOException: " + e.Message);\r
+ }\r
+ catch (XamlParseException e)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "XamlParseException: " + e.Message);\r
+ if (e.XmlInfo != null)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "XamlParseException, LineNo." + e.XmlInfo.LineNumber + " Pos: " + e.XmlInfo.LinePosition + " HasInfo: " + e.XmlInfo.HasLineInfo().ToString());\r
+ }\r
+ }\r
+ }\r
+\r
+ private void UpdateTheme(string platformThemeId)\r
+ {\r
+ if (platformThemeId == null)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Platform theme id is null");\r
+ return;\r
+ }\r
+ if (platformThemeId.Equals(AppConstants.LightPlatformThemeId))\r
+ {\r
+ SetTheme(Resources.GetThemePath() + "light.xaml");\r
+ }\r
+ else if (platformThemeId.Equals(AppConstants.DarkPlatformThemeId))\r
+ {\r
+ SetTheme(Resources.GetThemePath() + "dark.xaml");\r
+ }\r
+ }\r
+\r
+ static void Main(string[] args)\r
+ {\r
+ var app = new Application();\r
+ app.Run(args);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">\r
+\r
+ <PropertyGroup>\r
+ <OutputType>Exe</OutputType>\r
+ <TargetFramework>netcoreapp3.1</TargetFramework>\r
+ <TargetFrameworkIdentifier>Tizen</TargetFrameworkIdentifier>\r
+ <AssemblyName>ScreenMirroringSink</AssemblyName>\r
+ </PropertyGroup>\r
+\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+ <DebugType>portable</DebugType>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+ <DebugType>None</DebugType>\r
+ </PropertyGroup>\r
+\r
+ <ItemGroup>\r
+ <Folder Include="lib\" />\r
+ <Folder Include="res\" />\r
+ </ItemGroup>\r
+\r
+ <ItemGroup>\r
+ <PackageReference Include="Tizen.NET" Version="9.0.0.16707" />\r
+ <PackageReference Include="Tizen.NET.Sdk" Version="1.0.1" />\r
+ </ItemGroup>\r
+\r
+</Project>\r
+\r
--- /dev/null
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio Version 16\r
+VisualStudioVersion = 16.0.31025.194\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScreenMirroringSink", "ScreenMirroringSink.csproj", "{C3A5CC64-F899-4116-9959-B45B30D63A29}"\r
+EndProject\r
+Global\r
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+ Debug|Any CPU = Debug|Any CPU\r
+ Release|Any CPU = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+ {C3A5CC64-F899-4116-9959-B45B30D63A29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+ {C3A5CC64-F899-4116-9959-B45B30D63A29}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+ {C3A5CC64-F899-4116-9959-B45B30D63A29}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+ {C3A5CC64-F899-4116-9959-B45B30D63A29}.Release|Any CPU.Build.0 = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(SolutionProperties) = preSolution\r
+ HideSolutionNode = FALSE\r
+ EndGlobalSection\r
+ GlobalSection(ExtensibilityGlobals) = postSolution\r
+ SolutionGuid = {CF208F67-5E2E-4605-AE1B-5C6DDAA0593B}\r
+ EndGlobalSection\r
+EndGlobal\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using Tizen.NUI;\r
+using Tizen.NUI.BaseComponents;\r
+using Tizen.NUI.Components;\r
+\r
+namespace ScreenMirrorSink\r
+{\r
+ class TitleBarView : View\r
+ {\r
+ private const int Interval = 3000;\r
+ private const int AnimationTime = 300;\r
+ private const int ShowAnimationPosition = 0;\r
+ private const int HideAnimationPosition = -120;\r
+\r
+ private View titleBar;\r
+ private Button backButton;\r
+ private TextLabel titleLabel;\r
+ private Timer autoHideTimer;\r
+ private Animation showHideAnimation;\r
+ private bool isAnimating;\r
+ private bool isTitleBarVisible;\r
+ public TitleBarView() : base()\r
+ {\r
+ Name = "TitleBarView";\r
+ //StyleName = "AppBackground";\r
+ BackgroundColor = Color.Transparent;\r
+ ThemeChangeSensitive = true;\r
+ WidthResizePolicy = ResizePolicyType.FillToParent;\r
+ HeightResizePolicy = ResizePolicyType.FillToParent;\r
+ titleBar = new View()\r
+ {\r
+ BackgroundColor = Color.Transparent,\r
+ WidthResizePolicy = ResizePolicyType.FillToParent,\r
+ SizeHeight = 120,\r
+ Layout = new RelativeLayout()\r
+ {\r
+ Padding = new Extents(64, 64, 0, 0),\r
+ },\r
+ PositionX = 0,\r
+ PositionY = -120,\r
+ };\r
+ Add(titleBar);\r
+\r
+ backButton = new Button("BackButton")\r
+ {\r
+ ThemeChangeSensitive = true,\r
+ };\r
+ backButton.Clicked += (object sender, ClickedEventArgs e) =>\r
+ {\r
+ Tizen.Applications.Application.Current.Exit();\r
+ };\r
+ titleBar.Add(backButton);\r
+ titleBar.Hide();\r
+ isTitleBarVisible = false;\r
+ RelativeLayout.SetLeftRelativeOffset(backButton, 0.0f);\r
+ RelativeLayout.SetRightRelativeOffset(backButton, 0.0f);\r
+ RelativeLayout.SetHorizontalAlignment(backButton, RelativeLayout.Alignment.Start);\r
+ RelativeLayout.SetVerticalAlignment(backButton, RelativeLayout.Alignment.Center);\r
+\r
+ titleLabel = new TextLabel("LabelText")\r
+ {\r
+ Text = "Screen Mirroring",\r
+ PixelSize = 40,\r
+ FontFamily = "BreezeSans",\r
+ HorizontalAlignment = HorizontalAlignment.Begin,\r
+ VerticalAlignment = VerticalAlignment.Center,\r
+ Ellipsis = true,\r
+ FontStyle = UIConstants.NormalLight,\r
+ Margin = new Extents(24, 0, 0, 0),\r
+ };\r
+ titleBar.Add(titleLabel);\r
+ RelativeLayout.SetLeftTarget(titleLabel, backButton);\r
+ RelativeLayout.SetLeftRelativeOffset(titleLabel, 1.0f);\r
+ RelativeLayout.SetRightTarget(titleLabel, titleBar);\r
+ RelativeLayout.SetRightRelativeOffset(titleLabel, 1.0f);\r
+ RelativeLayout.SetFillHorizontal(titleLabel, true);\r
+ RelativeLayout.SetVerticalAlignment(titleLabel, RelativeLayout.Alignment.Center);\r
+\r
+ showHideAnimation = new Animation(AnimationTime);\r
+ showHideAnimation.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear);\r
+ showHideAnimation.Finished += OnAnimationFinished;\r
+ isAnimating = false;\r
+\r
+ autoHideTimer = new Timer(Interval);\r
+ autoHideTimer.Tick += OnAutoHide;\r
+\r
+ TouchEvent += OnTitleBarViewTouch;\r
+ }\r
+\r
+ private bool OnTitleBarViewTouch(object source, TouchEventArgs e)\r
+ {\r
+ PointStateType pointState = e.Touch.GetState(0);\r
+ if (pointState == PointStateType.Up)\r
+ {\r
+ if (isAnimating)\r
+ {\r
+ return false;\r
+ }\r
+\r
+ if (isTitleBarVisible)\r
+ {\r
+ HideTitleBar();\r
+ }\r
+ else\r
+ {\r
+ ShowTitleBar();\r
+ }\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ private void OnAnimationFinished(object sender, EventArgs e)\r
+ {\r
+ isAnimating = false;\r
+ if(isTitleBarVisible == false)\r
+ {\r
+ titleBar.Hide();\r
+ }\r
+ }\r
+\r
+ public void ShowTitleBar()\r
+ {\r
+ titleBar.Show();\r
+ isTitleBarVisible = true;\r
+ AnimateTitleBar(true);\r
+ autoHideTimer.Start();\r
+ }\r
+\r
+ public void HideTitleBar()\r
+ {\r
+ autoHideTimer.Stop();\r
+ isTitleBarVisible = false;\r
+ AnimateTitleBar(false);\r
+ }\r
+\r
+ private bool OnAutoHide(object source, Timer.TickEventArgs e)\r
+ {\r
+ HideTitleBar();\r
+ return false;\r
+ }\r
+\r
+ private void AnimateTitleBar(bool show)\r
+ {\r
+ int destionValue = show ? ShowAnimationPosition : HideAnimationPosition;\r
+ showHideAnimation.AnimateTo(titleBar, "PositionY", destionValue);\r
+ showHideAnimation.Play();\r
+ isAnimating = true;\r
+ }\r
+\r
+ protected override void Dispose(DisposeTypes type)\r
+ {\r
+ if(Disposed)\r
+ {\r
+ return;\r
+ }\r
+\r
+ if(type == DisposeTypes.Explicit)\r
+ {\r
+ titleBar.Remove(titleLabel);\r
+ titleBar.Remove(backButton);\r
+\r
+ titleLabel.Dispose();\r
+ titleLabel = null;\r
+\r
+ backButton.Dispose();\r
+ backButton = null;\r
+\r
+ base.Remove(titleBar);\r
+ titleBar.Dispose();\r
+ titleBar = null;\r
+\r
+ autoHideTimer.Dispose();\r
+ autoHideTimer = null;\r
+\r
+ showHideAnimation.Finished -= OnAnimationFinished;\r
+ showHideAnimation.Dispose();\r
+ showHideAnimation = null;\r
+\r
+ TouchEvent -= OnTitleBarViewTouch;\r
+ }\r
+\r
+ base.Dispose(type);\r
+ }\r
+\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using Tizen.NUI;\r
+\r
+namespace ScreenMirrorSink\r
+{\r
+ class UIConstants\r
+ {\r
+ public static readonly Color HEXEEEFF1 = new Color(0.9333f, 0.9373f, 0.9450f, 1.0f);\r
+ public static readonly PropertyMap NormalLight = new PropertyMap().\r
+ Add("width", new PropertyValue("normal")).\r
+ Add("weight", new PropertyValue("light"));\r
+\r
+ public static readonly PropertyMap AllNormal = new PropertyMap().\r
+ Add("width", new PropertyValue("normal")).\r
+ Add("weight", new PropertyValue("normal")).\r
+ Add("slant", new PropertyValue("normal"));\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using Tizen.Network.WiFiDirect;\r
+\r
+namespace ScreenMirrorSink\r
+{\r
+ class WifiDirectController\r
+ {\r
+\r
+ public event EventHandler<EventArgs> DeviceConnected;\r
+\r
+ private struct PeerInfo\r
+ {\r
+ public PeerInfo(WiFiDirectPeer peer )\r
+ {\r
+ Name = peer.Name;\r
+ IpAddress = peer.IpAddress;\r
+ MacAddress = peer.MacAddress;\r
+ Port = peer.Port;\r
+ }\r
+\r
+ public string Name { get; private set; }\r
+ public string IpAddress { get; private set; }\r
+ public string MacAddress { get; private set; }\r
+ public int Port { get; private set; }\r
+ }\r
+\r
+ private List<PeerInfo> peerInfoList;\r
+\r
+ public WifiDirectController()\r
+ {\r
+ WiFiDirectManager.DeviceStateChanged += OnDeviceStatusChanged;\r
+ WiFiDirectManager.ConnectionStatusChanged += OnConnectionStateChanged;\r
+ WiFiDirectManager.DiscoveryStateChanged += OnDiscoveryStateChanged;\r
+ WiFiDirectManager.StateChanged += OnStateChanged;\r
+ WiFiDirectManager.PeerFound += OnPeerFound;\r
+ WiFiDirectManager.Activate();\r
+ peerInfoList = new List<PeerInfo>();\r
+ }\r
+\r
+ public string ConnectedDeviceName\r
+ {\r
+ get\r
+ {\r
+ if (peerInfoList.Count > 0)\r
+ {\r
+ return peerInfoList[0].Name;\r
+ }\r
+ return string.Empty;\r
+ }\r
+ }\r
+\r
+ public string ConnectedDeviceIp\r
+ {\r
+ get\r
+ {\r
+ if(peerInfoList.Count > 0)\r
+ {\r
+ return peerInfoList[0].IpAddress;\r
+ }\r
+ return string.Empty;\r
+ }\r
+ }\r
+\r
+ public string ConnectedDeviceMac\r
+ {\r
+ get\r
+ {\r
+ if (peerInfoList.Count > 0)\r
+ {\r
+ return peerInfoList[0].MacAddress;\r
+ }\r
+ return string.Empty;\r
+ }\r
+ }\r
+\r
+ public int ConnectedDevicePort\r
+ {\r
+ get\r
+ {\r
+ if (peerInfoList.Count > 0)\r
+ {\r
+ return peerInfoList[0].Port;\r
+ }\r
+ return -1;\r
+ }\r
+ }\r
+\r
+ public void StopWifiDirect()\r
+ {\r
+ WiFiDirectManager.DeinitDisplay();\r
+ if (WiFiDirectManager.IsDiscoverable)\r
+ {\r
+ WiFiDirectManager.CancelDiscovery();\r
+ }\r
+ WiFiDirectManager.Deactivate();\r
+ }\r
+\r
+ private void OnPeerFound(object sender, PeerFoundEventArgs e)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Peer Found Error: " + e.Error.ToString());\r
+ Tizen.Log.Error(AppConstants.LogTag, "DiscoveryState: " + e.DiscoveryState.ToString());\r
+ if(e.Error == WiFiDirectError.None)\r
+ {\r
+ Tizen.Log.Info(AppConstants.LogTag, e.Peer.Name+", "+e.Peer.IpAddress+", "+e.Peer.MacAddress+", "+e.Peer.IsConnected.ToString());\r
+ }\r
+ }\r
+\r
+ private void OnStateChanged(object sender, StateChangedEventArgs e)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Current State: " + e.State.ToString());\r
+ if(e.State == WiFiDirectState.Connected)\r
+ {\r
+ IEnumerable<WiFiDirectPeer> wiFiDirectPeers = WiFiDirectManager.GetConnectedPeers();\r
+ peerInfoList.Clear();\r
+ foreach(WiFiDirectPeer peer in wiFiDirectPeers)\r
+ {\r
+ peerInfoList.Add(new PeerInfo(peer));\r
+ }\r
+ Tizen.Log.Info(AppConstants.LogTag, "Connected peer count: " + peerInfoList.Count);\r
+ DeviceConnected?.Invoke(this, new EventArgs());\r
+ }\r
+ }\r
+\r
+ private void OnDiscoveryStateChanged(object sender, DiscoveryStateChangedEventArgs e)\r
+ {\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Discovery Error: " + e.Error.ToString());\r
+ Tizen.Log.Debug(AppConstants.LogTag, "DiscoveryState: " + e.DiscoveryState.ToString());\r
+ }\r
+\r
+ private void OnConnectionStateChanged(object sender, ConnectionStatusChangedEventArgs e)\r
+ {\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Connection Error: " + e.Error.ToString());\r
+ Tizen.Log.Debug(AppConstants.LogTag, "Connection State: " + e.ConnectionState.ToString());\r
+ }\r
+\r
+ private void OnDeviceStatusChanged(object sender, DeviceStateChangedEventArgs e)\r
+ {\r
+ Tizen.Log.Debug(AppConstants.LogTag, "DeviceState Error: " + e.Error);\r
+ Tizen.Log.Debug(AppConstants.LogTag, "DeviceState: " + e.DeviceState.ToString());\r
+ if(e.DeviceState == WiFiDirectDeviceState.Activated)\r
+ {\r
+ Tizen.Log.Info(AppConstants.LogTag, "Start setting up wifi direct display");\r
+ SetupWifiDirectDisplay();\r
+ }\r
+ }\r
+\r
+ private void SetupWifiDirectDisplay()\r
+ {\r
+ try\r
+ {\r
+ //WiFiDirectManager.DisconnectAll();\r
+ WiFiDirectManager.InitDisplay();\r
+ WiFiDirectManager.SetDisplayAvailability(true);\r
+ WiFiDirectManager.SetDisplay(WiFiDirectDisplayType.Prisink, 2022, 0);\r
+ WiFiDirectManager.GroupOwnerIntent = 1;\r
+ WiFiDirectManager.MaxClients = 1;\r
+ WiFiDirectManager.StartDiscovery(false, 100);\r
+ }\r
+ catch (InvalidOperationException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Invalid operation null: " + ex.Message);\r
+ }\r
+ catch (UnauthorizedAccessException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Unauthorized access: " + ex.Message);\r
+ }\r
+ catch(NotSupportedException ex)\r
+ {\r
+ Tizen.Log.Error(AppConstants.LogTag, "Not supported access: " + ex.Message);\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using Tizen.Network.WiFiDirect;\r
+\r
+namespace ScreenMirrorSink\r
+{\r
+ class WifiDirectPeerController\r
+ {\r
+ private WiFiDirectPeer currentPeer;\r
+\r
+ public WifiDirectPeerController(WiFiDirectPeer peer)\r
+ {\r
+ if(peer == null)\r
+ {\r
+ throw new ArgumentNullException(nameof(peer), "provided peer is null");\r
+ }\r
+ currentPeer = peer;\r
+ }\r
+\r
+ public string Name\r
+ {\r
+ get => currentPeer.Name;\r
+ }\r
+\r
+ public string IpAddress\r
+ {\r
+ get => currentPeer.IpAddress;\r
+ }\r
+\r
+ public WiFiDirectDisplayType DisplayType\r
+ {\r
+ get => currentPeer.Display;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Theme\r
+xmlns="http://tizen.org/Tizen.NUI/2018/XAML"\r
+xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"\r
+xmlns:c="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components"\r
+Id="LightTheme">\r
+\r
+ <ViewStyle x:Key="AppBackground" BackgroundColor="#0E1017" />\r
+\r
+ <c:ButtonStyle x:Key="BackButton" Size="48, 48" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent">\r
+ <c:ButtonStyle.Icon>\r
+ <ImageViewStyle>\r
+ <ImageViewStyle.ResourceUrl>\r
+ <Selector x:TypeArguments="x:String" Normal="*Resource*/images/dark/back.png" />\r
+ </ImageViewStyle.ResourceUrl>\r
+ </ImageViewStyle>\r
+ </c:ButtonStyle.Icon>\r
+ </c:ButtonStyle>\r
+\r
+ <c:ButtonStyle x:Key="CancelButton" Size="336, 96" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >\r
+ <c:ButtonStyle.BackgroundImage>*Resource*/images/dark/cancel_button_bg.png</c:ButtonStyle.BackgroundImage>\r
+ <c:ButtonStyle.Text>\r
+ <TextLabelStyle TextColor="#FFFFFF" FontFamily="BreezeSans" PixelSize="32" Text="Cancel"/>\r
+ </c:ButtonStyle.Text>\r
+ </c:ButtonStyle>\r
+\r
+ <TextLabelStyle x:Key="LabelText" TextColor="#FFFFFF"></TextLabelStyle>\r
+\r
+</Theme>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Theme\r
+xmlns="http://tizen.org/Tizen.NUI/2018/XAML"\r
+xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"\r
+xmlns:c="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components"\r
+Id="LightTheme">\r
+\r
+ <ViewStyle x:Key="AppBackground" BackgroundColor="#EEEFF1" />\r
+\r
+ <c:ButtonStyle x:Key="BackButton" Size="48, 48" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent">\r
+ <c:ButtonStyle.Icon>\r
+ <ImageViewStyle>\r
+ <ImageViewStyle.ResourceUrl>\r
+ <Selector x:TypeArguments="x:String" Normal="*Resource*/images/light/back.png" />\r
+ </ImageViewStyle.ResourceUrl>\r
+ </ImageViewStyle>\r
+ </c:ButtonStyle.Icon>\r
+ </c:ButtonStyle>\r
+\r
+\r
+ <c:ButtonStyle x:Key="CancelButton" Size="336, 96" IsSelectable="false" IsEnabled="true" BackgroundColor="Transparent" >\r
+ <c:ButtonStyle.BackgroundImage>*Resource*/images/light/cancel_button_bg.png</c:ButtonStyle.BackgroundImage>\r
+ <c:ButtonStyle.Text>\r
+ <TextLabelStyle TextColor="#000C2B" FontFamily="BreezeSans" PixelSize="32" Text="Cancel"/>\r
+ </c:ButtonStyle.Text>\r
+ </c:ButtonStyle>\r
+\r
+ <TextLabelStyle x:Key="LabelText" TextColor="#000C2B"/>\r
+\r
+</Theme>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<manifest package="org.tizen.ScreenMirroringSink" version="1.0.0" api-version="6" xmlns="http://tizen.org/ns/packages">\r
+ <profile name="common" />\r
+ <ui-application appid="org.tizen.ScreenMirroringSink" exec="ScreenMirroringSink.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">\r
+ <label>ScreenMirroringSink</label>\r
+ <icon>ScreenMirroringSink.png</icon>\r
+ <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />\r
+ <splash-screens />\r
+ </ui-application>\r
+ <shortcut-list />\r
+ <privileges>\r
+ <privilege>http://tizen.org/privilege/internet</privilege>\r
+ <privilege>http://tizen.org/privilege/wifidirect</privilege>\r
+ </privileges>\r
+ <dependencies />\r
+ <provides-appdefined-privileges />\r
+</manifest>\r
+\r
+\r