public void EnsureMediaExtensionManager()
 {
     if (mediaExtensionMgr == null)
     {
         mediaExtensionMgr = new Windows.Media.MediaExtensionManager();
         mediaExtensionMgr.RegisterSchemeHandler("Microsoft.Samples.SimpleCommunication.StspSchemeHandler", "stsp:");
     }
 }
Example #2
0
 public void EnsureMediaExtensionManager()
 {
     if (mediaExtensionMgr == null)
     {
         mediaExtensionMgr = new Windows.Media.MediaExtensionManager();
         mediaExtensionMgr.RegisterSchemeHandler("Microsoft.Samples.SimpleCommunication.StspSchemeHandler", "stsp:");
     }
 }
Example #3
0
        void SetupProtectionManager(MediaElement mediaElement)
        {
            TestLogger.LogMessage("Enter Playback.SetupProtectionManager()");

            _mediaElement = mediaElement;

            TestLogger.LogMessage("Creating protection system mappings...");
            _protectionManager = new MediaProtectionManager();

            _protectionManager.ComponentLoadFailed += new ComponentLoadFailedEventHandler(ProtectionManager_ComponentLoadFailed);
            _protectionManager.ServiceRequested    += new ServiceRequestedEventHandler(ProtectionManager_ServiceRequested);

            TestLogger.LogMessage("Creating protection system mappings...");
            //Setup PlayReady as the ProtectionSystem to use by MF.
            //The code here is mandatory and should be just copied directly over to the app
            Windows.Foundation.Collections.PropertySet cpSystems = new Windows.Foundation.Collections.PropertySet();

            //Indicate to the MF pipeline to use PlayReady's TrustedInput
            cpSystems.Add("{F4637010-03C3-42CD-B932-B48ADF3A6A54}", "Windows.Media.Protection.PlayReady.PlayReadyWinRTTrustedInput");
            _protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemIdMapping", cpSystems);
            //Use by the media stream source about how to create ITA InitData.
            //See here for more detai: https://msdn.microsoft.com/en-us/library/windows/desktop/aa376846%28v=vs.85%29.aspx
            _protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemId", "{F4637010-03C3-42CD-B932-B48ADF3A6A54}");

            // Setup the container GUID that's in the PPSH box
            _protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionContainerGuid", "{9A04F079-9840-4286-AB92-E65BE0885F95}");

            TestLogger.LogMessage("Creating media extension manager...");
            _extensions = new Windows.Media.MediaExtensionManager();

            TestLogger.LogMessage("Registering ByteStreamHandlers for PIFF content");
            _extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml");
            _extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-sstr+xml");

            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            //Setup Software Override based on app setting
            //By default, PlayReady uses Hardware DRM if the machine support it. However, in case the app still want
            //software behavior, they can set localSettings.Containers["PlayReady"].Values["SoftwareOverride"]=1.
            //This code tells MF to use software override as well
            if (localSettings.Containers.ContainsKey("PlayReady") &&
                localSettings.Containers["PlayReady"].Values.ContainsKey("SoftwareOverride"))
            {
                int UseSoftwareProtectionLayer = (int)localSettings.Containers["PlayReady"].Values["SoftwareOverride"];

                if (UseSoftwareProtectionLayer == 1)
                {
                    TestLogger.LogMessage(" ");
                    TestLogger.LogMessage("***** Use Software Protection Layer ******");
                    _protectionManager.Properties.Add("Windows.Media.Protection.UseSoftwareProtectionLayer", true);
                }
            }

            _mediaElement.ProtectionManager = _protectionManager;

            TestLogger.LogMessage("Leave Playback.SetProtectionManager()");
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(SettingDAO settingDAO, Windows.Media.MediaExtensionManager extMgr)
        {
            this.settingDAO = settingDAO;

            this.CreateModels();
            this.CreateCommands();
            this.RegisterMessages();

            //셋팅 데이터 로드
            LoadSetting();
            //뒤로가기 버튼 이벤트 등록
            HardwareButtons.BackPressed += HardwareButtons_BackPressed;
            //화면 회전 고정
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;
            //에러 이벤트 추가
            App.Current.UnhandledException += Current_UnhandledException;
            //활성화 이벤트
            DispatcherHelper.CheckBeginInvokeOnUI(() => { Window.Current.Activated += Current_Activated; });
        }
        void RegisterPlugins()
        {
            if (MediaManager == null)
            {
                MediaManager = new Windows.Media.MediaExtensionManager();
            }
            if (AdaptiveSrcManager == null)
            {
                AdaptiveSrcManager = AdaptiveSourceManager.GetDefault();
            }
            PropertySet ssps = new PropertySet();

            ssps["{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}"] = AdaptiveSrcManager;


            MediaManager.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml", ssps);
            MediaManager.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-sstr+xml", ssps);
            MediaManager.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".isml", "text/xml", ssps);
            MediaManager.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".isml", "application/vnd.ms-sstr+xml", ssps);
            MediaManager.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstr:", ssps);
        }
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            mediaExtensionMgr = new Windows.Media.MediaExtensionManager();
            mediaExtensionMgr.RegisterSchemeHandler("Microsoft.Samples.SimpleCommunication.StspSchemeHandler", "stsp:");

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }

            ListenerManager.Instance.Start();
        }
Example #7
0
        /// <summary>
        /// This method Register the HLS component .
        /// </summary>
        public bool RegisterHLS()
        {
            bool bResult = false;
            if (extension == null)
                extension = new Windows.Media.MediaExtensionManager();

            if (hlsPlugin == null)
                hlsPlugin = new Microsoft.PlayerFramework.Adaptive.HLS.HLSPlugin();
            if ((hlsPlugin != null)&&
                (extension != null))
            {
                if (HLSControllerFactory != null)
                {
                    HLSControllerFactory.HLSControllerReady -= ControllerFactory_HLSControllerReady;
                    HLSControllerFactory = null;
                }
                HLSControllerFactory = (hlsPlugin as Microsoft.PlayerFramework.Adaptive.HLS.HLSPlugin).ControllerFactory;  
                //new Microsoft.HLSClient.HLSControllerFactory();
                HLSControllerFactory.HLSControllerReady += ControllerFactory_HLSControllerReady;

                PropertySet hlsps = new PropertySet();
                hlsps.Add("MimeType", "application/x-mpegurl");
                hlsps.Add("ControllerFactory", HLSControllerFactory);

                extension.RegisterSchemeHandler("Microsoft.HLSClient.HLSPlaylistHandler", "ms-hls:", hlsps);
                extension.RegisterSchemeHandler("Microsoft.HLSClient.HLSPlaylistHandler", "ms-hls-s:", hlsps);
                extension.RegisterByteStreamHandler("Microsoft.HLSClient.HLSPlaylistHandler", ".m3u8", "application/x-mpegurl", hlsps);
                extension.RegisterByteStreamHandler("Microsoft.HLSClient.HLSPlaylistHandler", ".ism/manifest(format=m3u8-aapl)", "application/x-mpegurl", hlsps);

                mediaElement.Plugins.Add(hlsPlugin);
                bResult = true;
            }
            return bResult;
        }
Example #8
0
        /// <summary>
        /// This method Register the Smooth Streaming component .
        /// </summary>
        public bool RegisterSmoothStreaming()
        {
            bool bResult = false;
            bResult = true;
            
            // Smooth Streaming initialization
            // Init SMOOTH Manager
            if (smoothStreamingManager != null)
            {
                smoothStreamingManager.ManifestReadyEvent -= SmoothStreamingManager_ManifestReadyEvent;
                smoothStreamingManager.AdaptiveSourceStatusUpdatedEvent -= SmoothStreamingManager_AdaptiveSourceStatusUpdatedEvent;
                smoothStreamingManager = null;
            }
            smoothStreamingManager = Microsoft.Media.AdaptiveStreaming.AdaptiveSourceManager.GetDefault() as Microsoft.Media.AdaptiveStreaming.AdaptiveSourceManager;
            if(extension==null)
                extension = new Windows.Media.MediaExtensionManager();
            if ((smoothStreamingManager != null) &&
                (extension != null))
            {
                PropertySet ssps = new PropertySet();
                ssps["{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}"] = smoothStreamingManager;


                extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml", ssps);
                extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-sstr+xml", ssps);
                extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".isml", "text/xml", ssps);
                extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".isml", "application/vnd.ms-sstr+xml", ssps);


                extension.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstr:", ssps);
                extension.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstrs:", ssps);

                smoothStreamingManager.ManifestReadyEvent += SmoothStreamingManager_ManifestReadyEvent;
                smoothStreamingManager.AdaptiveSourceStatusUpdatedEvent += SmoothStreamingManager_AdaptiveSourceStatusUpdatedEvent;
                bResult = true;
            }
            
            return bResult;
        }
Example #9
0
        /// <summary>
        /// Method: Initialize 
        /// Initialize the cache
        /// Parameter: container is a string defining the folder name where the cache will be stored on disk under folder
        /// \Users\<UserName>\AppData\Local\Packages\<PackageID>\LocalState
        /// Parameter: bDownloadToGo if true DownloadToGo scenario (offline playback), if false ProgressiveDownload scenario
        /// Parameter: maxDownloadSession maximum number of simultaneous download sessions
        /// Parameter: maxDownloadSession maximum number of simultaneous download sessions
        /// Parameter: maxMemoryBufferSizePerSession maximum buffer size per session, when the size if over this value, the chunks will be saved on disk and freed from memory.
        /// Parameter: maxDownloadedAssets maximum number of asset on disk
        /// Parameter: maxError maximum number of http error while downloading the chunks associated with an asset. When this value is reached the download thread will be cancelled
        /// Parameter: bAutoStartDownload if true after a resume the cache will start automatically the download 
        /// </summary>
        public IAsyncOperation<bool> Initialize(string container, uint maxDownloadSession, ulong maxMemoryBufferSizePerSession, uint maxDownloadedAssets, uint maxError, bool bAutoStartDownload)
        {
            return Task.Run<bool>(async () =>
            {
                if (ManifestCacheList != null)
                    Uninitialize();
                Container = container;


                MaxError = maxError;
                MaxMemoryBufferSizePerSession = maxMemoryBufferSizePerSession;
                MaxDownloadSessions = maxDownloadSession;
                MaxDownloadedAssets = maxDownloadedAssets;
                AutoStartDownload = bAutoStartDownload;

                // SMOOTH
                // Init Adaptative Manager
                AdaptiveSrcManager = AdaptiveSourceManager.GetDefault();
                AdaptiveSrcManager.SetDownloaderPlugin(this);
                AdaptiveSrcManager.AdaptiveSourceOpenedEvent += AdaptiveSrcManager_AdaptiveSourceOpenedEvent;
                AdaptiveSrcManager.AdaptiveSourceClosedEvent += AdaptiveSrcManager_AdaptiveSourceClosedEvent;


                // SMOOTH
                // Init SMOOTH Manager
                SmoothStreamingManager = Microsoft.Media.AdaptiveStreaming.AdaptiveSourceManager.GetDefault() as Microsoft.Media.AdaptiveStreaming.AdaptiveSourceManager;
                Extension = new Windows.Media.MediaExtensionManager();
                if ((SmoothStreamingManager != null) &&
                    (Extension != null))
                {
                    Windows.Foundation.Collections.PropertySet ssps = new Windows.Foundation.Collections.PropertySet();
                    ssps["{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}"] = SmoothStreamingManager;


                    Extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml", ssps);
                    Extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-sstr+xml", ssps);
                    Extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".isml", "text/xml", ssps);
                    Extension.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".isml", "application/vnd.ms-sstr+xml", ssps);


                    Extension.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstr:", ssps);
                    Extension.RegisterSchemeHandler("Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler", "ms-sstrs:", ssps);

                    SmoothStreamingManager.ManifestReadyEvent += SmoothStreamingManager_ManifestReadyEvent;
                    SmoothStreamingManager.SetDownloaderPlugin(this);
                }

                if (diskCache == null)
                {
                    diskCache = new DiskCache();
                    if (diskCache != null)
                    {
                        bool bResult = false;
                        bResult = await diskCache.Initialize(Container);
                        if (bResult != true)
                        {
                            System.Diagnostics.Debug.WriteLine("Can't initialize DiskCache");
                            return false;
                        }
                    }
                }
                if (ManifestCacheList == null)
                    ManifestCacheList = new ConcurrentDictionary<Uri, ManifestCache>();
                if (ManifestCacheList != null)
                    IsInitialized = true;
                return IsInitialized;
            }).AsAsyncOperation<bool>();
        }