[rtmpdump] r86 - trunk/streams.c

hyc subversion at mplayerhq.hu
Thu Dec 17 04:29:36 CET 2009


Author: hyc
Date: Thu Dec 17 04:29:36 2009
New Revision: 86

Log:
Win32 thread support

Modified:
   trunk/streams.c

Modified: trunk/streams.c
==============================================================================
--- trunk/streams.c	Thu Dec 17 03:43:24 2009	(r85)
+++ trunk/streams.c	Thu Dec 17 04:29:36 2009	(r86)
@@ -25,13 +25,18 @@
 
 #include <signal.h>
 #include <getopt.h>
-#include <pthread.h>
 
 #include <assert.h>
 
 #include "rtmp.h"
 #include "parseurl.h"
 
+#ifdef WIN32
+#include <process.h>
+#else
+#include <pthread.h>
+#endif
+
 #define RTMPDUMP_STREAMS_VERSION	"v2.0"
 
 #define RD_SUCCESS		0
@@ -40,23 +45,19 @@
 
 #define PACKET_SIZE 1024*1024
 
-/*
-inline void InitSockets() {
 #ifdef WIN32
-        WORD version;
-        WSADATA wsaData;
-
-        version = MAKEWORD(1,1);
-        WSAStartup(version, &wsaData);
-#endif
-}
+#define InitSockets()	{\
+        WORD version;			\
+        WSADATA wsaData;		\
+					\
+        version = MAKEWORD(1,1);	\
+        WSAStartup(version, &wsaData);	}
 
-inline void CleanupSockets() {
-#ifdef WIN32
-        WSACleanup();
+#define	CleanupSockets()	WSACleanup()
+#else
+#define InitSockets()
+#define	CleanupSockets()
 #endif
-}
-*/
 
 enum
 {
@@ -373,6 +374,19 @@ WriteStream(RTMP * rtmp, char **buf,	// 
   return ret;			// no more media packets
 }
 
+#ifdef WIN32
+HANDLE
+ThreadCreate(void *(*routine) (void *), void *args)
+{
+  HANDLE thd;
+
+  thd = (HANDLE) _beginthread(routine, 0, args);
+  if (thd == -1L)
+    LogPrintf("%s, _beginthread failed with %d\n", __FUNCTION__, errno);
+
+  return thd;
+}
+#else
 pthread_t
 ThreadCreate(void *(*routine) (void *), void *args)
 {
@@ -391,6 +405,7 @@ ThreadCreate(void *(*routine) (void *), 
 
   return id;
 }
+#endif
 
 void *
 controlServerThread(void *unused)
@@ -1212,7 +1227,7 @@ main(int argc, char **argv)
   netstackdump_read = fopen("netstackdump_read", "wb");
 #endif
 
-  //InitSockets();
+  InitSockets();
 
   // start text UI
   ThreadCreate(controlServerThread, 0);
@@ -1233,7 +1248,7 @@ main(int argc, char **argv)
     }
   Log(LOGDEBUG, "Done, exiting...");
 
-  //CleanupSockets();
+  CleanupSockets();
 
 #ifdef _DEBUG
   if (netstackdump != 0)


More information about the rtmpdump mailing list