Beispiel #1
0
Datei: vlc.py Projekt: kmshi/miro
    def __init__(self):
        vlc_logger.info("Initializing VLC")
        plugin_dir = os.path.join(resources.app_root(), 'vlc-plugins')
        self.exc = VLCException()

        # Note: if you need vlc output to stdout, remove the --quiet
        # from the list of arguments.
        vlc_args = [
            "vlc", '--quiet', '--nostats', '--intf', 'dummy',
            '--no-video-title-show', '--plugin-path', plugin_dir
        ]
        self.vlc = libvlc.libvlc_new(len(vlc_args),
                make_string_list(vlc_args), self.exc.ref())
        self.exc.check()
        self.vlc_instance = libvlc.libvlc_get_vlc_instance(self.vlc)
        self.media_player = libvlc.libvlc_media_player_new(self.vlc,
                self.exc.ref())
        self.exc.check()
        self._callback_ref = VLC_EVENT_CALLBACK(self.event_callback)
        self.play_from_time = None
        self.play_state = STOPPED
        self.hwnd = None
        self._duration = None
        self._filename = None
        self._rate = 1.0
        self.media_playing = None
        self.callback_info = None
        self._change_subtitle_timout = None
        self.subtitle_info = []
        self._hidden_window = gtk.gdk.Window(
            None, x=0, y=0, width=1, height=1,
            window_type=gtk.gdk.WINDOW_TOPLEVEL,
            wclass=gtk.gdk.INPUT_OUTPUT, event_mask=0)
        self.unset_widget()
Beispiel #2
0
def launch_download_daemon(oldpid, env):
    kill_process(oldpid)

    # FIXME - wtf is going on here between os.environ, env and
    # environ?
    for key, value in env.items():
        os.environ[key] = value

    environ = os.environ.copy()
    environ['DEMOCRACY_DOWNLOADER_LOG'] = app.config.get(
        prefs.DOWNLOADER_LOG_PATHNAME)
    environ['MIRO_APP_VERSION'] = app.config.get(prefs.APP_VERSION)
    if hasattr(app, 'in_unit_tests'):
        environ['MIRO_IN_UNIT_TESTS'] = '1'
    environ.update(env)

    # start the downloader.  We use the subprocess module to turn off
    # the console.  One slightly awkward thing is that the current
    # process might not have a valid stdin/stdout/stderr, so we create
    # a pipe to it that we never actually use.

    # note that we use "Miro" instead of the app name here, so custom
    # versions will work

    downloader_path = (os.path.join(resources.app_root(),
                                   "Miro_Downloader.exe"),) 
    return Popen(downloader_path, stdout=subprocess.PIPE,
                 stderr=subprocess.PIPE,
                 stdin=subprocess.PIPE,
                 env=environ)
Beispiel #3
0
Datei: vlc.py Projekt: kmshi/miro
    def __init__(self):
        plugin_dir = os.path.join(resources.app_root(), 'vlc-plugins')
        self.exc = VLCException()

        # Note: if you need vlc output to stdout, remove the --quiet
        # from the list of arguments.  Also, you can add -vvv.
        vlc_args = [
            "vlc", '--quiet',
            '--nostats', '--intf', 'dummy', '--volume=0',
            '--no-video-title-show', '--plugin-path', plugin_dir
        ]
        self.vlc = libvlc.libvlc_new(
            len(vlc_args), make_string_list(vlc_args), self.exc.ref())
        self.exc.check()
        self.media_player = libvlc.libvlc_media_player_new(
            self.vlc, self.exc.ref())
        self.exc.check()
        self._callback_ref = VLC_EVENT_CALLBACK(self.event_callback)
        self._filename = None
        self.media_playing = None
        self.callback_info = None

        self._hidden_window = gtk.gdk.Window(
            None, x=0, y=0, width=1, height=1,
            window_type=gtk.gdk.WINDOW_TOPLEVEL,
            wclass=gtk.gdk.INPUT_OUTPUT, event_mask=0)
        libvlc.libvlc_media_player_set_hwnd(
            self.media_player, self._hidden_window.handle, self.exc.ref())
        self.exc.check()
Beispiel #4
0
def launch_download_daemon(oldpid, env):
    kill_process(oldpid)

    # FIXME - wtf is going on here between os.environ, env and
    # environ?
    for key, value in env.items():
        os.environ[key] = value

    environ = os.environ.copy()
    environ['DEMOCRACY_DOWNLOADER_LOG'] = app.config.get(
        prefs.DOWNLOADER_LOG_PATHNAME)
    environ['MIRO_APP_VERSION'] = app.config.get(prefs.APP_VERSION)
    if hasattr(app, 'in_unit_tests'):
        environ['MIRO_IN_UNIT_TESTS'] = '1'
    environ.update(env)

    # start the downloader.  We use the subprocess module to turn off
    # the console.  One slightly awkward thing is that the current
    # process might not have a valid stdin/stdout/stderr, so we create
    # a pipe to it that we never actually use.

    # note that we use "Miro" instead of the app name here, so custom
    # versions will work

    downloader_path = (os.path.join(resources.app_root(),
                                   "Miro_Downloader.exe"),) 
    return Popen(downloader_path, stdout=subprocess.PIPE,
                 stderr=subprocess.PIPE,
                 stdin=subprocess.PIPE,
                 env=environ)
Beispiel #5
0
def startup(argv):
    # Before importing gstreamer, fix os.environ so gstreamer finds its
    # plugins.  Do this early before any code is run to prevent any import
    # of gst missing this!
    from miro.plat import resources
    GST_PLUGIN_PATH = os.path.join(resources.app_root(), 'gstreamer-0.10')
    os.environ["GST_PLUGIN_PATH"] = GST_PLUGIN_PATH
    os.environ["GST_PLUGIN_SYSTEM_PATH"] = GST_PLUGIN_PATH

    theme = None
    # Should have code to figure out the theme.

    from miro.plat import pipeipc
    try:
        pipe_server = pipeipc.Server()
    except pipeipc.PipeExists:
        pipeipc.send_command_line_args()
        return
    pipe_server.start_process()

    from miro.plat import prelogger
    prelogger.install()

    from miro.plat.utils import initialize_locale
    initialize_locale()

    from miro import bootstrap
    bootstrap.bootstrap()

    from miro.plat import commandline
    args = commandline.get_command_line()[1:]

    if '--theme' in args:
        index = args.index('--theme')
        theme = args[index+1]
        del args[index:index+1]

    if '--debug' in args:
        index = args.index('--debug')
        del args[index]
        from miro import app
        app.debugmode = True

    from miro import startup
    startup.initialize(theme)

    from miro.plat import migrateappname
    migrateappname.migrateSupport('Democracy', 'Miro')

    from miro import commandline
    commandline.set_command_line_args(args)

    # Kick off the application
    from miro.plat.frontends.widgets.application import WindowsApplication
    WindowsApplication().run()
    pipe_server.quit()
Beispiel #6
0
def startup(argv):
    # Before importing gstreamer, fix os.environ so gstreamer finds its
    # plugins.  Do this early before any code is run to prevent any import
    # of gst missing this!
    from miro.plat import resources
    GST_PLUGIN_PATH = os.path.join(resources.app_root(), 'gstreamer-0.10')
    os.environ["GST_PLUGIN_PATH"] = GST_PLUGIN_PATH
    os.environ["GST_PLUGIN_SYSTEM_PATH"] = GST_PLUGIN_PATH

    theme = None
    # Should have code to figure out the theme.

    from miro.plat import pipeipc
    try:
        pipe_server = pipeipc.Server()
    except pipeipc.PipeExists:
        pipeipc.send_command_line_args()
        return
    pipe_server.start_process()

    from miro.plat import prelogger
    prelogger.install()

    from miro.plat.utils import initialize_locale
    initialize_locale()

    from miro import bootstrap
    bootstrap.bootstrap()

    from miro.plat import commandline
    args = commandline.get_command_line()[1:]

    if '--theme' in args:
        index = args.index('--theme')
        theme = args[index + 1]
        del args[index:index + 1]

    if '--debug' in args:
        index = args.index('--debug')
        del args[index]
        from miro import app
        app.debugmode = True

    from miro import startup
    startup.initialize(theme)

    from miro.plat import migrateappname
    migrateappname.migrateSupport('Democracy', 'Miro')

    from miro import commandline
    commandline.set_command_line_args(args)

    # Kick off the application
    from miro.plat.frontends.widgets.application import WindowsApplication
    WindowsApplication().run()
    pipe_server.quit()
Beispiel #7
0
 def _get_icon_location(self):
     # we set the icon first (if available) so that it doesn't flash
     # on when the window is realized in Application.build_window()
     icopath = os.path.join(resources.app_root(), "Miro.ico")
     if app.config.get(prefs.THEME_NAME) and app.config.get(options.WINDOWS_ICON):
         themeIcoPath = resources.theme_path(app.config.get(prefs.THEME_NAME),
                                             app.config.get(options.WINDOWS_ICON))
         if os.path.exists(themeIcoPath):
             icopath = themeIcoPath
     gtk.window_set_default_icon_from_file(icopath)
     return icopath
Beispiel #8
0
def launch_download_daemon(oldpid, env):
    kill_process(oldpid)

    # FIXME - wtf is going on here between os.environ, env and
    # environ?
    for key, value in env.items():
        os.environ[key] = value

    environ = os.environ.copy()
    environ['DEMOCRACY_DOWNLOADER_LOG'] = app.config.get(
        prefs.DOWNLOADER_LOG_PATHNAME)
    environ['MIRO_APP_VERSION'] = app.config.get(prefs.APP_VERSION)
    if hasattr(app, 'in_unit_tests'):
        environ['MIRO_IN_UNIT_TESTS'] = '1'
    environ.update(env)

    # on windows, subprocess can ONLY accept strings (no unicode) in
    # environment values.  at present this affects FFMPEG_DATADIR
    # which doesn't matter in the downloader, so we remove it.
    del environ["FFMPEG_DATADIR"]
    del environ["GST_PLUGIN_PATH"]
    del environ["GST_PLUGIN_SYSTEM_PATH"]

    # start the downloader.  We use the subprocess module to turn off
    # the console.  One slightly awkward thing is that the current
    # process might not have a valid stdin/stdout/stderr, so we create
    # a pipe to it that we never actually use.

    # note that we use "Miro" instead of the app name here, so custom
    # versions will work

    # note that the application filename has to be in double-quotes
    # otherwise it kicks up "%1 is not a valid Win32 application"
    # errors on some Windows machines.  Why it only happens on some is
    # a mystery of the universe.  Bug #9274.
    downloader_path = '"%s"' % os.path.join(resources.app_root(),
                                           "Miro_Downloader.exe")
    startupinfo = subprocess.STARTUPINFO()
    # TEMPORARY: the STARTF_USESHOWWINDOW has been moved into
    # subprocess._subprocess in Python 2.6.6 and beyond.
    try:
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    except AttributeError:
        startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW

    subprocess.Popen(downloader_path, stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE,
                     stdin=subprocess.PIPE,
                     startupinfo=startupinfo,
                     env=environ)
Beispiel #9
0
def launch_download_daemon(oldpid, env):
    kill_process(oldpid)
    for key, value in env.items():
        os.environ[key] = value

    environ = os.environ.copy()
    environ['DEMOCRACY_DOWNLOADER_LOG'] = app.config.get(
        prefs.DOWNLOADER_LOG_PATHNAME)
    environ['MIRO_APP_VERSION'] = app.config.get(prefs.APP_VERSION)
    if hasattr(app, 'in_unit_tests'):
        environ['MIRO_IN_UNIT_TESTS'] = '1'
    environ.update(env)

    # on windows, subprocess can ONLY accept strings (no unicode) in
    # environment values.  at present this affects FFMPEG_DATADIR
    # which doesn't matter in the downloader, so we remove it.
    del environ["FFMPEG_DATADIR"]

    # start the downloader.  We use the subprocess module to turn off
    # the console.  One slightly awkward thing is that the current
    # process might not have a valid stdin/stdout/stderr, so we create
    # a pipe to it that we never actually use.

    # note that we use "Miro" instead of the app name here, so custom
    # versions will work

    # note that the application filename has to be in double-quotes
    # otherwise it kicks up "%1 is not a valid Win32 application"
    # errors on some Windows machines.  Why it only happens on some is
    # a mystery of the universe.  Bug #9274.
    downloader_path = '"%s"' % os.path.join(resources.app_root(),
                                            "Miro_Downloader.exe")
    startupinfo = subprocess.STARTUPINFO()
    # TEMPORARY: the STARTF_USESHOWWINDOW has been moved into
    # subprocess._subprocess in Python 2.6.6 and beyond.
    try:
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    except AttributeError:
        startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
    subprocess.Popen(downloader_path,
                     stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE,
                     stdin=subprocess.PIPE,
                     startupinfo=startupinfo,
                     env=environ)
Beispiel #10
0
def test_startup(argv):
    import sys
    import logging
    logging.basicConfig(level=logging.CRITICAL)

    from miro import app
    app.debugmode = True

    from miro.plat import utils
    utils.initialize_locale()

    from miro import bootstrap
    bootstrap.bootstrap()

    from miro import test
    from miro.plat import resources

    sys.path.append(resources.app_root())
    test.run_tests()
Beispiel #11
0
def test_startup(argv):
    import sys
    import logging
    logging.basicConfig(level=logging.CRITICAL)

    from miro import app
    app.debugmode = True

    from miro.plat import utils
    utils.initialize_locale()

    from miro import bootstrap
    bootstrap.bootstrap()

    from miro import test
    from miro.plat import resources

    sys.path.append(resources.app_root())
    test.run_tests()
Beispiel #12
0
def launch_download_daemon(oldpid, env):
    kill_process(oldpid)

    # FIXME - wtf is going on here between os.environ, env and
    # environ?
    for key, value in env.items():
        os.environ[key] = value

    environ = os.environ.copy()
    environ['DEMOCRACY_DOWNLOADER_LOG'] = app.config.get(
        prefs.DOWNLOADER_LOG_PATHNAME)
    environ['MIRO_APP_VERSION'] = app.config.get(prefs.APP_VERSION)
    if hasattr(app, 'in_unit_tests'):
        environ['MIRO_IN_UNIT_TESTS'] = '1'
    environ.update(env)

    # note that we use "Miro" instead of the app name here, so custom
    # versions will work

    downloader_path = (os.path.join(resources.app_root(),
                                    "Miro_Downloader.exe"), )
    return Popen(downloader_path, close_fds=True, env=environ)
Beispiel #13
0
def launch_download_daemon(oldpid, env):
    kill_process(oldpid)

    # FIXME - wtf is going on here between os.environ, env and
    # environ?
    for key, value in env.items():
        os.environ[key] = value

    environ = os.environ.copy()
    environ['DEMOCRACY_DOWNLOADER_LOG'] = app.config.get(
        prefs.DOWNLOADER_LOG_PATHNAME)
    environ['MIRO_APP_VERSION'] = app.config.get(prefs.APP_VERSION)
    if hasattr(app, 'in_unit_tests'):
        environ['MIRO_IN_UNIT_TESTS'] = '1'
    environ.update(env)

    # note that we use "Miro" instead of the app name here, so custom
    # versions will work

    downloader_path = (os.path.join(resources.app_root(),
                                   "Aurora_Downloader.exe"),) 
    return Popen(downloader_path, close_fds=True, env=environ)
Beispiel #14
0
def get_enmfp_executable_info():
    return {
        'path': os.path.join(resources.app_root(), "codegen.windows.exe")
    }
Beispiel #15
0
def get_segmenter_executable_path():
    return os.path.join(resources.app_root(), "miro-segmenter.exe")
Beispiel #16
0
def get_enmfp_executable_info():
    return {'path': os.path.join(resources.app_root(), "codegen.windows.exe")}
Beispiel #17
0
def setup_ffmpeg_presets():
    from miro.plat.specialfolders import get_short_path_name
    os.environ['AVCONV_DATADIR'] = get_short_path_name(resources.app_root())
Beispiel #18
0
def miro_helper_program_info():
    cmd_line = (os.path.join(resources.app_root(), 'Miro_Helper.exe'),)
    env = None
    return (cmd_line, env)
Beispiel #19
0
def movie_data_program_info(movie_path, thumbnail_path):
    exe_path = os.path.join(resources.app_root(), 'Miro_MovieData.exe')
    cmd_line = (exe_path, movie_path, thumbnail_path)
    env = None
    return (cmd_line, env)
Beispiel #20
0
def setup_ffmpeg_presets():
    os.environ['FFMPEG_DATADIR'] = resources.app_root()
Beispiel #21
0
def get_segmenter_executable_path():
    return os.path.join(resources.app_root(), "miro-segmenter.exe")
Beispiel #22
0
def startup(argv):
    # Rewrite the stdout and stderr to catch cases debug being printed via
    # a print or via a write to stderr.  Normally we would use shortAppName
    # but at this point nothing has been bootstrapped yet.  We only want to
    # catch it though if py2exe has fiddled with our file descriptors.
    #
    # The stdout/stderr are redirected again in the Windows-specific
    # setup_logging(). 
    #
    # See bz17793
    redirected = sys.stdout != sys.__stdout__
    if redirected:
        try:
            logfile = os.path.join(tempfile.gettempdir(), 'Miro_console.log')
            sys.stderr = sys.stdout = open(logfile, 'w')
        except EnvironmentError:
            # too bad ... let's silence rather than spew stuff to stop it 
            # writing to a file that it might not have permissions to.  
            # Hopefully, this does not happen often.
            sys.stderr = sys.stdout = open(os.devnull, 'w')

    # Before importing gstreamer, fix os.environ so gstreamer finds its
    # plugins.  Do this early before any code is run to prevent any import
    # of gst missing this!
    from miro.plat import resources
    from miro.plat import config
    GST_PLUGIN_PATH = os.path.join(resources.app_root(), 'gstreamer-0.10')
    os.environ["GST_PLUGIN_PATH"] = GST_PLUGIN_PATH
    os.environ["GST_PLUGIN_SYSTEM_PATH"] = GST_PLUGIN_PATH
    # normally we'd use app.config to get this, but we're starting up
    os.environ["GST_REGISTRY"] = os.path.join(config._get_support_directory(),
                                              'gst_registry.bin')

    theme = None
    # Should have code to figure out the theme.

    from miro.plat import pipeipc
    try:
        pipe_server = pipeipc.Server()
    except pipeipc.PipeExists:
        pipeipc.send_command_line_args()
        return
    pipe_server.start_process()

    from miro.plat import prelogger
    prelogger.install()

    from miro.plat.utils import initialize_locale
    initialize_locale()

    from miro import bootstrap
    bootstrap.bootstrap()

    from miro.plat import commandline
    args = commandline.get_command_line()[1:]

    if '--theme' in args:
        index = args.index('--theme')
        theme = args[index+1]
        del args[index:index+1]

    if '--debug' in args:
        index = args.index('--debug')
        del args[index]
        from miro import app
        app.debugmode = True

    from miro import startup
    startup.initialize(theme)

    from miro.plat import migrateappname
    migrateappname.migrateSupport('Democracy', 'Miro')

    from miro import commandline
    commandline.set_command_line_args(args)

    # Kick off the application
    startfrontend.run_application('widgets', {}, None)
    pipe_server.quit()
Beispiel #23
0
def miro_helper_program_info():
    cmd_line = (os.path.join(resources.app_root(), 'Miro_Helper.exe'),)
    env = None
    return (cmd_line, env)
Beispiel #24
0
def startup(argv):
    # Rewrite the stdout and stderr to catch cases debug being printed via
    # a print or via a write to stderr.  Normally we would use shortAppName
    # but at this point nothing has been bootstrapped yet.  We only want to
    # catch it though if py2exe has fiddled with our file descriptors.
    #
    # The stdout/stderr are redirected again in the Windows-specific
    # setup_logging().
    #
    # See bz17793
    redirected = sys.stdout != sys.__stdout__
    if redirected:
        try:
            logfile = os.path.join(tempfile.gettempdir(), 'Miro_console.log')
            sys.stderr = sys.stdout = open(logfile, 'w')
        except EnvironmentError:
            # too bad ... let's silence rather than spew stuff to stop it
            # writing to a file that it might not have permissions to.
            # Hopefully, this does not happen often.
            sys.stderr = sys.stdout = open(os.devnull, 'w')

    # Before importing gstreamer, fix os.environ so gstreamer finds its
    # plugins.  Do this early before any code is run to prevent any import
    # of gst missing this!
    from miro.plat import resources
    from miro.plat import config
    GST_PLUGIN_PATH = os.path.join(resources.app_root(), 'gstreamer-0.10')
    os.environ["GST_PLUGIN_PATH"] = GST_PLUGIN_PATH
    os.environ["GST_PLUGIN_SYSTEM_PATH"] = GST_PLUGIN_PATH
    # normally we'd use app.config to get this, but we're starting up
    os.environ["GST_REGISTRY"] = os.path.join(config._get_support_directory(),
                                              'gst_registry.bin')

    theme = None
    # Should have code to figure out the theme.

    from miro.plat import pipeipc
    try:
        pipe_server = pipeipc.Server()
    except pipeipc.PipeExists:
        pipeipc.send_command_line_args()
        return
    pipe_server.start_process()

    from miro.plat import prelogger
    prelogger.install()

    from miro.plat.utils import initialize_locale
    initialize_locale()

    from miro import bootstrap
    bootstrap.bootstrap()

    from miro.plat import commandline
    args = commandline.get_command_line()[1:]

    if '--theme' in args:
        index = args.index('--theme')
        theme = args[index + 1]
        del args[index:index + 1]

    if '--debug' in args:
        index = args.index('--debug')
        del args[index]
        from miro import app
        app.debugmode = True

    from miro.plat import migrateappname
    migrateappname.migrateSupport('Democracy', 'Miro')

    from miro import commandline
    commandline.set_command_line_args(args)

    # Kick off the application
    from miro import startfrontend
    startfrontend.run_application('widgets', {}, None)
    pipe_server.quit()
Beispiel #25
0
def setup_ffmpeg_presets():
    from miro.plat.specialfolders import get_short_path_name
    os.environ['AVCONV_DATADIR'] = get_short_path_name(
        resources.app_root())
Beispiel #26
0
def get_ffmpeg2theora_executable_path():
    return os.path.join(resources.app_root(), "ffmpeg2theora.exe")
Beispiel #27
0
def get_ffmpeg2theora_executable_path():
    return os.path.join(resources.app_root(), "ffmpeg2theora.exe")
Beispiel #28
0
def movie_data_program_info(movie_path, thumbnail_path):
    exe_path = os.path.join(resources.app_root(), 'Miro_MovieData.exe')
    cmd_line = (exe_path, movie_path, thumbnail_path)
    env = None
    return (cmd_line, env)
Beispiel #29
0
# permission to link the code of portions of this program with the OpenSSL
# library.
#
# You must obey the GNU General Public License in all respects for all of
# the code used other than OpenSSL. If you modify file(s) with this
# exception, you may extend this exception to your version of the file(s),
# but you are not obligated to do so. If you do not wish to do so, delete
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.

"""gstreamerrenderer.py -- Windows gstreamer renderer """

# Before importing gstreamer, fix os.environ so gstreamer finds it's plugins
import os
from miro.plat import resources
GST_PLUGIN_PATH = os.path.join(resources.app_root(), 'gstreamer-0.10')
os.environ["GST_PLUGIN_PATH"] = GST_PLUGIN_PATH
os.environ["GST_PLUGIN_SYSTEM_PATH"] = GST_PLUGIN_PATH

import pygst
pygst.require('0.10')
import gst

from miro import app
from miro.frontends.widgets.gst import renderer

# We need to define get_item_type().  Use the version from sniffer.
from miro.frontends.widgets.gst.sniffer import get_item_type

class WindowsSinkFactory(renderer.SinkFactory):
    """Windows class to create gstreamer audio/video sinks.