Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

advice on fixing https://gitlab.com/Mis012/flashplayer-standalone to make it work with freshplayer #387

Open
Mis012 opened this issue Oct 27, 2020 · 9 comments

Comments

@Mis012
Copy link

Mis012 commented Oct 27, 2020

Hi,
I have found https://github.com/idaunis/simple-linux-flash-embed and to my surprise, it works perfectly - but only with the native NPAPI flash plugin :(
I however plan to use this on armhf, so pepperflash is the only option
I have fixed the straight up crash, but now I am getting an all-white screen with working right-click menu that says "Movie not loaded".
Notably, I wasn't able to get the placeholder image to show up either (though looking at the code I don't see how it would do that).

Is there any chance that you might be able to help?

@Mis012
Copy link
Author

Mis012 commented Oct 31, 2020

hmm, it seems I'm able to change the rendered "bgcolor"...
so it does something

@Mis012
Copy link
Author

Mis012 commented Oct 31, 2020

probably an issue with ignoring unrequested stream

@Mis012
Copy link
Author

Mis012 commented Nov 3, 2020

Ok, got it to work to a point where the last needed hack is this:

diff --git a/src/ppb_url_loader.c b/src/ppb_url_loader.c
index 9690d83..8f930f9 100644
--- a/src/ppb_url_loader.c
+++ b/src/ppb_url_loader.c
@@ -241,10 +241,12 @@ open_temporary_file(void)
 {
     char *tmpfname;
     // TODO: make temp path configurable
-    tmpfname = g_strdup_printf("/tmp/FreshStreamXXXXXX");
-    int fd = mkstemp(tmpfname);
-    unlink(tmpfname);
-    g_free(tmpfname);
+//    tmpfname = g_strdup_printf("/tmp/FreshStreamXXXXXX");
+//    int fd = mkstemp(tmpfname);
+
+       int fd = open("/path/to/actual/file.swf", O_RDONLY);
+//    unlink(tmpfname);
+//    g_free(tmpfname);
     return fd;
 }

but as I understand it, freshplayer should try to capture the first unrequested stream and use that in order to behave just like NPAPI flash?

@i-rinat
Copy link
Owner

i-rinat commented Nov 3, 2020

freshplayer should try to capture the first unrequested stream and use that in order to behave just like NPAPI flash?

Yes, as far as I remember. When NPAPI Flash instance is created, browser itself initiates a flash movie download. So the first stream plugin gets is the .swf file. With PPAPI, browser does nothing, and the plugin is requesting a download.

See #153 and abe3d52.

@Mis012
Copy link
Author

Mis012 commented Nov 4, 2020

ok, I have figured out the issue

there is a race condition, if the NPAPI "browser" doesn't stream the file fast enough (ideally in one call to Write), it seems either freshplayer or flash will give up

@Mis012
Copy link
Author

Mis012 commented Nov 4, 2020

if I stream the file in one go like this:

	FILE *pp;
	char buffer[1977354];
	pp = fopen(filename,"rb");
	int len;
	while((len=fread(buffer, 1, sizeof(buffer), pp)) != 0) {
		pluginFuncs.writeready(instance, stream);
		pluginFuncs.write(instance, stream, 0, len, buffer);
	}
	fclose(pp);

where 1977354 is the file size, everything works with zero modifications to freshplayer

@i-rinat
Copy link
Owner

i-rinat commented Nov 7, 2020

Speaking of file sizes. simple-linux-flash-embed seems to hardcode file size here: https://github.com/idaunis/simple-linux-flash-embed/blob/b7d6ea436470a87659a5b1e59b54480c0664c303/player.c#L364. Did you try to change 99782 to -1 there? It may be important to have either correct data size there or -1. Otherwise Flash may decide to stop getting SWF content when it gets 99782 bytes.

@Mis012
Copy link
Author

Mis012 commented Nov 8, 2020

no difference unfortunately :(

@i-rinat
Copy link
Owner

i-rinat commented Nov 18, 2020

Try this patch:

diff --git a/player.c b/player.c
old mode 100755
new mode 100644
index 4925ec0..8690aa4
--- a/player.c
+++ b/player.c
@@ -226,7 +226,7 @@ switch (variable) {
 		*((int*)ret_value)= NPNVGtk2;
 		break;
 	case NPNVnetscapeWindow:
-		*((int*)ret_value)= PR_TRUE;
+		*((int*)ret_value)= None;
 		break;
 	default:
 		*((int*)ret_value)=PR_FALSE;
@@ -360,9 +360,9 @@ static NPWindow * npwindow_construct (GtkWidget *widget) {
 static NPStream * npstream_construct() {
     NPStream *stream = (NPStream *) malloc(sizeof(NPStream));
     
-    stream->url=strdup(URL);
+    stream->url=strdup("http://127.0.0.1/movie.swf");
     stream->ndata = 0;
-    stream->end = 99782;
+    stream->end = 0;
     stream->lastmodified= 1201822722;
     stream->notifyData = 0x00000000;
     stream->headers = NULL;
@@ -908,9 +908,11 @@ int main(int argc, char **argv)
 	char buffer[8192];
 	pp = fopen(argv[1],"rb");
 	int len;
+	int offset = 0;
 	while((len=fread(buffer, 1, sizeof(buffer), pp)) != 0) {
 		pluginFuncs.writeready(instance, stream);
-		pluginFuncs.write(instance, stream, 0, len, buffer);
+		pluginFuncs.write(instance, stream, offset, len, buffer);
+		offset += len;
 	}
 	fclose(pp);
 

The only essential part are: url being URL, and correct values of offset. Looks like NPAPI Flash ignored offsets, but I for some reason decided that if there is a parameter, I must honor it. I don't know for sure why URL matters, but it's something inside PPAPI Flash itself. If ->url is not an URL, it just doesn't try to load a movie.

stream->end doesn't seem to change anything, but freshplayerplugin converts 0 to -1, which is what in PPAPI "language" means that size is not known in advance.

NPNVnetscapeWindow is not really required too, but plugin expects there a browser window handle, not a boolean. Setting it to None prevents BadWindow errors (code 3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants