2 * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __TIZEN_MEDIA_TRANSPORTER_CONNECTION_STATS_H__
18 #define __TIZEN_MEDIA_TRANSPORTER_CONNECTION_STATS_H__
23 #include <glib-object.h>
25 #include "MediaTransporter.h"
26 #include "MediaTransporterCallback.h"
27 #include "MediaTransporterGst.h"
33 namespace tizen_media_transporter {
35 using ConnectionStatPropMap = std::map<std::string, mtprConnectionStatsProp>;
40 virtual ~IForeachable() = default;
42 virtual void foreach() = 0;
45 class AbstractConnectionStats : public IForeachable
48 AbstractConnectionStats(const GstElement* element, InvokablePtr callback, const ConnectionStatPropMap& prop)
49 : _element(element), _callback(std::move(callback)), _prop(prop) {}
50 virtual ~AbstractConnectionStats() = default;
53 const GstStructure* stats();
55 static gboolean _statsForeachCb(GQuark fieldId, const GValue* val, gpointer userData);
56 static std::optional<mtprConnectionStatsPropInfo> translateGvalue(const GValue* val,
57 const ConnectionStatPropMap& propList,
58 const std::string& fieldName);
60 const GstElement* _element { nullptr };
61 InvokablePtr _callback;
62 ConnectionStatPropMap _prop;
65 using ForeachablePtr = std::unique_ptr<IForeachable>;
67 struct ConnectionStatsFactory
69 static ForeachablePtr createReceiverSrtConnectionStats(const GstElement* element, InvokablePtr callback);
70 static ForeachablePtr createSenderSrtConnectionStats(const GstElement* element, InvokablePtr callback);
73 class ReceiverSrtConnectionStats : public AbstractConnectionStats
76 ReceiverSrtConnectionStats(const GstElement* element, InvokablePtr callback);
77 virtual ~ReceiverSrtConnectionStats() = default;
79 void foreach() override;
82 class SenderSrtConnectionStats : public AbstractConnectionStats
85 SenderSrtConnectionStats(const GstElement* element, InvokablePtr callback);
86 virtual ~SenderSrtConnectionStats() = default;
88 void foreach() override;
95 #endif /* __cplusplus */
97 #endif /* __TIZEN_MEDIA_TRANSPORTER_CONNECTION_STATS_H__ */