|
| 1 | +// Copyright 2023 LiveKit, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +use crate::proto; |
| 16 | +use livekit_protocol as protocol; |
| 17 | + |
| 18 | +impl From<protocol::MetricLabel> for proto::MetricLabel { |
| 19 | + fn from(value: protocol::MetricLabel) -> Self { |
| 20 | + match value { |
| 21 | + protocol::MetricLabel::AgentsLlmTtft => Self::AgentsLlmTtft, |
| 22 | + protocol::MetricLabel::AgentsSttTtft => Self::AgentsSttTtft, |
| 23 | + protocol::MetricLabel::AgentsTtsTtfb => Self::AgentsTtsTtfb, |
| 24 | + protocol::MetricLabel::ClientVideoSubscriberFreezeCount => Self::ClientVideoSubscriberFreezeCount, |
| 25 | + protocol::MetricLabel::ClientVideoSubscriberTotalFreezeDuration => Self::ClientVideoSubscriberTotalFreezeDuration, |
| 26 | + protocol::MetricLabel::ClientVideoSubscriberPauseCount => Self::ClientVideoSubscriberPauseCount, |
| 27 | + protocol::MetricLabel::ClientVideoSubscriberTotalPausesDuration => Self::ClientVideoSubscriberTotalPausesDuration, |
| 28 | + protocol::MetricLabel::ClientAudioSubscriberConcealedSamples => Self::ClientAudioSubscriberConcealedSamples, |
| 29 | + protocol::MetricLabel::ClientAudioSubscriberSilentConcealedSamples => Self::ClientAudioSubscriberSilentConcealedSamples, |
| 30 | + protocol::MetricLabel::ClientAudioSubscriberConcealmentEvents => Self::ClientAudioSubscriberConcealmentEvents, |
| 31 | + protocol::MetricLabel::ClientAudioSubscriberInterruptionCount => Self::ClientAudioSubscriberInterruptionCount, |
| 32 | + protocol::MetricLabel::ClientAudioSubscriberTotalInterruptionDuration => Self::ClientAudioSubscriberTotalInterruptionDuration, |
| 33 | + protocol::MetricLabel::ClientSubscriberJitterBufferDelay => Self::ClientSubscriberJitterBufferDelay, |
| 34 | + protocol::MetricLabel::ClientSubscriberJitterBufferEmittedCount => Self::ClientSubscriberJitterBufferEmittedCount, |
| 35 | + protocol::MetricLabel::ClientVideoPublisherQualityLimitationDurationBandwidth => Self::ClientVideoPublisherQualityLimitationDurationBandwidth, |
| 36 | + protocol::MetricLabel::ClientVideoPublisherQualityLimitationDurationCpu => Self::ClientVideoPublisherQualityLimitationDurationCpu, |
| 37 | + protocol::MetricLabel::ClientVideoPublisherQualityLimitationDurationOther => Self::ClientVideoPublisherQualityLimitationDurationOther, |
| 38 | + protocol::MetricLabel::PublisherRtt => Self::PublisherRtt, |
| 39 | + protocol::MetricLabel::ServerMeshRtt => Self::ServerMeshRtt, |
| 40 | + protocol::MetricLabel::SubscriberRtt => Self::SubscriberRtt, |
| 41 | + protocol::MetricLabel::PredefinedMaxValue => Self::MetricLabelPredefinedMaxValue, |
| 42 | + } |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +impl From<protocol::MetricSample> for proto::MetricSample { |
| 47 | + fn from(value: protocol::MetricSample) -> Self { |
| 48 | + Self { |
| 49 | + timestamp_ms: value.timestamp_ms, |
| 50 | + normalized_timestamp: value.normalized_timestamp.map(Into::into), |
| 51 | + value: value.value, |
| 52 | + } |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +impl From<protocol::TimeSeriesMetric> for proto::TimeSeriesMetric { |
| 57 | + fn from(value: protocol::TimeSeriesMetric) -> Self { |
| 58 | + Self { |
| 59 | + label: value.label, |
| 60 | + participant_identity: value.participant_identity, |
| 61 | + track_sid: value.track_sid, |
| 62 | + samples: value.samples.into_iter().map(Into::into).collect(), |
| 63 | + rid: value.rid, |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +impl From<protocol::EventMetric> for proto::EventMetric { |
| 69 | + fn from(value: protocol::EventMetric) -> Self { |
| 70 | + Self { |
| 71 | + label: value.label, |
| 72 | + participant_identity: value.participant_identity, |
| 73 | + track_sid: value.track_sid, |
| 74 | + start_timestamp_ms: value.start_timestamp_ms, |
| 75 | + end_timestamp_ms: value.end_timestamp_ms, |
| 76 | + normalized_start_timestamp: value.normalized_start_timestamp.map(Into::into), |
| 77 | + normalized_end_timestamp: value.normalized_end_timestamp.map(Into::into), |
| 78 | + metadata: value.metadata, |
| 79 | + rid: value.rid, |
| 80 | + } |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +impl From<protocol::MetricsBatch> for proto::MetricsBatch { |
| 85 | + fn from(value: protocol::MetricsBatch) -> Self { |
| 86 | + Self { |
| 87 | + timestamp_ms: value.timestamp_ms, |
| 88 | + normalized_timestamp: value.normalized_timestamp.map(Into::into), |
| 89 | + str_data: value.str_data, |
| 90 | + time_series: value.time_series.into_iter().map(Into::into).collect(), |
| 91 | + events: value.events.into_iter().map(Into::into).collect(), |
| 92 | + } |
| 93 | + } |
| 94 | +} |
| 95 | + |
0 commit comments