summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/AVStreams/benchmark/child.cpp
blob: 8d01818fb5bd7a3f593fa5fe7a3d3f28e27c728b (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// $Id$

#include "child.h"

ACE_RCSID(benchmark, child, "$Id$")

// Bench_Server_StreamEndPoint methods.

Bench_Server_StreamEndPoint::Bench_Server_StreamEndPoint (void)
{
}

int
Bench_Server_StreamEndPoint::handle_open (void) 
{
  return 0;
}

int
Bench_Server_StreamEndPoint::handle_close (void) 
{
  // called when streamendpoint is being destructed
  return 0;
}

int
Bench_Server_StreamEndPoint::handle_stop (const AVStreams::flowSpec &the_spec,
                                          CORBA::Environment &env) 
{
  return 0;
}
  
int
Bench_Server_StreamEndPoint::handle_start (const AVStreams::flowSpec &the_spec,  
                                           CORBA::Environment &env) 
{
 return 0;
}
  
int
Bench_Server_StreamEndPoint::handle_destroy (const AVStreams::flowSpec &the_spec,  
                                             CORBA::Environment &env) 
{
  return 0;
}

CORBA::Boolean 
Bench_Server_StreamEndPoint::handle_connection_requested (AVStreams::flowSpec &the_spec,  
                                                          CORBA::Environment &env) 
{
  ACE_DEBUG ((LM_DEBUG,"(%P|%t) Bench_Server_StreamEndPoint::handle_connection_requested:() length =%d\n",
              the_spec.length ()));

  return CORBA::B_TRUE;

  ACE_INET_Addr client_addr (the_spec [0]);
  u_short local_port = 0;
  ACE_INET_Addr local_addr (local_port,"merengue-atm.cs.wustl.edu");
  
  if (this->connector_.connect (this->tcp_stream_,
                                client_addr,
                                0,
                                local_addr) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "(%P|%t) Connection to server failed: %p\n",
                       "connect"),
                      CORBA::B_FALSE);
  ACE_DEBUG ((LM_DEBUG,"(%P|%t) tcp connect succeeded %d\n",this->tcp_stream_.get_handle ()));
  
  int sndbufsize = ACE_DEFAULT_MAX_SOCKET_BUFSIZ;
  int rcvbufsize = ACE_DEFAULT_MAX_SOCKET_BUFSIZ;
  
  if (this->tcp_stream_.set_option (SOL_SOCKET,
                                SO_SNDBUF,
                                (void *) &sndbufsize,
                                sizeof (sndbufsize)) == -1
      && errno != ENOTSUP)
    return -1;
  else if (this->tcp_stream_.set_option (SOL_SOCKET,
                                         SO_RCVBUF,
                                     (void *) &rcvbufsize,
                                     sizeof (rcvbufsize)) == -1
           && errno != ENOTSUP)
    return -1;
  
  int one = 1;
  if (this->tcp_stream_.set_option (SOL_SOCKET,
                                    TCP_NODELAY,
                                (char *)& one,
                                sizeof (one)) == -1 )
    return -1;

  ACE_NEW_RETURN (this->stream_handler_,
                  ttcp_Stream_Handler (this->tcp_stream_.get_handle ()),
                  CORBA::B_FALSE);
  int result;

  result = TAO_ORB_Core_instance ()->reactor ()->register_handler (this->stream_handler_,
                                                                   ACE_Event_Handler::READ_MASK);
  if (result < 0)
    return CORBA::B_FALSE;

  ACE_DEBUG ((LM_DEBUG,"(%P|%t) register handler for tcp_Stream success\n"));
  return CORBA::B_TRUE;
}

ttcp_Stream_Handler::ttcp_Stream_Handler (int control_fd)
  : control_handle_ (control_fd)
{
}

// Called by the reactor to extract the handle associated with this handler.
ACE_HANDLE
ttcp_Stream_Handler::get_handle (void) const
{
  return this->control_handle_ ;
}

// Called by the Reactor when data is ready to be read from the
// video control handle, which indicates a control message from the client.
int
ttcp_Stream_Handler::handle_input (ACE_HANDLE handle)
{
  //  ACE_DEBUG ((LM_DEBUG,"(%P|%t) Bench_Server_StreamEndPoint::handle_input ()\n"));

  char buf[BUFSIZ];
  int result =ACE_OS::read (this->control_handle_,buf,BUFSIZ);
  if (result < 0 )
    ACE_ERROR_RETURN ((LM_ERROR,
                       "(%P|%t) Bench_Server_StreamEndPoint::handle_input ()\n"),
                      -1);

  if (result == 0)
    return 0;
  return 0;
}


// --------------------------------------------------------------------------------


// int
// main (int argc, char **argv)
// {
//   TAO_AV_Child_Process_B<Bench_Server_StreamEndPoint,TAO_VDev,AV_Null_MediaCtrl> bench_child;
  
//    if (bench_child.init (argc,argv) == -1)
//      return 1;
//    if (bench_child.run () == -1)
//      return 2;
   
//    return 0;
// }