Exemple #1
0
    def newBlankProject(self):
        """ start up a new blank project """
        # if there's a running project we must close it
        if self.current is not None and not self.closeRunningProject():
            return False

        # we don't have an URI here, None means we're loading a new project
        self.emit("new-project-loading", None)
        project = Project(_("New Project"))
        self.emit("new-project-created", project)
        self.current = project

        # FIXME: this should not be hard-coded
        # add default tracks for a new project
        video = VideoStream(gst.Caps('video/x-raw-rgb; video/x-raw-yuv'))
        track = Track(video)
        project.timeline.addTrack(track)
        audio = AudioStream(gst.Caps('audio/x-raw-int; audio/x-raw-float'))
        track = Track(audio)
        project.timeline.addTrack(track)
        project.connect("project-changed", self._projectChangedCb)

        self.emit("new-project-loaded", self.current)

        return True
Exemple #2
0
    def newBlankProject(self):
        """ start up a new blank project """
        # if there's a running project we must close it
        if self.current is not None and not self.closeRunningProject():
            return False

        # we don't have an URI here, None means we're loading a new project
        self.emit("new-project-loading", None)
        project = Project(_("New Project"))
        self.emit("new-project-created", project)
        self.current = project

        # FIXME: this should not be hard-coded
        # add default tracks for a new project
        video = VideoStream(gst.Caps('video/x-raw-rgb; video/x-raw-yuv'))
        track = Track(video)
        project.timeline.addTrack(track)
        audio = AudioStream(gst.Caps('audio/x-raw-int; audio/x-raw-float'))
        track = Track(audio)
        project.timeline.addTrack(track)
        project.connect("project-changed", self._projectChangedCb)

        self.emit("new-project-loaded", self.current)

        return True
Exemple #3
0
    def newBlankProject(self):
        """ start up a new blank project """
        # if there's a running project we must close it
        if self.current is not None and not self.closeRunningProject():
            return False

        # we don't have an URI here, None means we're loading a new project
        self.emit("new-project-loading", None)
        project = Project(_("New Project"))

        # setting default values for project metadata
        project.author = getpwuid(os.getuid()).pw_gecos.split(",")[0]

        self.emit("new-project-created", project)
        self.current = project

        # FIXME: this should not be hard-coded
        # add default tracks for a new project
        settings = project.getSettings()
        video = VideoStream(gst.Caps(settings.getVideoCaps()))
        track = Track(video)
        project.timeline.addTrack(track)
        audio = AudioStream(gst.Caps(settings.getAudioCaps()))
        track = Track(audio)
        project.timeline.addTrack(track)
        project.connect("project-changed", self._projectChangedCb)

        self.emit("new-project-loaded", self.current)

        return True
Exemple #4
0
    def testLoadedCallback(self):
        def loaded(project, timeline, mainloop, result):
            result[0] = True
            mainloop.quit()

        def quit(mainloop):
            mainloop.quit()

        # Create a blank project and save it.
        project = Project("noname")
        result = [False]
        project.connect("loaded", loaded, self.mainloop, result)

        self.assertTrue(project.createTimeline())
        GLib.timeout_add_seconds(5, quit, self.mainloop)
        self.mainloop.run()
        self.assertTrue(result[0], "Blank project creation failed to trigger signal: loaded")

        # Load the blank project and make sure "loaded" is triggered.
        unused, xges_path = tempfile.mkstemp()
        uri = "file://%s" % xges_path
        try:
            project.save(project.timeline, uri, None, overwrite=True)

            project2 = Project(uri=uri)
            self.assertTrue(project2.createTimeline())
            result = [False]
            project2.connect("loaded", loaded, self.mainloop, result)
            GLib.timeout_add_seconds(5, quit, self.mainloop)
            self.mainloop.run()
            self.assertTrue(result[0], "Blank project loading failed to trigger signal: loaded")
        finally:
            os.remove(xges_path)
    def test_name(self):
        project = Project(common.create_pitivi_mock())

        project.uri = "file:///tmp/A%20B.xges"
        self.assertEqual(project.name, "A B")

        project.uri = "file:///tmp/%40%23%24%5E%26%60.xges"
        self.assertEqual(project.name, "@#$^&`")
Exemple #6
0
    def test_name(self):
        project = Project(common.create_pitivi_mock())

        project.uri = "file:///tmp/A%20B.xges"
        self.assertEqual(project.name, "A B")

        project.uri = "file:///tmp/%40%23%24%5E%26%60.xges"
        self.assertEqual(project.name, "@#$^&`")
Exemple #7
0
    def testLoadProject(self):
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        audio_stream = AudioStream(gst.Caps("audio/x-raw-int"))
        source1 = VideoTestSourceFactory()

        self.formatter._saveSource(source1)
        self.formatter._saveStream(video_stream)

        track_object = SourceTrackObject(source1,
                                         video_stream,
                                         start=10 * gst.SECOND,
                                         duration=20 * gst.SECOND,
                                         in_point=5 * gst.SECOND,
                                         media_duration=15 * gst.SECOND,
                                         priority=10)

        track = Track(video_stream)
        track.addTrackObject(track_object)

        self.formatter._saveTrackObject(track_object)

        timeline_object = TimelineObject(source1)
        timeline_object.addTrackObject(track_object)

        self.formatter._saveTimelineObject(timeline_object)

        timeline = Timeline()
        timeline.addTrack(track)

        self.formatter._saveTimeline(timeline)

        project = Project()
        project.timeline = timeline
        project.sources.addFactory(source1)

        element = self.formatter._serializeProject(project)

        self.failUnlessEqual(element.tag, "pitivi")
        self.failIfEqual(element.find("factories"), None)
        self.failIfEqual(element.find("timeline"), None)

        indent(element)
        f = file("/tmp/untitled.pptv", "w")
        f.write(tostring(element))
        f.close()
Exemple #8
0
    def testLoadTimeline(self):
        # we need a project for this to work
        self.formatter.project = Project()

        # create fake document tree
        timeline_element = Element("timeline")

        tracks_element = SubElement(timeline_element, "tracks")
        track_element = SubElement(tracks_element, "track")
        stream_element = SubElement(track_element,
                                    "stream",
                                    id="1",
                                    type="pitivi.stream.VideoStream",
                                    caps="video/x-raw-rgb")
        track_objects_element = SubElement(track_element, "track-objects")
        track_object = SubElement(
            track_objects_element,
            "track-object",
            type="pitivi.timeline.track.SourceTrackObject",
            start=ts(1 * gst.SECOND),
            duration=ts(10 * gst.SECOND),
            in_point=ts(5 * gst.SECOND),
            media_duration=ts(15 * gst.SECOND),
            priority=ts(5),
            id="1")
        factory_ref = SubElement(track_object, "factory-ref", id="1")
        stream_ref = SubElement(track_object, "stream-ref", id="1")
        timeline_objects_element = SubElement(timeline_element,
                                              "timeline-objects")
        timeline_object_element = \
                SubElement(timeline_objects_element, "timeline-object")
        factory_ref = SubElement(timeline_object_element,
                                 "factory-ref",
                                 id="1")
        stream_ref = SubElement(timeline_object_element, "stream-ref", id="1")
        track_object_refs = SubElement(timeline_object_element,
                                       "track-object-refs")
        track_object_ref = SubElement(track_object_refs,
                                      "track-object-ref",
                                      id="1")

        # insert fake streams and factories into context
        factory = VideoTestSourceFactory()
        self.formatter._context.factories["1"] = factory
        stream = VideoStream(gst.Caps("video/x-raw-rgb"))
        self.formatter._context.streams["1"] = stream
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        source1 = VideoTestSourceFactory()
        self.formatter._context.factories["2"] = source1
        self.formatter._context.track_objects["1"] = SourceTrackObject(
            source1, video_stream)

        # point gun at foot; pull trigger
        self.formatter._loadTimeline(timeline_element)
        self.failUnlessEqual(len(self.formatter.project.timeline.tracks), 1)
    def testLoadProject(self):
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        audio_stream = AudioStream(gst.Caps("audio/x-raw-int"))
        source1 = VideoTestSourceFactory()

        self.formatter._saveSource(source1)
        self.formatter._saveStream(video_stream)

        track_object = SourceTrackObject(source1, video_stream,
                start=10 * gst.SECOND, duration=20 * gst.SECOND,
                in_point=5 * gst.SECOND, media_duration=15 * gst.SECOND,
                priority=10)

        track = Track(video_stream)
        track.addTrackObject(track_object)

        self.formatter._saveTrackObject(track_object)

        timeline_object = TimelineObject(source1)
        timeline_object.addTrackObject(track_object)

        self.formatter._saveTimelineObject(timeline_object)

        timeline = Timeline()
        timeline.addTrack(track)

        self.formatter._saveTimeline(timeline)

        project = Project()
        project.timeline = timeline
        project.sources.addFactory(source1)

        element = self.formatter._serializeProject(project)

        self.failUnlessEqual(element.tag, "pitivi")
        self.failIfEqual(element.find("factories"), None)
        self.failIfEqual(element.find("timeline"), None)

        indent(element)
        f = file("/tmp/untitled.pptv", "w")
        f.write(tostring(element))
        f.close()
Exemple #10
0
    def testAssetAddingRemovingAdding(self):
        def loaded(project, timeline, mainloop, result, uris):
            result[0] = True
            project.addUris(uris)

        def added(project, mainloop, result, uris):
            result[1] = True
            assets = project.list_assets(GES.UriClip)
            asset = assets[0]
            project.remove_asset(asset)
            GLib.idle_add(readd, mainloop, result, uris)

        def readd(mainloop, result, uris):
            project.addUris(uris)
            result[2] = True
            mainloop.quit()

        def quit(mainloop):
            mainloop.quit()

        # Create a blank project and save it.
        project = Project("noname")
        result = [False, False, False]
        uris = ["file://%s/samples/tears of steel.webm" % os.path.dirname(os.path.abspath(__file__))]
        project.connect("loaded", loaded, self.mainloop, result, uris)
        project.connect("done-importing", added, self.mainloop, result, uris)

        self.assertTrue(project.createTimeline())
        GLib.timeout_add_seconds(5, quit, self.mainloop)
        self.mainloop.run()
        self.assertTrue(result[0], "Project creation failed to trigger signal: loaded")
        self.assertTrue(result[1], "Asset add failed to trigger signal: done-importing")
        self.assertTrue(result[2], "Asset re-adding failed")
 def testLoad(self):
     project = Project(uri="fake.xges", app=common.create_pitivi_mock())
     self.assertEqual(project.name, "fake")
     self.assertFalse(project._has_default_video_settings)
     self.assertFalse(project._has_default_audio_settings)
Exemple #12
0
 def __load_thumb_cb(self):
     self.__thumb.set_from_pixbuf(Project.get_thumb(self.uri))
     return False
Exemple #13
0
 def __load_thumb_cb(self):
     self.__thumb.set_from_pixbuf(Project.get_thumb(self.uri))
     return False
Exemple #14
0
 def setUp(self):
     self.project = Project()