コード例 #1
0
ファイル: utils.py プロジェクト: Letractively/timeside
def get_uri(source):
    """
    Check a media source as a valid file or uri and return the proper uri
    """

    import gst
    # Is this an valid URI source
    if gst.uri_is_valid(source):
        uri_protocol = gst.uri_get_protocol(source)
        if gst.uri_protocol_is_supported(gst.URI_SRC, uri_protocol):
            return source
        else:
            raise IOError('Invalid URI source for Gstreamer')

    # is this a file?
    import os.path
    if os.path.exists(source):
        # get the absolute path
        pathname = os.path.abspath(source)
        # and make a uri of it
        uri = path2uri(pathname)

        return get_uri(uri)
    else:
        raise IOError('Failed getting uri for path %s: not such file or directoy' % source)

    return uri
コード例 #2
0
ファイル: utils.py プロジェクト: ma4ank/TimeSide
def get_uri(source):
    """
    Check a media source as a valid file or uri and return the proper uri
    """

    import gst

    src_info = source_info(source)

    if src_info['is_file']:  # Is this a file?
        return get_uri(src_info['uri'])

    elif gst.uri_is_valid(source):  # Is this a valid URI source for Gstreamer
        uri_protocol = gst.uri_get_protocol(source)
        if gst.uri_protocol_is_supported(gst.URI_SRC, uri_protocol):
            return source
        else:
            raise IOError('Invalid URI source for Gstreamer')
    else:
        raise IOError('Failed getting uri for path %s: no such file' % source)
コード例 #3
0
ファイル: utils.py プロジェクト: Eyepea/TimeSide
def get_uri(source):
    """
    Check a media source as a valid file or uri and return the proper uri
    """

    import gst

    src_info = source_info(source)

    if src_info['is_file']:  # Is this a file?
        return get_uri(src_info['uri'])

    elif gst.uri_is_valid(source):  # Is this a valid URI source for Gstreamer
        uri_protocol = gst.uri_get_protocol(source)
        if gst.uri_protocol_is_supported(gst.URI_SRC, uri_protocol):
            return source
        else:
            raise IOError('Invalid URI source for Gstreamer')
    else:
        raise IOError('Failed getting uri for path %s: no such file' % source)
コード例 #4
0
    def live_pipeline(self, w=None):

        if self.player:
            self.player.set_state(gst.STATE_NULL)

        uri = self.uri.get_text()

        if uri != None :

            if gst.uri_is_valid (uri) is False:
                self.status.set_label("Invalid URI. Please verify.")
                gst.debug("Invalid URI")
                return
            if gst.uri_protocol_is_supported(gst.URI_SRC,
                                             uri.split('://')[0]):
                self.setSinks(uri)
                self.player.set_state(gst.STATE_PLAYING)
                self.status.push(self.status_id, "")
            else:
                self.status.set_label("Unsupported Protocol. Please verify the URI.")
                gst.debug("Unsupported Protocol")
コード例 #5
0
    def live_pipeline(self, w=None):

        if self.player:
            self.player.set_state(gst.STATE_NULL)

        uri = self.uri.get_text()

        if uri != None :

            if gst.uri_is_valid (uri) is False:
                self.status.set_label("Invalid URI. Please verify.")
                gst.debug("Invalid URI")
                return
            if gst.uri_protocol_is_supported(gst.URI_SRC,
                                             uri.split('://')[0]):
                self.setSinks(uri)
                self.player.set_state(gst.STATE_PLAYING)
                self.status.push(self.status_id, "")
            else:
                self.status.set_label("Unsupported Protocol. Please verify the URI.")
                gst.debug("Unsupported Protocol")
コード例 #6
0
    def capture_pipeline(self, w=None):

        uri = self.uri.get_text()
        if self.capture_btn.get_label() == "Capture":
            if self.player is False and gst.uri_protocol_is_supported(gst.URI_SRC, uri.split('://')[0]) is False :
                self.status.set_label("Unsupported Protocol. Please verify the URI.")
                return
            elif self.player is False:
                self.player.set_state(gst.STATE_NULL)
                self.setSinks(uri)


            gst.debug("recording started")
            self.filepath = 'file://'+tempfile.mktemp()+'.ogg'
            self.player.record(self.filepath, ExportSettings())
            self.capture_btn.set_label("Stop")


        else:
            gst.debug("recording stopped")
            self.player.stopRecording()
            self.sourcefactories.sourcelist.addUris([self.filepath])
            self.capture_btn.set_label("Capture")
コード例 #7
0
    def capture_pipeline(self, w=None):

        uri = self.uri.get_text()
        if self.capture_btn.get_label() == "Capture":
            if self.player is False and gst.uri_protocol_is_supported(gst.URI_SRC, uri.split('://')[0]) is False :
                self.status.set_label("Unsupported Protocol. Please verify the URI.")
                return
            elif self.player is False:
                self.player.set_state(gst.STATE_NULL)
                self.setSinks(uri)


            gst.debug("recording started")
            self.filepath = 'file://'+tempfile.mktemp()+'.ogg'
            self.player.record(self.filepath, ExportSettings())
            self.capture_btn.set_label("Stop")


        else:
            gst.debug("recording stopped")
            self.player.stopRecording()
            self.sourcefactories.sourcelist.addUris([self.filepath])
            self.capture_btn.set_label("Capture")