Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

libming: added function to output movie as array of bytes

  • Loading branch information...
commit 79893ccbd27e9450ffbf2e540bc83da64bfd99dd 1 parent 6db9245
Eldar Zaitov authored
Showing with 29 additions and 3 deletions.
  1. +3 −2 src/blocks/method.c
  2. +1 −0  src/ming.h.in
  3. +25 −1 src/movie.c
5 src/blocks/method.c
View
@@ -46,8 +46,9 @@ void methodWriteUInt32(int i, SWFByteOutputMethod method, void *data)
void fileOutputMethod(byte b, void *data)
{
- FILE *f = (FILE *)data;
- fputc(b, f);
+ if(!data) return;
+ FILE *f = (FILE *)data;
+ fputc(b, f);
}
1  src/ming.h.in
View
@@ -1065,6 +1065,7 @@ void SWFMovie_namedAnchor(SWFMovie movie, const char *label);
int SWFMovie_output(SWFMovie movie, SWFByteOutputMethod method, void *data);
int SWFMovie_save(SWFMovie movie, const char *filename);
int SWFMovie_output_to_stream(SWFMovie movie, FILE *fp);
+int SWFMovie_output_as_buffer(SWFMovie movie, byte *buffer);
void SWFMovie_protect(SWFMovie movie, const char *password);
void SWFMovie_setNetworkAccess(SWFMovie movie, int flag);
void SWFMovie_addMetadata(SWFMovie movie, const char *xml);
26 src/movie.c
View
@@ -857,7 +857,7 @@ SWFMovie_toOutput(SWFMovie movie, int level)
}
/*
- * Oputput a movie with SWFByteOutputMethod
+ * Output a movie with SWFByteOutputMethod
* returns the number of bytes written.
*/
int
@@ -880,6 +880,30 @@ SWFMovie_output(SWFMovie movie, SWFByteOutputMethod method, void *data)
}
/*
+ * Output a movie as bytes
+ * returns the number of bytes written.
+ */
+int
+SWFMovie_output_as_buffer(SWFMovie movie, byte *buffer)
+{
+ SWFOutput swfbuffer;
+ int swflength;
+ int n;
+ int level = SWF_compression;
+
+ swfbuffer = SWFMovie_toOutput(movie, level);
+ swflength = SWFOutput_getLength(swfbuffer);
+ if (!buffer) {
+ destroySWFOutput(swfbuffer);
+ return swflength;
+ }
+ memcpy(buffer, SWFOutput_getBuffer(swfbuffer), swflength);
+
+ destroySWFOutput(swfbuffer);
+ return swflength;
+}
+
+/*
* Save movie to file
* returns the number of bytes written. -1 on error.
*/
Please sign in to comment.
Something went wrong with that request. Please try again.