Commit graph

1442 commits

Author SHA1 Message Date
Mike Kaganski
762d76d9a4 Simplify avmedia::SoundHandler
Change-Id: I253d6eda265e3e93d4b85ac35376a96676a68553
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178050
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-12-07 20:06:37 +01:00
Caolán McNamara
836d73a651 consider VndSunStarExpand an exotic protocol
and generally don't bother with it when fetching data
from urls

Change-Id: I51a2601c6fb7d6c32f9e2d1286ee0d3b05b370b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176645
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-11-19 20:20:03 +01:00
Noel Grandin
ed0b12f4ea no need to take a copy of the getProcessComponentContext return value
we can just take a "const &".

(found by running clang-tidy with the
performance-unnecessary-copy-initialization warning)

Change-Id: I20fd208c65303da78170b1ac06c638fdf3aa094b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176267
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2024-11-08 15:23:52 +01:00
Noel Grandin
91106b5b61 loplugin:passstuffbyref in avmedia..canvas
Change-Id: I916a6431eb0720af16dcb5aa46b758f92dbe4ec4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176179
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-11-07 10:03:42 +01:00
Michael Weghorn
8eacf7e372 qt: Have just a single toQString(const OUString&)
Move the `toQString` helper function to
include/vcl/qt/QtUtils.hxx where it can be used from
multiple modules, instead of defining
it twice for both, avmedia (avmedia/source/qt6/QtPlayer.cxx)
and vcl (vcl/inc/qt5/QtTools.hxx).

Change-Id: I7ffe06eaa3aaf3e7c8cc7aa1a4ac41b14db5c20c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175526
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-10-24 09:10:19 +02:00
Michael Weghorn
2386540edf tdf#130857 qt: Move pixmap helper to new include/vcl/qt/QtUtils.hxx
Introduce include/vcl/qt/QtUtils.hxx as a new header
for Qt-specific utility functions that can be used
in multiple modules, e.g. avmedia and the Qt VCL
plugins in vcl.

This is meant to be used only by code that already
links in Qt.

There's already vcl/inc/qt{5,6}/QtTools.hxx for
helpers needed in vcl only.

Initially, add a `loadQPixmapIcon` helper function
that can be used to retrieve a QPixmap for an icon name
and is extracted from QtPlayer::createMediaPlayerWidget
in avmedia.

It will be reused to implement the
QtInstanceButton::set_from_icon_name logic in an upcoming
commit.

Change-Id: I9f25aa5ca8f00da97d06ecdd164a8fae10e492dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175524
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-10-24 09:10:00 +02:00
Stephan Bergmann
e7c4129a5c Silence -Werror,-Wdeprecated-declarations (macOS 15.0)
Change-Id: Ic765a5c7259896d7b8caebd50460be57dec9ba64
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174262
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
2024-09-30 12:07:21 +02:00
Vladislav Tarakanov
134fb4747a tdf#158510 Added fallback for media files in MediaWindowImpl
When launching media from Properties -> Media Playback,
no sound is currently playing. This is due to the fact that
there is no fallback URL defined for MediaWindowImpl.

To fix this problem, new methods have been added for
setting and getting the fallback URL, passing the path to
the presentation folder from "unoshap4.cxx" to
"mediawindow_imp.cxx".

Because the setURL method starts the media immediately,
calls to "setFallbackURL" method must be made BEFORE
calling "setURL".

Change-Id: I3054c90c648c5839a2eb3fc463eaefbf97500c05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170644
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2024-08-14 00:19:23 +02:00
Michael Weghorn
5bf58785ba gtk4: Require GTK >= 4.10
For the gtk4 VCL plugin, require GTK version >= 4.10
and drop code for older versions.

This simplifies maintenance, in particular since
requiring 4.10 ensures that the basic GtkAccessible API
is available.

GTK 4.10 was released on 2023-03-04 [1], so it
will be almost 2 years by the time that LO 25.2
will be released.

Given that the gtk4 VCL plugin is still experimental,
providing support for older GTK 4 releases shouldn't
have to be a concern.

[1] https://gitlab.gnome.org/GNOME/gtk/-/blob/4.10.0/NEWS?ref_type=tags

Change-Id: I6f361b533391225d0e74c174e0479b767b9d827a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169324
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-06-30 22:40:39 +02:00
Michael Weghorn
4df2a30c57 tdf#145735 qt avmedia: Don't deadlock with QGstreamerMediaPlayer
While opending a slide with a video worked fine for
me with the qt6 VCL plugin and a local Qt development
build on Debian testing (qtbase as of
8915ae3a75c4a356d94962dd9b31e1458f2a506f,
qtwayland as of deae8b9ce9f551b29ef98d0bb827a8543af2797e,
qtmultimedia as of 235ba5f273fbb7dfed8ba3736e4444a85aee5770),
this resulted in a freeze when using Debian's system-provided
Qt packages instead (libqt6multimedia6:amd64 6.4.2-11+b2).

While the self-compiled Qt dev is using `QFFmpegMediaPlayer`
which asynchronously loads media, the system QtMultimedia
is using `QGstreamerMediaPlayer` (s. frame 37 in below backtrace)
that apparently doesn't use multiple threads.

Therefore, using `Qt::BlockingQueuedConnection` is problematic,
as its documentation [1] says:

> Same as Qt::QueuedConnection, except that the signalling thread blocks
> until the slot returns. This connection must not be used if the receiver
> lives in the signalling thread, or else the application will deadlock.

Use `Qt::AutoConnection` (= 0, the default) instead and specify the
`Qt::SingleShotConnection` flag in addition to ensure the slot
gets called only once:

> This is a flag that can be combined with any one of the above connection
> types, using a bitwise OR. When Qt::SingleShotConnection is set, the
> slot is going to be called only once; the connection will be
> automatically broken when the signal is emitted. This flag was
> introduced in Qt 6.0.

Drop the now no longer needed manual disconnect.

This makes the scenario work with both, the custom-compiled
Qt dev using `QFFmpegMediaPlayer` and the system-provided
Qt 6.4.2 using `QGstreamerMediaPlayer`.

Side note: Unrelated to the issue addressed here, using the
system-provided Qt with `QGstreamerMediaPlayer` results
in a crash when started via the soffice shell script wrapper
with a LibreOffice debug build or when using soffice.bin directly
and manually setting `MALLOC_PERTURB_=153`, which indicates
some memory issue. That could be within Qt, though, haven't
analyzed that further.

Backtrace of deadlock:

    1 syscall syscall.S 38 0x7f40a83249f9
    2 QSemaphore::acquire(int) 0x7f40948714e2
    3 ?? 0x7f409477fede
    4 QVideoSink::videoFrameChanged(QVideoFrame const&) const 0x7f4095195376
    5 ?? 0x7f405c219f5c
    6 ?? 0x7f405c21a25b
    7 QApplicationPrivate::notify_helper(QObject *, QEvent *) 0x7f4093782d62
    8 QCoreApplication::notifyInternal2(QObject *, QEvent *) 0x7f40947356d8
    9 QCoreApplicationPrivate::sendPostedEvents(QObject *, int, QThreadData *) 0x7f40947358b7
    10 ?? 0x7f4094925257
    11 ?? 0x7f409ab0de3f
    12 ?? 0x7f409ab0fec7
    13 g_main_context_iteration 0x7f409ab104e0
    14 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) 0x7f4094922f60
    15 QtInstance::ImplYield QtInstance.cxx 455 0x7f4094e534e0
    16 QtInstance::DoYield QtInstance.cxx 464 0x7f4094e568a5
    17 ImplYield svapp.cxx 384 0x7f409f3c48cc
    18 Scheduler::ProcessEventsToIdle svapp.cxx 419 0x7f409f3c4bc8
    19 avmedia::qt::QtFrameGrabber::grabFrame QtFrameGrabber.cxx 106 0x7f405cac5524
    20 non-virtual thunk to avmedia::qt::QtFrameGrabber::grabFrame(double) 0x7f405cac564e
    21 avmedia::MediaWindow::grabFrame mediawindow.cxx 385 0x7f40a03e41ad
    22 SdrMediaObj::getSnapshot() const::$_0::operator()(com::sun::uno::Reference<com::sun::media::XPlayer> const&) const svdomedia.cxx 195 0x7f40a249e5b5
    23 std::__invoke_impl<void, SdrMediaObj::getSnapshot() const::$_0&, com::sun::uno::Reference<com::sun::media::XPlayer> const&>(std::__invoke_other, SdrMediaObj::getSnapshot() const::$_0&, com::sun::uno::Reference<com::sun::media::XPlayer> const&) invoke.h 61 0x7f40a249e52d
    24 std::__invoke_r<void, SdrMediaObj::getSnapshot() const::$_0&, com::sun::uno::Reference<com::sun::media::XPlayer> const&>(SdrMediaObj::getSnapshot() const::$_0&, com::sun::uno::Reference<com::sun::media::XPlayer> const&) invoke.h 111 0x7f40a249e4dd
    25 std::_Function_handler<void (com::sun::uno::Reference<com::sun::media::XPlayer> const&), SdrMediaObj::getSnapshot() const::$_0>::_M_invoke(std::_Any_data const&, com::sun::uno::Reference<com::sun::media::XPlayer> const&) std_function.h 290 0x7f40a249e345
    26 std::function<void (com::sun::uno::Reference<com::sun::media::XPlayer> const&)>::operator()(com::sun::uno::Reference<com::sun::media::XPlayer> const&) const std_function.h 591 0x7f40a03e96cd
    27 avmedia::PlayerListener::callPlayerWindowSizeAvailable mediawindow.hxx 76 0x7f40a03e6bf1
    28 avmedia::PlayerListener::preferredPlayerWindowSizeAvailable mediawindow.cxx 496 0x7f40a03e5055
    29 avmedia::qt::QtPlayer::notifyListeners QtPlayer.cxx 395 0x7f405cacfd53
    30 avmedia::qt::QtPlayer::notifyIfReady QtPlayer.cxx 326 0x7f405cacfb42
    31 QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<QMediaPlayer::MediaStatus>, void, void (avmedia::qt::QtPlayer:: *)(QMediaPlayer::MediaStatus)>::call qobjectdefs_impl.h 135 0x7f405cad477b
    32 QtPrivate::FunctionPointer<void (avmedia::qt::QtPlayer:: *)(QMediaPlayer::MediaStatus)>::call<QtPrivate::List<QMediaPlayer::MediaStatus>, void> qobjectdefs_impl.h 172 0x7f405cad46cd
    33 QtPrivate::QSlotObject<void (avmedia::qt::QtPlayer:: *)(QMediaPlayer::MediaStatus), QtPrivate::List<QMediaPlayer::MediaStatus>, void>::impl qobjectdefs_impl.h 383 0x7f405cad4612
    34 ?? 0x7f409477fbbe
    35 QMediaPlayer::mediaStatusChanged(QMediaPlayer::MediaStatus) 0x7f4095184a05
    36 ?? 0x7f405c210740
    37 non-virtual thunk to QGstreamerMediaPlayer::processBusMessage(QGstreamerMessage const&) 0x7f405c2009f7
    38 ?? 0x7f405c21aa94
    39 QObject::event(QEvent *) 0x7f40947723e0
    40 QApplicationPrivate::notify_helper(QObject *, QEvent *) 0x7f4093782d62
    41 QCoreApplication::notifyInternal2(QObject *, QEvent *) 0x7f40947356d8
    42 QCoreApplicationPrivate::sendPostedEvents(QObject *, int, QThreadData *) 0x7f40947358b7
    43 ?? 0x7f4094925257
    44 ?? 0x7f409ab0de3f
    45 ?? 0x7f409ab0fec7
    46 g_main_context_iteration 0x7f409ab104e0
    47 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) 0x7f4094922f60
    48 QtInstance::ImplYield QtInstance.cxx 455 0x7f4094e534e0
    49 QtInstance::DoYield QtInstance.cxx 464 0x7f4094e568a5
    50 ImplYield svapp.cxx 384 0x7f409f3c48cc
    51 Scheduler::ProcessEventsToIdle svapp.cxx 419 0x7f409f3c4bc8
    52 avmedia::qt::QtFrameGrabber::grabFrame QtFrameGrabber.cxx 106 0x7f405cac5524
    53 non-virtual thunk to avmedia::qt::QtFrameGrabber::grabFrame(double) 0x7f405cac564e
    54 avmedia::MediaWindow::grabFrame mediawindow.cxx 385 0x7f40a03e41ad
    55 SdrMediaObj::getSnapshot() const::$_0::operator()(com::sun::uno::Reference<com::sun::media::XPlayer> const&) const svdomedia.cxx 195 0x7f40a249e5b5
    56 std::__invoke_impl<void, SdrMediaObj::getSnapshot() const::$_0&, com::sun::uno::Reference<com::sun::media::XPlayer> const&>(std::__invoke_other, SdrMediaObj::getSnapshot() const::$_0&, com::sun::uno::Reference<com::sun::media::XPlayer> const&) invoke.h 61 0x7f40a249e52d
    57 std::__invoke_r<void, SdrMediaObj::getSnapshot() const::$_0&, com::sun::uno::Reference<com::sun::media::XPlayer> const&>(SdrMediaObj::getSnapshot() const::$_0&, com::sun::uno::Reference<com::sun::media::XPlayer> const&) invoke.h 111 0x7f40a249e4dd
    58 std::_Function_handler<void (com::sun::uno::Reference<com::sun::media::XPlayer> const&), SdrMediaObj::getSnapshot() const::$_0>::_M_invoke(std::_Any_data const&, com::sun::uno::Reference<com::sun::media::XPlayer> const&) std_function.h 290 0x7f40a249e345
    59 std::function<void (com::sun::uno::Reference<com::sun::media::XPlayer> const&)>::operator()(com::sun::uno::Reference<com::sun::media::XPlayer> const&) const std_function.h 591 0x7f40a03e96cd
    60 avmedia::PlayerListener::callPlayerWindowSizeAvailable mediawindow.hxx 76 0x7f40a03e6bf1
    61 avmedia::PlayerListener::preferredPlayerWindowSizeAvailable mediawindow.cxx 496 0x7f40a03e5055
    62 avmedia::qt::QtPlayer::notifyListeners QtPlayer.cxx 395 0x7f405cacfd53
    63 avmedia::qt::QtPlayer::notifyIfReady QtPlayer.cxx 326 0x7f405cacfb42
    64 QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<QMediaPlayer::MediaStatus>, void, void (avmedia::qt::QtPlayer:: *)(QMediaPlayer::MediaStatus)>::call qobjectdefs_impl.h 135 0x7f405cad477b
    65 QtPrivate::FunctionPointer<void (avmedia::qt::QtPlayer:: *)(QMediaPlayer::MediaStatus)>::call<QtPrivate::List<QMediaPlayer::MediaStatus>, void> qobjectdefs_impl.h 172 0x7f405cad46cd
    66 QtPrivate::QSlotObject<void (avmedia::qt::QtPlayer:: *)(QMediaPlayer::MediaStatus), QtPrivate::List<QMediaPlayer::MediaStatus>, void>::impl qobjectdefs_impl.h 383 0x7f405cad4612

[1] https://doc.qt.io/qt-6/qt.html#ConnectionType-enum

Change-Id: Ia8bfd19b0c0c4f970a5eb200c2a0b45784ef25fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169036
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-06-18 05:27:53 +02:00
Michael Weghorn
12c4b7ee91 tdf#145735 qt avmedia: Show audio placeholder for audio files
So far, `QtPlayer::createPlayerWindow` was unconditionally
creating a video widget.

However, audio-only media files can be used as well,
therefore handle that case, too and create a widget
holding an audio icon as a placeholder instead if
the media doesn't contain video.
(This is the same icon shown when using qt5 that
doesn't use QtMultimedia).

As described in

    commit a99575f04f
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Sat Jun 1 07:32:22 2024 +0200

        tdf#194504 qt avmedia: Don't wait for video frame if there's none

, `QMediaPlayer::hasVideo()` only returns a useful
result once loading media has finished. Therefore,
if the player is still in that state in
`QtPlayer::createPlayerWindow`, defer
creating the widget to when the media status
changes.

With this commit in place, opening an Impress presentation
that contains an audio file (like attachment 194504
from tdf#145735) and starting presentation mode now shows an
"audio icon" as placeholder as expected when using
the qt6 VCL plugin.

(This commit here makes that work for presentation
mode, while the above-mentioned commit already made
the icon show as expected for non-presentation mode.)

Change-Id: I1ff7e8b8659162a748abc3f97a8d2181375c0e7c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169009
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-06-18 05:27:47 +02:00
Oliver Specht
c39e4f6b8a Add SfxItemType to SfxPoolItem
The SfxPoolItem has a new member SfxItemType m_eItemType to
compare types based on enums instead of typeinfo() which
consumes a lot of time e.g. while AutoFormat is running

Change-Id: I033ce67bc9a28ee4790f162380314de85fb4154e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166452
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
2024-06-18 01:07:42 +02:00
Michael Weghorn
a99575f04f tdf#194504 qt avmedia: Don't wait for video frame if there's none
If the media doesn't have video, then don't try to
grab a frame, but stop waiting for the
`QVideoSink::videoFrameChanged` signal to be emitted
in `QtFrameGrabber::grabFrame`.

Don't call `QMediaPlayer::hasVideo` while the media
is still being loaded, as the result is only valid once loading
the media has been finished (`false` is returned otherwise
even if the media file contains video), s. the platform
implementation in qtmultimedia's `QFFmpegMediaPlayer::setMedia`,
which loads the media in a separate thread: Once the media
has been loaded, `QFFmpegMediaPlayer::setMediaAsync`
calls `QPlatformMediaPlayer::videoAvailableChanged`
to specify whether video is available.

With this commit in place, opening an Impress presentation
that contains an audio file (like attachment 194504
from tdf#145735) now shows an "audio icon" as placeholder
as expected and the application exits properly on close,
rather than blocking as it's still waiting for a video frame.

Change-Id: I5448a9f7396d4c419d76a2400e3f2a1ef52a7e85
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168305
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-06-02 06:19:25 +02:00
Andrea Gelmini
847781ea88 Fix typo
Change-Id: I904fb00c7aa934b27d6e4435a2495607f18b3abf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168290
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-05-31 17:32:32 +02:00
Michael Weghorn
f04e711ea3 tdf#145735 qt avmedia: Implement frame grabber
Add a new `QtFrameGrabber` class that implements
the `css::media::XFrameGrabber` interface and
return an instance of it in
`QtPlayer::createFrameGrabber`.

As there seems to be no direct way to retrieve
the image/frame of a video at a certain point
in time, create a separate `QMediaPlayer` instance
for the `QtFrameGrabber`, set a video sink, connect
to its `&QVideoSink::videoFrameChanged` signal and
start playing the video (and stop it again once the
first frame has been received) in order to retrieve
a corresponding frame.

From that `QVideoFrame`, a `QImage` can be retrieved
that can then be converted to an `XGraphic`.

With this in place, a frame from the actual video
is now displaced in Impress in non-presentation
mode instead of just a generic "video icon" placeholder
when opening a presentation containing a video,
(e.g. attachment 145517 from tdf#120452) when the
qt6 VCL plugin is in use.

Change-Id: I3bba3c0fb62a219ac632ceed03ec17f9078f18d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168255
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-05-31 09:24:01 +02:00
Michael Weghorn
79644440bd tdf#145735 qt avmedia: Return video resolution for preferred win size
In `QtPlayer::getPreferredPlayerWindowSize`, retrieve the
video resolution from the meta data and return that for the
preferred window size if available, instead of always returning
an empty rect.

For the sample presentation referenced in tdf#145735,
the size retrieved this way also matches what
`GtkPlayer::getPreferredPlayerWindowSize` returns
(720x400).

As mentioned in

    commit 441d8ed9be
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Mon May 20 16:25:09 2024 +0200

        tdf#145735 avmedia qt: Use QtMultimedia for Qt 6 media playback

, the behaviour without this was:

> * In non-presentation mode, the placeholder
>   shown until the video gets started using the controls
>   in the sidebar is just an "audio icon", not a frame
>   from the actual video. (This might be related to the
>   fact that `QtPlayer::createFrameGrabber` currently
>   returns an empty reference.)

With this in place, the placeholder is now a different
icon, a "video icon" (but still not a frame from the actual
video).

Change-Id: I295abe6b7973fece3fcaf9a38af2602cb08610a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168013
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-05-24 18:18:17 +02:00
Michael Weghorn
441d8ed9be tdf#145735 avmedia qt: Use QtMultimedia for Qt 6 media playback
Similar to the way that GTK 4's native facilities for
video playback are used for the gtk4 VCL plugin, initially
added in commit

        commit d0a527ec09
        Author: Caolán McNamara <caolanm@redhat.com>
        Date:   Thu Feb 10 12:55:18 2022 +0000

            first cut at using Gtk4 built in video playback

, implement media playback using QtMultimedia for the
Qt 6 based VCL plugins (qt6/kf6) via a new service
"com.sun.star.comp.avmedia.Manager_Qt".

Video playback with the mechanism used for qt5 no
longer works with qt6, as "qwidget5videosink"
that gets used on Wayland for qt5 wasn't ported
to Qt 6 and is unmaintained, s. the commit message of

        commit 88d57cf241
        Author: Michael Weghorn <m.weghorn@posteo.de>
        Date:   Wed Sep 29 11:09:51 2021 +0200

            qt6: Add a qt6 VCL plugin

for more details. Additionally, this also doesn't work
properly any more on X11/with the xcb Qt QPA platform, see
tdf#145735 comment 7.

Instead of using GStreamer directly, let Qt handle
the low-level stuff by using the QtMultimedia module [1]
instead.

This adds a new dependency on QtMultimedia.
For building, this requires installing the Qt 6 QtMultimedia
development headers (e.g. package `qt6-multimedia-dev`
on current Debian testing).

Except for WASM, the use of QtMultimedia is enabled by
default when building with autogen options `--enable-qt6`
or `--enable-kf6`, but can explicitly be disabled using
`--disable-qt6-multimedia`.

In tests with the qt6 VCL plugin on Debian testing, with a
sample presentation containing an embedded
video, attachment 145517 from tdf#120452, video playback
generally works for both, the xcb and the wayland
Qt QPA platforms:

* Video and audio are played as expected on the external
  screen in presentation mode when using the presenter
  console
* Video and audio playback work in non-presentation
  mode by clicking on the video and using the controls
  in the Impress sidebar (play, pause,...).

However, the following issues were observed with
the current implementation:

* There's an odd frame/margin around the video.
* In non-presentation mode, the placeholder
  shown until the video gets started using the controls
  in the sidebar is just an "audio icon", not a frame
  from the actual video. (This might be related to the
  fact that `QtPlayer::createFrameGrabber` currently
  returns an empty reference.)
* At least on Wayland (issue not observed with
  QT_QPA_PLATFORM=xcb so far), when using the presenter
  console,   video playback in the presenter console (i.e. on the
  non-presentation screen) is unreliable: The video
  sometimes shows, but sometimes doesn't. At least the
  (more important) one on the presentation screen was
  reliably shown in my tests, however.

Tested with git dev versions of qtbase
(as of commit 8d5e7d50d8dbf1ad79bd8ff9f6ef6028eba481c9),
qtwayland (as of commit 6f0ebd916f176f6fbe35af28caeb52b62768ac94)
and qtmultimedia (as of commit
264b7e8d7d5683252102b5e5149685c8b8a70c2d).

[1] https://doc.qt.io/qt-6/qtmultimedia-index.html

Change-Id: I29c3c7ded01c61b49b192fa5c313d8a92c942185
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167869
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-05-21 17:28:04 +02:00
Michael Weghorn
ba41718095 avmediagtk: Use gb_Library_set_include for GTK4_CFLAGS
In the same way that `vcl/Library_vclplug_gtk4.mk` does
it, set the `GTK4_CFLAGS` (which have the includes) via
`gb_Library_set_include`, not `gb_Library_add_cxxflags`.

This makes sure that they end up in the `INCLUDE`
section in `workdir/GbuildToJson/Library/libavmediagtk.so`
and thus end up in the IDE integrations as includes,
which makes Qt Creator's Clang Code Model  find them
instead of showing an error
("gtkplayer.cxx:28:10: 'gtk/gtk.h' file not found").

See also this similar commit for more details:

    commit 6a53832080
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Mon Dec 17 15:35:58 2018 +0100

        Use 'gb_Library_set_include' for GTK3_CFLAGS

Change-Id: I5ef01aff32073d37b8add0b2250402ccaa48b2dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167857
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-05-20 15:22:49 +02:00
Noel Grandin
8b091048d1 loplugin:ostr avmedia
Change-Id: Ice017029f0b93ae92e76d3905f38c730cc5a2fc8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167189
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-05-06 15:14:09 +02:00
Noel Grandin
2d8056d884 loplugin:unusedmethods
Change-Id: I19f466a272c821185bea4b45efd34392e525c0d1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165785
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-04-04 19:58:14 +02:00
Noel Grandin
2cc99a2550 convert PlayerListener to comphelper::WeakComponentImplHelper
Change-Id: I167354cbf998dd08ef8b5ffba744758539cabec5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165547
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-03-29 18:00:06 +01:00
Arnaud VERSINI
140a3719f8 avmedia : no need to use constexpr here
Change-Id: I1b9975841a702d7ad3e05adef3d849c63ddf264a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163009
Tested-by: Jenkins
Reviewed-by: Arnaud Versini <arnaud.versini@pm.me>
2024-03-10 15:32:52 +01:00
Luv Sharma
a6cdc75f98 tdf#158067: an example of OUStringLiteral -> operator u""_ustr replacement
Change-Id: I0b7f8dda1d266f6d71b5781bea65242ff235bc47
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161593
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-02-23 08:05:38 +01:00
Armin Le Grand (allotropia)
789a737ac9 Remove DeleteItemOnIdlex
There are some CrashReports in 7.6 which have
DeleteItemOnIdle on the stack, but there is nothing
reproducable. So I took a look...

I first thought it's a MCGR regression, due to classes
on the stack. But the Item involved is just random, can
happen with any Item.

Then I thought it may have to do with ITEM refactorings,
but it happens with DeleteItemOnIdle involved, so also
not the case. I already saw DeleteItemOnIdle when doing
these and qualified as 'hack' in the way. already

It is only on Windows and DeleteItemOnIdle is involved.
This again (took a deeper look now) is an old hack to
keep an SfxPoolItem 'alive' for some 'time'. For that,
it triggers an async reschedule which then deletes the
Item when being called. If the Item will be used after
that is pure coincidence - seems to work in most cases.

It seems as if for Windows the timing slightly changed
for some scenarios, so a reschedule is too early. This
can happen with this hack anytime.

DeleteItemOnIdle is used in scenarios where SfxPoolItem*
is e.g. returned, but is *not* anchored, so e.g. not
member of an SfxItemSet. Or in short: Lifetime is not
safe.

DeleteItemOnIdle exists since 1st import, but was
changed to AsyncEvent ca. 4 months ago (see
57145acf9e), so that may
have caused it. It is possible that these errors happen
on Windows since then. Before something more complicated
was used to delete it late, but surely also not really
safe.

Due to ITEM refactor I have the knowledge/tooling to
solve this. It will not be a 1-5 lines fix, but it is
a hack and in the way for further ITEM refactor anyways.
What we have nowadays is a SfxPoolItemHolder -> it's
like an SfxItemSet for a single Item. It safely holds/
controls the lifetime of an SfxPoolItem. It is already
used in quite some places. It helps to solve many hacks,
also the ones putting Items directly to the Pool - due
to there never was an alternative for that. In principle
the ItemPool/ItemSet/Item paradigm was never complete
without SfxPoolItemHolder.

Thus I started to fix that (and remove that hack for
good, sooo many changes over the years, sigh), but as
said is not straightforward. Will have to change
retvals of involved stuff to SfxPoolItemHolder - it's
just two pointers and designed to be copied (one is a
Pool, needed to cleanup when destructing).
CopyConstruct/destroy just counts the RefCnt up/down,
so cheap.

1st version compiling, let's check on gerrit...
Corrected one error in QueryState for securitypage, also
added some security features/asserts.

Change-Id: Ida49fd35ca88ead84b11d93e18b978cb9e395090
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161083
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
2023-12-21 21:13:55 +01:00
Caolán McNamara
cb18b12953 cid#1545617 COPY_INSTEAD_OF_MOVE
and

cid#1545748 COPY_INSTEAD_OF_MOVE
cid#1545741 COPY_INSTEAD_OF_MOVE
cid#1545698 COPY_INSTEAD_OF_MOVE
cid#1545594 COPY_INSTEAD_OF_MOVE
cid#1545588 COPY_INSTEAD_OF_MOVE
cid#1545558 COPY_INSTEAD_OF_MOVE
cid#1545545 COPY_INSTEAD_OF_MOVE

Change-Id: I5dfec77a68959b9384fc71a2fc0908c5d1b42869
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160448
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-12-08 09:34:29 +01:00
Stephan Bergmann
c0e516609b loplugin:stringstatic, lopluign:ostr (clang-cl)
Change-Id: I7a928a2385286f6d1ab3887c8d315af3f47c052d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159135
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-11-08 18:58:40 +01:00
Mike Kaganski
b65f295698 tdf#158068: an example of "abc" -> u"abc"_ustr conversion
Change-Id: I1225548ebc313cac98c4b924a8fb53f53bada76d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158946
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-11-05 19:54:18 +01:00
Mike Kaganski
eae5559af6 tdf#158067: an example of OUStringLiteral -> operator u""_ustr replacement
Change-Id: I0a15d1d30ee59d8f574a5a9c79ab11e316dbe76c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158945
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-11-05 19:54:11 +01:00
Caolán McNamara
af9b546cf5 avoid the neeed to escape url passed to gstreamer
Change-Id: I13d0cee911a3c9af99b494dde16b8d51f78d954a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158889
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-11-03 18:15:51 +01:00
Caolán McNamara
1e95b89f8f escape url passed to gstreamer
Change-Id: I3c93ee34800cc8563370f75ef3ef6f8a9220e6ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158884
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-11-03 16:51:03 +01:00
Stephan Bergmann
bd6fb0cd3e Extended loplugin:ostr: Rewrite some O[U]StringLiteral -> O[U]String
...in include files.  This is a mix of automatic rewriting in include files and
manual fixups (mostly addressing loplugin:redundantfcast) in source files that
include those.

Change-Id: I1f3cc1e67b9cabd2e9d61a4d9e9a01e587ea35cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158337
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-23 11:04:42 +02:00
Stephan Bergmann
c12df614ad Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: avmedia
Change-Id: Ib56a05e171f485ad01cb54ed87e01c3536ea733d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158142
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-19 13:07:58 +02:00
Stephan Bergmann
dcea29c283 Make NC_ constexpr-friendly
...by moving the char8_t -> char reinterpret_cast out of any potential constexpr
paths into a new TranslateId::getId.  And demonstrate constexpr'ability by
making the aCategories var in OApplicationIconControl::Fill
(dbaccess/source/ui/app/AppIconControl.cxx) constexpr.  (And there might be more
such cases that could now be made constexpr.)

Change-Id: I0b4e3292faf8f6b901f9b9e934e1aa6bf0f583ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157862
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-12 18:17:49 +02:00
Gabor Kelemen
c17d369230 Use less epoxy external headers dependency
Change-Id: If5d4e5a65a0fcea6bd67cdba48742f6aaec0811d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156556
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <kelemeng@ubuntu.com>
2023-09-23 10:38:36 +02:00
Arnaud Versini
4d54aeb67a avmedia : use std::recursive_mutex instead of osl::Mutex.
Mostly reverts 621143588b but using recursive_mutex instead.

Change-Id: I4b23410720834e19c5dd28c43bc84ed1b3e08072
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153236
Tested-by: Jenkins
Reviewed-by: Arnaud Versini <arnaud.versini@libreoffice.org>
2023-08-08 14:35:37 +02:00
Noel Grandin
e266d448f4 loplugin:stringstatic look for more strings
that can be initialised at compile-time instead of runtime

Change-Id: I08d516fdc13a3a79f93c079f89ac44cbc7a1ed71
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153620
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-06-27 13:10:44 +02:00
Eike Rathke
c203378894 Change LocaleDataWrapper::getDuration() parameter to tools::Duration
... instead of tools::Time

Change-Id: I8e49de43a1870541d75add34089eec67b7a8be31
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153533
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
2023-06-24 01:20:12 +02:00
Mike Kaganski
1df99a2155 Use getXWeak in avmedia
Change-Id: I1dc1e597c50b0081375b9216ac4e6436b84aaa0c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150832
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-04-29 21:35:24 +02:00
Stephan Bergmann
61717b215b Fix some getImplementationName
...to match the corresponding .component entries

Change-Id: I280619b9c5660910ecc5386b39aa2c8d2ba23f9f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150692
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-04-21 08:05:08 +02:00
Michael Stahl
a5225ba82e avmedia,*: guess the mime type of media files based on file name
.. at least for the most popular types, and do it automatically in
MediaItem::setURL().

This should work in practice in most cases and is much simpler than
adding some type detection or calling into platform dependent avmedia
backends.

Remove the parameter that was only ever set to
"application/vnd.sun.star.media" anyway, the same value that would be
used if it's missing.

Stop using that silly type for everything, only use it when guessing
fails.

In case an ODF document is loaded, it will use the mime type loaded from
the file (see setting of MediaMimeType in SdXMLPluginShapeContext) and
not guess it because that would require updating the entry in
manifest.xml as well.

Change-Id: I8ce29cf7425678ae11dda1d8c875be818f8623af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150049
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-04-05 14:34:51 +02:00
Mike Kaganski
116b9d6ddf Avoid conversions between OUString and OString in VCL
Standardize on OUString, which is the main internal string class.
Convert from/to OUString only when communicating with respective
external APIs.

Removes about 200 conversions from the code.

Change-Id: I96ecee7c6fd271bb76639220e96d69d2964bed26
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149930
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-04-02 18:46:47 +02:00
Noel Grandin
e7dbef922a rtl::Static to thread-safe-static
Change-Id: Ife02e6d2be3ebfbb08522ab0183ef4aa31a99e19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149415
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-03-23 19:49:25 +00:00
Michael Stahl
621143588b Revert "avmedia : use std::mutex instead of osl::Mutex"
This reverts commit 477fa6c3cb.

MissingPluginInstaller requires a recursive lock:

Thread 2 (Thread 0x7f8e73d69700 (LWP 29931)):
0  __lll_lock_wait () at /lib64/libpthread.so.0
...
5  std::unique_lock<std::mutex>::lock() (this=0x7f8e73d65a88) at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_mutex.h:267
6  std::unique_lock<std::mutex>::unique_lock(std::mutex&) (this=0x7f8e73d65a88, __m=...) at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_mutex.h:197
7  avmedia::gstreamer::(anonymous namespace)::MissingPluginInstaller::detach(avmedia::gstreamer::Player const*) (this=0x7f8e644c6be0 <rtl::Static<avmedia::gstreamer::(anonymous namespace)::MissingPluginInstaller, avmedia::gstreamer::(anonymous namespace)::TheMissingPluginInstaller>::get()::instance>, source=0x75d2fa0) at avmedia/source/gstreamer/gstplayer.cxx:187
8  avmedia::gstreamer::Player::disposing() (this=0x75d2fa0) at avmedia/source/gstreamer/gstplayer.cxx:334
9  cppu::WeakComponentImplHelperBase::dispose() (this=0x75d2fa0) at cppuhelper/source/implbase.cxx:104
10 cppu::PartialWeakComponentImplHelper<com::sun::media::XPlayer, com::sun::lang::XServiceInfo>::dispose() (this=0x75d2fa0) at include/cppuhelper/compbase.hxx:90
11 cppu::WeakComponentImplHelperBase::release() (this=0x75d2fa0) at cppuhelper/source/implbase.cxx:79
13 rtl::Reference<avmedia::gstreamer::Player>::~Reference() (this=0x7f8e7c028f20) at include/rtl/ref.hxx:129
...
21 std::__debug::set<rtl::Reference<avmedia::gstreamer::Player>, std::less<rtl::Reference<avmedia::gstreamer::Player> >, std::allocator<rtl::Reference<avmedia::gstreamer::Player> > >::clear() (this=0x7f8e644c6cd8 <rtl::Static<avmedia::gstreamer::(anonymous namespace)::MissingPluginInstaller, avmedia::gstreamer::(anonymous namespace)::TheMissingPluginInstaller>::get()::instance+248>) at /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/debug/set.h:426
22 avmedia::gstreamer::(anonymous namespace)::MissingPluginInstaller::report(rtl::Reference<avmedia::gstreamer::Player> const&, _GstMessage*) (this=0x7f8e644c6be0 <rtl::Static<avmedia::gstreamer::(anonymous namespace)::MissingPluginInstaller, avmedia::gstreamer::(anonymous namespace)::TheMissingPluginInstaller>::get()::instance>, source=..., message=0x7cdb400) at avmedia/source/gstreamer/gstplayer.cxx:156
23 avmedia::gstreamer::Player::processSyncMessage(_GstMessage*) (this=0x75abfe0, message=0x7cdb400) at avmedia/source/gstreamer/gstplayer.cxx:536
24 avmedia::gstreamer::pipeline_bus_sync_handler(_GstBus*, _GstMessage*, void*) (message=0x7cdb400, data=0x75abfe0) at avmedia/source/gstreamer/gstplayer.cxx:382
25 gst_bus_post () at /lib64/libgstreamer-1.0.so.0

Change-Id: Ia8e7fef4d4cee2dde7189702af6dddf883b6cceb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149233
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-03-22 08:25:26 +00:00
Stephan Bergmann
7a21cba913 Silence -Werror=deprecated-declarations for now
...as seen with gtk4-devel-4.10.0-3.fc38.x86_64,

> avmedia/source/gtk/gtkplayer.cxx: In member function ‘virtual com::sun::uno::Reference<com::sun::media::XPlayerWindow> avmedia::gtk::GtkPlayer::createPlayerWindow(const com::sun::uno::Sequence<com::sun::uno::Any>&)’:
> avmedia/source/gtk/gtkplayer.cxx:358:20: error: ‘void gtk_widget_show(GtkWidget*)’ is deprecated: Use 'gtk_widget_set_visible or gtk_window_present' instead [-Werror=deprecated-declarations]
>   358 |     gtk_widget_show(m_pVideo);
>       |     ~~~~~~~~~~~~~~~^~~~~~~~~~
> In file included from /usr/include/gtk-4.0/gtk/gtkapplication.h:27,
>                  from /usr/include/gtk-4.0/gtk/gtkwindow.h:33,
>                  from /usr/include/gtk-4.0/gtk/gtkaboutdialog.h:30,
>                  from /usr/include/gtk-4.0/gtk/gtk.h:34,
>                  from avmedia/source/gtk/gtkplayer.cxx:28:
> /usr/include/gtk-4.0/gtk/gtkwidget.h:273:12: note: declared here
>   273 | void       gtk_widget_show                (GtkWidget           *widget);
>       |            ^~~~~~~~~~~~~~~
> avmedia/source/gtk/gtkplayer.cxx:359:20: error: ‘void gtk_widget_show(GtkWidget*)’ is deprecated: Use 'gtk_widget_set_visible or gtk_window_present' instead [-Werror=deprecated-declarations]
>   359 |     gtk_widget_show(pParent);
>       |     ~~~~~~~~~~~~~~~^~~~~~~~~
> /usr/include/gtk-4.0/gtk/gtkwidget.h:273:12: note: declared here
>   273 | void       gtk_widget_show                (GtkWidget           *widget);
>       |            ^~~~~~~~~~~~~~~

Change-Id: I1cb2988cec6cda3dd3e43a3773647a3ddaf211e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148899
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-03-15 08:23:24 +00:00
Noel Grandin
770580ba8e osl::Mutex->std::mutex in avmedia::win::Window
Change-Id: I4e6e7fd03c4aa7847edbc48bccac88ec361c8237
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148637
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-03-11 05:54:26 +00:00
Noel Grandin
21734247d5 drop internal support for 1-bit images
on modern hardware, these are less efficient than regular alpha
channels.

Also, this greatly simplies the range of stuff that vcl needs to deal
with, which will make the upcoming transparency->alpha patch easier to
deal with.

Enhance vcl::CreateFromData to convert incoming 1-bit data to 8-bit
image.

Change-Id: I35829da750029fe373d0d2911a669d10bab6ad23
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145321
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-01-12 06:52:42 +00:00
Noel Grandin
16987d2aae unique_ptr->optional for Graphic
Graphic is just a wrapper around shared_ptr, so no need to
allocate this separately

Change-Id: Ie657dea1c021e66a6876e814090a44cb6f995b91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139739
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-10 12:19:13 +02:00
Miklos Vajna
916848d877 tdf#149971 avmedia: implement video crop support in the gsteamer backend
If a media shape had cropping defined, we already took that into account
when presenting a preview for it, but not during video playback.

The reason for this is that the preview may be set by a file importer
(e.g. PPTX) explicitly, in which case the preview is a bitmap we get
without any video processing.

As a start, implement video crop for the gstreamer backend (used on
Linux), and also pass in the media item (containing crop and other
properties) both during the edit view (MediaWindowImpl) and presenting
(ViewMediaShape). We pass in the whole media item, so in case later
other filters (e.g. black-and-white) are wanted, we have all that info
in the backends already.

Other backends (avmediaMacAVF and avmediawin) are untouched so far.
svx/qa/unit/data/video-snapshot.pptx is modified to have a yellow border
when cropping is unimplemented, which is now not visible with the
gtreamer backend, matching PowerPoint behavior. PPTX export was working
out of the box already.

Change-Id: If26b7a4391bcffe9cbddd9933e1bab69be52924e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138867
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2022-08-26 11:48:41 +02:00
Miklos Vajna
b6f0fd6a2f Related: tdf#149971 avmedia: add doc model and render for crop of media objects
It is possible to provide an explicit preview of media objects since
commit 8fa1d453c9 (Related: tdf#149971
svx: support explicitly provided snapshots for media shapes,
2022-08-24), however they can't be cropped.

This means that media shapes from PPTX with cropping show unexpected
content and can also have a buggy aspect ratio.

Extend avmedia::MediaItem to store cropping and take it into account
when returning the preview bitmap in SdrMediaObj::getSnapshot(). PPTX
import works out of the box, as oox/ already tried to set a cropping
property on the media shape.

This is just the preview, the cropping of the video itself is not yet
implemented.

Change-Id: I8db3e0dcf252613d56eb0e6139adf097e53b15cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138808
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2022-08-25 15:41:34 +02:00
Michael Weghorn
53b5b720d3 avmedia gtk: Fix build for Gtk >= 4.7.2 ('-Werror=deprecated-declarations')
Failed like this:

    .../libreoffice/avmedia/source/gtk/gtkplayer.cxx: In member function ‘virtual com::sun::uno::Reference<com::sun::media::XPlayerWindow> avmedia::gtk::GtkPlayer::createPlayerWindow(const com::sun::uno::Sequence<com::sun::uno::Any>&)’:
    .../libreoffice/avmedia/source/gtk/gtkplayer.cxx:346:38: error: ‘void gtk_picture_set_keep_aspect_ratio(GtkPicture*, gboolean)’ is deprecated: Use 'gtk_picture_set_content_fit' instead [-Werror=deprecated-declarations]
      346 |     gtk_picture_set_keep_aspect_ratio(GTK_PICTURE(m_pVideo), false);
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /usr/include/gtk-4.0/gtk/gtk.h:196,
                     from .../libreoffice/avmedia/source/gtk/gtkplayer.cxx:28:
    /usr/include/gtk-4.0/gtk/gtkpicture.h:73:17: note: declared here
       73 | void            gtk_picture_set_keep_aspect_ratio       (GtkPicture             *self,
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1plus: all warnings being treated as errors
    make[1]: *** [.../libreoffice/solenv/gbuild/LinkTarget.mk:337: .../libreoffice/workdir/CxxObject/avmedia/source/gtk/gtkplayer.o] Error 1
    make: *** [Makefile:289: build] Error 2

Corresponding Gtk commit [1]:

    commit d8a73cbd03118e94bd75f5fa183a646fecb053ce
    Author: Marco Melorio <marco.melorio@protonmail.com>
    Date:   Fri Jul 15 18:18:26 2022 +0200

        picture: Add content-fit property

        It allows to specify the resize mode of the paintable inside the
        GtkPicture allocation. This also deprecates the keep-aspect-ratio
        property.

        Fixes #5027.

While the doc [2] says its deprecated for 4.8, that sems to refer to stable
Gtk version only and it's already the case for the unstable version
4.7.2 (as packaged in Debian testing now):

    $ git tag --contains d8a73cbd03118e94bd75f5fa183a646fecb053ce
    4.7.2

Use `gtk_picture_set_content_fit` with `GTK_CONTENT_FIT_FILL`
that results in the same behavior for Gtk >= 4.7.2.

[1] d8a73cbd03
[2] https://docs.gtk.org/gtk4/method.Picture.set_keep_aspect_ratio.html

Change-Id: I9fc527e6674cb8e4774adbe7d14cce2a264a5a67
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138797
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-08-25 09:49:49 +02:00