Line data Source code
1 : /*
2 : * If not stated otherwise in this file or this component's LICENSE file the
3 : * following copyright and licenses apply:
4 : *
5 : * Copyright 2026 Sky UK
6 : *
7 : * Licensed under the Apache License, Version 2.0 (the "License");
8 : * you may not use this file except in compliance with the License.
9 : * You may obtain a copy of the License at
10 : *
11 : * http://www.apache.org/licenses/LICENSE-2.0
12 : *
13 : * Unless required by applicable law or agreed to in writing, software
14 : * distributed under the License is distributed on an "AS IS" BASIS,
15 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 : * See the License for the specific language governing permissions and
17 : * limitations under the License.
18 : */
19 :
20 : #include "MediaPipelineMetricsClient.h"
21 : #include "RialtoServerLogging.h"
22 :
23 : namespace firebolt::rialto::server::service
24 : {
25 92 : MediaPipelineMetricsClient::MediaPipelineMetricsClient(int sessionId, const std::shared_ptr<IMediaPipelineClient> &client,
26 92 : IPrivateMetricsService &metricsService)
27 92 : : m_sessionId{sessionId}, m_client{client}, m_metricsService{metricsService}
28 : {
29 : }
30 :
31 1 : void MediaPipelineMetricsClient::notifyDuration(int64_t duration)
32 : {
33 1 : m_client->notifyDuration(duration);
34 : }
35 1 : void MediaPipelineMetricsClient::notifyPosition(int64_t position)
36 : {
37 1 : m_client->notifyPosition(position);
38 : }
39 1 : void MediaPipelineMetricsClient::notifyNativeSize(uint32_t width, uint32_t height, double aspect)
40 : {
41 1 : m_client->notifyNativeSize(width, height, aspect);
42 : }
43 1 : void MediaPipelineMetricsClient::notifyNetworkState(NetworkState state)
44 : {
45 1 : m_client->notifyNetworkState(state);
46 : }
47 2 : void MediaPipelineMetricsClient::notifyPlaybackState(PlaybackState state)
48 : {
49 2 : m_metricsService.notifyPlaybackStateChanged(m_sessionId, m_currentPlaybackState, state);
50 2 : m_currentPlaybackState = state;
51 2 : m_client->notifyPlaybackState(state);
52 : }
53 1 : void MediaPipelineMetricsClient::notifyVideoData(bool hasData)
54 : {
55 1 : m_client->notifyVideoData(hasData);
56 : }
57 1 : void MediaPipelineMetricsClient::notifyAudioData(bool hasData)
58 : {
59 1 : m_client->notifyAudioData(hasData);
60 : }
61 1 : void MediaPipelineMetricsClient::notifyNeedMediaData(int32_t sourceId, size_t frameCount, uint32_t needDataRequestId,
62 : const std::shared_ptr<MediaPlayerShmInfo> &shmInfo)
63 : {
64 1 : m_client->notifyNeedMediaData(sourceId, frameCount, needDataRequestId, shmInfo);
65 : }
66 1 : void MediaPipelineMetricsClient::notifyCancelNeedMediaData(int32_t sourceId)
67 : {
68 1 : m_client->notifyCancelNeedMediaData(sourceId);
69 : }
70 1 : void MediaPipelineMetricsClient::notifyQos(int32_t sourceId, const QosInfo &qosInfo)
71 : {
72 1 : m_client->notifyQos(sourceId, qosInfo);
73 : }
74 1 : void MediaPipelineMetricsClient::notifyMetric(const MetricEvent &metric)
75 : {
76 1 : RIALTO_SERVER_LOG_DEBUG("Relaying playback metric event sessionId: %d, sourceId: %d, ptsNs: %llu, metric: %u, "
77 : "observationKind: %u, count: %llu, durationNs: %llu",
78 : m_sessionId, metric.sourceId,
79 : static_cast<unsigned long long>(metric.presentationTimeStampNs.value_or(0)), // NOLINT(runtime/int)
80 : static_cast<uint32_t>(metric.type), static_cast<uint32_t>(metric.phase),
81 : static_cast<unsigned long long>(metric.count.value_or(0)), // NOLINT(runtime/int)
82 : static_cast<unsigned long long>(metric.durationNs.value_or(0))); // NOLINT(runtime/int)
83 1 : m_client->notifyMetric(metric);
84 : }
85 1 : void MediaPipelineMetricsClient::notifyBufferUnderflow(int32_t sourceId)
86 : {
87 1 : m_client->notifyBufferUnderflow(sourceId);
88 : }
89 1 : void MediaPipelineMetricsClient::notifyFirstFrameReceived(int32_t sourceId)
90 : {
91 1 : m_client->notifyFirstFrameReceived(sourceId);
92 : }
93 1 : void MediaPipelineMetricsClient::notifyPlaybackError(int32_t sourceId, PlaybackError error)
94 : {
95 1 : m_client->notifyPlaybackError(sourceId, error);
96 : }
97 1 : void MediaPipelineMetricsClient::notifySourceFlushed(int32_t sourceId)
98 : {
99 1 : m_client->notifySourceFlushed(sourceId);
100 : }
101 1 : void MediaPipelineMetricsClient::notifyPlaybackInfo(const PlaybackInfo &playbackInfo)
102 : {
103 1 : m_client->notifyPlaybackInfo(playbackInfo);
104 : }
105 : } // namespace firebolt::rialto::server::service
|