From 26d6add9457f00ce8ec13844368466f0e3816e5d Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Thu, 6 Oct 2011 17:43:19 +0200 Subject: [PATCH] rtmp: add WSAStartup and WSACleanup on Win32 https://bugzilla.gnome.org/show_bug.cgi?id=661098 --- ext/rtmp/gstrtmpsink.c | 24 ++++++++++++++++++++++++ ext/rtmp/gstrtmpsrc.c | 16 ++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/ext/rtmp/gstrtmpsink.c b/ext/rtmp/gstrtmpsink.c index 90a1a79ec8..db066847d6 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); @@ -116,6 +121,7 @@ gst_rtmp_sink_class_init (GstRTMPSinkClass * klass) GstBaseSinkClass *gstbasesink_class = (GstBaseSinkClass *) klass; gobject_class = (GObjectClass *) 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; @@ -133,8 +139,26 @@ gst_rtmp_sink_class_init (GstRTMPSinkClass * klass) static void gst_rtmp_sink_init (GstRTMPSink * sink, GstRTMPSinkClass * klass) { +#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 e37ac06b73..578bd8f90a 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 @@ -153,6 +157,14 @@ gst_rtmp_src_class_init (GstRTMPSrcClass * klass) static void gst_rtmp_src_init (GstRTMPSrc * rtmpsrc, GstRTMPSrcClass * klass) { +#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; @@ -167,6 +179,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); }