support/testing: fix test_gst1_python

The config is missing the following packages:
  - BR2_PACKAGE_GST1_PLUGINS_BASE
    This is needed for the videotestsrc plugin which provides
    videotestsrc.

  - BR2_PACKAGE_GST1_PLUGINS_BAD
    This is needed for the debugutils plugin which provides
    fakevideosink.

  - BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_VIDEOTESTSRC
    videotestsrcplugin used by the example pipeline.

  - BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_DEBUGUTILS
    fakevideosink plugin used by the example pipeline.

The sample was also amended to fix:
  - no call to main.

  - using autovideosink instead of fakevideosink. Using Fakevideoskink
    is preferred because its primary purpose is for debugging and sample
    pipelines. Autovideosink does not work because there is no video
    output device.

  - No function on_message. Without this function, the script fails
    because of the missing function.

  - The script sets the pipeline to Gst.State.EOS instead of
    Gst.State.NULL which results in a failed pipeline state. When the
    state is set to NULL, gstreamer automatically calls EOS. Manually
    setting the pipeline state to EOS results in the following error:

        Trying to dispose element sink, but it is in PLAYING instead of
        the NULL state. You need to explicitly set elements to the NULL
        state before dropping the final reference, to allow them to
        clean up. A refcounting bug may also cause this problem in the
        application or some element.

In addition, the default timeout is set too low and would result in a
test failure, this has been changed to 200 seconds.

These issues are now properly fixed, and the sample script passes.

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
[yann.morin.1998@free.fr:
  - meld the two patches together
  - add the print() in the on_demand callback
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
Adam Duskett 2020-03-24 10:38:53 -07:00 committed by Yann E. MORIN
parent e3053f2176
commit 207d276d98
2 changed files with 21 additions and 4 deletions

View File

@ -1,20 +1,32 @@
#!/usr/bin/env python #!/usr/bin/env python
"""A simple test that uses gst1-python to run a fake videotestsrc for 100 frames""" """A simple test that uses gst1-python to run a fake videotestsrc for 100
frames
"""
import sys import sys
import gi import gi
gi.require_version('Gst', '1.0') gi.require_version('Gst', '1.0')
from gi.repository import Gst, GLib # noqa: E402 from gi.repository import Gst, GLib # noqa: E402
def on_message(bus: Gst.Bus, message: Gst.Message, loop: GLib.MainLoop):
print('Received Gst.Message.type: {}'.format(message.type))
if message.type == Gst.MessageType.EOS:
loop.quit()
return True
def main(): def main():
# Initializes Gstreamer # Initializes Gstreamer
Gst.init(sys.argv) Gst.init(sys.argv)
pipeline = Gst.parse_launch("videotestsrc num-buffers=100 ! autovideosink") pipeline = Gst.parse_launch("videotestsrc num-buffers=100 ! fakevideosink")
bus = pipeline.get_bus() bus = pipeline.get_bus()
bus.add_signal_watch() bus.add_signal_watch()
pipeline.set_state(Gst.State.PLAYING) pipeline.set_state(Gst.State.PLAYING)
loop = GLib.MainLoop() loop = GLib.MainLoop()
bus.connect("message", on_message, loop) bus.connect("message", on_message, loop)
loop.run() loop.run()
pipeline.set_state(Gst.State.EOS) pipeline.set_state(Gst.State.NULL)
exit(0)
if __name__ == '__main__':
main()

View File

@ -14,6 +14,10 @@ class TestGst1Python(TestPythonPackageBase):
BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM=y BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM=y
BR2_PACKAGE_GOBJECT_INTROSPECTION=y BR2_PACKAGE_GOBJECT_INTROSPECTION=y
BR2_PACKAGE_GSTREAMER1=y BR2_PACKAGE_GSTREAMER1=y
BR2_PACKAGE_GST1_PLUGINS_BASE=y
BR2_PACKAGE_GST1_PLUGINS_BAD=y
BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_VIDEOTESTSRC=y
BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_DEBUGUTILS=y
BR2_PACKAGE_GST1_PYTHON=y BR2_PACKAGE_GST1_PYTHON=y
BR2_PACKAGE_PYTHON3=y BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_GOBJECT=y BR2_PACKAGE_PYTHON_GOBJECT=y
@ -26,3 +30,4 @@ class TestGst1Python(TestPythonPackageBase):
options=["-initrd", cpio_file]) options=["-initrd", cpio_file])
self.emulator.login() self.emulator.login()
sample_scripts = ["tests/package/sample_gst1_python.py"] sample_scripts = ["tests/package/sample_gst1_python.py"]
timeout = 200