source: flair-src/trunk/lib/FlairCore/src/unexported/ui_com.h @ 442

Last change on this file since 442 was 442, checked in by Sanahuja Guillaume, 3 months ago

update buffering

File size: 2.3 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5//  created:    2011/05/01
6//  filename:   ui_com.h
7//
8//  author:     Guillaume Sanahuja
9//              Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11//  version:    $Id: $
12//
13//  purpose:    classe permettant la lecture et l'ecriture RT sur socket UDT
14//
15//
16/*********************************************************************/
17
18#ifndef UI_COM_H
19#define UI_COM_H
20
21#include "Thread.h"
22#include <udt.h>
23#ifdef __XENO__
24#include <native/pipe.h>
25#endif
26
27namespace flair {
28namespace core {
29class Mutex;
30class Object;
31}
32namespace gui {
33class SendData;
34}
35}
36
37class ui_com : public flair::core::Thread {
38public:
39  ui_com(const flair::core::Object *parent, UDTSOCKET sock);
40  ~ui_com();
41  //Send, public part
42  void Send(char *buf, ssize_t size,int ttl = -1);//ttl in ms, -1 for infinite
43  ssize_t Receive(char *buf, ssize_t buf_size);
44  void AddSendData(const flair::gui::SendData *obj);
45  void UpdateSendData(const flair::gui::SendData *obj);//must be called with mutex locked
46  void RemoveSendData(const flair::gui::SendData *obj);
47  void UpdateDataToSendBufferSize(const flair::gui::SendData *obj);
48  void UpdateDataToSendSize(void);
49  void Block(void);
50  void UnBlock(void);
51  bool ConnectionLost(void);
52  void CheckConnection(void);
53private:
54  ssize_t send_size;
55  char *send_buffer;
56  std::vector<const flair::gui::SendData *> datasToSend;
57  std::vector<flair::core::Time> resumeTimes;
58  flair::core::Mutex *send_mutex;
59  UDTSOCKET socket_fd;
60  bool connection_lost;
61  void Run(void);
62  void SendDatas(void);
63  //private part, called to effectively send to udt
64  void SendNRT(char *buf, ssize_t size,int ttl);
65  void PushDatasToSend(const flair::gui::SendData *dataToSend);
66  typedef struct {
67    char* buf;
68    size_t actual_size;
69    size_t final_size;
70    uint16_t period;
71    uint16_t nb_buffering;
72  } PushedData_t;
73  std::vector<PushedData_t> pushedDatas;
74
75  static int compressBuffer(char *in, ssize_t in_size, char **out,
76                            ssize_t *out_size, int level);
77  static int uncompressBuffer(unsigned char *in, ssize_t in_size,
78                              unsigned char **out, ssize_t *out_size);
79#ifdef __XENO__
80  bool is_running;
81  static void *user_thread(void *arg);
82  pthread_t thread;
83  RT_PIPE pipe;
84#endif
85};
86
87#endif // UI_COM_H
Note: See TracBrowser for help on using the repository browser.