Beispiel #1
0
    def testGetReleaseBinForFactoryStream(self):
        factory = FakeSourceFactory()
        stream = VideoStream(gst.Caps('any'), 'src0')
        factory.addOutputStream(stream)

        # try to get a cached instance
        self.failUnlessRaises(PipelineError,
                self.pipeline.getBinForFactoryStream, factory, stream, False)

        # create a bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(bin1, gst.Element))
        # return the cached instance
        bin2 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnlessEqual(id(bin1), id(bin2))

        self.pipeline.releaseBinForFactoryStream(factory, stream)
        self.pipeline.releaseBinForFactoryStream(factory, stream)

        # the bin has been destroyed at this point
        self.failUnlessRaises(PipelineError,
                self.pipeline.releaseBinForFactoryStream, factory, stream)

        # we should get a new instance
        bin2 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.pipeline.releaseBinForFactoryStream(factory, stream)
Beispiel #2
0
    def testGetReleaseBinForFactoryStream(self):
        factory = FakeSourceFactory()
        stream = VideoStream(gst.Caps('any'), 'src0')
        factory.addOutputStream(stream)

        # try to get a cached instance
        self.failUnlessRaises(PipelineError,
                self.pipeline.getBinForFactoryStream, factory, stream, False)

        # create a bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(bin1, gst.Element))
        # return the cached instance
        bin2 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnlessEqual(id(bin1), id(bin2))

        self.pipeline.releaseBinForFactoryStream(factory, stream)
        self.pipeline.releaseBinForFactoryStream(factory, stream)

        # the bin has been destroyed at this point
        self.failUnlessRaises(PipelineError,
                self.pipeline.releaseBinForFactoryStream, factory, stream)

        # we should get a new instance
        bin2 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.pipeline.releaseBinForFactoryStream(factory, stream)
Beispiel #3
0
    def testGetReleaseQueueForFactoryStream(self):
        factory = FakeSinkFactory()
        stream = VideoStream(gst.Caps('any'), 'sink')
        factory.addInputStream(stream)

        self.failUnlessRaises(PipelineError,
            self.pipeline.getQueueForFactoryStream, factory, stream, True)

        # getBinForFactoryStream(factory, stream) must be called before
        self.failUnlessRaises(PipelineError,
            self.pipeline.getQueueForFactoryStream, factory, stream, True)

        # create the bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)

        # try to get a cached queue
        self.failUnlessRaises(PipelineError,
            self.pipeline.getQueueForFactoryStream, factory, stream, False)

        # create queue
        queue1 = self.pipeline.getQueueForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(queue1, gst.Element))

        gst.debug("pouet")

        # get the cached instance
        queue2 = self.pipeline.getQueueForFactoryStream(factory, stream, True)
        self.failUnlessEqual(id(queue1), id(queue2))

        # release
        self.pipeline.releaseQueueForFactoryStream(factory, stream)

        gst.debug("pouet")

        # there's still a queue alive, so we can't release the bin
        self.failUnlessRaises(PipelineError,
                self.pipeline.releaseBinForFactoryStream, factory, stream)

        self.pipeline.releaseQueueForFactoryStream(factory, stream)

        gst.debug("pouet2")
        self.failUnlessRaises(PipelineError,
                self.pipeline.releaseQueueForFactoryStream, factory, stream)

        # should always fail with a src bin
        factory2 = FakeSourceFactory()
        stream2 = VideoStream(gst.Caps('any'), 'src')
        factory2.addOutputStream(stream2)

        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnlessRaises(PipelineError,
            self.pipeline.getQueueForFactoryStream, factory2, stream2, True)
        self.pipeline.releaseBinForFactoryStream(factory, stream)

        self.pipeline.releaseBinForFactoryStream(factory, stream)
        self.assertEquals(factory.current_bins, 0)
Beispiel #4
0
    def testGetReleaseQueueForFactoryStream(self):
        factory = FakeSinkFactory()
        stream = VideoStream(gst.Caps('any'), 'sink')
        factory.addInputStream(stream)

        self.failUnlessRaises(PipelineError,
            self.pipeline.getQueueForFactoryStream, factory, stream, True)

        # getBinForFactoryStream(factory, stream) must be called before
        self.failUnlessRaises(PipelineError,
            self.pipeline.getQueueForFactoryStream, factory, stream, True)

        # create the bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)

        # try to get a cached queue
        self.failUnlessRaises(PipelineError,
            self.pipeline.getQueueForFactoryStream, factory, stream, False)

        # create queue
        queue1 = self.pipeline.getQueueForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(queue1, gst.Element))

        gst.debug("pouet")

        # get the cached instance
        queue2 = self.pipeline.getQueueForFactoryStream(factory, stream, True)
        self.failUnlessEqual(id(queue1), id(queue2))

        # release
        self.pipeline.releaseQueueForFactoryStream(factory, stream)

        gst.debug("pouet")

        # there's still a queue alive, so we can't release the bin
        self.failUnlessRaises(PipelineError,
                self.pipeline.releaseBinForFactoryStream, factory, stream)

        self.pipeline.releaseQueueForFactoryStream(factory, stream)

        gst.debug("pouet2")
        self.failUnlessRaises(PipelineError,
                self.pipeline.releaseQueueForFactoryStream, factory, stream)

        # should always fail with a src bin
        factory2 = FakeSourceFactory()
        stream2 = VideoStream(gst.Caps('any'), 'src')
        factory2.addOutputStream(stream2)

        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnlessRaises(PipelineError,
            self.pipeline.getQueueForFactoryStream, factory2, stream2, True)
        self.pipeline.releaseBinForFactoryStream(factory, stream)

        self.pipeline.releaseBinForFactoryStream(factory, stream)
        self.assertEquals(factory.current_bins, 0)
Beispiel #5
0
    def testGetReleaseTeeForFactoryStream(self):
        factory = FakeSourceFactory()
        stream = VideoStream(gst.Caps('any'), 'src')
        factory.addOutputStream(stream)

        self.failUnlessRaises(PipelineError,
            self.pipeline.getTeeForFactoryStream, factory, stream, True)

        # getBinForFactoryStream(factory, stream) must be called before
        self.failUnlessRaises(PipelineError,
            self.pipeline.getTeeForFactoryStream, factory, stream, True)

        # create the bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)

        # try to get a cached tee
        self.failUnlessRaises(PipelineError,
            self.pipeline.getTeeForFactoryStream, factory, stream, False)

        # create tee
        tee1 = self.pipeline.getTeeForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(tee1, gst.Element))

        # get the cached instance
        tee2 = self.pipeline.getTeeForFactoryStream(factory, stream, True)
        self.failUnlessEqual(id(tee1), id(tee2))

        # release
        self.pipeline.releaseTeeForFactoryStream(factory, stream)

        # there's still a tee alive, so we can't release the bin
        #self.failUnlessRaises(PipelineError,
        #        self.pipeline.releaseBinForFactoryStream, factory, stream)

        self.pipeline.releaseTeeForFactoryStream(factory, stream)
        self.failUnlessRaises(PipelineError,
                self.pipeline.releaseTeeForFactoryStream, factory, stream)

        # should always fail with a sink bin
        factory2 = FakeSinkFactory()
        stream2= VideoStream(gst.Caps('any'), 'src')
        factory2.addInputStream(stream2)

        self.failUnlessRaises(PipelineError,
            self.pipeline.getTeeForFactoryStream, factory2, stream2, True)
        self.pipeline.releaseBinForFactoryStream(factory, stream)
Beispiel #6
0
    def testGetReleaseTeeForFactoryStream(self):
        factory = FakeSourceFactory()
        stream = VideoStream(gst.Caps('any'), 'src')
        factory.addOutputStream(stream)

        self.failUnlessRaises(PipelineError,
            self.pipeline.getTeeForFactoryStream, factory, stream, True)

        # getBinForFactoryStream(factory, stream) must be called before
        self.failUnlessRaises(PipelineError,
            self.pipeline.getTeeForFactoryStream, factory, stream, True)

        # create the bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)

        # try to get a cached tee
        self.failUnlessRaises(PipelineError,
            self.pipeline.getTeeForFactoryStream, factory, stream, False)

        # create tee
        tee1 = self.pipeline.getTeeForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(tee1, gst.Element))

        # get the cached instance
        tee2 = self.pipeline.getTeeForFactoryStream(factory, stream, True)
        self.failUnlessEqual(id(tee1), id(tee2))

        # release
        self.pipeline.releaseTeeForFactoryStream(factory, stream)

        # there's still a tee alive, so we can't release the bin
        #self.failUnlessRaises(PipelineError,
        #        self.pipeline.releaseBinForFactoryStream, factory, stream)

        self.pipeline.releaseTeeForFactoryStream(factory, stream)
        self.failUnlessRaises(PipelineError,
                self.pipeline.releaseTeeForFactoryStream, factory, stream)

        # should always fail with a sink bin
        factory2 = FakeSinkFactory()
        stream2= VideoStream(gst.Caps('any'), 'src')
        factory2.addInputStream(stream2)

        self.failUnlessRaises(PipelineError,
            self.pipeline.getTeeForFactoryStream, factory2, stream2, True)
        self.pipeline.releaseBinForFactoryStream(factory, stream)