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 error(QMediaPlayer::Error::ResourceError, u"Resource cannot be discovered"_s);
167 m_hasPendingMedia =
false;
168 mediaStatusChanged(QMediaPlayer::InvalidMedia);
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 },
382 constexpr bool useNxpWorkaround = std::is_same_v<
decltype(&gst_play_config_set_seek_accurate),
383 void (*)(GstPlay *, gboolean)>;
385 QUniqueGstStructureHandle config{
386 gst_play_get_config(m_gstPlay.get()),
389 if constexpr (useNxpWorkaround)
390 setSeekAccurate(m_gstPlay.get(),
true);
392 setSeekAccurate(config.get(),
true);
394 gst_play_set_config(m_gstPlay.get(), config.release());
396 QUniqueGstStructureHandle config{
397 gst_play_get_config(m_gstPlay.get()),
399 gst_play_config_set_seek_accurate(config.get(),
true);
400 gst_play_set_config(m_gstPlay.get(), config.release());
403 gstVideoOutput->setParent(
this);
407 m_gstVideoSink =
new QGstreamerRelayVideoSink(
this);
410 m_playbin.set(
"video-sink", gstVideoOutput->gstElement());
411 m_playbin.set(
"text-sink", gstVideoOutput->gstSubtitleElement());
412 m_playbin.set(
"audio-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
414 m_gstPlayBus.installMessageFilter(
this);
417 gst_play_set_subtitle_track_enabled(m_gstPlay.get(),
false);
419 sourceSetup = m_playbin.connect(
"source-setup", GCallback(sourceSetupCallback),
this);
421 m_activeTrack.fill(-1);
429 cleanupCustomPipeline();
431 m_gstPlayBus.removeMessageFilter(
static_cast<QGstreamerBusMessageFilter *>(
this));
432 gst_bus_set_flushing(m_gstPlayBus.get(), TRUE);
433 gst_play_stop(m_gstPlay.get());
436 m_playbin.setStateSync(GST_STATE_NULL);
438 m_playbin.set(
"video-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
439 m_playbin.set(
"text-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
440 m_playbin.set(
"audio-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
445 using namespace std::chrono;
447 positionChanged(round<milliseconds>(nanoseconds{
448 gst_play_get_position(m_gstPlay.get()),
454 if (isCustomSource()) {
455 constexpr bool traceBusMessages =
true;
456 if (traceBusMessages)
457 qCDebug(qLcMediaPlayer) <<
"received bus message:" << message;
459 switch (message.type()) {
460 case GST_MESSAGE_WARNING:
461 qWarning() <<
"received bus message:" << message;
464 case GST_MESSAGE_INFO:
465 qInfo() <<
"received bus message:" << message;
468 case GST_MESSAGE_ERROR:
469 qWarning() <<
"received bus message:" << message;
470 customPipeline.dumpPipelineGraph(
"GST_MESSAGE_ERROR");
473 case GST_MESSAGE_LATENCY:
474 customPipeline.recalculateLatency();
483 switch (message.type()) {
484 case GST_MESSAGE_APPLICATION:
485 if (gst_play_is_play_message(message.message()))
486 return processBusMessageApplication(message);
490 qCDebug(qLcMediaPlayer) << message;
500 using namespace std::chrono;
502 gst_play_message_parse_type(message.message(), &type);
506 case GST_PLAY_MESSAGE_URI_LOADED: {
507 mediaStatusChanged(QMediaPlayer::LoadedMedia);
511 case GST_PLAY_MESSAGE_POSITION_UPDATED: {
512 if (state() == QMediaPlayer::PlaybackState::PlayingState) {
514 constexpr bool usePayload =
false;
515 if constexpr (usePayload) {
516 GstClockTime position;
517 gst_play_message_parse_position_updated(message.message(), &position);
518 positionChanged(round<milliseconds>(nanoseconds{ position }));
520 GstClockTime position = gst_play_get_position(m_gstPlay.get());
521 positionChanged(round<milliseconds>(nanoseconds{ position }));
526 case GST_PLAY_MESSAGE_DURATION_CHANGED: {
527 GstClockTime duration;
528 gst_play_message_parse_duration_updated(message.message(), &duration);
529 milliseconds durationInMs = round<milliseconds>(nanoseconds{ duration });
530 durationChanged(durationInMs);
532 m_metaData.insert(QMediaMetaData::Duration,
int(durationInMs.count()));
537 case GST_PLAY_MESSAGE_BUFFERING: {
539 gst_play_message_parse_buffering_percent(message.message(), &percent);
540 updateBufferProgress(percent * 0.01f);
543 case GST_PLAY_MESSAGE_STATE_CHANGED: {
545 gst_play_message_parse_state_changed(message.message(), &state);
548 case GstPlayState::GST_PLAY_STATE_STOPPED:
549 if (stateChangeToSkip) {
550 qCDebug(qLcMediaPlayer) <<
" skipping StoppedState transition";
552 stateChangeToSkip -= 1;
555 stateChanged(QMediaPlayer::StoppedState);
556 updateBufferProgress(0);
559 case GstPlayState::GST_PLAY_STATE_PAUSED:
560 stateChanged(QMediaPlayer::PausedState);
561 mediaStatusChanged(QMediaPlayer::BufferedMedia);
563 updateBufferProgress(1);
565 case GstPlayState::GST_PLAY_STATE_BUFFERING:
566 mediaStatusChanged(QMediaPlayer::BufferingMedia);
568 case GstPlayState::GST_PLAY_STATE_PLAYING:
569 stateChanged(QMediaPlayer::PlayingState);
570 mediaStatusChanged(QMediaPlayer::BufferedMedia);
572 updateBufferProgress(1);
579 case GST_PLAY_MESSAGE_MEDIA_INFO_UPDATED: {
582 QUniqueGstPlayMediaInfoHandle info{};
583 gst_play_message_parse_media_info_updated(message.message(), &info);
585 seekableChanged(gst_play_media_info_is_seekable(info.get()));
587 const gchar *title = gst_play_media_info_get_title(info.get());
588 m_metaData.insert(QMediaMetaData::Title, QString::fromUtf8(title));
595 case GST_PLAY_MESSAGE_END_OF_STREAM: {
597 positionChanged(m_duration);
598 qCDebug(qLcMediaPlayer) <<
"EOS: restarting loop";
599 gst_play_play(m_gstPlay.get());
600 positionChanged(0ms);
604 stateChangeToSkip += 1;
606 qCDebug(qLcMediaPlayer) <<
"EOS: done";
607 positionChanged(m_duration);
608 mediaStatusChanged(QMediaPlayer::EndOfMedia);
609 stateChanged(QMediaPlayer::StoppedState);
615 case GST_PLAY_MESSAGE_ERROR:
616 case GST_PLAY_MESSAGE_WARNING:
617 case GST_PLAY_MESSAGE_VIDEO_DIMENSIONS_CHANGED:
618 case GST_PLAY_MESSAGE_VOLUME_CHANGED:
619 case GST_PLAY_MESSAGE_MUTE_CHANGED:
620 case GST_PLAY_MESSAGE_SEEK_DONE:
624 Q_UNREACHABLE_RETURN(
false);
630 return m_duration.count();
635 return !m_url.isEmpty() || m_stream;
643 switch (mediaStatus()) {
644 case QMediaPlayer::MediaStatus::NoMedia:
645 case QMediaPlayer::MediaStatus::InvalidMedia:
655 return m_bufferProgress;
660 return QMediaTimeRange();
665 return gst_play_get_rate(m_gstPlay.get());
670 if (isCustomSource()) {
671 static std::once_flag flag;
672 std::call_once(flag, [] {
675 <<
"setPlaybackRate with custom gstreamer pipelines can cause pipeline hangs. "
679 customPipeline.setPlaybackRate(rate);
683 if (rate == playbackRate())
686 qCDebug(qLcMediaPlayer) <<
"gst_play_set_rate" << rate;
687 gst_play_set_rate(m_gstPlay.get(), rate);
688 playbackRateChanged(rate);
693 std::chrono::milliseconds posInMs{ pos };
695 setPosition(posInMs);
700 using namespace std::chrono;
702 if (isCustomSource()) {
703 static std::once_flag flag;
704 std::call_once(flag, [] {
706 qWarning() <<
"setPosition with custom gstreamer pipelines can cause pipeline hangs. "
710 customPipeline.setPosition(pos);
714 if (m_hasPendingMedia) {
718 qCDebug(qLcMediaPlayer) <<
"gst_play_seek" << pos;
719 gst_play_seek(m_gstPlay.get(), nanoseconds(pos).count());
721 if (mediaStatus() == QMediaPlayer::EndOfMedia)
722 mediaStatusChanged(QMediaPlayer::LoadedMedia);
723 positionChanged(pos);
728 if (isCustomSource()) {
730 customPipeline.setState(GST_STATE_PLAYING);
731 stateChanged(QMediaPlayer::PlayingState);
735 if (m_hasPendingMedia) {
738 m_requestedPlaybackState = QMediaPlayer::PlayingState;
742 QMediaPlayer::PlaybackState currentState = state();
743 if (currentState == QMediaPlayer::PlayingState || !hasValidMedia())
746 if (currentState != QMediaPlayer::PausedState)
749 if (mediaStatus() == QMediaPlayer::EndOfMedia) {
751 mediaStatusChanged(QMediaPlayer::LoadedMedia);
755 gst_play_seek(m_gstPlay.get(), m_pendingSeek->count());
756 m_pendingSeek = std::nullopt;
759 qCDebug(qLcMediaPlayer) <<
"gst_play_play";
761 gst_play_play(m_gstPlay.get());
762 stateChanged(QMediaPlayer::PlayingState);
767 if (isCustomSource()) {
769 customPipeline.setState(GST_STATE_PAUSED);
770 stateChanged(QMediaPlayer::PausedState);
774 if (m_hasPendingMedia) {
775 m_requestedPlaybackState = QMediaPlayer::PausedState;
779 if (state() == QMediaPlayer::PausedState || !hasMedia()
780 || m_resourceErrorState != ResourceErrorState::NoError)
785 qCDebug(qLcMediaPlayer) <<
"gst_play_pause";
786 gst_play_pause(m_gstPlay.get());
788 mediaStatusChanged(QMediaPlayer::BufferedMedia);
789 stateChanged(QMediaPlayer::PausedState);
794 if (isCustomSource()) {
795 customPipeline.setState(GST_STATE_READY);
796 stateChanged(QMediaPlayer::StoppedState);
801 if (m_hasPendingMedia) {
802 m_requestedPlaybackState = QMediaPlayer::StoppedState;
806 using namespace std::chrono_literals;
807 if (state() == QMediaPlayer::StoppedState) {
808 if (position() != 0) {
810 positionChanged(0ms);
811 mediaStatusChanged(QMediaPlayer::LoadedMedia);
816 qCDebug(qLcMediaPlayer) <<
"gst_play_stop";
818 gst_play_stop(m_gstPlay.get());
820 stateChanged(QMediaPlayer::StoppedState);
822 mediaStatusChanged(QMediaPlayer::LoadedMedia);
823 positionChanged(0ms);
828 if (isCustomSource())
829 return customPipeline;
847 return PitchCompensationAvailability::AlwaysOn;
865 const gchar *typeName = g_type_name_from_instance((GTypeInstance *)source);
866 qCDebug(qLcMediaPlayer) <<
"Setting up source:" << typeName;
868 if (typeName == std::string_view(
"GstRTSPSrc")) {
872 int v = qEnvironmentVariableIntValue(
"QT_MEDIA_RTSP_LATENCY", &ok);
875 qCDebug(qLcMediaPlayer) <<
" -> setting source latency to:" << latency <<
"ms";
876 s.set(
"latency", latency);
879 v = qEnvironmentVariableIntValue(
"QT_MEDIA_RTSP_DROP_ON_LATENCY", &ok);
882 qCDebug(qLcMediaPlayer) <<
" -> setting drop-on-latency to:" << drop;
883 s.set(
"drop-on-latency", drop);
886 v = qEnvironmentVariableIntValue(
"QT_MEDIA_RTSP_DO_RETRANSMISSION", &ok);
889 qCDebug(qLcMediaPlayer) <<
" -> setting do-retransmission to:" << retrans;
890 s.set(
"do-retransmission", retrans);
897 cleanupCustomPipeline();
899 m_resourceErrorState = ResourceErrorState::NoError;
904 m_discoveryHandler.cancel();
905 m_discoverFuture.cancel();
909 streamURL = qGstRegisterQIODevice(stream);
911 if (content.isEmpty() && !stream) {
912 mediaStatusChanged(QMediaPlayer::NoMedia);
913 resetStateForEmptyOrInvalidMedia();
917 if (isCustomSource()) {
918 setMediaCustomSource(content);
920 mediaStatusChanged(QMediaPlayer::LoadingMedia);
921 m_hasPendingMedia =
true;
922 m_requestedPlaybackState = std::nullopt;
924 const QUrl &playUrl = stream ? streamURL : content;
925 m_discoverFuture = discover(playUrl);
928 m_discoverFuture.then(
this,[
this, playUrl](
const DiscoverResult &result) {
929 handleDiscoverResult(result, playUrl);
936 using namespace Qt::Literals;
937 using namespace std::chrono;
938 using namespace std::chrono_literals;
943 m_playbin.set(
"video-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
944 m_playbin.set(
"text-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
945 m_playbin.set(
"audio-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
948 if (QGstElement sink = gstVideoOutput->gstreamerVideoSink()->gstSink())
953 customPipeline = QGstPipeline::create(
"customPipeline");
954 customPipeline.installMessageFilter(
this);
955 positionUpdateTimer = std::make_unique<QTimer>();
957 QObject::connect(positionUpdateTimer.get(), &QTimer::timeout,
this, [
this] {
958 Q_ASSERT(customPipeline);
959 auto position = customPipeline.position();
961 positionChanged(round<milliseconds>(position));
964 positionUpdateTimer->start(100ms);
966 QByteArray gstLaunchString =
967 content.toString(QUrl::RemoveScheme | QUrl::PrettyDecoded).toLatin1();
968 qCDebug(qLcMediaPlayer) <<
"generating" << gstLaunchString;
971 emit error(QMediaPlayer::ResourceError, u"Could not create custom pipeline"_s);
976 customPipeline.add(decoder);
979 qGstSafeCast<GstBin>(element.element()),
983 elementBin.addUnlinkedGhostPads(GstPadDirection::GST_PAD_SRC);
986 padAdded = decoder.onPadAdded<&QGstreamerMediaPlayer::decoderPadAddedCustomSource>(
this);
987 padRemoved = decoder.onPadRemoved<&QGstreamerMediaPlayer::decoderPadRemovedCustomSource>(
this);
989 customPipeline.setStateSync(GstState::GST_STATE_PAUSED);
991 auto srcPadVisitor = [](GstElement *element, GstPad *pad,
void *self) -> gboolean {
992 reinterpret_cast<QGstreamerMediaPlayer *>(self)->decoderPadAddedCustomSource(
993 QGstElement{ element, QGstElement::NeedsRef }, QGstPad{ pad, QGstPad::NeedsRef });
997 gst_element_foreach_pad(element.element(), srcPadVisitor,
this);
999 mediaStatusChanged(QMediaPlayer::LoadedMedia);
1001 customPipeline.dumpGraph(
"setMediaCustomPipeline");
1006 customPipeline.setStateSync(GST_STATE_NULL);
1007 customPipeline.removeMessageFilter(
this);
1009 for (QGstElement &sink : customPipelineSinks)
1011 customPipeline.remove(sink);
1013 positionUpdateTimer = {};
1014 customPipeline = {};
1019 if (isCustomSource()) {
1020 qWarning() <<
"QMediaPlayer::setAudioOutput not supported when using custom sources";
1024 if (gstAudioOutput == output)
1029 gstOutput->setAsync(
true);
1033 m_playbin.set(
"audio-sink", gstAudioOutput->gstElement());
1035 m_playbin.set(
"audio-sink", QGstElement::createFromPipelineDescription(
"fakesink"));
1036 updateAudioTrackEnabled();
1040 if (!qmediaplayerDestructorCalled)
1041 m_playbin.finishStateChange();
1059 Q_ASSERT(pluggableSink);
1065 QSpan<
const QMediaMetaData> tracks = m_trackMetaData[type];
1066 return tracks.size();
1071 QSpan<
const QMediaMetaData> tracks = m_trackMetaData[type];
1072 if (index < tracks.size())
1073 return tracks[index];
1079 return m_activeTrack[type];
1084 if (m_activeTrack[type] == index)
1087 int formerTrack = m_activeTrack[type];
1088 m_activeTrack[type] = index;
1091 case TrackType::VideoStream: {
1093 gst_play_set_video_track(m_gstPlay.get(), index);
1094 updateVideoTrackEnabled();
1095 updateNativeSizeOnVideoOutput();
1098 case TrackType::AudioStream: {
1100 gst_play_set_audio_track(m_gstPlay.get(), index);
1101 updateAudioTrackEnabled();
1104 case TrackType::SubtitleStream: {
1106 gst_play_set_subtitle_track(m_gstPlay.get(), index);
1107 gst_play_set_subtitle_track_enabled(m_gstPlay.get(), index != -1);
1114 if (formerTrack != -1 && index != -1)
1117 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)