[xiph-commits] r3064 - in liboggplay/trunk: include/oggplay plugin
src/liboggplay src/tools
shans at svn.annodex.net
shans at svn.annodex.net
Tue Jun 26 04:15:14 PDT 2007
Author: shans
Date: 2007-06-26 04:15:14 -0700 (Tue, 26 Jun 2007)
New Revision: 3064
Modified:
liboggplay/trunk/include/oggplay/oggplay_reader.h
liboggplay/trunk/plugin/plugin.cpp
liboggplay/trunk/plugin/plugin_oggplay.c
liboggplay/trunk/plugin/plugin_oggplay.h
liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.h
liboggplay/trunk/src/tools/glut-player.c
Log:
Implementation that deals with firefox proxy settings
Modified: liboggplay/trunk/include/oggplay/oggplay_reader.h
===================================================================
--- liboggplay/trunk/include/oggplay/oggplay_reader.h 2007-06-26 10:24:38 UTC (rev 3063)
+++ liboggplay/trunk/include/oggplay/oggplay_reader.h 2007-06-26 11:15:14 UTC (rev 3064)
@@ -65,6 +65,6 @@
oggplay_file_reader_new(char *filename);
OggPlayReader *
-oggplay_tcp_reader_new(char *uri);
+oggplay_tcp_reader_new(char *uri, char *proxy, int proxy_port);
#endif
Modified: liboggplay/trunk/plugin/plugin.cpp
===================================================================
--- liboggplay/trunk/plugin/plugin.cpp 2007-06-26 10:24:38 UTC (rev 3063)
+++ liboggplay/trunk/plugin/plugin.cpp 2007-06-26 11:15:14 UTC (rev 3064)
@@ -273,9 +273,14 @@
}
if (branch != NULL) {
- char *host = NULL;
- branch->GetCharPref("http", &host);
- printf("host is %s\n", host);
+ char *proxy;
+ branch->GetCharPref("http", &proxy);
+ branch->GetIntPref("http_port", &mProxyPort);
+ if (strlen(proxy) == 0) {
+ mProxyHost = NULL;
+ } else {
+ mProxyHost = strdup(proxy);
+ }
}
}
@@ -393,7 +398,7 @@
// code is responsible for destroying it, because only the gui code knows
// when to shut down the old handle after a new media source has been
// provided.
- mOggHandle = initialise_oggplay(getSource());
+ mOggHandle = initialise_oggplay(getSource(), mProxyHost, mProxyPort);
mGuiHandle = initialise_gui(this, aWindow, mOggHandle);
mWindow = aWindow;
mWindowInitialised = TRUE;
@@ -591,7 +596,7 @@
void
nsPluginInstance::restart() {
if (getSource() != NULL) {
- mOggHandle = initialise_oggplay(getSource());
+ mOggHandle = initialise_oggplay(getSource(), mProxyHost, mProxyPort);
update_gui_with_new_oggplay(mGuiHandle, mOggHandle);
gui_play(mGuiHandle);
}
@@ -607,7 +612,7 @@
// It's ok to lose the reference to the old oggplay handle (no, really, it
// is). The gui code will destroy it before swapping over to the new handle.
setSource(url);
- mOggHandle = initialise_oggplay(getSource());
+ mOggHandle = initialise_oggplay(getSource(), mProxyHost, mProxyPort);
update_gui_with_new_oggplay(mGuiHandle, mOggHandle);
}
Modified: liboggplay/trunk/plugin/plugin_oggplay.c
===================================================================
--- liboggplay/trunk/plugin/plugin_oggplay.c 2007-06-26 10:24:38 UTC (rev 3063)
+++ liboggplay/trunk/plugin/plugin_oggplay.c 2007-06-26 11:15:14 UTC (rev 3064)
@@ -62,6 +62,8 @@
OggPlay * player;
int shutdown_oggplay;
char * location;
+ char * proxy;
+ int proxy_port;
int seek_flag;
long seek_pos;
OggPlayErrorCode seek_err;
@@ -112,13 +114,16 @@
#endif
PluginPointers * pointers = (PluginPointers *)handle;
- OggPlayReader * reader = oggplay_tcp_reader_new(pointers->location);
+ OggPlayReader * reader;
OggPlay * player;
int i;
int video_track = -1;
int audio_track = -1;
ogg_int64_t time_ref;
+ reader = oggplay_tcp_reader_new(pointers->location, pointers->proxy,
+ pointers->proxy_port);
+
player = oggplay_new_with_reader(reader);
pointers->shutdown_oggplay = 0;
@@ -252,7 +257,7 @@
}
void *
-initialise_oggplay(char *location) {
+initialise_oggplay(char *location, char *proxy, int proxy_port) {
#if defined(XP_WIN)
int dec_id;
@@ -261,6 +266,8 @@
pointers->player = NULL;
pointers->location = strdup(location);
+ pointers->proxy = strdup(proxy);
+ pointers->proxy_port = proxy_port;
pointers->last_displayed_frame_time = 0;
pointers->video_rate = 0;
pointers->audio_rate = 0;
@@ -270,6 +277,7 @@
pointers->seek_flag = 0;
pointers->seek_pos = 0;
pointers->seek_err = E_OGGPLAY_OK;
+
SEM_CREATE(pointers->seek_sem, 1);
SEM_CREATE(pointers->start_stop_sem, 1);
Modified: liboggplay/trunk/plugin/plugin_oggplay.h
===================================================================
--- liboggplay/trunk/plugin/plugin_oggplay.h 2007-06-26 10:24:38 UTC (rev 3063)
+++ liboggplay/trunk/plugin/plugin_oggplay.h 2007-06-26 11:15:14 UTC (rev 3064)
@@ -64,7 +64,7 @@
} PluginOggFrame;
void *
-initialise_oggplay(char *location);
+initialise_oggplay(char *location, char *proxy, int proxy_port);
void
shut_oggplay(void *handle);
Modified: liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c 2007-06-26 10:24:38 UTC (rev 3063)
+++ liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c 2007-06-26 11:15:14 UTC (rev 3064)
@@ -110,7 +110,6 @@
OggPlayTCPReader * me = (OggPlayTCPReader *)opr;
struct hostent * he;
struct sockaddr_in addr;
- char * _location;
char * host;
char * path;
char * colon;
@@ -181,51 +180,62 @@
/*
* Extract the host name and the path from the location.
*/
- len = strlen(me->location);
- _location = (char*)malloc(len + 2);
- strcpy(_location, me->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;
- }
+ if (me->proxy == NULL) {
+ char *_location;
+ len = strlen(me->location);
+ _location = (char*)malloc(len + 2);
+ strcpy(_location, me->location);
- port = 80;
- if (colon != NULL) {
- if (path == NULL || colon < path) {
- port = (int)strtol(colon+1, NULL, 10);
- if (path != NULL) {
- strcpy(colon, me->location + (path - _location));
- path = colon;
+ 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, me->location + (path - _location));
+ path = colon;
+ }
+ else {
+ *colon = '\0';
+ path = NULL;
+ }
}
- else {
- *colon = '\0';
- path = NULL;
- }
}
- }
-
+
- if (path == NULL) {
- _location[len] = '/';
- _location[len + 1] = '\0';
- path = _location + len;
- }
+ if (path == NULL) {
+ _location[len] = '/';
+ _location[len + 1] = '\0';
+ path = _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';
+ 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 = me->proxy;
+ port = me->proxy_port;
+ path = me->location;
+ }
/*
* Prepare the HTTP request header now, so we can free all our
@@ -239,8 +249,10 @@
"Connection: Keep-Alive\n\n", path, host);
he = gethostbyname(host);
- free(_location);
- free(host);
+ if (me->proxy == NULL) {
+ free(host);
+ }
+
if (he == NULL) {
printf("Host not found\n");
return E_OGGPLAY_BAD_INPUT;
@@ -544,7 +556,7 @@
}
OggPlayReader *
-oggplay_tcp_reader_new(char *location) {
+oggplay_tcp_reader_new(char *location, char *proxy, int proxy_port) {
OggPlayTCPReader * me = (OggPlayTCPReader *)malloc (sizeof (OggPlayTCPReader));
@@ -558,6 +570,9 @@
me->backing_store = NULL;
me->stored_offset = 0;
+ me->proxy = proxy;
+ me->proxy_port = proxy_port;
+
me->functions.initialise = &oggplay_tcp_reader_initialise;
me->functions.destroy = &oggplay_tcp_reader_destroy;
me->functions.seek = NULL;
Modified: liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.h
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.h 2007-06-26 10:24:38 UTC (rev 3063)
+++ liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.h 2007-06-26 11:15:14 UTC (rev 3064)
@@ -74,6 +74,8 @@
int buffer_size;
int current_position;
char * location;
+ char * proxy;
+ int proxy_port;
int amount_in_memory;
FILE * backing_store;
int stored_offset;
Modified: liboggplay/trunk/src/tools/glut-player.c
===================================================================
--- liboggplay/trunk/src/tools/glut-player.c 2007-06-26 10:24:38 UTC (rev 3063)
+++ liboggplay/trunk/src/tools/glut-player.c 2007-06-26 11:15:14 UTC (rev 3064)
@@ -431,7 +431,7 @@
}
if (strncmp(argv[1], "http://", 7) == 0) {
- reader = oggplay_tcp_reader_new(argv[1]);
+ reader = oggplay_tcp_reader_new(argv[1], NULL, 0);
} else {
reader = oggplay_file_reader_new(argv[1]);
}
More information about the commits
mailing list