[gecko-mediaplayer] r512 committed - Very Large Change...

2 views
Skip to first unread message

codesite...@google.com

unread,
Sep 4, 2012, 4:51:56 PM9/4/12
to gecko-mediap...@googlegroups.com
Revision: 512
Author: kdekorte
Date: Tue Sep 4 13:51:08 2012
Log: Very Large Change
rework the processing of playlists so that items are downloaded
one at a time and only as needed
Convert NPRES and NPERR codes to text in messages
ASX and M3U files should be properly parsed and not streamed in all cases
http://code.google.com/p/gecko-mediaplayer/source/detail?r=512

Modified:
/trunk/src/plugin.cpp
/trunk/src/plugin.h
/trunk/src/plugin_dbus.cpp
/trunk/src/plugin_list.cpp
/trunk/src/plugin_list.h
/trunk/src/plugin_setup.cpp

=======================================
--- /trunk/src/plugin.cpp Sat Aug 4 10:19:43 2012
+++ /trunk/src/plugin.cpp Tue Sep 4 13:51:08 2012
@@ -181,6 +181,84 @@
//NPN_GetURL(mInstance, jscript, NULL);
g_free(jscript);
}
+
+const gchar *NPReasonToString(NPReason reason)
+{
+
+ switch (reason) {
+ case NPRES_DONE:
+ return "Done";
+ break;
+ case NPRES_NETWORK_ERR:
+ return "Network Error";
+ break;
+ case NPRES_USER_BREAK:
+ return "User Break";
+ break;
+ default:
+ return "Unknown Reason";
+ }
+
+}
+
+
+const gchar *NPErrorToString(NPError error)
+{
+
+ switch (error) {
+ case NPERR_NO_ERROR:
+ return "No Error";
+ break;
+ case NPERR_GENERIC_ERROR:
+ return "Generic Error";
+ break;
+ case NPERR_INVALID_INSTANCE_ERROR:
+ return "Invalid Instance Error";
+ break;
+ case NPERR_INVALID_FUNCTABLE_ERROR:
+ return "Invalid Functable Error";
+ break;
+ case NPERR_MODULE_LOAD_FAILED_ERROR:
+ return "Module Load Failed Error";
+ break;
+ case NPERR_OUT_OF_MEMORY_ERROR:
+ return "Out Of Memory Error";
+ break;
+ case NPERR_INVALID_PLUGIN_ERROR:
+ return "Invalid Plugin Error";
+ break;
+ case NPERR_INVALID_PLUGIN_DIR_ERROR:
+ return "Invalid Plugin Dir Error";
+ break;
+ case NPERR_INCOMPATIBLE_VERSION_ERROR:
+ return "Incompatible Version Error";
+ break;
+ case NPERR_INVALID_PARAM:
+ return "Invalid Param";
+ break;
+ case NPERR_INVALID_URL:
+ return "Invalid URL";
+ break;
+ case NPERR_FILE_NOT_FOUND:
+ return "File Not Found";
+ break;
+ case NPERR_NO_DATA:
+ return "No Data";
+ break;
+ case NPERR_STREAM_NOT_SEEKABLE:
+ return "Stream Not Seekable";
+ break;
+ case NPERR_TIME_RANGE_NOT_SUPPORTED:
+ return "Time Range Not Supported";
+ break;
+ case NPERR_MALFORMED_SITE:
+ return "Malformed Site";
+ break;
+ default:
+ return "Unknown NPError Code";
+ break;
+ }
+}

////////////////////////////////////////
//
@@ -353,7 +431,7 @@
gm_log(debug_level, G_LOG_LEVEL_INFO, "debug_level = %i",
debug_level);
player_backend = gm_pref_store_get_string(store, PLAYER_BACKEND);
gm_log(debug_level, G_LOG_LEVEL_INFO, "Using player backend
of '%s'\n",
- (player_backend == NULL) ? "gnome-mplayer" :
player_backend);
+ (player_backend == NULL || strlen(player_backend) == 0
) ? "gnome-mplayer" : player_backend);
gm_pref_store_free(store);
} else {
gm_log(TRUE, G_LOG_LEVEL_INFO, "Unable to find preference store,
setting debug_level to 1");
@@ -604,22 +682,20 @@
NPError CPlugin::DestroyStream(NPStream * stream, NPError reason)
{
ListItem *item;
- gint id;
- gchar *path;
+ ListItem *fetch_item;
gchar *text;
- gboolean ready;
- gboolean newwindow;
+ gboolean fetch_next = TRUE;

if (g_strrstr(stream->url, "javascript") == NULL)
- gm_log(debug_level, G_LOG_LEVEL_DEBUG, "Entering destroy stream
reason = %i for %s\n",
- reason, stream->url);
+ gm_log(debug_level, G_LOG_LEVEL_MESSAGE, "Entering destroy stream
reason = %i - %s for %s",
+ reason, NPErrorToString(reason), stream->url);

if (reason == NPERR_NO_ERROR) {
item = (ListItem *) stream->notifyData;
// item = list_find(playlist, (gchar*)stream->url);

if (item == NULL) {
- gm_log(debug_level, G_LOG_LEVEL_DEBUG, "Leaving destroy stream
- item not found\n");
+ gm_log(debug_level, G_LOG_LEVEL_DEBUG, "Leaving destroy stream
- item not found");
return NPERR_NO_ERROR;
}

@@ -632,59 +708,66 @@
send_signal_with_string(this, item, "SetProgressText", text);
g_free(text);
}
+

if (!item->opened && item->play) {
- id = item->controlid;
- path = g_strdup(item->path);
- ready = item->playerready;
- newwindow = item->newwindow;
+ gm_log(debug_level, G_LOG_LEVEL_MESSAGE, "item '%s' is not
opened and is playable",
+ item->src);
if (!item->streaming)
item->streaming = streaming(item->src);
if (!item->streaming) {
- gm_log(debug_level, G_LOG_LEVEL_DEBUG, "in Destroy
Stream\n");
- playlist = list_parse_qt(playlist, item);
- playlist = list_parse_qt2(playlist, item);
- playlist = list_parse_asx(playlist, item);
- playlist = list_parse_qml(playlist, item);
- playlist = list_parse_ram(playlist, item);
+ gm_log(debug_level, G_LOG_LEVEL_DEBUG, "in Destroy
Stream");
+ playlist = list_parse_qt(playlist, item, FALSE);
+ playlist = list_parse_qt2(playlist, item, FALSE);
+ playlist = list_parse_asx(playlist, item, FALSE);
+ playlist = list_parse_qml(playlist, item, FALSE);
+ playlist = list_parse_ram(playlist, item, FALSE);
}
- // printf("item->play = %i\n",item->play);
- // printf("item->src = %s\n", item->src);
- // printf("item->streaming = %i\n", item->streaming);
- // printf("calling open_location from DestroyStream\n");
- if (item->play) {
- item->requested = TRUE;
- open_location(this, item, TRUE);
- if (post_dom_events && this->id != NULL) {
- postDOMEvent(mInstance, this->id, "qt_play");
+
+ if (item->playlist == FALSE) {
+ if (item != NULL && item->queuedtoplay == FALSE) {
+ if (!list_item_opened(playlist)) {
+ item = list_find_first_playable(playlist);
+ }
+ }
+ if (item != NULL) {
+ if (item->play == TRUE && item->opened == FALSE) {
+
+ open_location(this, item, TRUE);
+ if (post_dom_events && this->id != NULL) {
+ postDOMEvent(mInstance, this->id, "qt_play");
+ }
+ }
}
} else {
- item = list_find_next_playable(playlist);
+ item = list_find_first_playable(playlist);
if (item != NULL) {
- // printf("item->play = %i\n",item->play);
- // printf("item->src = %s\n", item->src);
- // printf("item->streaming = %i\n", item->streaming);
if (!item->streaming) {
- item->controlid = id;
- g_strlcpy(item->path, path, 1024);
- item->playerready = ready;
- item->newwindow = newwindow;
- item->cancelled = FALSE;
- item->requested = TRUE;
- if (item != NULL)
+ if (item->requested == FALSE) {
+ gm_log(debug_level, G_LOG_LEVEL_INFO, "Getting
URL '%s'", item->src);
+ item->requested = TRUE;
this->GetURLNotify(mInstance, item->src, NULL,
item);
- } else {
- open_location(this, item, FALSE);
- item->requested = TRUE;
- if (post_dom_events && this->id != NULL) {
- postDOMEvent(mInstance, this->id, "qt_play");
+ fetch_next = FALSE;
}
+ } else {
+ if (!list_item_opened(playlist))
+ open_location(this, item, FALSE);
}
}
}
- g_free(path);
+
+ // fetch the next item on the playlist
+ if (fetch_next) {
+ fetch_item =
list_find_next_playable_after_listitem(playlist, item);
+ if (fetch_item != NULL) {
+ if (!fetch_item->streaming) {
+ gm_log(debug_level, G_LOG_LEVEL_INFO, "Prefetching
URL '%s'", fetch_item->src);
+ fetch_item->requested = TRUE;
+ this->GetURLNotify(mInstance, fetch_item->src,
NULL, fetch_item);
+ }
+ }
+ }
}
- //printf("Leaving destroy stream src = %s\n", item->src);

} else if (reason == NPERR_INVALID_URL) {
item = (ListItem *) stream->notifyData;
@@ -719,72 +802,26 @@
}
}

- // list_dump(playlist);
+ gm_log(debug_level, G_LOG_LEVEL_INFO,
+ "Leaving DestroyStream for %s and the playlist looks like
this", stream->url);
+ list_dump(playlist);
return NPERR_NO_ERROR;
}

void CPlugin::URLNotify(const char *url, NPReason reason, void *notifyData)
{
ListItem *item = (ListItem *) notifyData;
- //DBusMessage *message;
- //const char *file;

- gm_log(debug_level, G_LOG_LEVEL_DEBUG, "URL Notify url = '%s'\nreason
= %i\n%s\n%s\n%s\n", url,
- reason, item->src, item->local, path);
+ gm_log(debug_level, G_LOG_LEVEL_MESSAGE, "URL Notify url
= '%s'\nreason = %i - %s\n%s\n%s\n%s",
+ url, reason, NPReasonToString(reason), item->src, item->local,
path);
if (reason == NPRES_DONE) {
-
- if (!item->opened) {
- // open_location(this,item, TRUE);
-
- /*
- file = g_strdup(item->local);
- while (!playerready) {
- // printf("waiting for player\n");
- g_main_context_iteration(NULL,FALSE);
- }
- message =
dbus_message_new_signal(path,"com.gnome.mplayer","Open");
- dbus_message_append_args(message, DBUS_TYPE_STRING, &file,
DBUS_TYPE_INVALID);
- dbus_connection_send(connection,message,NULL);
- dbus_message_unref(message);
- */
- }
-
- if (item) {
- item->played = TRUE;
- if (!item->streaming) {
- item = list_find_next_playable(playlist);
- if (item) {
- if (item->retrieved || item->streaming) {
- open_location(this, item, TRUE);
- item->requested = TRUE;
- } else {
- this->GetURLNotify(mInstance, item->src, NULL,
item);
- item->requested = TRUE;
- }
- }
- }
- } else {
- item = list_find_next_playable(playlist);
- if (item) {
- if (item->retrieved || item->streaming) {
- open_location(this, item, TRUE);
- item->requested = TRUE;
- } else {
- this->GetURLNotify(mInstance, item->src, NULL, item);
- item->requested = TRUE;
- }
- }
- }
-
-
-
+ // done
} else if (reason == NPRES_NETWORK_ERR) {
- gm_log(debug_level, G_LOG_LEVEL_INFO, "URL Notify result is
Network Error\n");
+ // error
} else if (reason == NPRES_USER_BREAK) {
- gm_log(debug_level, G_LOG_LEVEL_INFO, "URL Notify result is User
Break\n");
+ // user cancelled
} else {
- gm_log(debug_level, G_LOG_LEVEL_INFO, "%i is an invalid reason
code in URLNotify\n",
- reason);
+ // something else
}
}

@@ -807,17 +844,6 @@
if (item == NULL) {

if (mode == NP_FULL) {
- // printf("adding new item %s\n",stream->url);
- /*
- item = g_new0(ListItem, 1);
- g_strlcpy(item->src, stream->url, 1024);
- item->requested = TRUE;
- item->play = TRUE;
- if (!item->streaming)
- item->streaming = streaming(item->src);
- playlist = g_list_append(playlist, item);
- stream->notifyData = item;
- */
return -1;
} else {
gm_log(debug_level, G_LOG_LEVEL_INFO, "item is null\nstream
url %s\n", stream->url);
@@ -880,11 +906,6 @@
gchar *text;
gdouble percent = 0.0;
gdouble rate = 0.0;
- gint id;
- gchar *path;
- gboolean ready;
- gboolean newwindow;
- gboolean ok_to_play = FALSE;
gchar *upper = NULL;

gm_log(debug_level, G_LOG_LEVEL_DEBUG, "Write Called\n");
@@ -913,17 +934,7 @@
if (strstr((char *) buffer, "ICY 200 OK") != NULL
|| strstr((char *) buffer, "Content-length:") != NULL
|| (upper != NULL && strstr(upper, "<HTML>") != NULL) ||
item->streaming == TRUE
- || strstr(item->src, "file://") != NULL
- || (upper != NULL && strstr(upper, "#EXTM3U") != NULL)
- || (upper != NULL && strstr(upper, "<ASX") != NULL)) {
- // If item is a block of jpeg images, just stream it
- // || stream->lastmodified == 0) { this is not valid for many
sites
-
- // printf("BUFFER='%s'\n", buffer);
-
- // printf("item->streaming = %i\n", item->streaming);
- // printf("stream->lastmodified = %i\n", stream->lastmodified);
- // printf("stream->end = %i\n", stream->end);
+ || strstr(item->src, "file://") != NULL) {

item->streaming = TRUE;
open_location(this, item, FALSE);
@@ -951,7 +962,7 @@

if (item->localfp == NULL) {
gm_log(debug_level, G_LOG_LEVEL_INFO, "Local cache file is not
open, cannot write data\n");
- NPN_DestroyStream(mInstance, stream, NPERR_NO_ERROR);
+ NPN_DestroyStream(mInstance, stream, NPERR_GENERIC_ERROR);
return -1;
}
fseek(item->localfp, offset, SEEK_SET);
@@ -997,15 +1008,15 @@
if ((item->localsize >= (cache_size * 1024)) && (percent >=
0.2)) {
gm_log(debug_level, G_LOG_LEVEL_DEBUG, "Setting to play
because %i > %i\n",
item->localsize, cache_size * 1024);
- ok_to_play = TRUE;
+ item->oktoplay = TRUE;
}
- if (ok_to_play == FALSE && (item->localsize > (cache_size * 2
* 1024))
+ if (item->oktoplay == FALSE && (item->localsize > (cache_size
* 2 * 1024))
&& (cache_size >= 512)) {
// printf("Setting to play because %i > %i (double
cache)\n", item->localsize,
// cache_size * 2 * 1024);
- ok_to_play = TRUE;
+ item->oktoplay = TRUE;
}
- if (ok_to_play == FALSE) {
+ if (item->oktoplay == FALSE) {
if (item->bitrate == 0 && item->bitrate_requests < 5
&& ((gint) (percent * 100) > item->bitrate_requests)) {
item->bitrate = request_bitrate(this, item,
item->local);
@@ -1015,7 +1026,7 @@
if (item->localsize / item->bitrate >= 10 && (percent
>= 0.2)) {
// printf("Setting to play because %i >= 10\n",
// item->localsize / item->bitrate);
- ok_to_play = TRUE;
+ item->oktoplay = TRUE;
if (post_dom_events && this->id != NULL) {
postDOMEvent(mInstance,
this->id, "qt_canplay");
}
@@ -1024,52 +1035,50 @@
}

}
- // if not opened, over cache level and not an href target then try
and open it
- if ((!item->opened) && ok_to_play == TRUE) {
- id = item->controlid;
- path = g_strdup(item->path);
- ready = item->playerready;
- newwindow = item->newwindow;
+
+ // item->playlist may have been set on an earlier pass, so do not
bother
+ // checking for playlist again, if it is true.
+
+ if (!item->opened && item->play && item->oktoplay
&& !item->playlist) {
+ gm_log(debug_level, G_LOG_LEVEL_MESSAGE, "item '%s' is not
opened and is playable",
+ item->src);
if (!item->streaming)
item->streaming = streaming(item->src);
if (!item->streaming) {
- playlist = list_parse_qt(playlist, item);
- playlist = list_parse_asx(playlist, item);
- playlist = list_parse_qml(playlist, item);
- playlist = list_parse_ram(playlist, item);
+ gm_log(debug_level, G_LOG_LEVEL_DEBUG, "in Write");
+ // we want to detect a playlist, but not add any items to
the actual playlist
+ // if we find them
+ playlist = list_parse_qt(playlist, item, TRUE);
+ playlist = list_parse_qt2(playlist, item, TRUE);
+ playlist = list_parse_asx(playlist, item, TRUE);
+ playlist = list_parse_qml(playlist, item, TRUE);
+ playlist = list_parse_ram(playlist, item, TRUE);
}
- // printf("item->play = %i\n",item->play);
- // printf("item->src = %i\n", item->src);
- // printf("calling open_location from Write\n");
- if (item->play) {
- send_signal_with_integer(this, item, "SetGUIState",
PLAYING);
- open_location(this, item, TRUE);
- item->requested = TRUE;
- if (post_dom_events && this->id != NULL) {
- postDOMEvent(mInstance,
this->id, "qt_loadedfirstframe");
- postDOMEvent(mInstance, this->id, "qt_canplay");
- postDOMEvent(mInstance, this->id, "qt_play");
- }
- } else {
- item = list_find_next_playable(playlist);
- if (item != NULL) {
- item->controlid = id;
- g_strlcpy(item->path, path, 1024);
- item->playerready = ready;
- item->newwindow = newwindow;
- item->cancelled = FALSE;
- gm_log(debug_level, G_LOG_LEVEL_DEBUG,
- "opening next playable items on the
playlist\n");
- if (item->streaming) {
- open_location(this, item, FALSE);
- item->requested = TRUE;
- } else {
- this->GetURLNotify(mInstance, item->src, NULL,
item);
- item->requested = TRUE;
+
+ gm_log(debug_level, G_LOG_LEVEL_MESSAGE, "Write item (%s)
playlist = %i", item->src, item->playlist);
+
+ if (item->playlist == FALSE) {
+
+ // queuedtoplay is only true on a item when the player has
requested the
+ // next item to play. So the rule is this
+ /*
+ 1. Automatically play only the first playable item on
the playlist
+ 2. Play queuedtoplay items when they are playable and
not opened
+
+ */
+ if (item->queuedtoplay == FALSE) {
+ if (!list_item_opened(playlist)) {
+ item = list_find_first_playable(playlist);
+ }
+ if (item->play == TRUE && item->opened == FALSE) {
+
+ open_location(this, item, TRUE);
+ if (post_dom_events && this->id != NULL) {
+ postDOMEvent(mInstance, this->id, "qt_play");
+ }
}
}
}
- g_free(path);
}

}
@@ -1415,97 +1424,6 @@
item->lastsize = item->localsize;
}
}
- // Disable playing of partially cached apple.com files, mplayer
seems to crash on these files
- /*
- if (!item->opened) {
- if ((item->localsize >= (plugin->cache_size * 1024)) &&
(percent >= 0.2)) {
- //printf("Setting to play because %i > %i\n", item->localsize,
- // plugin->cache_size * 1024);
- ok_to_play = TRUE;
- }
- if (ok_to_play == FALSE && (item->localsize >
(plugin->cache_size * 2 * 1024))
- && (plugin->cache_size >= 512)) {
- //printf("Setting to play because %i > %i (double cache)\n",
item->localsize,
- // plugin->cache_size * 2 * 1024);
- ok_to_play = TRUE;
- }
- if (ok_to_play == FALSE) {
- if (item->bitrate == 0 && item->bitrate_requests < 5
- && ((gint) (percent * 100) > item->bitrate_requests)) {
- //item->bitrate = request_bitrate(plugin, item, item->local);
- item->bitrate_requests++;
- }
- if (item->bitrate > 0) {
- if (item->localsize / item->bitrate >= 10 && (percent >= 0.2)) {
- printf("Setting to play becuase %i >= 10\n",
- item->localsize / item->bitrate);
- ok_to_play = TRUE;
- if (plugin->post_dom_events && plugin->id != NULL) {
- postDOMEvent(plugin->mInstance, plugin->id, "qt_canplay");
- }
- }
- }
- }
-
- }
- */
-
- // try downloading entire file
- ok_to_play = FALSE;
-
- // if not opened, over cache level and not an href target then try
and open it
- if ((!item->opened) && ok_to_play == TRUE) {
- id = item->controlid;
- path = g_strdup(item->path);
- ready = item->playerready;
- newwindow = item->newwindow;
- if (!item->streaming)
- item->streaming = streaming(item->src);
- if (!item->streaming) {
- gm_log(plugin->debug_level, G_LOG_LEVEL_INFO, "in
progress_callback\n");
- plugin->playlist = list_parse_qt(plugin->playlist, item);
- plugin->playlist = list_parse_qt2(plugin->playlist, item);
- plugin->playlist = list_parse_asx(plugin->playlist, item);
- plugin->playlist = list_parse_qml(plugin->playlist, item);
- plugin->playlist = list_parse_ram(plugin->playlist, item);
- }
- gm_log(plugin->debug_level, G_LOG_LEVEL_INFO, "item->play
= %i\n", item->play);
- gm_log(plugin->debug_level, G_LOG_LEVEL_INFO, "item->src
= %s\n", item->src);
- gm_log(plugin->debug_level, G_LOG_LEVEL_INFO,
- "calling open_location from progress_callback\n");
- if (item->play) {
- send_signal_with_integer(plugin, item, "SetGUIState",
PLAYING);
- open_location(plugin, item, TRUE);
- item->requested = TRUE;
- if (plugin->post_dom_events && plugin->id != NULL) {
- postDOMEvent(plugin->mInstance,
plugin->id, "qt_loadedfirstframe");
- postDOMEvent(plugin->mInstance,
plugin->id, "qt_canplay");
- postDOMEvent(plugin->mInstance, plugin->id, "qt_play");
- }
- } else {
- item = list_find_next_playable(plugin->playlist);
- if (item != NULL) {
- item->controlid = id;
- g_strlcpy(item->path, path, 1024);
- item->playerready = ready;
- item->newwindow = newwindow;
- item->cancelled = FALSE;
- // printf("opening next playable items on the
playlist\n");
- if (item->streaming) {
- open_location(plugin, item, FALSE);
- item->requested = TRUE;
- } else {
- if (!item->requested) {
- plugin->GetURLNotify(plugin->mInstance,
item->src, NULL, item);
- item->requested = TRUE;
- }
- }
- }
- }
- g_free(path);
- }
-
-
}

return 0;
@@ -1514,13 +1432,10 @@
gpointer CURLGetURLNotify(gpointer data)
{
ListItem *item = (ListItem *) data;
+ ListItem *fetch_item = NULL;
CPlugin *plugin = (CPlugin *) item->plugin;
- gchar *path;
FILE *local;
CURL *curl;
- gint id;
- gboolean ready;
- gboolean newwindow;

if (item) {
local = fopen(item->local, "wb");
@@ -1548,56 +1463,66 @@
send_signal_with_double(plugin, item, "SetCachePercent", 0.0);
item->retrieved = TRUE;
}
-

if (!item->opened) {
- id = item->controlid;
- path = g_strdup(item->path);
- ready = item->playerready;
- newwindow = item->newwindow;
if (!item->streaming)
item->streaming = streaming(item->src);
if (!item->streaming) {
gm_log(plugin->debug_level, G_LOG_LEVEL_DEBUG, "in
CURLGetURLNotify\n");
- plugin->playlist = list_parse_qt(plugin->playlist, item);
- plugin->playlist = list_parse_qt2(plugin->playlist, item);
- plugin->playlist = list_parse_asx(plugin->playlist, item);
- plugin->playlist = list_parse_qml(plugin->playlist, item);
- plugin->playlist = list_parse_ram(plugin->playlist, item);
+ plugin->playlist = list_parse_qt(plugin->playlist, item,
FALSE);
+ plugin->playlist = list_parse_qt2(plugin->playlist, item,
FALSE);
+ plugin->playlist = list_parse_asx(plugin->playlist, item,
FALSE);
+ plugin->playlist = list_parse_qml(plugin->playlist, item,
FALSE);
+ plugin->playlist = list_parse_ram(plugin->playlist, item,
FALSE);
}
// printf("item->play = %i\n", item->play);
// printf("item->src = %i\n", item->src);
// printf("calling open_location from CURLGetURLNotify\n");
- if (item->play) {
- send_signal_with_integer(plugin, item, "SetGUIState",
PLAYING);
- open_location(plugin, item, TRUE);
- item->requested = TRUE;
- if (plugin->post_dom_events && plugin->id != NULL) {
- postDOMEvent(plugin->mInstance,
plugin->id, "qt_loadedfirstframe");
- postDOMEvent(plugin->mInstance,
plugin->id, "qt_canplay");
- postDOMEvent(plugin->mInstance, plugin->id, "qt_play");
+
+ if (item->playlist == FALSE) {
+ if (item != NULL && item->queuedtoplay == FALSE) {
+ if (!list_item_opened(plugin->playlist)) {
+ item = list_find_first_playable(plugin->playlist);
+ }
+ }
+ if (item != NULL) {
+ if (item->play == TRUE && item->opened == FALSE) {
+
+ open_location(plugin, item, TRUE);
+ if (plugin->post_dom_events && plugin->id != NULL)
{
+ postDOMEvent(plugin->mInstance,
plugin->id, "qt_loadedfirstframe");
+ postDOMEvent(plugin->mInstance,
plugin->id, "qt_canplay");
+ postDOMEvent(plugin->mInstance,
plugin->id, "qt_play");
+ }
+ }
}
} else {
- item = list_find_next_playable(plugin->playlist);
+ item = list_find_first_playable(plugin->playlist);
if (item != NULL) {
- item->controlid = id;
- g_strlcpy(item->path, path, 1024);
- item->playerready = ready;
- item->newwindow = newwindow;
- item->cancelled = FALSE;
- // printf("opening next playable items on the
playlist\n");
- if (item->streaming) {
- open_location(plugin, item, FALSE);
- item->requested = TRUE;
- } else {
- if (!item->requested) {
- plugin->GetURLNotify(plugin->mInstance,
item->src, NULL, item);
+ if (!item->streaming) {
+ if (item->requested == FALSE) {
+ gm_log(plugin->debug_level,
G_LOG_LEVEL_INFO, "Getting URL '%s'",
+ item->src);
item->requested = TRUE;
+ plugin->GetURLNotify(plugin->mInstance,
item->src, NULL, item);
}
+ } else {
+ if (!list_item_opened(plugin->playlist))
+ open_location(plugin, item, FALSE);
}
}
}
- g_free(path);
+
+ // fetch the next item on the playlist
+ fetch_item =
list_find_next_playable_after_listitem(plugin->playlist, item);
+ if (fetch_item != NULL) {
+ if (!fetch_item->streaming) {
+ gm_log(plugin->debug_level, G_LOG_LEVEL_INFO, "Getting
URL '%s'",
+ fetch_item->src);
+ fetch_item->requested = TRUE;
+ CURLGetURLNotify(fetch_item);
+ }
+ }

}
}
=======================================
--- /trunk/src/plugin.h Tue Jul 19 13:25:02 2011
+++ /trunk/src/plugin.h Tue Sep 4 13:51:08 2012
@@ -93,6 +93,8 @@

void postDOMEvent(NPP mInstance, const gchar * id, const gchar * event);
void postPlayStateChange(NPP mInstance, const gint state);
+const gchar *NPErrorToString(NPError error);
+const gchar *NPReasonToString(NPReason reason);

class CPlugin {
private:
=======================================
--- /trunk/src/plugin_dbus.cpp Mon Jul 2 08:24:05 2012
+++ /trunk/src/plugin_dbus.cpp Tue Sep 4 13:51:08 2012
@@ -50,6 +50,7 @@
gchar *path;
CPlugin *instance;
ListItem *item = NULL;
+ ListItem *fetch_item = NULL;
gchar *arg[10];
gint i;
GRand *rand;
@@ -144,6 +145,8 @@
if (item->streaming) {
send_signal_with_string(instance,
item, "Open", item->src);
} else {
+ item->requested = TRUE;
+ item->queuedtoplay = TRUE;

instance->GetURLNotify(instance->mInstance, item->src, NULL, item);
}
} else {
@@ -182,6 +185,8 @@
g_free(app_name);
gm_log(instance->debug_level,
G_LOG_LEVEL_INFO, "requesting %s \n",
item->src);
+ item->requested = TRUE;
+ item->queuedtoplay = TRUE;
instance->GetURLNotify(instance->mInstance,
item->src, NULL, item);
}
instance->lastopened->played = TRUE;
@@ -222,9 +227,14 @@
}
}

- //printf("next item src = %s\n", item->src);
- //printf("next item local = %s\n", item->local);
- //printf("next item streaming = %i\n", item->streaming);
+ if (item != NULL) {
+ printf("next item src = %s\n", item->src);
+ printf("next item local = %s\n", item->local);
+ printf("next item streaming = %i\n", item->streaming);
+ } else {
+ printf("do not know what the next item is\n");
+ list_dump(instance->playlist);
+ }

if (item != NULL) {
/*
@@ -253,11 +263,35 @@
item->cancelled = FALSE;
if (item->retrieved) {
open_location(instance, item, TRUE);
+ fetch_item =
+
list_find_next_playable_after_listitem(instance->playlist, item);
+ if (fetch_item != NULL) {
+ if (!fetch_item->streaming) {
+ gm_log(instance->debug_level,
G_LOG_LEVEL_INFO,
+ "Getting URL '%s'",
fetch_item->src);
+ fetch_item->requested = TRUE;
+
instance->GetURLNotify(instance->mInstance, fetch_item->src,
+ NULL,
fetch_item);
+ }
+ }
} else {
+ item->requested = TRUE;
+ item->queuedtoplay = TRUE;
instance->GetURLNotify(instance->mInstance,
item->src, NULL, item);
}
} else {
open_location(instance, item, FALSE);
+ fetch_item =
+
list_find_next_playable_after_listitem(instance->playlist, item);
+ if (fetch_item != NULL) {
+ if (!fetch_item->streaming) {
+ gm_log(instance->debug_level,
G_LOG_LEVEL_INFO, "Getting URL '%s'",
+ fetch_item->src);
+ fetch_item->requested = TRUE;
+
instance->GetURLNotify(instance->mInstance, fetch_item->src, NULL,
+ fetch_item);
+ }
+ }
}
}
return DBUS_HANDLER_RESULT_HANDLED;
@@ -275,21 +309,25 @@
NPN_GetURL(instance->mInstance,
instance->event_mediacomplete, NULL);
}
postPlayStateChange(instance->mInstance,
STATE_MEDIAENDED);
+ return DBUS_HANDLER_RESULT_HANDLED;
}
if (g_ascii_strcasecmp(s, "MouseClicked") == 0) {
if (instance->event_mouseclicked != NULL) {
NPN_GetURL(instance->mInstance,
instance->event_mouseclicked, NULL);
}
+ return DBUS_HANDLER_RESULT_HANDLED;
}
if (g_ascii_strcasecmp(s, "EnterWindow") == 0) {
if (instance->event_enterwindow != NULL) {
NPN_GetURL(instance->mInstance,
instance->event_enterwindow, NULL);
}
+ return DBUS_HANDLER_RESULT_HANDLED;
}
if (g_ascii_strcasecmp(s, "LeaveWindow") == 0) {
if (instance->event_leavewindow != NULL) {
NPN_GetURL(instance->mInstance,
instance->event_leavewindow, NULL);
}
+ return DBUS_HANDLER_RESULT_HANDLED;
}
if (g_ascii_strcasecmp(s, "MouseDown") == 0) {
if (instance->event_mousedown != NULL) {
@@ -297,6 +335,7 @@
NPN_GetURL(instance->mInstance, tmp, NULL);
g_free(tmp);
}
+ return DBUS_HANDLER_RESULT_HANDLED;
}
if (g_ascii_strcasecmp(s, "MouseUp") == 0) {
if (instance->event_mouseup != NULL) {
@@ -304,36 +343,43 @@
NPN_GetURL(instance->mInstance, tmp, NULL);
g_free(tmp);
}
+ return DBUS_HANDLER_RESULT_HANDLED;
}
if (g_ascii_strcasecmp(s, "TimeChanged") == 0) {
if (instance->post_dom_events && instance->id !=
NULL) {
postDOMEvent(instance->mInstance,
instance->id, "qt_timechanged");
}
+ return DBUS_HANDLER_RESULT_HANDLED;
}
if (g_ascii_strcasecmp(s, "Ended") == 0) {
if (instance->post_dom_events && instance->id !=
NULL) {
postDOMEvent(instance->mInstance,
instance->id, "qt_ended");
}
+ return DBUS_HANDLER_RESULT_HANDLED;
}
if (g_ascii_strcasecmp(s, "MediaStopped") == 0) {
if (instance->post_dom_events && instance->id !=
NULL) {
postDOMEvent(instance->mInstance,
instance->id, "qt_ended");
}
postPlayStateChange(instance->mInstance,
STATE_STOPPED);
+ return DBUS_HANDLER_RESULT_HANDLED;
}
if (g_ascii_strcasecmp(s, "MediaPlaying") == 0) {
if (instance->post_dom_events && instance->id !=
NULL) {
postDOMEvent(instance->mInstance,
instance->id, "qt_play");
}
postPlayStateChange(instance->mInstance,
STATE_PLAYING);
+ return DBUS_HANDLER_RESULT_HANDLED;
}
if (g_ascii_strcasecmp(s, "MediaPaused") == 0) {
if (instance->post_dom_events && instance->id !=
NULL) {
postDOMEvent(instance->mInstance,
instance->id, "qt_pause");
}
postPlayStateChange(instance->mInstance,
STATE_PAUSED);
+ return DBUS_HANDLER_RESULT_HANDLED;
}
}
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
}
} else {
@@ -400,6 +446,10 @@
} else {
file = g_strdup(item->src);
}
+
+ gm_log(instance->debug_level, G_LOG_LEVEL_INFO,
+ "Opening %s with launch\nitem->hrefid = %i item->src
= %s", file, item->hrefid,
+ item->src);

//printf("launching gnome-mplayer from Open with id
= %i\n",instance->controlid);
app_name = NULL;
@@ -493,7 +543,8 @@
item->opened = TRUE;
instance->lastopened = item;
} else {
- gm_log(instance->debug_level, G_LOG_LEVEL_INFO, "Item already
opened before\n");
+ gm_log(instance->debug_level, G_LOG_LEVEL_INFO, "Item '%s' already
opened before",
+ item->src);
}
}

@@ -596,8 +647,8 @@

if (instance == NULL)
return;
- gm_log(instance->debug_level, G_LOG_LEVEL_INFO, "Sending %s to
connection %p\n", signal,
- instance->connection);
+// gm_log(instance->debug_level, G_LOG_LEVEL_INFO, "Sending %s to
connection %p\n", signal,
+// instance->connection);

if (instance->console != NULL) {
path = g_strdup_printf("/console/%s", instance->console);
@@ -630,8 +681,8 @@
if (instance == NULL)
return;

- gm_log(instance->debug_level, G_LOG_LEVEL_INFO, "Sending %s to
connection %p\n", signal,
- instance->connection);
+// gm_log(instance->debug_level, G_LOG_LEVEL_INFO, "Sending %s to
connection %p\n", signal,
+// instance->connection);

if (instance->console != NULL) {
path = g_strdup_printf("/console/%s", instance->console);
=======================================
--- /trunk/src/plugin_list.cpp Mon Jul 2 09:01:48 2012
+++ /trunk/src/plugin_list.cpp Tue Sep 4 13:51:08 2012
@@ -40,6 +40,7 @@
gint entry_id = 0;
GList *parser_list;
ListItem *parser_item;
+gboolean global_detect_only;
extern gint streaming(gchar * url);

ListItem *list_find(GList * list, gchar * url)
@@ -55,11 +56,6 @@
// printf("found %s at %p\n",url,item);
return item;
}
-// if (g_strrstr(url, item->src) != NULL && item->play == TRUE)
{
-// // printf("found %s at %p\n",url,item);
-// return item;
-// }
-
}
}

@@ -175,6 +171,62 @@
}
return NULL;
}
+
+ListItem *list_find_next_playable_after_listitem(GList * list, ListItem *
find)
+{
+ ListItem *item;
+ GList *iter;
+ ListItem *found = NULL;
+
+ if (list != NULL && find != NULL) {
+ for (iter = g_list_last(list); iter != NULL; iter =
g_list_previous(iter)) {
+ item = (ListItem *) iter->data;
+ if (item != NULL) {
+ if (g_ascii_strcasecmp(find->src, item->src) == 0) {
+ return found;
+ }
+ if (item->played == FALSE && item->play == TRUE) {
+ found = item;
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+ListItem *list_find_first_playable(GList * list)
+{
+ ListItem *item;
+ GList *iter;
+
+ for (iter = list; iter != NULL; iter = g_list_next(iter)) {
+ item = (ListItem *) iter->data;
+ if (item != NULL) {
+ if (item->play == TRUE) {
+ return item;
+ }
+ }
+ }
+ return NULL;
+}
+
+gboolean list_item_opened(GList * list)
+{
+ ListItem *item;
+ GList *iter;
+
+ for (iter = list; iter != NULL; iter = g_list_next(iter)) {
+ item = (ListItem *) iter->data;
+ if (item != NULL) {
+ if (item->opened == TRUE) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+

void list_qualify_url(GList * list, gchar * page_url)
{
@@ -230,34 +282,43 @@
{
ListItem *item;
GList *iter;
+ gint count = 1;

if (list != NULL) {
for (iter = list; iter != NULL; iter = g_list_next(iter)) {
item = (ListItem *) iter->data;
if (item != NULL) {
- gm_log(TRUE, G_LOG_LEVEL_INFO, "Item \n");
- gm_log(TRUE, G_LOG_LEVEL_INFO, "src = %s\n", item->src);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "local = %s\n",
item->local);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "id = %i\n", item->id);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "hrefid = %i\n",
item->hrefid);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "play = %i\n", item->play);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "played = %i\n",
item->played);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "path = %s\n", item->path);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "controlid = %i\n",
item->controlid);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "playerready = %i\n",
item->playerready);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "newwindow = %i\n",
item->newwindow);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "cancelled = %i\n",
item->cancelled);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "streaming = %i\n",
item->streaming);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "loop = %i\n", item->loop);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "loopcount = %i\n",
item->loopcount);
- gm_log(TRUE, G_LOG_LEVEL_INFO, "plugin = %p\n",
item->plugin);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "----- Item %i -----",
count++);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "src = %s", item->src);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "local = %s", item->local);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "id = %i", item->id);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "localsize = %i",
item->localsize);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "lastsize = %i",
item->lastsize);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "hrefid = %i",
item->hrefid);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "requested = %i",
item->requested);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "retrieved = %i",
item->retrieved);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "cancelled = %i",
item->cancelled);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "streaming = %i",
item->streaming);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "opened = %i",
item->opened);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "oktoplay = %i",
item->oktoplay);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "queuedtoplay = %i",
item->queuedtoplay);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "play = %i", item->play);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "played = %i",
item->played);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "playlist = %i",
item->playlist);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "path = %s", item->path);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "controlid = %i",
item->controlid);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "playerready = %i",
item->playerready);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "newwindow = %i",
item->newwindow);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "loop = %i", item->loop);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "loopcount = %i",
item->loopcount);
+ gm_log(TRUE, G_LOG_LEVEL_INFO, "plugin = %p",
item->plugin);
}
}
}
}


-GList *list_parse_qt(GList * list, ListItem * item)
+GList *list_parse_qt(GList * list, ListItem * item, gboolean detect_only)
{
ListItem *newitem;
gchar *data;
@@ -278,7 +339,7 @@
//printf("read %i bytes from %s\n",datalen, item->local);
p = (gchar *) memmem_compat(data, datalen, "rmda", 4);
if (p == NULL) {
- gm_log(TRUE, G_LOG_LEVEL_INFO, "unable to find rmda
in %s\n", item->local);
+ gm_log(TRUE, G_LOG_LEVEL_DEBUG, "unable to find rmda
in %s", item->local);
return list;
} else {
if (datalen > 4) {
@@ -323,16 +384,18 @@
gm_log(TRUE, G_LOG_LEVEL_INFO, "Skipped
URL: %s\n", rdrf);
} else {
if (list_find(list, url) == NULL &&
strlen(rdrf) > 0) {
- item->play = FALSE;
- newitem = g_new0(ListItem, 1);
- g_strlcpy(newitem->src, url, 1024);
- // newitem->streaming =
streaming(newitem->src);
- newitem->play = TRUE;
- newitem->id = item->id;
- newitem->controlid = item->controlid;
- g_strlcpy(newitem->path, item->path, 1024);
- item->id = -1;
- list = g_list_append(list, newitem);
+ if (!detect_only) {
+ item->play = FALSE;
+ newitem = g_new0(ListItem, 1);
+ g_strlcpy(newitem->src, url, 1024);
+ // newitem->streaming =
streaming(newitem->src);
+ newitem->play = TRUE;
+ newitem->id = item->id;
+ newitem->controlid = item->controlid;
+ g_strlcpy(newitem->path, item->path,
1024);
+ item->id = -1;
+ list = g_list_append(list, newitem);
+ }
added = TRUE;
}
}
@@ -363,11 +426,14 @@
//printf("file not parsed > 16K actual size
is %i\n",item->localsize);
}
// printf("Exiting list_parse_qt\n");
+ if (added) {
+ item->playlist = TRUE;
+ }
return list;

}

-GList *list_parse_qt2(GList * list, ListItem * item)
+GList *list_parse_qt2(GList * list, ListItem * item, gboolean detect_only)
{
ListItem *newitem;
gchar *data;
@@ -385,7 +451,7 @@
//printf("read %i bytes from %s\n",datalen, item->local);
p = (gchar *) memmem_compat(data, datalen, "mmdr", 4);
if (p == NULL) {
- gm_log(TRUE, G_LOG_LEVEL_INFO, "unable to find mmdr
in %s\n", item->local);
+ gm_log(TRUE, G_LOG_LEVEL_DEBUG, "unable to find mmdr
in %s", item->local);
return list;
} else {
while (p != NULL && !added) {
@@ -407,16 +473,18 @@
}

if (list_find(list, url) == NULL) {
- item->play = FALSE;
- newitem = g_new0(ListItem, 1);
- g_strlcpy(newitem->src, url, 1024);
- // newitem->streaming =
streaming(newitem->src);
- newitem->play = TRUE;
- newitem->id = item->id;
- newitem->controlid = item->controlid;
- g_strlcpy(newitem->path, item->path, 1024);
- item->id = -1;
- list = g_list_append(list, newitem);
+ if (!detect_only) {
+ item->play = FALSE;
+ newitem = g_new0(ListItem, 1);
+ g_strlcpy(newitem->src, url, 1024);
+ // newitem->streaming =
streaming(newitem->src);
+ newitem->play = TRUE;
+ newitem->id = item->id;
+ newitem->controlid = item->controlid;
+ g_strlcpy(newitem->path, item->path, 1024);
+ item->id = -1;
+ list = g_list_append(list, newitem);
+ }
added = TRUE;
}
p = (gchar *) memmem_compat(urlptr, datalen -
(urlptr - data), "mmdr", 4);
@@ -437,6 +505,9 @@
//printf("file not parsed > 256K actual size
is %i\n",item->localsize);
}
// printf("Exiting list_parse_qt2\n");
+ if (added) {
+ item->playlist = TRUE;
+ }
return list;

}
@@ -494,7 +565,7 @@

}

-GList *list_parse_asx(GList * list, ListItem * item)
+GList *list_parse_asx(GList * list, ListItem * item, gboolean detect_only)
{
GMarkupParseContext *context;
gchar *data;
@@ -506,6 +577,7 @@
if (g_file_get_contents(item->local, &data, &datalen, NULL)) {
parser_list = list;
parser_item = item;
+ global_detect_only = detect_only;
asx_loop = 0;
strip_unicode(data, datalen);
replace_amp(data);
@@ -513,6 +585,7 @@
context = g_markup_parse_context_new(&asx_parser,
(GMarkupParseFlags) 0, data, NULL);
g_markup_parse_context_parse(context, data, datalen, NULL);
g_markup_parse_context_free(context);
+ global_detect_only = FALSE;
parser_item = NULL;
parser_list = NULL;
}
@@ -541,45 +614,48 @@
if (list_find(parser_list, (gchar *) attribute_values[i])
== NULL) {
parser_item->play = FALSE;
- newitem = g_new0(ListItem, 1);
- value = g_strdup(attribute_values[i]);
- unreplace_amp(value);
- ptr = g_strrstr(value, "/");
- if (ptr == NULL) {
- g_strlcpy(url, parser_item->src, 1024);
- ptr = g_strrstr(url, "/");
- if (ptr != NULL) {
- ptr[1] = (char) NULL;
- g_strlcpy(newitem->src, url, 1024);
- g_strlcat(newitem->src, value, 1024);
+ parser_item->playlist = TRUE;
+ if (!global_detect_only) {
+ newitem = g_new0(ListItem, 1);
+ value = g_strdup(attribute_values[i]);
+ unreplace_amp(value);
+ ptr = g_strrstr(value, "/");
+ if (ptr == NULL) {
+ g_strlcpy(url, parser_item->src, 1024);
+ ptr = g_strrstr(url, "/");
+ if (ptr != NULL) {
+ ptr[1] = (char) NULL;
+ g_strlcpy(newitem->src, url, 1024);
+ g_strlcat(newitem->src, value, 1024);
+ }
+ } else {
+ g_strlcpy(newitem->src, value, 1024);
}
- } else {
- g_strlcpy(newitem->src, value, 1024);
- }

- g_free(value);
- newitem->streaming = streaming(newitem->src);
- // crappy hack, mplayer needs the protocol in lower
case, some sites don't
- if (newitem->streaming) {
- newitem->src[0] = g_ascii_tolower(newitem->src[0]);
- newitem->src[1] = g_ascii_tolower(newitem->src[1]);
- newitem->src[2] = g_ascii_tolower(newitem->src[2]);
- newitem->src[3] = g_ascii_tolower(newitem->src[3]);
+ g_free(value);
+ newitem->streaming = streaming(newitem->src);
+ // crappy hack, mplayer needs the protocol in
lower case, some sites don't
+ if (newitem->streaming) {
+ newitem->src[0] =
g_ascii_tolower(newitem->src[0]);
+ newitem->src[1] =
g_ascii_tolower(newitem->src[1]);
+ newitem->src[2] =
g_ascii_tolower(newitem->src[2]);
+ newitem->src[3] =
g_ascii_tolower(newitem->src[3]);
+ }
+ newitem->play = TRUE;
+ if (entry_id != 0) {
+ newitem->id = entry_id;
+ } else {
+ newitem->id = parser_item->id;
+ parser_item->id = -1;
+ }
+ newitem->controlid = parser_item->controlid;
+ if (asx_loop != 0) {
+ newitem->loop = TRUE;
+ newitem->loopcount = asx_loop;
+ }
+ g_strlcpy(newitem->path, parser_item->path, 1024);
+ parser_list = g_list_append(parser_list, newitem);
}
- newitem->play = TRUE;
- if (entry_id != 0) {
- newitem->id = entry_id;
- } else {
- newitem->id = parser_item->id;
- parser_item->id = -1;
- }
- newitem->controlid = parser_item->controlid;
- if (asx_loop != 0) {
- newitem->loop = TRUE;
- newitem->loopcount = asx_loop;
- }
- g_strlcpy(newitem->path, parser_item->path, 1024);
- parser_list = g_list_append(parser_list, newitem);
}

}
@@ -596,6 +672,7 @@
if (list_find(parser_list, (gchar *) attribute_values[i])
== NULL) {
parser_item->play = FALSE;
+ parser_item->playlist = TRUE;
newitem = g_new0(ListItem, 1);
value = g_strdup(attribute_values[i]);
unreplace_amp(value);
@@ -650,7 +727,7 @@

}

-GList *list_parse_qml(GList * list, ListItem * item)
+GList *list_parse_qml(GList * list, ListItem * item, gboolean detect_only)
{
GMarkupParseContext *context;
gchar *data;
@@ -662,6 +739,7 @@
if (g_file_get_contents(item->local, &data, &datalen, NULL)) {
parser_list = list;
parser_item = item;
+ global_detect_only = detect_only;
asx_loop = 0;
strip_unicode(data, datalen);
replace_amp(data);
@@ -671,6 +749,7 @@
g_markup_parse_context_free(context);
parser_item = NULL;
parser_list = NULL;
+ global_detect_only = FALSE;
}
// list_dump(list);
}
@@ -696,33 +775,36 @@
== NULL) {
if (parser_item->play) {
parser_item->play = FALSE;
- newitem = g_new0(ListItem, 1);
- value = g_strdup(attribute_values[i]);
- unreplace_amp(value);
- g_strlcpy(newitem->src, value, 1024);
- g_free(value);
- newitem->streaming = streaming(newitem->src);
- // crappy hack, mplayer needs the protocol in
lower case, some sites don't
- if (newitem->streaming) {
- newitem->src[0] =
g_ascii_tolower(newitem->src[0]);
- newitem->src[1] =
g_ascii_tolower(newitem->src[1]);
- newitem->src[2] =
g_ascii_tolower(newitem->src[2]);
- newitem->src[3] =
g_ascii_tolower(newitem->src[3]);
+ parser_item->playlist = TRUE;
+ if (!global_detect_only) {
+ newitem = g_new0(ListItem, 1);
+ value = g_strdup(attribute_values[i]);
+ unreplace_amp(value);
+ g_strlcpy(newitem->src, value, 1024);
+ g_free(value);
+ newitem->streaming = streaming(newitem->src);
+ // crappy hack, mplayer needs the protocol in
lower case, some sites don't
+ if (newitem->streaming) {
+ newitem->src[0] =
g_ascii_tolower(newitem->src[0]);
+ newitem->src[1] =
g_ascii_tolower(newitem->src[1]);
+ newitem->src[2] =
g_ascii_tolower(newitem->src[2]);
+ newitem->src[3] =
g_ascii_tolower(newitem->src[3]);
+ }
+ newitem->play = TRUE;
+ if (entry_id != 0) {
+ newitem->id = entry_id;
+ } else {
+ newitem->id = parser_item->id;
+ parser_item->id = -1;
+ }
+ newitem->controlid = parser_item->controlid;
+ if (asx_loop != 0) {
+ newitem->loop = TRUE;
+ newitem->loopcount = asx_loop;
+ }
+ g_strlcpy(newitem->path, parser_item->path,
1024);
+ parser_list = g_list_append(parser_list,
newitem);
}
- newitem->play = TRUE;
- if (entry_id != 0) {
- newitem->id = entry_id;
- } else {
- newitem->id = parser_item->id;
- parser_item->id = -1;
- }
- newitem->controlid = parser_item->controlid;
- if (asx_loop != 0) {
- newitem->loop = TRUE;
- newitem->loopcount = asx_loop;
- }
- g_strlcpy(newitem->path, parser_item->path, 1024);
- parser_list = g_list_append(parser_list, newitem);
}
}
}
@@ -731,7 +813,7 @@
}
}

-GList *list_parse_ram(GList * list, ListItem * item)
+GList *list_parse_ram(GList * list, ListItem * item, gboolean detect_only)
{
gchar *data;
gsize datalen;
@@ -765,35 +847,38 @@
if (list_find(parser_list, (gchar *) output[i])
== NULL) {
parser_item->play = FALSE;
- newitem = g_new0(ListItem, 1);
- value = g_strdup(output[i]);
- unreplace_amp(value);
- ptr = g_strrstr(value, "/");
- if (ptr == NULL) {
- g_strlcpy(url, parser_item->src, 1024);
- ptr = g_strrstr(url, "/");
- if (ptr != NULL) {
- ptr[1] = (char) NULL;
- g_strlcpy(newitem->src, url, 1024);
- g_strlcat(newitem->src, value, 1024);
+ parser_item->playlist = TRUE;
+ if (!detect_only) {
+ newitem = g_new0(ListItem, 1);
+ value = g_strdup(output[i]);
+ unreplace_amp(value);
+ ptr = g_strrstr(value, "/");
+ if (ptr == NULL) {
+ g_strlcpy(url, parser_item->src, 1024);
+ ptr = g_strrstr(url, "/");
+ if (ptr != NULL) {
+ ptr[1] = (char) NULL;
+ g_strlcpy(newitem->src, url, 1024);
+ g_strlcat(newitem->src, value,
1024);
+ }
+ } else {
+ g_strlcpy(newitem->src, value, 1024);
}
- } else {
- g_strlcpy(newitem->src, value, 1024);
+ g_free(value);
+ newitem->streaming =
streaming(newitem->src);
+ // crappy hack, mplayer needs the protocol
in lower case, some sites don't
+ if (newitem->streaming) {
+ newitem->src[0] =
g_ascii_tolower(newitem->src[0]);
+ newitem->src[1] =
g_ascii_tolower(newitem->src[1]);
+ newitem->src[2] =
g_ascii_tolower(newitem->src[2]);
+ newitem->src[3] =
g_ascii_tolower(newitem->src[3]);
+ }
+ newitem->play = TRUE;
+ newitem->id = ++entry_id;
+ newitem->controlid =
parser_item->controlid;
+ g_strlcpy(newitem->path,
parser_item->path, 1024);
+ parser_list = g_list_append(parser_list,
newitem);
}
- g_free(value);
- newitem->streaming = streaming(newitem->src);
- // crappy hack, mplayer needs the protocol in
lower case, some sites don't
- if (newitem->streaming) {
- newitem->src[0] =
g_ascii_tolower(newitem->src[0]);
- newitem->src[1] =
g_ascii_tolower(newitem->src[1]);
- newitem->src[2] =
g_ascii_tolower(newitem->src[2]);
- newitem->src[3] =
g_ascii_tolower(newitem->src[3]);
- }
- newitem->play = TRUE;
- newitem->id = ++entry_id;
- newitem->controlid = parser_item->controlid;
- g_strlcpy(newitem->path, parser_item->path,
1024);
- parser_list = g_list_append(parser_list,
newitem);
}
}
i++;
=======================================
--- /trunk/src/plugin_list.h Mon Jul 2 09:01:48 2012
+++ /trunk/src/plugin_list.h Tue Sep 4 13:51:08 2012
@@ -57,9 +57,12 @@
gboolean streaming;
gboolean requested;
gboolean retrieved;
+ gboolean oktoplay;
+ gboolean queuedtoplay;
gboolean play;
gboolean played;
gboolean opened;
+ gboolean playlist;
guint mediasize;
gint localsize;
gint lastsize;
@@ -114,13 +117,16 @@
void list_mark_controlid_cancelled(GList * list, gint id, gboolean
cancelled);
void list_mark_id_played(GList * list, gint id);
ListItem *list_find_next_playable(GList * list);
+ListItem *list_find_next_playable_after_listitem(GList * list, ListItem *
find);
+ListItem *list_find_first_playable(GList * list);
void list_qualify_url(GList * list, gchar * page_url);
GList *list_clear(GList * list);
void list_dump(GList * list);
-GList *list_parse_qt(GList * list, ListItem * item);
-GList *list_parse_qt2(GList * list, ListItem * item);
-GList *list_parse_asx(GList * list, ListItem * item);
-GList *list_parse_qml(GList * list, ListItem * item); // Quick Time
Media Link
-GList *list_parse_ram(GList * list, ListItem * item); // Real Audio
Playlist
+GList *list_parse_qt(GList * list, ListItem * item, gboolean detect_only);
+GList *list_parse_qt2(GList * list, ListItem * item, gboolean detect_only);
+GList *list_parse_asx(GList * list, ListItem * item, gboolean detect_only);
+GList *list_parse_qml(GList * list, ListItem * item, gboolean
detect_only); // Quick Time Media Link
+GList *list_parse_ram(GList * list, ListItem * item, gboolean
detect_only); // Real Audio Playlist
+gboolean list_item_opened(GList * list);

#endif // _PLUGIN_LIST_H
=======================================
--- /trunk/src/plugin_setup.cpp Mon Jul 2 08:24:05 2012
+++ /trunk/src/plugin_setup.cpp Tue Sep 4 13:51:08 2012
@@ -75,7 +75,7 @@

for (i = 0; i < argc; i++) {

- gm_log(instance->debug_level, G_LOG_LEVEL_INFO, "ARG[%i]: %s
= %s\n", i, argn[i],
+ gm_log(instance->debug_level, G_LOG_LEVEL_INFO, "ARG[%i]: %s
= %s", i, argn[i],
argv[i]);

if (argn[i] == NULL)
Reply all
Reply to author
Forward
0 new messages