Exemplo n.º 1
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Sets the transform information panel on the control
        /// </summary>
        /// <param name="transformToDisplay">the transform to display</param>
        /// <history>
        ///    01 Nov 18  Cynic - Started
        /// </history>
        private void SetTransformInfoPanel(TantaMFTCapabilityContainer transformToDisplay)
        {
            List <IMFMediaType> outputTypes = null;
            List <IMFMediaType> inputTypes  = null;
            StringBuilder       displaySb   = new StringBuilder();
            StringBuilder       outputSb    = new StringBuilder();
            StringBuilder       inputSb     = new StringBuilder();
            StringBuilder       headerSb    = new StringBuilder();
            StringBuilder       outSb;
            HResult             hr;

            // clear it down
            ClearTransformInfoPanel();

            if (transformToDisplay == null)
            {
                return;
            }

            // set up our header information
            headerSb.Append(transformToDisplay.TransformFriendlyName);
            headerSb.Append("\r\n");
            headerSb.Append(transformToDisplay.TransformGuidValueAsString);
            headerSb.Append("\r\n");
            if (transformToDisplay.IsAsyncMFT == "x")
            {
                headerSb.Append("IsAsyncMFT" + ", ");
            }
            if (transformToDisplay.IsSyncMFT == "x")
            {
                headerSb.Append("IsSyncMFT" + ", ");
            }
            if (transformToDisplay.IsFieldOfUse == "x")
            {
                headerSb.Append("IsFieldOfUse" + ", ");
            }

            // we do not include these, the enum function does not give us this
            // if (transformToDisplay.IsHardware == "x") headerSb.Append("IsHardware" + ", ");
            // if (transformToDisplay.IsLocalMFT == "x") headerSb.Append("IsLocalMFT" + ", ");
            // if (transformToDisplay.IsTranscodeOnly == "x") headerSb.Append("IsTranscodeOnly" + ", ");
            headerSb.Append("\r\n");

            try
            {
                // populate the RichText box with the input media type capabilities
                inputTypes = TantaWMFUtils.GetInputMediaTypesFromTransformByGuid(transformToDisplay.TransformGuidValue, false);

                // do we have any input types?
                if ((inputTypes != null) && (inputTypes.Count != 0))
                {
                    // go through the types
                    foreach (IMFMediaType mediaType in inputTypes)
                    {
                        // the major media type
                        hr = TantaMediaTypeInfo.GetMediaMajorTypeAsText(mediaType, out outSb);
                        if (hr != HResult.S_OK)
                        {
                            continue;
                        }
                        if (outSb == null)
                        {
                            continue;
                        }
                        inputSb.Append(outSb);
                        inputSb.Append("\r\n");

                        // the sub media type
                        hr = TantaMediaTypeInfo.GetMediaSubTypeAsText(mediaType, out outSb);
                        if (hr != HResult.S_OK)
                        {
                            continue;
                        }
                        if (outSb == null)
                        {
                            continue;
                        }
                        inputSb.Append(outSb);
                        inputSb.Append("\r\n");

                        // enumerate all of the possible Attributes so we can see which ones are present that we did not report on
                        StringBuilder allAttrs = new StringBuilder();
                        hr = TantaMediaTypeInfo.EnumerateAllAttributeNamesInMediaTypeAsText(mediaType, true, true, TantaWMFUtils.MAX_TYPES_TESTED_PER_TRANSFORM, out allAttrs);
                        if (hr != HResult.S_OK)
                        {
                            continue;
                        }
                        char[] charsToTrim = { ',', '.', ' ' };
                        inputSb.Append("OtherAttrs=" + allAttrs.ToString().TrimEnd(charsToTrim));
                        inputSb.Append("\r\n");

                        inputSb.Append("\r\n");
                    }
                }
            }
            finally
            {
                // release the list of media type objects
                if ((inputTypes != null) && (inputTypes.Count != 0))
                {
                    foreach (IMFMediaType mediaType in inputTypes)
                    {
                        Marshal.ReleaseComObject(mediaType);
                    }
                }
            }

            try
            {
                // populate the RichText box with the output media type capabilities
                outputTypes = TantaWMFUtils.GetOutputMediaTypesFromTransformByGuid(transformToDisplay.TransformGuidValue, false);

                // do we have any output types?
                if ((outputTypes != null) && (outputTypes.Count != 0))
                {
                    // go through the types
                    foreach (IMFMediaType mediaType in outputTypes)
                    {
                        // the major media type
                        hr = TantaMediaTypeInfo.GetMediaMajorTypeAsText(mediaType, out outSb);
                        if (hr != HResult.S_OK)
                        {
                            continue;
                        }
                        if (outSb == null)
                        {
                            continue;
                        }
                        outputSb.Append(outSb);
                        outputSb.Append("\r\n");

                        // the sub media type
                        hr = TantaMediaTypeInfo.GetMediaSubTypeAsText(mediaType, out outSb);
                        if (hr != HResult.S_OK)
                        {
                            continue;
                        }
                        if (outSb == null)
                        {
                            continue;
                        }
                        outputSb.Append(outSb);
                        outputSb.Append("\r\n");

                        // enumerate all of the possible Attributes so we can see which ones are present that we did not report on
                        StringBuilder allAttrs = new StringBuilder();
                        hr = TantaMediaTypeInfo.EnumerateAllAttributeNamesInMediaTypeAsText(mediaType, true, true, TantaWMFUtils.MAX_TYPES_TESTED_PER_TRANSFORM, out allAttrs);
                        if (hr != HResult.S_OK)
                        {
                            continue;
                        }
                        char[] charsToTrim = { ',', '.', ' ' };
                        outputSb.Append("OtherAttrs=" + allAttrs.ToString().TrimEnd(charsToTrim));
                        outputSb.Append("\r\n");

                        outputSb.Append("\r\n");
                    }
                }
            }
            finally
            {
                // release the list of media type objects
                if ((outputTypes != null) && (outputTypes.Count != 0))
                {
                    foreach (IMFMediaType mediaType in outputTypes)
                    {
                        Marshal.ReleaseComObject(mediaType);
                    }
                }
            }

            // display what we have
            displaySb.Append(headerSb);
            displaySb.Append("\r\n");
            displaySb.Append("\r\n");

            displaySb.Append("####\r\n");
            displaySb.Append("#### INPUT TYPES\r\n");
            displaySb.Append("####\r\n");
            displaySb.Append("\r\n");
            if (inputSb.Length > 0)
            {
                displaySb.Append(inputSb);
            }
            else
            {
                displaySb.Append("<not known>");
                displaySb.Append("\r\n");
            }
            displaySb.Append("\r\n");

            displaySb.Append("####\r\n");
            displaySb.Append("#### OUTPUT TYPES\r\n");
            displaySb.Append("####\r\n");
            displaySb.Append("\r\n");
            if (outputSb.Length > 0)
            {
                displaySb.Append(outputSb);
            }
            else
            {
                displaySb.Append("<not known>");
                displaySb.Append("\r\n");
            }
            displaySb.Append("\r\n");

            richTextBoxtTransformDetails.Text = displaySb.ToString();
        }