From 57623b5dcac68367c5fbd83d80152c1e831c5f78 Mon Sep 17 00:00:00 2001 From: Ratchanan Srirattanamet Date: Sun, 24 Sep 2023 01:58:59 +0700 Subject: [PATCH] NgwNativeRTCDataChannel: turns to final class Since we no longer use vfuncs, we might as well make it a final class. Not that it makes much sense practically, but why not? --- src-native/NgwNativeRTCDataChannel.c | 30 ++++++++++++---------------- src-native/NgwNativeRTCDataChannel.h | 6 +----- src/@types/node-ngwnative-0.0.d.ts | 4 ---- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src-native/NgwNativeRTCDataChannel.c b/src-native/NgwNativeRTCDataChannel.c index df92106..2268c0f 100644 --- a/src-native/NgwNativeRTCDataChannel.c +++ b/src-native/NgwNativeRTCDataChannel.c @@ -6,11 +6,13 @@ #include "NgwNativeRTCDataChannel.h" -typedef struct { +struct _NgwNativeRTCDataChannel { + GObject parent_object; + GstWebRTCDataChannel *gstdatachannel; -} NgwNativeRTCDataChannelPrivate; +}; -G_DEFINE_TYPE_WITH_PRIVATE( +G_DEFINE_TYPE( NgwNativeRTCDataChannel, ngw_native_rtc_data_channel, G_TYPE_OBJECT) @@ -115,9 +117,7 @@ static void ngw_native_rtc_data_channel_class_init( static void ngw_native_rtc_data_channel_init( NgwNativeRTCDataChannel * self) { - NgwNativeRTCDataChannelPrivate * priv = ngw_native_rtc_data_channel_get_instance_private(self); - - priv->gstdatachannel = NULL; + self->gstdatachannel = NULL; } static void ngw_native_rtc_data_channel_set_property( @@ -127,14 +127,13 @@ static void ngw_native_rtc_data_channel_set_property( GParamSpec *pspec) { NgwNativeRTCDataChannel * self = NGW_NATIVE_RTC_DATA_CHANNEL(object); - NgwNativeRTCDataChannelPrivate * priv = ngw_native_rtc_data_channel_get_instance_private(self); switch (property_id) { case PROP_GSTDATACHANNEL: - if (priv->gstdatachannel) // ??? - g_object_unref(priv->gstdatachannel); + if (self->gstdatachannel) // ??? + g_object_unref(self->gstdatachannel); - priv->gstdatachannel = g_value_dup_object(value); + self->gstdatachannel = g_value_dup_object(value); break; default: @@ -150,11 +149,10 @@ static void ngw_native_rtc_data_channel_get_property( GParamSpec *pspec) { NgwNativeRTCDataChannel * self = NGW_NATIVE_RTC_DATA_CHANNEL(object); - NgwNativeRTCDataChannelPrivate * priv = ngw_native_rtc_data_channel_get_instance_private(self); switch (property_id) { case PROP_GSTDATACHANNEL: - g_value_set_object(value, priv->gstdatachannel); + g_value_set_object(value, self->gstdatachannel); break; default: @@ -188,9 +186,8 @@ static void on_open_callback( static void ngw_native_rtc_data_channel_constructed(GObject * object) { NgwNativeRTCDataChannel * self = NGW_NATIVE_RTC_DATA_CHANNEL(object); - NgwNativeRTCDataChannelPrivate * priv = ngw_native_rtc_data_channel_get_instance_private(self); - g_object_connect(priv->gstdatachannel, + g_object_connect(self->gstdatachannel, "signal::on-buffered-amount-low", on_buffered_amount_low_callback, self, "signal::on-close", on_close_callback, self, "signal::on-error", on_error_callback, self, @@ -205,10 +202,9 @@ static void ngw_native_rtc_data_channel_constructed(GObject * object) static void ngw_native_rtc_data_channel_dispose(GObject * object) { NgwNativeRTCDataChannel * self = NGW_NATIVE_RTC_DATA_CHANNEL(object); - NgwNativeRTCDataChannelPrivate * priv = ngw_native_rtc_data_channel_get_instance_private(self); - g_signal_handlers_disconnect_by_data(priv->gstdatachannel, self); - g_clear_object(&priv->gstdatachannel); + g_signal_handlers_disconnect_by_data(self->gstdatachannel, self); + g_clear_object(&self->gstdatachannel); } static int ngw_native_rtc_data_channel_on_buffered_amount_low(gpointer user_data) diff --git a/src-native/NgwNativeRTCDataChannel.h b/src-native/NgwNativeRTCDataChannel.h index d172810..ca335bc 100644 --- a/src-native/NgwNativeRTCDataChannel.h +++ b/src-native/NgwNativeRTCDataChannel.h @@ -16,15 +16,11 @@ G_BEGIN_DECLS */ #define NGW_NATIVE_RTC_DATA_CHANNEL_TYPE ngw_native_rtc_data_channel_get_type() -NGWNATIVE_PUBLIC G_DECLARE_DERIVABLE_TYPE( +NGWNATIVE_PUBLIC G_DECLARE_FINAL_TYPE( NgwNativeRTCDataChannel, ngw_native_rtc_data_channel, NGW_NATIVE, RTC_DATA_CHANNEL, GObject) -struct _NgwNativeRTCDataChannelClass { - GObjectClass parent_class; -}; - NGWNATIVE_PUBLIC NgwNativeRTCDataChannel * ngw_native_rtc_data_channel_new( GstWebRTCDataChannel * gstdatachannel diff --git a/src/@types/node-ngwnative-0.0.d.ts b/src/@types/node-ngwnative-0.0.d.ts index 82decbd..90e9c93 100644 --- a/src/@types/node-ngwnative-0.0.d.ts +++ b/src/@types/node-ngwnative-0.0.d.ts @@ -86,10 +86,6 @@ interface RTCDataChannel { readonly gstDataChannel: GstWebRTC.WebRTCDataChannel __gtype__: number - // Own fields of NgwNative-0.0.NgwNative.RTCDataChannel - - parentInstance: GObject.Object - // Own signals of NgwNative-0.0.NgwNative.RTCDataChannel connect(sigName: "on-buffered-amount-low", callback: RTCDataChannel.OnBufferedAmountLowSignalCallback): number