Skip to content

Commit cff168d

Browse files
Draft proposal of RDK Telemetry quirk for gstreamer
1 parent 6a5ec7d commit cff168d

File tree

5 files changed

+149
-13
lines changed

5 files changed

+149
-13
lines changed

Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,10 @@ MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer()
224224
{
225225
GST_DEBUG_OBJECT(pipeline(), "Disposing player");
226226
m_isPlayerShuttingDown.store(true);
227-
m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::STOP);
227+
228+
auto& quirksManager = GStreamerQuirksManager::singleton();
229+
if (quirksManager.isEnabled())
230+
quirksManager.reportPlaybackState(Telemetry::IReport::AVPipelineState::STOP);
228231

229232
if (m_gstreamerHolePunchHost)
230233
m_gstreamerHolePunchHost->playerPrivateWillBeDestroyed();
@@ -292,7 +295,9 @@ MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer()
292295

293296
m_player = nullptr;
294297
m_notifier->invalidate();
295-
m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::DESTROY);
298+
299+
if (quirksManager.isEnabled())
300+
quirksManager.reportPlaybackState(Telemetry::IReport::AVPipelineState::DESTROY);
296301
}
297302

298303
bool MediaPlayerPrivateGStreamer::isAvailable()
@@ -452,7 +457,10 @@ void MediaPlayerPrivateGStreamer::play()
452457
m_preload = MediaPlayer::Preload::Auto;
453458
updateDownloadBufferingFlag();
454459
GST_INFO_OBJECT(pipeline(), "Play");
455-
m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::PLAY);
460+
461+
auto& quirksManager = GStreamerQuirksManager::singleton();
462+
if (quirksManager.isEnabled())
463+
quirksManager.reportPlaybackState(Telemetry::IReport::AVPipelineState::PLAY);
456464
} else
457465
loadingFailed(MediaPlayer::NetworkState::Empty);
458466
}
@@ -471,7 +479,9 @@ void MediaPlayerPrivateGStreamer::pause()
471479
auto result = changePipelineState(GST_STATE_PAUSED);
472480
if (result == ChangePipelineStateResult::Ok) {
473481
GST_INFO_OBJECT(pipeline(), "Pause");
474-
m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::PAUSE);
482+
auto& quirksManager = GStreamerQuirksManager::singleton();
483+
if (quirksManager.isEnabled())
484+
quirksManager.reportPlaybackState(Telemetry::IReport::AVPipelineState::PAUSE);
475485
} else if (result == ChangePipelineStateResult::Failed)
476486
loadingFailed(MediaPlayer::NetworkState::Empty);
477487
}
@@ -578,8 +588,11 @@ void MediaPlayerPrivateGStreamer::seek(const MediaTime& mediaTime)
578588

579589
MediaTime time = std::min(mediaTime, durationMediaTime());
580590
GST_INFO_OBJECT(pipeline(), "[Seek] seeking to %s", toString(time).utf8().data());
581-
m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::SEEK_START,
582-
"seek_from:" + std::to_string(playbackPosition().toDouble()) + ", seek_to:" + std::to_string(time.toDouble()));
591+
592+
auto& quirksManager = GStreamerQuirksManager::singleton();
593+
if (quirksManager.isEnabled())
594+
quirksManager.reportPlaybackState(Telemetry::IReport::AVPipelineState::SEEK_START,
595+
"seek_from:" + std::to_string(playbackPosition().toDouble()) + ", seek_to:" + std::to_string(time.toDouble()));
583596

584597
if (m_isSeeking) {
585598
m_timeOfOverlappingSeek = time;
@@ -1882,7 +1895,10 @@ void MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
18821895
break;
18831896

18841897
m_errorMessage = String::fromLatin1(err->message);
1885-
m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::PLAYBACK_ERROR, std::string(err->message));
1898+
1899+
auto& quirksManager = GStreamerQuirksManager::singleton();
1900+
if (quirksManager.isEnabled())
1901+
quirksManager.reportPlaybackState(Telemetry::IReport::AVPipelineState::PLAYBACK_ERROR, std::string(err->message));
18861902

18871903
error = MediaPlayer::NetworkState::Empty;
18881904
if (g_error_matches(err.get(), GST_STREAM_ERROR, GST_STREAM_ERROR_CODEC_NOT_FOUND)
@@ -2521,7 +2537,11 @@ void MediaPlayerPrivateGStreamer::purgeOldDownloadFiles(const String& downloadFi
25212537
void MediaPlayerPrivateGStreamer::finishSeek()
25222538
{
25232539
GST_DEBUG_OBJECT(pipeline(), "[Seek] seeked to %s", toString(m_seekTime).utf8().data());
2524-
m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::SEEK_DONE, "seek_to:" + std::to_string(m_seekTime.toDouble()));
2540+
2541+
auto& quirksManager = GStreamerQuirksManager::singleton();
2542+
if (quirksManager.isEnabled())
2543+
quirksManager.reportPlaybackState(Telemetry::IReport::AVPipelineState::SEEK_DONE, "seek_to:" + std::to_string(m_seekTime.toDouble()));
2544+
25252545
m_isSeeking = false;
25262546
invalidateCachedPosition();
25272547
if (m_timeOfOverlappingSeek != m_seekTime && m_timeOfOverlappingSeek.isValid()) {
@@ -2881,7 +2901,10 @@ void MediaPlayerPrivateGStreamer::didEnd()
28812901
#endif
28822902
}
28832903
timeChanged();
2884-
m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::END_OF_STREAM);
2904+
2905+
auto& quirksManager = GStreamerQuirksManager::singleton();
2906+
if (quirksManager.isEnabled())
2907+
quirksManager.reportPlaybackState(Telemetry::IReport::AVPipelineState::END_OF_STREAM);
28852908
}
28862909

28872910
void MediaPlayerPrivateGStreamer::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types)
@@ -3113,8 +3136,11 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin(const URL& url)
31133136
player->videoSinkCapsChanged(videoSinkPad);
31143137
}), this);
31153138

3116-
m_telemetry.reportDrmInfo(getDrm());
3117-
m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::CREATE);
3139+
auto& quirksManager = GStreamerQuirksManager::singleton();
3140+
if (quirksManager.isEnabled()) {
3141+
quirksManager.reportDrmInfo(getDrm());
3142+
quirksManager.reportPlaybackState(Telemetry::IReport::AVPipelineState::CREATE);
3143+
}
31183144
}
31193145

31203146
void MediaPlayerPrivateGStreamer::configureVideoDecoder(GstElement* decoder)
@@ -3204,7 +3230,10 @@ void MediaPlayerPrivateGStreamer::pausedTimerFired()
32043230
{
32053231
GST_DEBUG_OBJECT(pipeline(), "In PAUSED for too long. Releasing pipeline resources.");
32063232
changePipelineState(GST_STATE_NULL);
3207-
m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::DESTROY);
3233+
3234+
auto& quirksManager = GStreamerQuirksManager::singleton();
3235+
if (quirksManager.isEnabled())
3236+
quirksManager.reportPlaybackState(Telemetry::IReport::AVPipelineState::DESTROY);
32083237
}
32093238

32103239
void MediaPlayerPrivateGStreamer::acceleratedRenderingStateChanged()
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2024 RDK Management
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
#include "GStreamerQuirkRdkTelemetry.h"
28+
29+
#if USE(GSTREAMER)
30+
31+
#include "GStreamerCommon.h"
32+
33+
namespace WebCore {
34+
35+
GST_DEBUG_CATEGORY_STATIC(webkit_rdktelemetry_quirks_debug);
36+
#define GST_CAT_DEFAULT webkit_rdktelemetry_quirks_debug
37+
38+
GStreamerQuirkRdkTelemetry::GStreamerQuirkRdkTelemetry()
39+
{
40+
GST_DEBUG_CATEGORY_INIT(webkit_rdktelemetry_quirks_debug, "webkitquirksrdktelemetry", 0, "WebKit RDK Telemetry Quirks");
41+
}
42+
43+
void GStreamerQuirkRdkTelemetry::reportPlaybackState(AVPipelineState state, const std::string &additionalInfo, MediaType mediaType)
44+
{
45+
//TBD
46+
}
47+
48+
void GStreamerQuirkRdkTelemetry::reportDrmInfo(DrmType drmType, const std::string &additionalInfo)
49+
{
50+
//TBD
51+
}
52+
53+
#undef GST_CAT_DEFAULT
54+
55+
} // namespace WebCore
56+
57+
#endif // USE(GSTREAMER)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (C) 2024 Igalia S.L
3+
* Copyright (C) 2024 Metrological Group B.V.
4+
*
5+
* This library is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Library General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 2 of the License, or (at your option) any later version.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Library General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Library General Public License
16+
* aint with this library; see the file COPYING.LIB. If not, write to
17+
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18+
* Boston, MA 02110-1301, USA.
19+
*/
20+
21+
#pragma once
22+
23+
#if USE(GSTREAMER)
24+
25+
#include "GStreamerQuirks.h"
26+
#include "ITelemetry.h"
27+
28+
namespace WebCore {
29+
30+
class GStreamerQuirkRdkTelemetry final : public GStreamerQuirk {
31+
public:
32+
GStreamerQuirkRdkTelemetry();
33+
const ASCIILiteral identifier() const final { return "RdkTelemetry"_s; }
34+
35+
void reportPlaybackState(AVPipelineState state, const std::string &additionalInfo, MediaType mediaType) final;
36+
void reportDrmInfo(DrmType drmType, const std::string &additionalInfo) final;
37+
};
38+
39+
} // namespace WebCore
40+
41+
#endif // USE(GSTREAMER)

Source/WebCore/platform/gstreamer/GStreamerQuirks.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ GStreamerQuirksManager::GStreamerQuirksManager(bool isForTesting, bool loadQuirk
8585
#if PLATFORM(RPI) && CPU(ARM) && !CPU(ARM64)
8686
quirksListBuilder.append("openmax,");
8787
#endif
88+
#if USE(RDK_TELEMETRY)
89+
quirksListBuilder.append("rdktelemetry");
90+
#endif
8891
#if PLATFORM(REALTEK)
8992
quirksListBuilder.append("realtek,");
9093
#endif
@@ -96,7 +99,7 @@ GStreamerQuirksManager::GStreamerQuirksManager(bool isForTesting, bool loadQuirk
9699
GST_DEBUG("Attempting to parse requested quirks: %s", quirks.ascii().data());
97100
if (!quirks.isEmpty()) {
98101
if (WTF::equalLettersIgnoringASCIICase(quirks, "help"_s)) {
99-
WTFLogAlways("Supported quirks for WEBKIT_GST_QUIRKS are: amlogic, broadcom, bcmnexus, openmax, realtek, westeros");
102+
WTFLogAlways("Supported quirks for WEBKIT_GST_QUIRKS are: amlogic, broadcom, bcmnexus, openmax, rdktelemetry, realtek, westeros");
100103
return;
101104
}
102105

@@ -110,6 +113,8 @@ GStreamerQuirksManager::GStreamerQuirksManager(bool isForTesting, bool loadQuirk
110113
quirk = WTF::makeUnique<GStreamerQuirkBcmNexus>();
111114
else if (WTF::equalLettersIgnoringASCIICase(identifier, "openmax"_s))
112115
quirk = WTF::makeUnique<GStreamerQuirkOpenMAX>();
116+
else if (WTF::equalLettersIgnoringASCIICase(identifier, "rdktelemetry"_s))
117+
quirk = WTF::makeUnique<GStreamerQuirkRdkTelemetry>();
113118
else if (WTF::equalLettersIgnoringASCIICase(identifier, "realtek"_s))
114119
quirk = WTF::makeUnique<GStreamerQuirkRealtek>();
115120
else if (WTF::equalLettersIgnoringASCIICase(identifier, "rialto"_s))

Source/WebCore/platform/gstreamer/GStreamerQuirks.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ class GStreamerQuirksManager : public RefCounted<GStreamerQuirksManager> {
147147
void setupBufferingPercentageCorrection(MediaPlayerPrivateGStreamer*, GstState currentState, GstState newState, GRefPtr<GstElement>&&) const;
148148

149149
void processWebAudioSilentBuffer(GstBuffer*) const;
150+
151+
void reportPlaybackState(AVPipelineState state, const std::string &additionalInfo = "", MediaType mediaType = MediaType::NONE);
152+
void reportDrmInfo(DrmType drmType, const std::string &additionalInfo = "");
153+
150154
private:
151155
GStreamerQuirksManager(bool, bool);
152156

0 commit comments

Comments
 (0)