def test_createSourceNodeFromExternalSourceWithDownStreamConnection(self):
        sourceControl = captureManager.createSourceControl()
        mediaSource = self.test_createSource()

        sinkControl = captureManager.createSinkControl()
        XMLstring = sinkControl.getCollectionOfSinks()
        root = ElementTree.fromstring(XMLstring)
        sinkFactories = ElementPath.findall(root, "SinkFactory")
        fileSinkFactoreGUID = ''
        asfContainerGUID = ''
        for sinkFactory in sinkFactories:
            if (sinkFactory.get('GUID') ==
                    '{D6E342E3-7DDD-4858-AB91-4253643864C2}'):
                fileSinkFactoreGUID = '{D6E342E3-7DDD-4858-AB91-4253643864C2}'
                for valuePart in ElementPath.findall(
                        sinkFactory, 'Value.ValueParts/ValuePart'):
                    if (valuePart.get('GUID') ==
                            '{A2A56DA1-EB84-460E-9F05-FEE51D8C81E3}'):
                        asfContainerGUID = '{A2A56DA1-EB84-460E-9F05-FEE51D8C81E3}'
        fileSinkFactory = SinkFactories.FileSinkFactory(
            sinkControl.createSinkFactory(asfContainerGUID,
                                          fileSinkFactoreGUID))

        indexOfStream = 0
        indexOfMediaType = 2

        outputMediaType = sourceControl.getSourceOutputMediaTypeFromMediaSource(
            mediaSource, indexOfStream, indexOfMediaType)
        aArrayPtrCompressedMediaTypes = []
        aArrayPtrCompressedMediaTypes.append(outputMediaType)
        outputNodes = fileSinkFactory.createOutputNodes(
            aArrayPtrCompressedMediaTypes, 'test.asf')

        sourceNode = sourceControl.createSourceNodeFromExternalSourceWithDownStreamConnection(
            mediaSource, indexOfStream, indexOfMediaType, outputNodes[0])
    def initSession(self):

        if (self.session == None):
            fileSinkFactoreGUID = '{D6E342E3-7DDD-4858-AB91-4253643864C2}'
            fileSinkFactory = SinkFactories.FileSinkFactory(
                self.sinkControl.createSinkFactory(
                    self.outputContainerTypeGUID, fileSinkFactoreGUID))
            selectedMediaTypeIndex = self.mediaTypeComboBox.subwidget_list[
                'slistbox'].subwidget_list['listbox'].curselection()
            inputMediaType = self.sourceControl.getSourceOutputMediaType(
                self.symbolicLink, 0, int(selectedMediaTypeIndex[0]))
            encoderNodeFactory = self.encoderControl.createEncoderNodeFactory(
                self.encoderCLSID)
            encoderModeGUID = self.encoderModeGUIDlist[int(
                self.encoderModeComboBox.subwidget_list['slistbox'].
                subwidget_list['listbox'].curselection()[0])]
            compressedMediaTypeIndex = int(
                self.encoderOutputMediaTypeComboBox.subwidget_list['slistbox'].
                subwidget_list['listbox'].curselection()[0])

            compressedMediaType = encoderNodeFactory.createCompressedMediaType(
                inputMediaType, encoderModeGUID, 80, compressedMediaTypeIndex)

            arrayPtrCompressedMediaTypes = []
            arrayPtrCompressedMediaTypes.append(compressedMediaType)

            outputNode = fileSinkFactory.createOutputNodes(
                arrayPtrCompressedMediaTypes, self.filePath)

            encoderNode = encoderNodeFactory.createEncoderNode(
                inputMediaType, encoderModeGUID, 80, compressedMediaTypeIndex,
                outputNode[0])

            sourceNode = self.sourceControl.createSourceNodeWithDownStreamConnection(
                self.symbolicLink, 0, int(selectedMediaTypeIndex[0]),
                encoderNode)

            sources = []
            sources.append(sourceNode)
            self.session = self.sessionControl.createSession(sources)

            self.session.startSession(
                0, '{00000000-0000-0000-0000-000000000000}')

            self.sessionBtn.config(text='stop')
        else:
            self.session.stopSession()
            self.session.closeSession()
    def test_createSourceNodeWithDownStreamConnection(self):
        sourceControl = captureManager.createSourceControl()
        XMLstring = sourceControl.getCollectionOfSources()
        selfSources = ElementTree.fromstring(XMLstring)
        sources = ElementPath.findall(selfSources, "Source")
        symboliclink = ''
        for source in sources:
            state = False
            for attributes in ElementPath.findall(source, "Source.Attributes"):
                for attribute in ElementPath.findall(attributes, "Attribute"):
                    if (attribute.get(
                            'Name'
                    ) == 'MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK'
                        ):
                        symboliclink = attribute.find('SingleValue').get(
                            'Value')
        sinkControl = captureManager.createSinkControl()
        XMLstring = sinkControl.getCollectionOfSinks()
        root = ElementTree.fromstring(XMLstring)
        sinkFactories = ElementPath.findall(root, "SinkFactory")
        fileSinkFactoreGUID = ''
        asfContainerGUID = ''
        for sinkFactory in sinkFactories:
            if (sinkFactory.get('GUID') ==
                    '{D6E342E3-7DDD-4858-AB91-4253643864C2}'):
                fileSinkFactoreGUID = '{D6E342E3-7DDD-4858-AB91-4253643864C2}'
                for valuePart in ElementPath.findall(
                        sinkFactory, 'Value.ValueParts/ValuePart'):
                    if (valuePart.get('GUID') ==
                            '{A2A56DA1-EB84-460E-9F05-FEE51D8C81E3}'):
                        asfContainerGUID = '{A2A56DA1-EB84-460E-9F05-FEE51D8C81E3}'
        fileSinkFactory = SinkFactories.FileSinkFactory(
            sinkControl.createSinkFactory(asfContainerGUID,
                                          fileSinkFactoreGUID))

        indexOfStream = 0
        indexOfMediaType = 2

        outputMediaType = sourceControl.getSourceOutputMediaType(
            symboliclink, indexOfStream, indexOfMediaType)
        aArrayPtrCompressedMediaTypes = []
        aArrayPtrCompressedMediaTypes.append(outputMediaType)
        outputNodes = fileSinkFactory.createOutputNodes(
            aArrayPtrCompressedMediaTypes, 'test.asf')

        sourceNode = sourceControl.createSourceNodeWithDownStreamConnection(
            symboliclink, indexOfStream, indexOfMediaType, outputNodes[0])
 def test_createFileSinkFactory(self):
     sinkControl = captureManager.createSinkControl()
     XMLstring = sinkControl.getCollectionOfSinks()
     root = ElementTree.fromstring(XMLstring)
     sinkFactories = ElementPath.findall(root, "SinkFactory")
     fileSinkFactoreGUID = ''
     asfContainerGUID = ''
     for sinkFactory in sinkFactories:
         if (sinkFactory.get('GUID') ==
                 '{D6E342E3-7DDD-4858-AB91-4253643864C2}'):
             fileSinkFactoreGUID = '{D6E342E3-7DDD-4858-AB91-4253643864C2}'
             for valuePart in ElementPath.findall(
                     sinkFactory, 'Value.ValueParts/ValuePart'):
                 if (valuePart.get('GUID') ==
                         '{A2A56DA1-EB84-460E-9F05-FEE51D8C81E3}'):
                     asfContainerGUID = '{A2A56DA1-EB84-460E-9F05-FEE51D8C81E3}'
     fileSinkFactory = SinkFactories.FileSinkFactory(
         sinkControl.createSinkFactory(asfContainerGUID,
                                       fileSinkFactoreGUID))
     return fileSinkFactory