| 1 | // Copyright (C) 2024 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 QGST_PLAY_P_H |
| 5 | #define QGST_PLAY_P_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 <QtCore/qglobal.h> |
| 19 | #include <QtCore/qlocale.h> |
| 20 | |
| 21 | #include <QtMultimedia/private/qmultimediautils_p.h> |
| 22 | |
| 23 | #include "common/qgst_handle_types_p.h" |
| 24 | |
| 25 | #include <gst/play/gstplay.h> |
| 26 | |
| 27 | QT_BEGIN_NAMESPACE |
| 28 | |
| 29 | namespace QGstPlaySupport { |
| 30 | |
| 31 | using QUniqueGstPlayMediaInfoHandle = |
| 32 | QGstImpl::QGObjectHandleHelper<GstPlayMediaInfo>::SharedHandle; |
| 33 | using QUniqueGstPlayAudioInfoHandle = |
| 34 | QGstImpl::QGObjectHandleHelper<GstPlayAudioInfo>::SharedHandle; |
| 35 | using QUniqueGstPlayVideoInfoHandle = |
| 36 | QGstImpl::QGObjectHandleHelper<GstPlayVideoInfo>::SharedHandle; |
| 37 | using QUniqueGstPlaySubtitleInfoHandle = |
| 38 | QGstImpl::QGObjectHandleHelper<GstPlaySubtitleInfo>::SharedHandle; |
| 39 | |
| 40 | struct VideoInfo |
| 41 | { |
| 42 | int bitrate{}; |
| 43 | int maxBitrate{}; |
| 44 | QSize size; |
| 45 | Fraction framerate{}; |
| 46 | Fraction pixelAspectRatio{}; |
| 47 | }; |
| 48 | |
| 49 | VideoInfo parseGstPlayVideoInfo(const GstPlayVideoInfo *); |
| 50 | |
| 51 | struct AudioInfo |
| 52 | { |
| 53 | int channels{}; |
| 54 | int sampleRate{}; |
| 55 | int bitrate{}; |
| 56 | int maxBitrate{}; |
| 57 | QLocale::Language language{}; |
| 58 | }; |
| 59 | |
| 60 | AudioInfo parseGstPlayAudioInfo(const GstPlayAudioInfo *); |
| 61 | |
| 62 | struct SubtitleInfo |
| 63 | { |
| 64 | QLocale::Language language{}; |
| 65 | }; |
| 66 | |
| 67 | SubtitleInfo parseGstPlaySubtitleInfo(const GstPlaySubtitleInfo *); |
| 68 | |
| 69 | template <typename T> |
| 70 | constexpr bool isStreamType = std::is_same_v<std::decay_t<T>, GstPlayVideoInfo> |
| 71 | || std::is_same_v<std::decay_t<T>, GstPlayAudioInfo> |
| 72 | || std::is_same_v<std::decay_t<T>, GstPlaySubtitleInfo>; |
| 73 | |
| 74 | int getStreamIndex(const GstPlayStreamInfo *); |
| 75 | |
| 76 | template <typename T, typename Enabler = std::enable_if_t<isStreamType<T>>> |
| 77 | int getStreamIndex(const T *info) |
| 78 | { |
| 79 | return getStreamIndex(GST_PLAY_STREAM_INFO(info)); |
| 80 | } |
| 81 | |
| 82 | } // namespace QGstPlaySupport |
| 83 | |
| 84 | QT_END_NAMESPACE |
| 85 | |
| 86 | #endif |
| 87 |
