Skip to content

Commit

Permalink
Added a thread to send video out
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Jaramillo committed May 24, 2013
1 parent 683f3b9 commit 4800dca
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 660 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CFLAGS = -Wall -g
INCLUDEFLAGS = -I../include -I./include
ENVVARS = # -DSHOWHOST -DDEVELOP
ALLFLAGS = $(CFLAGS) $(INCLUDEFLAGS) # $(ENVVARS)
LDFLAGS = -lv4l2 -lcaca -lncurses -lrt #-lpthread # "librt" stands for "real time library" used for the AIO
LDFLAGS = -lv4l2 -lcaca -lncurses -lpthread # -lrt # "librt" stands for "real time library" used for the AIO

all: $(OBJS) $(EXECS)

Expand Down
2 changes: 1 addition & 1 deletion include/caca_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#define SIZE sizeof(struct sockaddr_in)
#define DEFAULT_HOST "eniac.geo.hunter.cuny.edu"
#define PORT_CHAT 25666
#define PORT_VIDEO 25777
#define PORT_VIDEO 25667
#define ERROR_EXIT( _mssg, _num) perror(_mssg);exit(_num);
#define MAXLINE 4096
#define LISTEN_QUEUE_SIZE 5
Expand Down
24 changes: 13 additions & 11 deletions include/cacatalk.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
#include <sys/param.h>
#include <linux/videodev2.h>
#include <libv4l2.h>
#include <pthread.h>
#include "caca.h"

#define BUFFER_SIZE MAX_INPUT
#define TEXT_ENTRIES 5
#define NUM_THREADS 1 // just one for now

typedef struct textentry
{
Expand Down Expand Up @@ -51,17 +53,6 @@ typedef struct options_s
int is_server; ///< To indicate socket behavior (either as server=1, or client=0 (default))
} options;

// TODO: delete
struct thread_arg_struct {
int socketfd;
int text_buffer_size;
unsigned int row_offset;
unsigned int col_offset;
char label[MAX_INPUT]; ///< title string
caca_canvas_t *cv; ///< caca canvas
caca_display_t *dp; ///< caca display
};

typedef struct video_params_s {
int is_ok; ///< 1: Indicates when the video device is setup correctly. 0: is not okay
int is_on; ///< 1: Indicates when the video device is streaming. 0: the video is not streaming. -1: status is undefined
Expand All @@ -86,6 +77,17 @@ typedef struct video_params_s {
unsigned int cv_cols; ///< Number of columns to resolve video on caca _anvas
} video_params;

/** @brief structure of arguments passed to a thread (also is going to be made global to be able to shut the video on and off)
* TODO:
*
*/
typedef struct video_out_args_s {
int socketfd; ///< The socket file descriptor for streaming video
int video_stream_on; ///< Set to 1 to indicate streaming is on. 0 for off
int quit; ///< Set to 1 to indicate to quite
Window *win; ///< Pointer to window object structure
video_params *vid_params; ///< Pointer to host's video device parameters structure
} video_out_args;

/** @brief TODO
*
Expand Down
4 changes: 2 additions & 2 deletions src/caca_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ void print_IP_addresses()

/** TODO: description
*
* @return socket file descriptor
* @return socket file descriptor number. Or -1 if not connected.
*/
int connect_to_peer_socket(const char* peer_hostname, struct sockaddr_in * server, in_port_t port)
{
int sockfd;
int sockfd = -1; // Initial invalid file descriptor number
char ip_name[256] = "";
char my_host_name[MAXHOSTNAMELEN] = "";
// struct sockaddr_in server;
Expand Down
Loading

0 comments on commit 4800dca

Please sign in to comment.