private async Task <object> getEncoderNode(
            object aMediaSource,
            uint aStreamIndex,
            uint aMediaTypeIndex,
            Guid aCLSIDEncoder,
            Guid aCLSIDEncoderMode,
            int aCompressedMediaTypeIndex,
            object aOutputNode)
        {
            object lresult = null;

            do
            {
                if (aCompressedMediaTypeIndex < 0)
                {
                    break;
                }

                object lSourceMediaType = await mSourceControl.getSourceOutputMediaTypeFromMediaSourceAsync(
                    aMediaSource,
                    aStreamIndex,
                    aMediaTypeIndex);

                if (lSourceMediaType == null)
                {
                    break;
                }

                var lEncoderNodeFactory = await mEncoderControl.createEncoderNodeFactoryAsync(
                    aCLSIDEncoder);

                if (lEncoderNodeFactory == null)
                {
                    break;
                }

                object lEncoderNode = await lEncoderNodeFactory.createEncoderNodeAsync(
                    lSourceMediaType,
                    aCLSIDEncoderMode,
                    50,
                    (uint)aCompressedMediaTypeIndex,
                    aOutputNode);

                lresult = lEncoderNode;
            } while (false);

            return(lresult);
        }
        private async Task <object> getCompressedMediaType(
            ICaptureProcessor a_ICaptureProcessor,
            int a_StreamIndex,
            int a_MediaTypeIndex,
            XmlNode aEncoderNode,
            XmlNode aEncoderModeNode,
            int aCompressedMediaTypeIndex)
        {
            object lresult = null;

            do
            {
                if (aCompressedMediaTypeIndex < 0)
                {
                    break;
                }

                object lMediaSource = await mSourceControl.createSourceFromCaptureProcessorAsync(a_ICaptureProcessor);

                if (lMediaSource == null)
                {
                    break;
                }

                if (a_StreamIndex < 0)
                {
                    break;
                }

                if (a_MediaTypeIndex < 0)
                {
                    break;
                }

                if (aEncoderNode == null)
                {
                    break;
                }


                if (aEncoderModeNode == null)
                {
                    break;
                }

                var lEncoderGuidAttr = aEncoderNode.Attributes["CLSID"];

                if (lEncoderGuidAttr == null)
                {
                    break;
                }

                Guid lCLSIDEncoder;

                if (!Guid.TryParse(lEncoderGuidAttr.Value, out lCLSIDEncoder))
                {
                    break;
                }

                var lEncoderModeGuidAttr = aEncoderModeNode.Attributes["GUID"];

                if (lEncoderModeGuidAttr == null)
                {
                    break;
                }

                Guid lCLSIDEncoderMode;

                if (!Guid.TryParse(lEncoderModeGuidAttr.Value, out lCLSIDEncoderMode))
                {
                    break;
                }

                uint lStreamIndex = (uint)a_StreamIndex;

                uint lMediaTypeIndex = (uint)a_MediaTypeIndex;

                object lSourceMediaType = await mSourceControl.getSourceOutputMediaTypeFromMediaSourceAsync(
                    lMediaSource,
                    lStreamIndex,
                    lMediaTypeIndex);

                if (lSourceMediaType == null)
                {
                    break;
                }

                var lEncoderNodeFactory = await mEncoderControl.createEncoderNodeFactoryAsync(lCLSIDEncoder);

                if (lEncoderNodeFactory == null)
                {
                    break;
                }

                lresult = await lEncoderNodeFactory.createCompressedMediaTypeAsync(
                    lSourceMediaType,
                    lCLSIDEncoderMode,
                    50,
                    (uint)aCompressedMediaTypeIndex);
            } while (false);

            return(lresult);
        }