Example #1
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()");
        }
        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);
        }
Example #3
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>();
        }
Example #4
0
        /// <summary>
        /// This method Register the Smooth Streaming component .
        /// </summary>
        public bool RegisterSmoothStreaming()
        {
            bool bResult = false;
            // 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;
            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;
        }