diff --git a/ext/rtmp/gstrtmpsink.c b/ext/rtmp/gstrtmpsink.c index df395aab70..23d580cfd2 100644 --- a/ext/rtmp/gstrtmpsink.c +++ b/ext/rtmp/gstrtmpsink.c @@ -43,6 +43,10 @@ #include "gstrtmpsink.h" +#ifdef G_OS_WIN32 +#include +#endif + GST_DEBUG_CATEGORY_STATIC (gst_rtmp_sink_debug); #define GST_CAT_DEFAULT gst_rtmp_sink_debug @@ -71,6 +75,7 @@ static void gst_rtmp_sink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_rtmp_sink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); +static void gst_rtmp_sink_finalize (GObject * object); static gboolean gst_rtmp_sink_stop (GstBaseSink * sink); static gboolean gst_rtmp_sink_start (GstBaseSink * sink); static GstFlowReturn gst_rtmp_sink_render (GstBaseSink * sink, GstBuffer * buf); @@ -92,6 +97,7 @@ gst_rtmp_sink_class_init (GstRTMPSinkClass * klass) gstelement_class = (GstElementClass *) klass; gstbasesink_class = (GstBaseSinkClass *) klass; + gobject_class->finalize = gst_rtmp_sink_finalize; gobject_class->set_property = gst_rtmp_sink_set_property; gobject_class->get_property = gst_rtmp_sink_get_property; @@ -120,8 +126,26 @@ gst_rtmp_sink_class_init (GstRTMPSinkClass * klass) static void gst_rtmp_sink_init (GstRTMPSink * sink) { +#ifdef G_OS_WIN32 + WSADATA wsa_data; + + if (WSAStartup (MAKEWORD (2, 2), &wsa_data) != 0) { + GST_ERROR_OBJECT (sink, "WSAStartup failed: 0x%08x", WSAGetLastError ()); + } +#endif } +static void +gst_rtmp_sink_finalize (GObject * object) +{ +#ifdef G_OS_WIN32 + WSACleanup (); +#endif + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + + static gboolean gst_rtmp_sink_start (GstBaseSink * basesink) { diff --git a/ext/rtmp/gstrtmpsrc.c b/ext/rtmp/gstrtmpsrc.c index 9a30b28c00..28f5ea5689 100644 --- a/ext/rtmp/gstrtmpsrc.c +++ b/ext/rtmp/gstrtmpsrc.c @@ -53,6 +53,10 @@ #include +#ifdef G_OS_WIN32 +#include +#endif + GST_DEBUG_CATEGORY_STATIC (rtmpsrc_debug); #define GST_CAT_DEFAULT rtmpsrc_debug @@ -139,6 +143,14 @@ gst_rtmp_src_class_init (GstRTMPSrcClass * klass) static void gst_rtmp_src_init (GstRTMPSrc * rtmpsrc) { +#ifdef G_OS_WIN32 + WSADATA wsa_data; + + if (WSAStartup (MAKEWORD (2, 2), &wsa_data) != 0) { + GST_ERROR_OBJECT (rtmpsrc, "WSAStartup failed: 0x%08x", WSAGetLastError ()); + } +#endif + rtmpsrc->cur_offset = 0; rtmpsrc->last_timestamp = 0; @@ -153,6 +165,10 @@ gst_rtmp_src_finalize (GObject * object) g_free (rtmpsrc->uri); rtmpsrc->uri = NULL; +#ifdef G_OS_WIN32 + WSACleanup (); +#endif + G_OBJECT_CLASS (parent_class)->finalize (object); }