summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/AVStreams/benchmark/client.h
blob: eb6abf24021cd13cd3da94fa66685d7cde16c866 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

// $Id$

#if !defined (TAO_AV_BENCH_CLIENT_H)
#define TAO_AV_BENCH_CLIENT_H

#include "ace/Reactor.h"
#include "ace/Event_Handler.h"
#include "ace/ARGV.h"
#include "tao/TAO.h"
#include "orbsvcs/CosNamingC.h"
#include "ace/SOCK_Dgram.h"
#include "orbsvcs/AV/AVStreams_i.h"
#include "ace/SOCK_Acceptor.h"
#include "ace/Synch.h"

#define TCP_PORT 5000

class Client_StreamEndPoint
  : public virtual TAO_Client_StreamEndPoint
{
  // = TITLE
  //    Defines a client StreamEndpoint class
  // = DESCRIPTION
  //    Makes use of a connected dgram to receive data from the server
  //    side stream endpoint.
public:
  Client_StreamEndPoint (void);

  virtual int handle_open (void);
  // called when streamendpoint is instantiated

  virtual int handle_close (void);
  // called when streamendpoint is being destructed

  virtual CORBA::Boolean handle_preconnect (AVStreams::flowSpec &the_spec);
  // called before connecting

  virtual CORBA::Boolean handle_postconnect (AVStreams::flowSpec &the_spec);
  // called after connecting
  
  virtual int handle_start (const AVStreams::flowSpec &the_spec,  
                             CORBA::Environment &env) ;

  virtual int handle_stop (const AVStreams::flowSpec &the_spec,
                            CORBA::Environment &env) ;
  
  virtual int handle_destroy (const AVStreams::flowSpec &the_spec,  
                               CORBA::Environment &env);
  
};

class ttcp_Client_StreamEndPoint;

class ttcp_Acceptor 
  :public virtual ACE_Acceptor <ttcp_Client_StreamEndPoint,ACE_SOCK_ACCEPTOR>
{
public:
  ttcp_Acceptor (ttcp_Client_StreamEndPoint *endpoint);
  
  virtual int make_svc_handler (ttcp_Client_StreamEndPoint *&sh);
private:
  ttcp_Client_StreamEndPoint *endpoint_;
};

class ttcp_Client_StreamEndPoint
  :public Client_StreamEndPoint,
   public virtual ACE_Svc_Handler <ACE_SOCK_STREAM, ACE_NULL_SYNCH>
{
public:
  ttcp_Client_StreamEndPoint (void);
  // constructor
  virtual CORBA::Boolean handle_preconnect (AVStreams::flowSpec &the_spec);
  // called before connecting

  virtual int open (void *);
  // called when server connects to us.
private:
  ttcp_Acceptor acceptor_;
  // The Acceptor.
};

class Client : public ACE_Task<ACE_SYNCH>
// one of these per client thread
{
public:
  Client (int argc, char **argv, ACE_Barrier *barrier);

  virtual int svc (void);

private:
  
  int bind_to_server (void);

  int establish_stream (void);


  TAO_ORB_Manager orb_manager_;

  TAO_AV_Endpoint_Reactive_Strategy_A<Client_StreamEndPoint, TAO_VDev,
    AV_Null_MediaCtrl> reactive_strategy_;

  AVStreams::MMDevice_var server_mmdevice_;

  TAO_MMDevice client_mmdevice_;

  TAO_StreamCtrl streamctrl_;
  // Video stream controller 

  int argc_;

  char **argv_;
  
  ACE_Barrier *barrier_;

};

#endif /* TAO_AV_BENCH_CLIENT_H */