| 159 | |
| 160 | |
| 161 | def testGoodConstructor(self): |
| 162 | loop = gobject.MainLoop() |
| 163 | gst.info ("creating pipeline") |
| 164 | pipeline = gst.parse_launch("fakesrc ! fakesink") |
| 165 | gst.info ("getting bus") |
| 166 | bus = pipeline.get_bus() |
| 167 | gst.info ("got bus") |
| 168 | gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) |
| 169 | self.assertEquals(bus.__gstrefcount__, 2) |
| 170 | self.assertEquals(pipeline.__gstrefcount__, 1) |
| 171 | gst.info ("about to add a watch on the bus") |
| 172 | watch_id = bus.add_watch(self._message_received, pipeline, loop, "one") |
| 173 | gst.info ("added a watch on the bus") |
| 174 | gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) |
| 175 | self.assertEquals(bus.__gstrefcount__, 3) |
| 176 | self.assertEquals(pipeline.__gstrefcount__, 1) |
| 177 | |
| 178 | gst.info("setting to playing") |
| 179 | ret = pipeline.set_state(gst.STATE_PLAYING) |
| 180 | gst.info("set to playing %s, loop.run" % ret) |
| 181 | gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) |
| 182 | loop.run() |
| 183 | |
| 184 | gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) |
| 185 | gst.info("setting to paused") |
| 186 | ret = pipeline.set_state(gst.STATE_PAUSED) |
| 187 | gst.info("set to paused %s, loop.run" % ret) |
| 188 | gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) |
| 189 | loop.run() |
| 190 | gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) |
| 191 | |
| 192 | gst.info("setting to ready") |
| 193 | ret = pipeline.set_state(gst.STATE_READY) |
| 194 | gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) |
| 195 | gst.info("set to READY %s, loop.run" % ret) |
| 196 | loop.run() |
| 197 | |
| 198 | gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) |
| 199 | gst.info("setting to NULL") |
| 200 | ret = pipeline.set_state(gst.STATE_NULL) |
| 201 | gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) |
| 202 | gst.info("set to NULL %s" % ret) |
| 203 | self.gccollect() |
| 204 | self.assertEquals(bus.__gstrefcount__, 3) |
| 205 | self.assertEquals(pipeline.__gstrefcount__, 1) |
| 206 | |
| 207 | gst.info("about to remove the watch id") |
| 208 | gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) |
| 209 | self.failUnless(gobject.source_remove(watch_id)) |
| 210 | gst.info("bus watch id removed") |
| 211 | gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) |
| 212 | self.gccollect() |
| 213 | gst.info("pipeliner:%d/%d busr:%d" % (pipeline.__gstrefcount__, pipeline.__grefcount__, bus.__gstrefcount__)) |
| 214 | |
| 215 | self.assertEquals(bus.__gstrefcount__, 2) |
| 216 | self.assertEquals(pipeline.__gstrefcount__, 1) |
| 217 | |
| 218 | gst.info("removing pipeline") |