Exemplo n.º 1
0
def handle_message(data, msg):
    if message.type == gst.MESSAGE_ERROR:
        err, debug = message.parse_error()
        print >> sys.stderr, "Error received from element %s: %s" % (
            message.src.get_name(), err)
        print >> sys.stderr, "Debugging information: %s" % debug
        data["terminate"] = True
    elif message.type == gst.MESSAGE_EOS:
        print "End-Of-Stream reached."
        data["terminate"] = True
    elif message.type == gst.MESSAGE_DURATION:
        # The duration has changed, mark the current one as invalid
        data["duration"] = gst.CLOCK_TIME_NONE
    elif message.type == gst.MESSAGE_STATE_CHANGED:
        if message.src == data["playbin2"]:
            old_state, new_state, pending_state = message.parse_state_changed()
            print("Pipeline state changed from %s to %s." %
                  (gst.element_state_get_name(old_state),
                   gst.element_state_get_name(new_state)))
            data["playing"] = (new_state == gst.STATE_PLAYING)
            if data["playing"]:
                query = gst.query_new_seeking(gst.FORMAT_TIME)
                if data["playbin2"].query(query):
                    (aux, data["seek_enabled"], start,
                     end) = query.parse_seeking()
                    if data["seek_enabled"]:
                        print "Seeking is ENABLED from %s to %s" % (
                            convert_ns(start), convert_ns(end))
                    else:
                        print "Seeking is DISABLED for this stream."
                else:
                    print >> sys.stderr, "Seeking query failed."

    else:
        print >> sys.stderr, "Unexpected message received."
def handle_message(data, msg):
    if message.type == gst.MESSAGE_ERROR:
        err, debug = message.parse_error()
        print >> sys.stderr, "Error received from element %s: %s"% (message.src.get_name(), err)
        print >> sys.stderr, "Debugging information: %s"% debug
        data["terminate"] = True
    elif message.type == gst.MESSAGE_EOS:
        print "End-Of-Stream reached."
        data["terminate"] = True
    elif message.type == gst.MESSAGE_DURATION:
        # The duration has changed, mark the current one as invalid
        data["duration"] = gst.CLOCK_TIME_NONE
    elif message.type == gst.MESSAGE_STATE_CHANGED:
        if message.src == data["playbin2"]:
            old_state, new_state, pending_state = message.parse_state_changed()
            print ("Pipeline state changed from %s to %s."% 
                   (gst.element_state_get_name(old_state), gst.element_state_get_name (new_state)))
            data["playing"] = (new_state == gst.STATE_PLAYING)
            if data["playing"]:
                query = gst.query_new_seeking(gst.FORMAT_TIME)
                if data["playbin2"].query(query):
                    (aux, data["seek_enabled"], start, end) = query.parse_seeking()
                    if data["seek_enabled"]:
                        print "Seeking is ENABLED from %s to %s"%(convert_ns(start), convert_ns(end))
                    else:
                        print "Seeking is DISABLED for this stream."
                else:
                    print >> sys.stderr, "Seeking query failed."

                                      
                
            
    else:
        print >> sys.stderr, "Unexpected message received."
Exemplo n.º 3
0
def _query_seekable(pipeline):
    query = gst.query_new_seeking(gst.FORMAT_TIME)
    pipeline.query(query)
    return query.parse_seeking()[1]
Exemplo n.º 4
0
def _query_seekable(pipeline):
    query = gst.query_new_seeking(gst.FORMAT_TIME)
    pipeline.query(query)
    return query.parse_seeking()[1]