[xiph-commits] r14194 -
experimental/ribamar/etheora/examples/client-server-sdl
ribamar at svn.xiph.org
ribamar at svn.xiph.org
Mon Nov 19 13:23:39 PST 2007
Author: ribamar
Date: 2007-11-19 13:23:39 -0800 (Mon, 19 Nov 2007)
New Revision: 14194
Modified:
experimental/ribamar/etheora/examples/client-server-sdl/client-decoder.c
experimental/ribamar/etheora/examples/client-server-sdl/server-encoder.c
Log:
server-encoder now forks to accept multiple client connections.
Modified: experimental/ribamar/etheora/examples/client-server-sdl/client-decoder.c
===================================================================
--- experimental/ribamar/etheora/examples/client-server-sdl/client-decoder.c 2007-11-19 20:38:23 UTC (rev 14193)
+++ experimental/ribamar/etheora/examples/client-server-sdl/client-decoder.c 2007-11-19 21:23:39 UTC (rev 14194)
@@ -34,8 +34,7 @@
#include <netdb.h>
-#define RGB_DECODING 1
-//#define YUV_DECODING 1
+#define YUV_DECODING 1
//#define OVERLAY 1
int tcp_socket_connect(char *host, int port, FILE *finfo){
@@ -126,7 +125,7 @@
etheora_ctx ec;
FILE *finfo, *fin;
#if YUV_DECODING
- unsigned char r, g, b;
+ unsigned char y, u, v;
#else
float r, g, b;
#endif
@@ -225,18 +224,36 @@
read in yuv colorspace.*/
#if YUV_DECODING
etheora_dec_yuv_read(&ec, i, j,
- &r, &g, &b);
+ &y, &u, &v);
#else
etheora_dec_rgb_read(&ec, i, j,
&r, &g, &b);
#endif
/* sdl - drawing the pixel. */
+#if YUV_DECODING
+ /*
*((Uint16 *)scr->pixels + j*scr->pitch/2 + i)=
-#if YUV_DECODING
- SDL_MapRGB(scr->format, (Uint8)r,
- (Uint8)g, (Uint8)b);
+ SDL_MapRGB(scr->format, (Uint8)y,
+ (Uint8)u, (Uint8)v);
+ */
+
+ Uint32 a = 0;
+ a = (Uint32) 0
+ // + (((Uint32)y) << 2)
+ + (((Uint32)y) << 2)
+ + (((Uint32)u) << 1)
+ + (((Uint32)v) << 0);
+ *((Uint16 *)scr->pixels + j*scr->pitch/2 + i)= a;
+
+ /*
+ *((Uint16 *)(scr->pixels[0]+ scr->pitch[0]*i)) = y;
+ *((Uint16 *)scr->pixels[1]+ scr->pitch[1]*i) = v;
+ *((Uint16 *)scr->pixels[2]+ scr->pitch[2]*i) = u;
+ */
+
#else
+ *((Uint16 *)scr->pixels + j*scr->pitch/2 + i)=
SDL_MapRGB(scr->format, (Uint8)r,
(Uint8)g, (Uint8)b);
Modified: experimental/ribamar/etheora/examples/client-server-sdl/server-encoder.c
===================================================================
--- experimental/ribamar/etheora/examples/client-server-sdl/server-encoder.c 2007-11-19 20:38:23 UTC (rev 14193)
+++ experimental/ribamar/etheora/examples/client-server-sdl/server-encoder.c 2007-11-19 21:23:39 UTC (rev 14194)
@@ -67,7 +67,7 @@
int main(int argc, char **args){
- int f, i, j, sock_fd, port;
+ int f, i, j, sock, fout_fd, port;
etheora_ctx ec;
char *vendor = "etheora/libtheora";
FILE *finfo, *fout;
@@ -77,20 +77,23 @@
increase, you may want open a null device file as
/dev/null. */
- finfo = fopen("Debug.txt", "w");
- fprintf(stderr, "debug info in Debug.txt.\n");
-
/* listening. */
(argc > 1) ? (port = atoi(args[1])) : (port = PORT);
- if( (sock_fd = tcp_listen(stderr, port)) < 0 ){
+ if( (sock = tcp_listen(stderr, port)) < 0 ){
fprintf(stderr, "usage: \n%s [PORT]\n", args[0]);
return 1;
}
- if( (sock_fd = accept(sock_fd, 0, 0) ) < 0 ){
+while(1){ /* forked while */
+ if( (fout_fd = accept(sock, 0, 0) ) < 0 ){
fprintf(stderr, "Can't accept connection.\n");
return 1;
}
- fout = fdopen(sock_fd, "w");
+ if(fork()) continue;
+
+ finfo = fopen("Debug.txt", "w");
+ fprintf(stderr, "debug info in Debug.txt.\n");
+
+ fout = fdopen(fout_fd, "w");
if(fout == NULL || finfo == NULL){
fprintf(stderr, "Debug.txt or output file"
" couldn't be open.\n");
@@ -143,17 +146,8 @@
fprintf(stderr, "video generated. \n");
return 0;
+} /* forked while */
}
-#if 0
- if(argc > 1) {
- fout = fopen(args[1], "w");
- fprintf(stderr, "opening %s to write video file . \n", args[1]);
- }
- else {
- fout = stdout;
- fprintf(stderr, "opening standard output to write video file. \n");
- }
-#endif
More information about the commits
mailing list