[xiph-commits] r3120 - in liboggplay/trunk: include/oggplay plugin
src/liboggplay
shans at svn.annodex.net
shans at svn.annodex.net
Thu Jun 28 06:45:37 PDT 2007
Author: shans
Date: 2007-06-28 06:45:37 -0700 (Thu, 28 Jun 2007)
New Revision: 3120
Modified:
liboggplay/trunk/include/oggplay/oggplay_tools.h
liboggplay/trunk/plugin/plugin.h
liboggplay/trunk/src/liboggplay/Version_script.in
liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
liboggplay/trunk/src/liboggplay/oggplay_tools.c
Log:
Moved tcp functions back into tcp reader (THANKS, MICROSOFT!)
Modified: liboggplay/trunk/include/oggplay/oggplay_tools.h
===================================================================
--- liboggplay/trunk/include/oggplay/oggplay_tools.h 2007-06-28 13:03:23 UTC (rev 3119)
+++ liboggplay/trunk/include/oggplay/oggplay_tools.h 2007-06-28 13:45:37 UTC (rev 3120)
@@ -47,19 +47,10 @@
#endif
#ifdef WIN32
-#include <sys/time.h>
-#include <process.h>
-#include <io.h>
+#include <time.h>
#else
-#include <sys/types.h>
-#include <sys/select.h>
-#include <sys/socket.h>
-#include <sys/fcntl.h>
-#include <sys/errno.h>
#include <sys/time.h>
#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
#endif
/* structure holds pointers to y, u, v channels */
@@ -92,45 +83,6 @@
void
oggplay_millisleep(long ms);
-#ifndef WIN32
-typedef int SOCKET;
-#define INVALID_SOCKET -1
-#endif
-
-int
-oggplay_set_socket_blocking_state(SOCKET socket, int is_blocking);
-
-SOCKET
-oggplay_create_socket();
-
-void
-oggplay_hostname_and_path(char *location, char *proxy, int proxy_port,
- char **host, int *port, char **path);
-
-OggPlayErrorCode
-oggplay_connect_to_host(SOCKET socket, struct sockaddr *addr);
-
-#define START_TIMEOUT(ref) \
- (ref) = oggplay_sys_time_in_ms()
-
-#ifdef WIN32
-#define CHECK_ERROR(error) \
- (WSAGetLastError() == WSA##error)
-#else
-#define CHECK_ERROR(error) \
- (errno == error)
-#endif
-
-#define RETURN_ON_TIMEOUT_OR_CONTINUE(ref) \
- if (oggplay_sys_time_in_ms() - (ref) > 500) { \
- return E_OGGPLAY_TIMEOUT; \
- } else { \
- oggplay_millisleep(10); \
- continue; \
- }
-
-
-
#ifdef __cplusplus
}
#endif
Modified: liboggplay/trunk/plugin/plugin.h
===================================================================
--- liboggplay/trunk/plugin/plugin.h 2007-06-28 13:03:23 UTC (rev 3119)
+++ liboggplay/trunk/plugin/plugin.h 2007-06-28 13:45:37 UTC (rev 3120)
@@ -49,9 +49,7 @@
#include <gtk/gtk.h>
#endif
-#if defined(XP_MACOSX) || defined(XP_WIN)
#include <vector>
-#endif
class nsPluginInstance : public nsPluginInstanceBase
{
Modified: liboggplay/trunk/src/liboggplay/Version_script.in
===================================================================
--- liboggplay/trunk/src/liboggplay/Version_script.in 2007-06-28 13:03:23 UTC (rev 3119)
+++ liboggplay/trunk/src/liboggplay/Version_script.in 2007-06-28 13:45:37 UTC (rev 3120)
@@ -58,10 +58,6 @@
oggplay_sys_time_in_ms;
oggplay_millisleep;
- oggplay_set_blocking_state;
- oggplay_create_socket;
- oggplay_hostname_and_path;
- oggplay_connect_to_host;
oggplay_seek;
oggplay_get_available;
Modified: liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c 2007-06-28 13:03:23 UTC (rev 3119)
+++ liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c 2007-06-28 13:45:37 UTC (rev 3120)
@@ -66,7 +66,181 @@
s, m->amount_in_memory, m->buffer_size, \
m->current_position, m->stored_offset);
+#ifndef WIN32
+typedef int SOCKET;
+#define INVALID_SOCKET -1
+#endif
+
+#define START_TIMEOUT(ref) \
+ (ref) = oggplay_sys_time_in_ms()
+
+#ifdef WIN32
+#define CHECK_ERROR(error) \
+ (WSAGetLastError() == WSA##error)
+#else
+#define CHECK_ERROR(error) \
+ (errno == error)
+#endif
+
+#define RETURN_ON_TIMEOUT_OR_CONTINUE(ref) \
+ if (oggplay_sys_time_in_ms() - (ref) > 500) { \
+ return E_OGGPLAY_TIMEOUT; \
+ } else { \
+ oggplay_millisleep(10); \
+ continue; \
+ }
+
+#ifdef WIN32
+int
+oggplay_set_socket_blocking_state(SOCKET socket, int is_blocking) {
+ u_long io_mode = !is_blocking;
+ if (ioctlsocket(socket, FIONBIO, &io_mode) == SOCKET_ERROR) {
+ return 0;
+ }
+ return 1;
+}
+#else
+int
+oggplay_set_socket_blocking_state(SOCKET socket, int is_blocking) {
+ if (fcntl(socket, F_SETFL, is_blocking ? 0 : O_NONBLOCK) == -1) {
+ return 0;
+ }
+ return 1;
+}
+#endif
+
+SOCKET
+oggplay_create_socket() {
+ SOCKET sock;
+
+#ifdef WIN32
+ WORD wVersionRequested;
+ WSADATA wsaData;
+#ifdef HAVE_WINSOCK2
+ wVersionRequested = MAKEWORD(2,2);
+#else
+ wVersionRequested = MAKEWORD(1,1);
+#endif
+ if (WSAStartup(wVersionRequested, &wsaData) == -1) {
+ printf("Socket open error\n");
+ return INVALID_SOCKET;
+ }
+ if (wsaData.wVersion != wVersionRequested) {
+ printf("Incorrect winsock version [%d]\n", wVersionRequested);
+ WSACleanup();
+ return INVALID_SOCKET;
+ }
+#endif
+
+ sock = socket(PF_INET, SOCK_STREAM, 0);
+ if (sock == INVALID_SOCKET) {
+ printf("Could not create socket\n");
+#ifdef WIN32
+ WSACleanup();
+#endif
+ return INVALID_SOCKET;
+ }
+
+ return sock;
+}
+
+void
+oggplay_hostname_and_path(char *location, char *proxy, int proxy_port,
+ char **host, int *port, char **path) {
+
+ char * colon;
+ int len;
+ int has_http;
+
+ if (proxy == NULL) {
+ char *_location;
+ len = strlen(location);
+ _location = (char*)malloc(len + 2);
+ strcpy(_location, location);
+
+ if (strncmp(_location, "http://", 7) == 0) {
+ *path = strchr(_location + 7, '/');
+ colon = strchr(_location + 7, ':');
+ has_http = 1;
+ } else {
+ *path = strchr(_location, '/');
+ colon = strchr(_location, ':');
+ has_http = 0;
+ }
+
+ *port = 80;
+ if (colon != NULL) {
+ if (*path == NULL || colon < *path) {
+ *port = (int)strtol(colon+1, NULL, 10);
+ if (*path != NULL) {
+ strcpy(colon, location + (*path - _location));
+ *path = strdup(colon);
+ }
+ else {
+ *colon = '\0';
+ *path = NULL;
+ }
+ }
+ }
+
+
+ if (*path == NULL) {
+ _location[len] = '/';
+ _location[len + 1] = '\0';
+ *path = strdup(_location + len);
+ }
+
+ if (has_http) {
+ *host = (char*)malloc((*path - _location) - 6);
+ strncpy(*host, _location + 7, (*path - _location) - 7);
+ (*host)[(*path - _location) - 7] = '\0';
+ } else {
+ *host = (char*)malloc((*path - _location) + 1);
+ strncpy(*host, _location, *path - _location);
+ (*host)[*path - _location] = '\0';
+ }
+ free(_location);
+ }
+ else
+ {
+ *host = strdup(proxy);
+ *port = proxy_port;
+ *path = strdup(location);
+ }
+
+}
+
OggPlayErrorCode
+oggplay_connect_to_host(SOCKET socket, struct sockaddr *addr) {
+
+ ogg_int64_t time_ref;
+
+ START_TIMEOUT(time_ref);
+
+ while (connect(socket, addr, sizeof(struct sockaddr_in)) < 0) {
+ if (
+ CHECK_ERROR(EINPROGRESS) || CHECK_ERROR(EALREADY)
+#ifdef WIN32
+ /* see http://msdn2.microsoft.com/en-us/library/ms737625.aspx */
+ || CHECK_ERROR(EWOULDBLOCK) || CHECK_ERROR(EINVAL)
+#endif
+ ) {
+ RETURN_ON_TIMEOUT_OR_CONTINUE(time_ref);
+ }
+ else if CHECK_ERROR(EISCONN)
+ {
+ break;
+ }
+ printf("Could not connect to host; error code is %d\n", errno);
+ return CHECK_ERROR(ETIMEDOUT) ? E_OGGPLAY_TIMEOUT :
+ E_OGGPLAY_SOCKET_ERROR;
+ }
+
+ return E_OGGPLAY_OK;
+
+}
+
+OggPlayErrorCode
oggplay_tcp_reader_initialise(OggPlayReader * opr, int block) {
OggPlayTCPReader * me = (OggPlayTCPReader *)opr;
Modified: liboggplay/trunk/src/liboggplay/oggplay_tools.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_tools.c 2007-06-28 13:03:23 UTC (rev 3119)
+++ liboggplay/trunk/src/liboggplay/oggplay_tools.c 2007-06-28 13:45:37 UTC (rev 3120)
@@ -64,152 +64,4 @@
#endif
}
-#ifdef WIN32
-int
-oggplay_set_socket_blocking_state(SOCKET socket, int is_blocking) {
- u_long io_mode = !is_blocking;
- if (ioctlsocket(socket, FIONBIO, &io_mode) == SOCKET_ERROR) {
- return 0;
- }
- return 1;
-}
-#else
-int
-oggplay_set_socket_blocking_state(SOCKET socket, int is_blocking) {
- if (fcntl(socket, F_SETFL, is_blocking ? 0 : O_NONBLOCK) == -1) {
- return 0;
- }
- return 1;
-}
-#endif
-SOCKET
-oggplay_create_socket() {
- SOCKET sock;
-
-#ifdef WIN32
- WORD wVersionRequested;
- WSADATA wsaData;
-#ifdef HAVE_WINSOCK2
- wVersionRequested = MAKEWORD(2,2);
-#else
- wVersionRequested = MAKEWORD(1,1);
-#endif
- if (WSAStartup(wVersionRequested, &wsaData) == -1) {
- printf("Socket open error\n");
- return INVALID_SOCKET;
- }
- if (wsaData.wVersion != wVersionRequested) {
- printf("Incorrect winsock version [%d]\n", wVersionRequested);
- WSACleanup();
- return INVALID_SOCKET;
- }
-#endif
-
- sock = socket(PF_INET, SOCK_STREAM, 0);
- if (sock == INVALID_SOCKET) {
- printf("Could not create socket\n");
-#ifdef WIN32
- WSACleanup();
-#endif
- return INVALID_SOCKET;
- }
-
- return sock;
-}
-
-void
-oggplay_hostname_and_path(char *location, char *proxy, int proxy_port,
- char **host, int *port, char **path) {
-
- char * colon;
- int len;
- int has_http;
-
- if (proxy == NULL) {
- char *_location;
- len = strlen(location);
- _location = (char*)malloc(len + 2);
- strcpy(_location, location);
-
- if (strncmp(_location, "http://", 7) == 0) {
- *path = strchr(_location + 7, '/');
- colon = strchr(_location + 7, ':');
- has_http = 1;
- } else {
- *path = strchr(_location, '/');
- colon = strchr(_location, ':');
- has_http = 0;
- }
-
- *port = 80;
- if (colon != NULL) {
- if (*path == NULL || colon < *path) {
- *port = (int)strtol(colon+1, NULL, 10);
- if (*path != NULL) {
- strcpy(colon, location + (*path - _location));
- *path = strdup(colon);
- }
- else {
- *colon = '\0';
- *path = NULL;
- }
- }
- }
-
-
- if (*path == NULL) {
- _location[len] = '/';
- _location[len + 1] = '\0';
- *path = strdup(_location + len);
- }
-
- if (has_http) {
- *host = (char*)malloc((*path - _location) - 6);
- strncpy(*host, _location + 7, (*path - _location) - 7);
- (*host)[(*path - _location) - 7] = '\0';
- } else {
- *host = (char*)malloc((*path - _location) + 1);
- strncpy(*host, _location, *path - _location);
- (*host)[*path - _location] = '\0';
- }
- free(_location);
- }
- else
- {
- *host = strdup(proxy);
- *port = proxy_port;
- *path = strdup(location);
- }
-
-}
-
-OggPlayErrorCode
-oggplay_connect_to_host(SOCKET socket, struct sockaddr *addr) {
-
- ogg_int64_t time_ref;
-
- START_TIMEOUT(time_ref);
-
- while (connect(socket, addr, sizeof(struct sockaddr_in)) < 0) {
- if (
- CHECK_ERROR(EINPROGRESS) || CHECK_ERROR(EALREADY)
-#ifdef WIN32
- /* see http://msdn2.microsoft.com/en-us/library/ms737625.aspx */
- || CHECK_ERROR(EWOULDBLOCK) || CHECK_ERROR(EINVAL)
-#endif
- ) {
- RETURN_ON_TIMEOUT_OR_CONTINUE(time_ref);
- }
- else if CHECK_ERROR(EISCONN)
- {
- break;
- }
- printf("Could not connect to host; error code is %d\n", errno);
- return CHECK_ERROR(ETIMEDOUT) ? E_OGGPLAY_TIMEOUT :
- E_OGGPLAY_SOCKET_ERROR;
- }
-
- return E_OGGPLAY_OK;
-
-}
More information about the commits
mailing list