diff options
author | Martin Lucina <mato@kotelna.sk> | 2010-01-30 21:04:14 +0100 |
---|---|---|
committer | Martin Lucina <mato@kotelna.sk> | 2010-01-30 21:04:14 +0100 |
commit | a4807b4810c2e41d6d3b156aa433b4c75ca75c6f (patch) | |
tree | 70193433075463b9ef5c3dfa52bea3929d7b4c0d | |
parent | b5c351f2beff5ffbd5ff59e488a25fbf0b85e453 (diff) |
Add architecture description, make ESC quit the app
-rw-r--r-- | zmq-camera.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/zmq-camera.c b/zmq-camera.c index 61c7edd..2192165 100644 --- a/zmq-camera.c +++ b/zmq-camera.c @@ -34,6 +34,41 @@ #include <zmq.h> +/* + * Overall architecture: + * + * zmq-camera uses 3 application threads: + * + * 1) the main thread, which receives and displays video from either the + * sender thread using inproc://local-camera if running in sender mode (-s) + * or from a remote endpoint specified by the user if running in + * receive-only mode (-r). + * + * the main thread also receives and handles signals and timers, + * using inproc://local-signal and periodically polls for UI events. + * + * 2) the signal handling thread, which handles all signals synchronously + * using a sigwait() loop and sends a single message for each signal + * received to the main thread. + * + * 3) the sender thread which does the actual video capture and sends one + * message per raw video frame both to inproc://local-camera so that the + * user sees what they are sending and to the remote endpoint specified. + * + * Message formats: + * + * inproc://local-signal + * + * [ signo (int) ] + * + * Video data: + * + * [ width (uint32_t in network byte order), + * height (uint32_t in network byte order), + * (RGB24 pixel data) ] + * + */ + #define FOURCC(a,b,c,d) (unsigned int)((((unsigned int)d)<<24)+\ (((unsigned int)c)<<16)+(((unsigned int)b)<<8)+a) @@ -552,11 +587,15 @@ int main (int argc, char *argv []) { if (event.type == SDL_QUIT) quit = 1; + if (event.type == SDL_KEYDOWN) + if (event.key.keysym.sym == SDLK_ESCAPE) + quit = 1; } } /* TODO: Send a 'stop' message to sender thread rather than killing it - forcefully by terminating the main thread. */ + forcefully by terminating the main thread. This would allow it + to call zmq_close() correctly and us to call zmq_term() here. */ /* Cleanup */ SDL_Quit (); |