Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
avfmediaplayer_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef AVFMEDIAPLAYER_H
5#define AVFMEDIAPLAYER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtMultimedia/qmediaplayer.h>
19#include <QtMultimedia/qvideoframe.h>
20#include <QtMultimedia/private/qplatformmediaplayer_p.h>
21#include <QtCore/qbytearray.h>
22#include <QtCore/qobject.h>
23#include <QtCore/qresource.h>
24#include <QtCore/qset.h>
25#include <QtCore/qtimer.h>
26#include <QtCore/qurl.h>
27
28#import <AVFoundation/AVFoundation.h>
29
30@class AVFMediaPlayerObserver;
31
32QT_BEGIN_NAMESPACE
33
34class AVFMediaPlayer;
36class AVFVideoSink;
37
39{
41public:
44
45 void setVideoSink(QVideoSink *sink) override;
48
49 QUrl media() const override;
50 QIODevice *mediaStream() const override;
51 void setMedia(const QUrl &content, QIODevice *stream) override;
52
53 qint64 position() const override;
54 qint64 duration() const override;
55
56 float bufferProgress() const override;
57
59
60 qreal playbackRate() const override;
61
62 void setAudioOutput(QPlatformAudioOutput *output) override;
64
65 QMediaMetaData metaData() const override;
66
67 static void videoOrientationForAssetTrack(AVAssetTrack *track,
68 QtVideo::Rotation &angle,
69 bool &mirrored);
70
72 void setPitchCompensation(bool enabled) override;
73 bool pitchCompensation() const override;
74
75public Q_SLOTS:
77 void nativeSizeChanged(QSize size);
78
79 void setPosition(qint64 pos) override;
80
81 void play() override;
82 void pause() override;
83 void stop() override;
84
85 void setVolume(float volume);
86 void setMuted(bool muted);
88
89 void processEOS();
90 void processLoadStateChange(QMediaPlayer::PlaybackState newState);
92 void processMediaLoadError(QMediaPlayer::Error errorCode);
93
94 void seekCompleted();
95
98
99 void processBufferStateChange(int bufferProgress);
100
101 void processDurationChange(qint64 duration);
102
103 void streamReady();
104 void streamDestroyed();
105 void loadMediaStream();
106 void updateTracks();
107 void setActiveTrack(QPlatformMediaPlayer::TrackType type, int index) override;
108 int activeTrack(QPlatformMediaPlayer::TrackType type) override;
109 int trackCount(TrackType) override;
110 QMediaMetaData trackMetaData(TrackType type, int trackNumber) override;
111
112public:
115
116private:
117 void resetStream(QIODevice *stream = nullptr);
118 void applyPitchCompensation(bool enabled);
119 void resetBufferProgress();
120
121 void orientationChanged(QtVideo::Rotation rotation, bool mirrored);
122
123 AVFVideoRendererControl *m_videoOutput = nullptr;
124 AVFVideoSink *m_videoSink = nullptr;
125
126 QIODevice *m_mediaStream;
127 QUrl m_resources;
128 QMediaMetaData m_metaData;
129
130 qreal m_rate;
131 qint64 m_requestedPosition;
132
133 qint64 m_duration;
134 int m_bufferProgress;
135 bool m_pitchCompensationEnabled{ false };
136
137 AVFMediaPlayerObserver *m_observer;
138
139 QTimer m_playbackTimer;
140};
141
142QT_END_NAMESPACE
143
144#endif // AVFMEDIAPLAYER_H
static AVMetadataIdentifier toIdentifier(QMediaMetaData::Key key, AVMetadataKeySpace keySpace)
static AVMutableMetadataItem * setAVMetadataItemForKey(QMediaMetaData::Key key, const QVariant &value, AVMetadataKeySpace keySpace=AVMetadataKeySpaceCommon)
static std::optional< QMediaMetaData::Key > toKey(AVMetadataItem *item)
static QMediaMetaData fromAVMetadata(NSArray *metadataItems)
const AVMetadataIDs keyToAVMetaDataID[]
QMediaMetaData trackMetaData(TrackType type, int trackNumber) override
qint64 duration() const override
void setVolume(float volume)
void processLoadStateChange()
int trackCount(TrackType) override
void setPosition(qint64 pos) override
void setVideoSink(QVideoSink *sink) override
QMediaTimeRange availablePlaybackRanges() const override
void nativeSizeChanged(QSize size)
static void videoOrientationForAssetTrack(AVAssetTrack *track, QtVideo::Rotation &angle, bool &mirrored)
QMediaMetaData metaData() const override
void setVideoOutput(AVFVideoRendererControl *output)
void stop() override
float bufferProgress() const override
void processMediaLoadError(QMediaPlayer::Error errorCode)
void setMedia(const QUrl &content, QIODevice *stream) override
qint64 position() const override
int activeTrack(QPlatformMediaPlayer::TrackType type) override
void setPitchCompensation(bool enabled) override
void setMuted(bool muted)
void pause() override
QPlatformAudioOutput * m_audioOutput
void play() override
void processDurationChange(qint64 duration)
QUrl media() const override
QList< AVPlayerItemTrack * > nativeTracks[QPlatformMediaPlayer::NTrackTypes]
bool pitchCompensation() const override
void processLoadStateFailure()
void updateAudioOutputDevice()
qreal playbackRate() const override
void processLoadStateChange(QMediaPlayer::PlaybackState newState)
QIODevice * mediaStream() const override
PitchCompensationAvailability pitchCompensationAvailability() const override
~AVFMediaPlayer() override
AVAsset * currentAssetHandle()
void setAudioOutput(QPlatformAudioOutput *output) override
void setActiveTrack(QPlatformMediaPlayer::TrackType type, int index) override
QList< QMediaMetaData > tracks[QPlatformMediaPlayer::NTrackTypes]
void processBufferStateChange(int bufferProgress)
#define __has_include(x)
AVMetadataIdentifier quickTimeUserData
AVMetadataIdentifier common
AVMetadataIdentifier ID3
AVMetadataIdentifier iTunes
AVMetadataIdentifier isoUserData
AVMetadataIdentifier quickTime