def do_transform_caps(self, direction, caps):
     caps = gst.Caps.copy(caps)
     rate, = [s["rate"] for s in caps]
     if direction == gst.PAD_SRC:
         # Source pad's format is the same as sink pad's
         # except it can have any sample rate equal to or
         # less than the sink pad's. (Really needs to be
         # an integer multiple, actually, but that requirement
         # is not enforced here).
         tmpltcaps = self.get_pad("sink").get_pad_template_caps()
         for n in range(gst.Caps.get_size(caps)):
             s = caps[n]
             if s.has_field_typed("rate", "GstIntRange"):
                 allowed_rate = gst.IntRange(rate.low, gobject.G_MAXINT)
             elif s.has_field_typed("rate", "gint"):
                 allowed_rate = gst.IntRange(rate, gobject.G_MAXINT)
             else:
                 gst.message_new_error(
                     self,
                     gst.GError(gst.CORE_ERROR, gst.CORE_ERROR_NEGOTIATION,
                                "negotiation error"),
                     "invalid type for rate in caps")
     elif direction == gst.PAD_SINK:
         # Source pad's format is the same as sink pad's
         # except it can have any sample rate equal to or
         # less than the sink pad's. (Really needs to be
         # an integer multiple, actually, but that requirement
         # is not enforced here).
         tmpltcaps = self.get_pad("src").get_pad_template_caps()
         for n in range(gst.Caps.get_size(caps)):
             s = caps[n]
             if s.has_field_typed("rate", "GstIntRange"):
                 if rate.high == 1:
                     allowed_rate = 1
                 else:
                     allowed_rate = gst.IntRange(1, rate.high)
             elif s.has_field_typed("rate", "gint"):
                 if rate == 1:
                     allowed_rate = 1
                 else:
                     allowed_rate = gst.IntRange(1, rate)
             else:
                 gst.message_new_error(
                     self,
                     gst.GError(gst.CORE_ERROR, gst.CORE_ERROR_NEGOTIATION,
                                "negotiation error"),
                     "invalid type for rate in caps")
     else:
         raise AssertionError
     result = gst.Caps()
     for s in tmpltcaps:
         s = s.copy()
         s["rate"] = allowed_rate
         result.append_structure(s)
     return result
Пример #2
0
 def pad_event(self, pad, event):
     if event.has_name('urilist-played'):
         error = gst.GError(gst.RESOURCE_ERROR, gst.RESOURCE_ERROR_FAILED,
                            b'Nested playlists not supported.')
         message = b'Playlists pointing to other playlists is not supported'
         self.post_message(gst.message_new_error(self, error, message))
     return 1  # GST_PAD_PROBE_OK
Пример #3
0
    def preview(self):
        logger.debug("recorder preview")
        if not len(self.bins):
            self.dispatcher.emit("recorder-error", "No tracks on profile")
            return False
        else:
            change = self.pipeline.set_state(gst.STATE_PAUSED)

            if change == gst.STATE_CHANGE_FAILURE:
                text = None
                random_bin = None
                for key, value in self.bins.iteritems():
                    if not value.getSource():
                        random_bin = value
                        text = "Error on track : " + key
                    if not random_bin:
                        random_bin = value
                        text = "Error on unknow track"

                src = random_bin
                error = gst.GError(gst.RESOURCE_ERROR,
                                   gst.RESOURCE_ERROR_FAILED, text)

                message = gst.message_new_error(
                    src, error,
                    str(random_bin) + "\nunknown system_error")
                self.bus.post(message)
                #self.dispatcher.emit("recorder-error","Driver error")
                return False
            else:
                return True
Пример #4
0
    def testBusError(self):
        def discovery_error_cb(discoverer, uri, error, debug, dic):
            dic['uri'] = uri
            dic['error'] = error
            dic['debug'] = debug

        dic = {}
        self.discoverer.connect('discovery-error', discovery_error_cb, dic)

        src = gst.Pad('src', gst.PAD_SRC)
        gerror = gst.GError(gst.STREAM_ERROR, gst.STREAM_ERROR_FAILED, 'meh')
        message = gst.message_new_error(src, gerror, 'debug1')

        self.failUnlessEqual(self.discoverer.error, None)
        self.discoverer.addUri('popme')
        self.discoverer._busMessageErrorCb(None, message)
        self.failUnlessEqual(dic['debug'], 'debug1')

        # errors shouldn't be overridden
        gerror = gst.GError(gst.STREAM_ERROR, gst.STREAM_ERROR_FAILED, 'muh')
        message = gst.message_new_error(src, gerror, 'debug2')
        self.discoverer.addUri('popme')
        self.discoverer._busMessageErrorCb(None, message)
        self.failUnlessEqual(dic['debug'], 'debug2')
Пример #5
0
 def _handle_error(self, message):
     err = gst.GError(gst.RESOURCE_ERROR, gst.RESOURCE_ERROR_FAILED,
                      message)
     m = gst.message_new_error(self, err, message)
     self.post_message(m)
     self.error(message)