Git Product home page Git Product logo

Comments (17)

philn avatar philn commented on August 11, 2024 2

Yes it was. This MR is mostly about CI, I should rebase it at some point :)

from gstcefsrc.

nazar-pc avatar nazar-pc commented on August 11, 2024 1

OK, with this modification it runs indeed:

use gstreamer as gst;
use gstreamer::glib;
use gstreamer::prelude::*;

fn main() {
    gst::init().unwrap();

    let pipeline = gst::Pipeline::new(None);
    let cefsrc = gst::ElementFactory::make("cefsrc", None).unwrap();
    let queue = gst::ElementFactory::make("queue", None).unwrap();
    let cefdemux = gst::ElementFactory::make("cefdemux", None).unwrap();
    let queue2 = gst::ElementFactory::make("queue", None).unwrap();
    let videoconvert = gst::ElementFactory::make("videoconvert", None).unwrap();
    let autovideosink = gst::ElementFactory::make("autovideosink", None).unwrap();

    cefsrc
        .set_property("url", &"https://soundcloud.com/platform/sama")
        .unwrap();
    pipeline
        .add_many(&[
            &cefsrc,
            &queue,
            &cefdemux,
            &queue2,
            &videoconvert,
            &autovideosink,
        ])
        .unwrap();
    gst::Element::link_many(&[
        &cefsrc,
        &queue,
        &cefdemux,
        &queue2,
        &videoconvert,
        &autovideosink,
    ])
    .unwrap();
    pipeline.set_state(gst::State::Playing).unwrap();

    let main_loop = glib::MainLoop::new(None, false);

    let bus = pipeline.get_bus().unwrap();
    bus.add_watch({
        let main_loop = main_loop.clone();
        move |_, msg| {
            match msg.view() {
                gst::MessageView::Eos(..) => main_loop.quit(),
                gst::MessageView::Error(err) => {
                    println!(
                        "Error from {:?}: {} ({:?})",
                        err.get_src().map(|s| s.get_path_string()),
                        err.get_error(),
                        err.get_debug()
                    );
                    main_loop.quit();
                }
                _ => (),
            }
            glib::Continue(true)
        }
    })
    .unwrap();

    main_loop.run();

    pipeline.set_state(gst::State::Null).unwrap();

    bus.remove_watch().unwrap();
}

Will work on reduced example now.

from gstcefsrc.

MathieuDuponchelle avatar MathieuDuponchelle commented on August 11, 2024 1

As of the latest commit, cefsrc is usable in Debug mode, including at program destruction :)

from gstcefsrc.

MathieuDuponchelle avatar MathieuDuponchelle commented on August 11, 2024

That's probably a CEF / chromium issue. I can't reproduce this with the master branch, the default CEF build and the latest version of gstreamer (in the gst-build devenv). Can you provide more information wrt OS / whether you can reproduce the issue with the example pipeline / whether you've modified your local checkout of gstcefsrc or use your own CEF build?

from gstcefsrc.

nazar-pc avatar nazar-pc commented on August 11, 2024

I'm using Docker for development and I can confirm that gst-launch command from readme indeed works fine.

I've simplified it to this since I only care about video for now:

gst-launch-1.0 cefsrc url="https://soundcloud.com/platform/sama" ! queue ! cefdemux ! queue ! videoconvert ! autovideosink

Then I've tried to make reduced example, starting with above pipeline created programmatically, but it only shows black screen:

Cargo.toml:

[package]
name = "gstcefsrc-test"
version = "0.1.0"
authors = ["Nazar Mokrynskyi <[email protected]>"]
edition = "2018"

[dependencies]
gstreamer = "0.15.0"

src/main.rs:

use gst::prelude::*;
use gstreamer as gst;

fn main() {
    gst::init().unwrap();

    let pipeline = gst::Pipeline::new(None);
    let cefsrc = gst::ElementFactory::make("cefsrc", None).unwrap();
    let queue = gst::ElementFactory::make("queue", None).unwrap();
    let cefdemux = gst::ElementFactory::make("cefdemux", None).unwrap();
    let queue2 = gst::ElementFactory::make("queue", None).unwrap();
    let videoconvert = gst::ElementFactory::make("videoconvert", None).unwrap();
    let autovideosink = gst::ElementFactory::make("autovideosink", None).unwrap();

    cefsrc
        .set_property("url", &"https://soundcloud.com/platform/sama")
        .unwrap();
    pipeline
        .add_many(&[
            &cefsrc,
            &queue,
            &cefdemux,
            &queue2,
            &videoconvert,
            &autovideosink,
        ])
        .unwrap();
    gst::Element::link_many(&[
        &cefsrc,
        &queue,
        &cefdemux,
        &queue2,
        &videoconvert,
        &autovideosink,
    ])
    .unwrap();
    pipeline.set_state(gst::State::Playing).unwrap();

    let bus = pipeline.get_bus().unwrap();
    for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
        match msg.view() {
            gst::MessageView::Eos(..) => break,
            gst::MessageView::Error(err) => {
                println!(
                    "Error from {:?}: {} ({:?})",
                    err.get_src().map(|s| s.get_path_string()),
                    err.get_error(),
                    err.get_debug()
                );
                break;
            }
            _ => (),
        }
    }

    pipeline.set_state(gst::State::Null).unwrap();
}

It seems to be literally the same thing.

Once I have that not showing black screen, I should be able to reduce my use case to a smaller demo. I'm using Rust, so getting segfaults is not quite what I expect 🙂

You can reproduce my current environment by using this Dockerfile:

FROM restreamio/gstreamer:latest-dev
RUN \
    apt-get update && apt-get install -y cmake && \
    git clone https://github.com/centricular/gstcefsrc.git && \
    cd gstcefsrc && \
    mkdir build && \
    cd build && \
    cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. && \
    make -j$(nproc --all)

USER 1000:1000
ENV XDG_RUNTIME_DIR=/run/user/1000
ENV DISPLAY=:0.0
ENV GST_PLUGIN_PATH=/gstcefsrc/build/Release
It uses the image I've built from here (which will have docs and stuff later): https://github.com/restreamio/docker-gstreamer

Build it with docker build -t gstcefsrc-test ..

Then you should be able to to use even your X session with it (Dockerfile above assumes you have user ID 1000 in Linux):

docker run --rm -it --net host -v /run:/run gstcefsrc-test

After that it should work (may occasionally fail with X errors, but most of the time it works fine).

UPD: OS is Ubuntu 19.10 and packages are as shipped in the repos except GStreamer, its plugins and libnice that are built from source.

from gstcefsrc.

sdroege avatar sdroege commented on August 11, 2024

I'm using Rust, so getting segfaults is not quite what I expect 🙂

There's https://github.com/servo/servo/tree/master/ports/gstplugin btw, which is a (more-or-less) pure Rust version of a browser source plugin based on Servo. If you feel like trying it :) It's probably not mature enough yet, but might be fun to try.

from gstcefsrc.

MathieuDuponchelle avatar MathieuDuponchelle commented on August 11, 2024

Hey @nazar-pc , the difference between your application and gst-launch is the lack of a GMainLoop. cefsrc uses https://magpcss.org/ceforum/apidocs3/projects/(default)/(_globals).html#CefDoMessageLoopWork() , which is non-blocking but must be called from the main thread of the application, so the source uses g_timeout_add to do so. Without a main loop around, the timeout never gets triggered, hence the black screen.

I can't remember the exact reason why I didn't use CefRunMessageLoop() at the time but I could look into that, in the meantime you can work around this by running a main loop in your test application, instead of blocking on bus pops.

from gstcefsrc.

nazar-pc avatar nazar-pc commented on August 11, 2024

I've tried Webkit WPE-based plugin first, but it requires EGL which was not available in my case, so I decided to try this one. I've seen that Servo has something that looks like a plugin, but it is not on crates.io from what I've seen, so probably not very usable. I'll probably give it a try later though.

I'll try to run the main loop and let you know how it goes.

from gstcefsrc.

MathieuDuponchelle avatar MathieuDuponchelle commented on August 11, 2024

@nazar-pc , any news on that?

from gstcefsrc.

nazar-pc avatar nazar-pc commented on August 11, 2024

Not yet, I was busy with other things, will get back to this as soon as I can

from gstcefsrc.

nazar-pc avatar nazar-pc commented on August 11, 2024

Hm.. there is something weird going on. I'm not getting segfaults on this machine after a few hours trying. This machine is strange though. It reproduces other errors and warnings that the machine I had that segfault on didn't, probably because I'm running Ubuntu daily here.

I'll have to test again on the other machine where I got this segfault initially, probably tomorrow. Though it doesn't make any sense to me since it runs inside of a container...

from gstcefsrc.

MathieuDuponchelle avatar MathieuDuponchelle commented on August 11, 2024

After some investigation, I found that I can reproduce a similar crash when cefsrc is built in Debug mode. The initial issue is fixed by setting locales_dir_path as such (hardcoded):

CefString(&settings.locales_dir_path).FromASCII("/home/meh/devel/gst-build/sandbox/gstcefsrc/build/Debug/locales");

There are however subsequent issues on shutdown. Some refactoring would be needed to address those, this will probably be best done when lifting the main loop requirement, as these tie in to the element's lifecycle as well.

from gstcefsrc.

MathieuDuponchelle avatar MathieuDuponchelle commented on August 11, 2024

@nazar-pc , can you confirm you were seeing the issue with a Debug build?

from gstcefsrc.

nazar-pc avatar nazar-pc commented on August 11, 2024

Yes, that is the difference! I was building it in Debug mode when it crashed and then spent 3 hours trying to find out why it doesn't crash in Release build yesterday.

from gstcefsrc.

philn avatar philn commented on August 11, 2024

I've tried Webkit WPE-based plugin first, but it requires EGL which was not available in my case, so I decided to try this one.

This requirement is optional now, you need gst 1.17, wpebackend-fdo git master (upcoming 1.8.x) though. To use swrast, set LIBGL_ALWAYS_SOFTWARE=true at runtime.

from gstcefsrc.

nazar-pc avatar nazar-pc commented on August 11, 2024

you need gst 1.17

Was the change actually merged to master though? https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1267 is still open.

from gstcefsrc.

philn avatar philn commented on August 11, 2024

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/commit/9ac798ae5e7ebefea626d796eac8d859c3dfdf60

from gstcefsrc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.