diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/camera.c | 12 | ||||
| -rw-r--r-- | src/camera.h | 4 | ||||
| -rw-r--r-- | src/display.c | 14 | ||||
| -rw-r--r-- | src/listener.c | 1 | ||||
| -rw-r--r-- | src/talker.c | 1 | 
5 files changed, 12 insertions, 20 deletions
| diff --git a/src/camera.c b/src/camera.c index 8d74217..61eb592 100644 --- a/src/camera.c +++ b/src/camera.c @@ -3,18 +3,18 @@  void camera_init(camera_handle *handle, camera_params params)  { -    handle->handle = malloc(sizeof(CommonV4l2)); -    CommonV4l2_init(handle->handle, params.device, params.x_res, params.y_res); +    *handle = malloc(sizeof(CommonV4l2)); +    CommonV4l2_init(*handle, params.device, params.x_res, params.y_res);  }  char *camera_get_image(camera_handle *handle)  { -    CommonV4l2_update_image(handle->handle); -    return CommonV4l2_get_image(handle->handle); +    CommonV4l2_update_image(*handle); +    return CommonV4l2_get_image(*handle);  }  void camera_deinit(camera_handle *handle)  { -    CommonV4l2_deinit(handle->handle); -    free(handle->handle); +    CommonV4l2_deinit(*handle); +    free(*handle);  } diff --git a/src/camera.h b/src/camera.h index bfc5394..f9f45ef 100644 --- a/src/camera.h +++ b/src/camera.h @@ -1,9 +1,7 @@  #ifndef CAMERA_H  #define CAMERA_H -typedef struct camera_handle { -    void *handle; -} camera_handle; +typedef void *camera_handle;  typedef struct camera_params {      char *device; diff --git a/src/display.c b/src/display.c index a09cc46..ba9bc48 100644 --- a/src/display.c +++ b/src/display.c @@ -12,7 +12,7 @@ static void error_callback(int error, const char* description)  static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)  { -    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) +    if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)          glfwSetWindowShouldClose(window, GLFW_TRUE);  } @@ -24,6 +24,7 @@ GLubyte pixels[BUF_CAP] = {0};  void pixel(int x, int y, char *buf)  { +    // for rotating the screen      int p = (y*WIDTH + x)*3;      int b = ((HEIGHT-1-y)*WIDTH+x)*3;      pixels[p+0] = buf[b+0]; @@ -53,20 +54,15 @@ int display(void)      glfwMakeContextCurrent(window);      glfwSwapInterval(1); - -    unsigned char *copy_cam_data;      while (!glfwWindowShouldClose(window))      { -        // memcpy(copy_cam_data, cam_data, BUF_CAP); -        copy_cam_data = cam_data; - -        WIDTH = MAX(copy_cam_data[0], 1); -        HEIGHT = MAX(copy_cam_data[1], 1); +        WIDTH = MAX(cam_data[0], 1); +        HEIGHT = MAX(cam_data[1], 1);          glfwSetWindowSize(window, WIDTH, HEIGHT);          for(int i = 0; i < HEIGHT; i++)              for(int j = 0; j < WIDTH; j++) -                pixel(j, i, &(copy_cam_data[2])); +                pixel(j, i, &(cam_data[2]));          glClear(GL_COLOR_BUFFER_BIT);          glDrawPixels(WIDTH, HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels); diff --git a/src/listener.c b/src/listener.c index 9360c55..b344b6e 100644 --- a/src/listener.c +++ b/src/listener.c @@ -22,7 +22,6 @@ void *display_thread(void *arg)      else          err("display: failed\n");      exit(r); -    // pthread_exit(0);  }  void on_recv(char *buf, int numbytes) diff --git a/src/talker.c b/src/talker.c index c481570..bfea616 100644 --- a/src/talker.c +++ b/src/talker.c @@ -26,7 +26,6 @@ void on_send(char *buf, int *bytes)      *bytes = REC_CAP + 2 + image_sz;      memcpy(&(buf[REC_CAP+2]), camera_get_image(&cam_handle), image_sz); -  }  int main(void) | 
