4#include <common/qgstreamermediaplayer_p.h>
6#include <audio/qgstreameraudiodevice_p.h>
7#include <common/qglist_helper_p.h>
8#include <common/qgst_debug_p.h>
9#include <common/qgstutils_p.h>
10#include <common/qgst_discoverer_p.h>
11#include <common/qgst_play_p.h>
12#include <common/qgstpipeline_p.h>
13#include <common/qgstreameraudiooutput_p.h>
14#include <common/qgstreamermessage_p.h>
15#include <common/qgstreamermetadata_p.h>
16#include <common/qgstreamervideooutput_p.h>
17#include <common/qgstreamervideosink_p.h>
18#include <uri_handler/qgstreamer_qiodevice_handler_p.h>
19#include <qgstreamerformatinfo_p.h>
21#include <QtMultimedia/private/qthreadlocalrhi_p.h>
22#include <QtMultimedia/qaudiodevice.h>
23#include <QtConcurrent/qtconcurrentrun.h>
24#include <QtCore/qdebug.h>
25#include <QtCore/qiodevice.h>
26#include <QtCore/qloggingcategory.h>
27#include <QtCore/qthread.h>
28#include <QtCore/qurl.h>
29#include <QtCore/private/quniquehandle_p.h>
39 using TrackType = QGstreamerMediaPlayer::TrackType;
41 QByteArrayView type = caps
.at(0
).name();
43 if (type.startsWith(
"video/x-raw"))
44 return TrackType::VideoStream;
45 if (type.startsWith(
"audio/x-raw"))
46 return TrackType::AudioStream;
47 if (type.startsWith(
"text"))
48 return TrackType::SubtitleStream;
57 return QtConcurrent::run([url = std::move(url)] {
58 QGst::QGstDiscoverer discoverer;
59 return discoverer.discover(url);
66 using namespace Qt::Literals;
67 using namespace std::chrono;
68 using namespace std::chrono_literals;
70 if (discoveryResult) {
72 gst_play_set_uri(m_gstPlay.get(), url.toEncoded().constData());
74 m_trackMetaData.fill({});
75 seekableChanged(discoveryResult->isSeekable);
76 if (discoveryResult->duration)
77 m_duration = round<milliseconds>(*discoveryResult->duration);
80 durationChanged(m_duration);
82 m_metaData = QGst::toContainerMetadata(*discoveryResult);
84 videoAvailableChanged(!discoveryResult->videoStreams.empty());
85 audioAvailableChanged(!discoveryResult->audioStreams.empty());
88 for (
const auto &videoInfo : discoveryResult->videoStreams) {
89 m_trackMetaData[0].emplace_back(QGst::toStreamMetadata(videoInfo));
90 QSize nativeSize = QGstUtils::qCalculateFrameSizeGStreamer(videoInfo.size,
91 videoInfo.pixelAspectRatio);
92 m_nativeSize.emplace_back(nativeSize);
94 for (
const auto &audioInfo : discoveryResult->audioStreams)
95 m_trackMetaData[1].emplace_back(QGst::toStreamMetadata(audioInfo));
96 for (
const auto &subtitleInfo : discoveryResult->subtitleStreams)
97 m_trackMetaData[2].emplace_back(QGst::toStreamMetadata(subtitleInfo));
99 using Key = QMediaMetaData::Key;
100 auto copyKeysToRootMetadata = [&](
const QMediaMetaData &reference, QSpan<
const Key> keys) {
101 for (QMediaMetaData::Key key : keys) {
102 QVariant referenceValue = reference.value(key);
103 if (referenceValue.isValid())
104 m_metaData.insert(key, referenceValue);
110 if (!m_trackMetaData[0].empty())
111 copyKeysToRootMetadata(m_trackMetaData[0].front(),
121 if (!m_trackMetaData[1].empty())
122 copyKeysToRootMetadata(m_trackMetaData[1].front(),
128 if (!m_url.isEmpty())
129 m_metaData.insert(QMediaMetaData::Key::Url, m_url);
131 qCDebug(qLcMediaPlayer) <<
"metadata:" << m_metaData;
132 qCDebug(qLcMediaPlayer) <<
"video metadata:" << m_trackMetaData[0];
133 qCDebug(qLcMediaPlayer) <<
"audio metadata:" << m_trackMetaData[1];
134 qCDebug(qLcMediaPlayer) <<
"subtitle metadata:" << m_trackMetaData[2];
139 isVideoAvailable() ? 0 : -1,
140 isAudioAvailable() ? 0 : -1,
143 updateVideoTrackEnabled();
144 updateAudioTrackEnabled();
145 updateNativeSizeOnVideoOutput();
146 positionChanged(0ms);
149 m_hasPendingMedia =
false;
150 if (m_requestedPlaybackState) {
151 switch (*m_requestedPlaybackState) {
152 case QMediaPlayer::PlayingState:
155 case QMediaPlayer::PausedState:
164 qCDebug(qLcMediaPlayer) <<
"Discovery error:" << discoveryResult.error();
165 m_resourceErrorState = ResourceErrorState::ErrorOccurred;
166 setInvalidMediaWithError(QMediaPlayer::Error::ResourceError,
167 u"Resource cannot be discovered"_s);
168 m_hasPendingMedia =
false;
169 resetStateForEmptyOrInvalidMedia();
179 qCDebug(qLcMediaPlayer) <<
"Added pad" << pad.name() <<
"from" << src.name();
183 std::optional<QGstreamerMediaPlayer::TrackType> type = toTrackType(caps);
187 customPipelinePads[*type] = pad;
195 customPipeline.add(sink);
197 customPipelineSinks[VideoStream] = sink;
204 customPipeline.add(sink);
206 customPipelineSinks[AudioStream] = sink;
210 case SubtitleStream: {
214 customPipeline.add(sink);
216 customPipelineSinks[SubtitleStream] = sink;
233 Q_ASSERT(thread()->isCurrentThread());
235 qCDebug(qLcMediaPlayer) <<
"Removed pad" << pad.name() <<
"from" << src.name() <<
"for stream"
238 auto found =
std::find(customPipelinePads.begin(), customPipelinePads.end(), pad);
239 if (found == customPipelinePads.end())
242 TrackType type = TrackType(
std::distance(customPipelinePads.begin(), found));
247 case SubtitleStream: {
248 if (customPipelineSinks[VideoStream]) {
249 customPipeline.stopAndRemoveElements(customPipelineSinks[VideoStream]);
250 customPipelineSinks[VideoStream] = {};
262 using namespace std::chrono_literals;
263 m_nativeSize.clear();
265 bool metadataNeedsSignal = !m_metaData.isEmpty();
266 bool tracksNeedsSignal =
267 std::any_of(m_trackMetaData.begin(), m_trackMetaData.end(), [](
const auto &container) {
268 return !container.empty();
272 m_trackMetaData.fill({});
274 seekableChanged(
false);
276 videoAvailableChanged(
false);
277 audioAvailableChanged(
false);
279 m_activeTrack.fill(-1);
281 if (metadataNeedsSignal)
283 if (tracksNeedsSignal)
289 int activeVideoTrack = activeTrack(TrackType::VideoStream);
290 bool hasVideoTrack = activeVideoTrack != -1;
292 QSize nativeSize = hasVideoTrack ? m_nativeSize[activeTrack(TrackType::VideoStream)] : QSize{};
294 QVariant orientation = hasVideoTrack
295 ? m_trackMetaData[TrackType::VideoStream][activeTrack(TrackType::VideoStream)].value(
296 QMediaMetaData::Key::Orientation)
299 if (orientation.isValid()) {
300 auto rotation = orientation.value<QtVideo::Rotation>();
301 gstVideoOutput->setRotation(rotation);
308 gst_play_seek(m_gstPlay.get(), gst_play_get_position(m_gstPlay.get()));
313 bool hasTrack = m_activeTrack[TrackType::VideoStream] != -1;
317 gst_play_set_video_track_enabled(m_gstPlay.get(), hasTrack && hasSink);
322 bool hasTrack = m_activeTrack[TrackType::AudioStream] != -1;
323 bool hasAudioOut = gstAudioOutput;
325 gst_play_set_audio_track_enabled(m_gstPlay.get(), hasTrack && hasAudioOut);
330 if (qFuzzyIsNull(newProgress - m_bufferProgress))
333 m_bufferProgress = newProgress;
334 bufferProgressChanged(m_bufferProgress);
339 auto handlers = std::initializer_list<QGObjectHandlerScopedConnection *>{ &sourceSetup };
340 for (QGObjectHandlerScopedConnection *handler : handlers)
341 handler->disconnect();
346 auto videoOutput = QGstreamerVideoOutput::create();
348 return q23::unexpected{ videoOutput.error() };
356 gst_play_config_set_seek_accurate(config, accurate);
360 QMediaPlayer *parent)
362 QPlatformMediaPlayer(parent),
363 gstVideoOutput(videoOutput),
365 gst_play_new(
nullptr),
366 QGstPlayHandle::HasRef,
369 GST_PIPELINE_CAST(gst_play_get_pipeline(m_gstPlay.get())),
370 QGstPipeline::HasRef,
373 QGstBusHandle{ gst_play_get_message_bus(m_gstPlay.get()), QGstBusHandle::HasRef },
387 constexpr bool useNxpWorkaround = std::is_same_v<
decltype(&gst_play_config_set_seek_accurate),
388 void (*)(GstPlay *, gboolean)>;
390 QUniqueGstStructureHandle config{
391 gst_play_get_config(m_gstPlay.get()),
394 if constexpr (useNxpWorkaround)
395 setSeekAccurate(m_gstPlay.get(),
true);
397 setSeekAccurate(config.get(),
true);
399 gst_play_set_config(m_gstPlay.get(), config.release());
401 QUniqueGstStructureHandle config{
402 gst_play_get_config(m_gstPlay.get()),
404 gst_play_config_set_seek_accurate(config.get(),
true);
405 gst_play_set_config(m_gstPlay.get(), config.release());
408 gstVideoOutput->setParent(
this);
412 m_gstVideoSink =
new QGstreamerRelayVideoSink(
this);
415 m_playbin.set(
"video-sink", gstVideoOutput->gstElement());
416 m_playbin.set(
"text-sink", gstVideoOutput->gstSubtitleElement());
417 m_playbin.set(
"audio-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
419 m_gstPlayBus.installMessageFilter(
this);
422 gst_play_set_subtitle_track_enabled(m_gstPlay.get(),
false);
424 sourceSetup = m_playbin.connect(
"source-setup", GCallback(sourceSetupCallback),
this);
426 m_activeTrack.fill(-1);
434 cleanupCustomPipeline();
436 m_gstPlayBus.removeMessageFilter(
static_cast<QGstreamerBusMessageFilter *>(
this));
437 gst_bus_set_flushing(m_gstPlayBus.get(), TRUE);
438 gst_play_stop(m_gstPlay.get());
441 m_playbin.setStateSync(GST_STATE_NULL);
443 m_playbin.set(
"video-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
444 m_playbin.set(
"text-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
445 m_playbin.set(
"audio-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
450 using namespace std::chrono;
452 positionChanged(round<milliseconds>(nanoseconds{
453 gst_play_get_position(m_gstPlay.get()),
459 if (isCustomSource()) {
460 constexpr bool traceBusMessages =
true;
461 if (traceBusMessages)
462 qCDebug(qLcMediaPlayer) <<
"received bus message:" << message;
464 switch (message.type()) {
465 case GST_MESSAGE_WARNING:
466 qWarning() <<
"received bus message:" << message;
469 case GST_MESSAGE_INFO:
470 qInfo() <<
"received bus message:" << message;
473 case GST_MESSAGE_ERROR:
474 qWarning() <<
"received bus message:" << message;
475 customPipeline.dumpPipelineGraph(
"GST_MESSAGE_ERROR");
478 case GST_MESSAGE_LATENCY:
479 customPipeline.recalculateLatency();
488 switch (message.type()) {
489 case GST_MESSAGE_APPLICATION:
490 if (gst_play_is_play_message(message.message()))
491 return processBusMessageApplication(message);
495 qCDebug(qLcMediaPlayer) << message;
505 using namespace std::chrono;
507 gst_play_message_parse_type(message.message(), &type);
511 case GST_PLAY_MESSAGE_URI_LOADED: {
512 mediaStatusChanged(QMediaPlayer::LoadedMedia);
516 case GST_PLAY_MESSAGE_POSITION_UPDATED: {
517 if (state() == QMediaPlayer::PlaybackState::PlayingState) {
519 constexpr bool usePayload =
false;
520 if constexpr (usePayload) {
521 GstClockTime position;
522 gst_play_message_parse_position_updated(message.message(), &position);
523 positionChanged(round<milliseconds>(nanoseconds{ position }));
525 GstClockTime position = gst_play_get_position(m_gstPlay.get());
526 positionChanged(round<milliseconds>(nanoseconds{ position }));
531 case GST_PLAY_MESSAGE_DURATION_CHANGED: {
532 GstClockTime duration;
533 gst_play_message_parse_duration_updated(message.message(), &duration);
534 milliseconds durationInMs = round<milliseconds>(nanoseconds{ duration });
535 durationChanged(durationInMs);
537 m_metaData.insert(QMediaMetaData::Duration,
int(durationInMs.count()));
542 case GST_PLAY_MESSAGE_BUFFERING: {
544 gst_play_message_parse_buffering_percent(message.message(), &percent);
545 updateBufferProgress(percent * 0.01f);
548 case GST_PLAY_MESSAGE_STATE_CHANGED: {
550 gst_play_message_parse_state_changed(message.message(), &state);
553 case GstPlayState::GST_PLAY_STATE_STOPPED:
554 if (stateChangeToSkip) {
555 qCDebug(qLcMediaPlayer) <<
" skipping StoppedState transition";
557 stateChangeToSkip -= 1;
560 stateChanged(QMediaPlayer::StoppedState);
561 updateBufferProgress(0);
564 case GstPlayState::GST_PLAY_STATE_PAUSED:
565 stateChanged(QMediaPlayer::PausedState);
566 mediaStatusChanged(QMediaPlayer::BufferedMedia);
568 updateBufferProgress(1);
570 case GstPlayState::GST_PLAY_STATE_BUFFERING:
571 mediaStatusChanged(QMediaPlayer::BufferingMedia);
573 case GstPlayState::GST_PLAY_STATE_PLAYING:
574 stateChanged(QMediaPlayer::PlayingState);
575 mediaStatusChanged(QMediaPlayer::BufferedMedia);
577 updateBufferProgress(1);
584 case GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED: {
587 QUniqueGstPlayMediaInfoHandle info{};
588 gst_play_message_parse_media_info_updated(message.message(), &info);
590 seekableChanged(gst_play_media_info_is_seekable(info.get()));
592 const gchar *title = gst_play_media_info_get_title(info.get());
593 m_metaData.insert(QMediaMetaData::Title, QString::fromUtf8(title));
600 case GST_PLAY_MESSAGE_END_OF_STREAM: {
602 positionChanged(m_duration);
603 qCDebug(qLcMediaPlayer) <<
"EOS: restarting loop";
604 gst_play_play(m_gstPlay.get());
605 positionChanged(0ms);
609 stateChangeToSkip += 1;
611 qCDebug(qLcMediaPlayer) <<
"EOS: done";
612 positionChanged(m_duration);
613 mediaStatusChanged(QMediaPlayer::EndOfMedia);
614 stateChanged(QMediaPlayer::StoppedState);
620 case GST_PLAY_MESSAGE_ERROR:
621 case GST_PLAY_MESSAGE_WARNING:
622 case GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED:
623 case GST_PLAY_MESSAGE_VOLUME_CHANGED:
624 case GST_PLAY_MESSAGE_MUTE_CHANGED:
625 case GST_PLAY_MESSAGE_SEEK_DONE:
629 Q_UNREACHABLE_RETURN(
false);
635 return m_duration.count();
640 return !m_url.isEmpty() || m_stream;
648 switch (mediaStatus()) {
649 case QMediaPlayer::MediaStatus::NoMedia:
650 case QMediaPlayer::MediaStatus::InvalidMedia:
660 return m_bufferProgress;
665 return QMediaTimeRange();
670 return gst_play_get_rate(m_gstPlay.get());
675 if (isCustomSource()) {
676 static std::once_flag flag;
677 std::call_once(flag, [] {
680 <<
"setPlaybackRate with custom gstreamer pipelines can cause pipeline hangs. "
684 customPipeline.setPlaybackRate(rate);
688 if (rate == playbackRate())
691 qCDebug(qLcMediaPlayer) <<
"gst_play_set_rate" << rate;
692 gst_play_set_rate(m_gstPlay.get(), rate);
693 playbackRateChanged(rate);
698 std::chrono::milliseconds posInMs{ pos };
700 setPosition(posInMs);
705 using namespace std::chrono;
707 if (isCustomSource()) {
708 static std::once_flag flag;
709 std::call_once(flag, [] {
711 qWarning() <<
"setPosition with custom gstreamer pipelines can cause pipeline hangs. "
715 customPipeline.setPosition(pos);
719 if (m_hasPendingMedia) {
723 qCDebug(qLcMediaPlayer) <<
"gst_play_seek" << pos;
724 gst_play_seek(m_gstPlay.get(), nanoseconds(pos).count());
726 if (mediaStatus() == QMediaPlayer::EndOfMedia)
727 mediaStatusChanged(QMediaPlayer::LoadedMedia);
728 positionChanged(pos);
733 if (isCustomSource()) {
735 customPipeline.setState(GST_STATE_PLAYING);
736 stateChanged(QMediaPlayer::PlayingState);
740 if (m_hasPendingMedia) {
743 m_requestedPlaybackState = QMediaPlayer::PlayingState;
747 QMediaPlayer::PlaybackState currentState = state();
748 if (currentState == QMediaPlayer::PlayingState || !hasValidMedia())
751 if (currentState != QMediaPlayer::PausedState)
754 if (mediaStatus() == QMediaPlayer::EndOfMedia) {
756 mediaStatusChanged(QMediaPlayer::LoadedMedia);
760 gst_play_seek(m_gstPlay.get(), m_pendingSeek->count());
761 m_pendingSeek = std::nullopt;
764 qCDebug(qLcMediaPlayer) <<
"gst_play_play";
766 gst_play_play(m_gstPlay.get());
767 stateChanged(QMediaPlayer::PlayingState);
772 if (isCustomSource()) {
774 customPipeline.setState(GST_STATE_PAUSED);
775 stateChanged(QMediaPlayer::PausedState);
779 if (m_hasPendingMedia) {
780 m_requestedPlaybackState = QMediaPlayer::PausedState;
784 if (state() == QMediaPlayer::PausedState || !hasMedia()
785 || m_resourceErrorState != ResourceErrorState::NoError)
790 qCDebug(qLcMediaPlayer) <<
"gst_play_pause";
791 gst_play_pause(m_gstPlay.get());
793 mediaStatusChanged(QMediaPlayer::BufferedMedia);
794 stateChanged(QMediaPlayer::PausedState);
799 if (isCustomSource()) {
800 customPipeline.setState(GST_STATE_READY);
801 stateChanged(QMediaPlayer::StoppedState);
806 if (m_hasPendingMedia) {
807 m_requestedPlaybackState = QMediaPlayer::StoppedState;
811 using namespace std::chrono_literals;
812 if (state() == QMediaPlayer::StoppedState) {
813 if (position() != 0) {
815 positionChanged(0ms);
816 mediaStatusChanged(QMediaPlayer::LoadedMedia);
821 qCDebug(qLcMediaPlayer) <<
"gst_play_stop";
823 gst_play_stop(m_gstPlay.get());
825 stateChanged(QMediaPlayer::StoppedState);
827 mediaStatusChanged(QMediaPlayer::LoadedMedia);
828 positionChanged(0ms);
833 if (isCustomSource())
834 return customPipeline;
852 return PitchCompensationAvailability::AlwaysOn;
870 const gchar *typeName = g_type_name_from_instance((GTypeInstance *)source);
871 qCDebug(qLcMediaPlayer) <<
"Setting up source:" << typeName;
873 if (typeName == std::string_view(
"GstRTSPSrc")) {
877 int v = qEnvironmentVariableIntValue(
"QT_MEDIA_RTSP_LATENCY", &ok);
880 qCDebug(qLcMediaPlayer) <<
" -> setting source latency to:" << latency <<
"ms";
881 s.set(
"latency", latency);
884 v = qEnvironmentVariableIntValue(
"QT_MEDIA_RTSP_DROP_ON_LATENCY", &ok);
887 qCDebug(qLcMediaPlayer) <<
" -> setting drop-on-latency to:" << drop;
888 s.set(
"drop-on-latency", drop);
891 v = qEnvironmentVariableIntValue(
"QT_MEDIA_RTSP_DO_RETRANSMISSION", &ok);
894 qCDebug(qLcMediaPlayer) <<
" -> setting do-retransmission to:" << retrans;
895 s.set(
"do-retransmission", retrans);
902 cleanupCustomPipeline();
904 m_resourceErrorState = ResourceErrorState::NoError;
909 m_discoveryHandler.cancel();
910 m_discoverFuture.cancel();
914 streamURL = qGstRegisterQIODevice(stream);
916 if (content.isEmpty() && !stream) {
917 mediaStatusChanged(QMediaPlayer::NoMedia);
918 resetStateForEmptyOrInvalidMedia();
922 if (isCustomSource()) {
923 setMediaCustomSource(content);
925 mediaStatusChanged(QMediaPlayer::LoadingMedia);
926 m_hasPendingMedia =
true;
927 m_requestedPlaybackState = std::nullopt;
929 const QUrl &playUrl = stream ? streamURL : content;
930 m_discoverFuture = discover(playUrl);
933 m_discoverFuture.then(
this,[
this, playUrl](
const DiscoverResult &result) {
934 handleDiscoverResult(result, playUrl);
941 using namespace Qt::Literals;
942 using namespace std::chrono;
943 using namespace std::chrono_literals;
948 m_playbin.set(
"video-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
949 m_playbin.set(
"text-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
950 m_playbin.set(
"audio-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
953 if (QGstElement sink = gstVideoOutput->gstreamerVideoSink()->gstSink())
958 customPipeline = QGstPipeline::create(
"customPipeline");
959 customPipeline.installMessageFilter(
this);
960 positionUpdateTimer = std::make_unique<QTimer>();
962 QObject::connect(positionUpdateTimer.get(), &QTimer::timeout,
this, [
this] {
963 Q_ASSERT(customPipeline);
964 auto position = customPipeline.position();
966 positionChanged(round<milliseconds>(position));
969 positionUpdateTimer->start(100ms);
971 QByteArray gstLaunchString =
972 content.toString(QUrl::RemoveScheme | QUrl::PrettyDecoded).toLatin1();
973 qCDebug(qLcMediaPlayer) <<
"generating" << gstLaunchString;
976 emit error(QMediaPlayer::ResourceError, u"Could not create custom pipeline"_s);
981 customPipeline.add(decoder);
984 qGstSafeCast<GstBin>(element.element()),
988 elementBin.addUnlinkedGhostPads(GstPadDirection::GST_PAD_SRC);
991 padAdded = decoder.onPadAdded<&QGstreamerMediaPlayer::decoderPadAddedCustomSource>(
this);
992 padRemoved = decoder.onPadRemoved<&QGstreamerMediaPlayer::decoderPadRemovedCustomSource>(
this);
994 customPipeline.setStateSync(GstState::GST_STATE_PAUSED);
996 auto srcPadVisitor = [](GstElement *element, GstPad *pad,
void *self) -> gboolean {
997 reinterpret_cast<QGstreamerMediaPlayer *>(self)->decoderPadAddedCustomSource(
998 QGstElement{ element, QGstElement::NeedsRef }, QGstPad{ pad, QGstPad::NeedsRef });
1002 gst_element_foreach_pad(element.element(), srcPadVisitor,
this);
1004 mediaStatusChanged(QMediaPlayer::LoadedMedia);
1006 customPipeline.dumpGraph(
"setMediaCustomPipeline");
1011 customPipeline.setStateSync(GST_STATE_NULL);
1012 customPipeline.removeMessageFilter(
this);
1014 for (QGstElement &sink : customPipelineSinks)
1016 customPipeline.remove(sink);
1018 positionUpdateTimer = {};
1019 customPipeline = {};
1024 if (isCustomSource()) {
1025 qWarning() <<
"QMediaPlayer::setAudioOutput not supported when using custom sources";
1029 if (gstAudioOutput == output)
1034 gstOutput->setAsync(
true);
1038 m_playbin.set(
"audio-sink", gstAudioOutput->gstElement());
1040 m_playbin.set(
"audio-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
1041 updateAudioTrackEnabled();
1045 if (!qmediaplayerDestructorCalled)
1046 m_playbin.finishStateChange();
1064 Q_ASSERT(pluggableSink);
1070 QSpan<
const QMediaMetaData> tracks = m_trackMetaData[type];
1071 return tracks.size();
1076 QSpan<
const QMediaMetaData> tracks = m_trackMetaData[type];
1077 if (index < tracks.size())
1078 return tracks[index];
1084 return m_activeTrack[type];
1089 if (m_activeTrack[type] == index)
1092 int formerTrack = m_activeTrack[type];
1093 m_activeTrack[type] = index;
1096 case TrackType::VideoStream: {
1098 gst_play_set_video_track(m_gstPlay.get(), index);
1099 updateVideoTrackEnabled();
1100 updateNativeSizeOnVideoOutput();
1103 case TrackType::AudioStream: {
1105 gst_play_set_audio_track(m_gstPlay.get(), index);
1106 updateAudioTrackEnabled();
1109 case TrackType::SubtitleStream: {
1111 gst_play_set_subtitle_track(m_gstPlay.get(), index);
1112 gst_play_set_subtitle_track_enabled(m_gstPlay.get(), index != -1);
1119 if (formerTrack != -1 && index != -1)
1122 seekToCurrentPosition();
QGstStructureView at(int index) const
bool syncStateWithParent()
static QGstElement createFromPipelineDescription(const char *)
bool link(const QGstPad &sink) const
QGstCaps queryCaps() const
QGString streamId() const
QGstElement gstElement() const
void connectPluggableVideoSink(QGstreamerPluggableVideoSink *pluggableSink)
void disconnectPluggableVideoSink()
void setVideoSink(QGstreamerRelayVideoSink *sink)
QGstreamerRelayVideoSink * gstreamerVideoSink() const
void setNativeSize(QSize)
std::optional< QGstreamerMediaPlayer::TrackType > toTrackType(const QGstCaps &caps)
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
QGstPlayMessageAdaptor(const QGstreamerMessage &m)