summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/AVStreams/Use_Case/Connection_Setup_Helper.h
blob: fad396a9cc0d7f29ce6b5e28d2f3cf709d9b46d2 (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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
//$Id$
#ifndef CONNECTION_SETUP_HELPER_H
#define CONNECTION_SETUP_HELPER_H

// ============================================================================
//
// = LIBRARY
//    TAO/orbsvcs/tests/AVStreams/Three_Stage
//
// = FILENAME
//    Connection_Setup_Helper.h
//
// = DESCRIPTION
//    This is a helper class that allows the senders bind to multiple receivers
//    and receivers to bind to senders. It also lets the senders and receivers
//    disconnect the streams set up.
//
// = AUTHOR
//    Yamuna Krishnamurthy <yamuna@cs.wustl.edu>
//
// ============================================================================



#include "orbsvcs/Naming/Naming_Utils.h"
#include "orbsvcs/AV/AVStreams_i.h"
#include "orbsvcs/AV/Protocol_Factory.h"
#include "tao/PortableServer/PortableServer.h"


class Recv_Obj_Ref_Item
{
  // = TITLE
  //    Defines a class which stores the receiver device name
  //    and its reference.
  // 
  // = DESCRIPTION
  //    This class defines a component to store the receiver
  //    device name and refernce.
  
 public:
  ACE_CString name;
  // Receiver MMDevice Name

  AVStreams::MMDevice_var ref;
  // Receiver MMDevice Object Reference
};

class StreamCtrl_Item
{
  // = TITLE
  //    Defines a class which stores the flow name
  //    and the corresponding stream controller
  // 
  // = DESCRIPTION
  //    This class defines a component to store  the flow name
  //    and the corresponding stream controller
  
 public:
  ACE_CString flowname;
  // The name of the stream

  TAO_StreamCtrl *streamctrl;
  // The corresponding stream controller
};

class Protocol_Object_Item
{
  // = TITLE
  //    Defines a class which stores the flow name
  //    and the corresponding protocol object
  // 
  // = DESCRIPTION
  //    This class defines a component to store  the flow name
  //    and the corresponding protocol object

 public:
  ACE_CString flowname;
  // Name of the stream

  TAO_AV_Protocol_Object* protocol_object;
  // The corresponding protocol object
};

class StreamEndpoint_Item
{
  // = TITLE
  //    Defines a class which stores the flow name
  //    and the corresponding stream endpoint
  // 
  // = DESCRIPTION
  //    This class defines a component to store  the flow name
  //    and the corresponding streamendpoint

 public:
  ACE_CString flowname;
  // The name of the stream

  TAO_StreamEndPoint* endpoint;
  // The corresponding stream enpoint
};


// Set of receiver device names and thier object refences
typedef ACE_Unbounded_Set <Recv_Obj_Ref_Item*> Recv_Obj_Ref_Set;
typedef ACE_Unbounded_Set_Iterator <Recv_Obj_Ref_Item*> Recv_Obj_Ref_Set_Itor;

// Set of flow names and the corresponding protocol objects
typedef ACE_Unbounded_Set <Protocol_Object_Item*> Protocol_Object_Set;
typedef ACE_Unbounded_Set_Iterator <Protocol_Object_Item*> Protocol_Object_Set_Itor;

// Set of flow names and the corresponding stream endpoints
typedef ACE_Unbounded_Set <StreamEndpoint_Item*> StreamEndpoint_Set;
typedef ACE_Unbounded_Set_Iterator <StreamEndpoint_Item*> StreamEndpoint_Set_Itor;

// Hash map of flow names and corresponding stream controllers.
typedef ACE_Hash_Map_Manager <TAO_String_Hash_Key, StreamCtrl_Item*, ACE_Null_Mutex> StreamCtrl_Map;
typedef ACE_Hash_Map_Iterator <TAO_String_Hash_Key, StreamCtrl_Item*, ACE_Null_Mutex> StreamCtrl_Map_Iterator;
typedef ACE_Hash_Map_Entry <TAO_String_Hash_Key, StreamCtrl_Item*> StreamCtrl_Map_Entry;

class Connection_Setup_Helper
{
  // = TITLE
  //    Defines the Connection Setup Helper Class.
  // 
  // = DESCRIPTION
  //    This is a helper class that allows the senders bind to multiple receivers
  //    and receivers to bind to senders. It also lets the senders and receivers
  //    disconnect the streams set up.
  
 public:
  
  Connection_Setup_Helper (void);
  // Constructor
  
  ~Connection_Setup_Helper (void);
  // Destructor

  int init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
  // Initialize the helper

  int bind_to_receivers (ACE_CString *sender_device_name,
                         AVStreams::MMDevice_ptr sender_mmdevice_obj,
                         Recv_Obj_Ref_Set &recv_obj_ref_set,
                         CORBA::Environment& ACE_TRY_ENV);
  // Method that binds the client to the Naming Service and retreives
  // the references of the receivers
  
  int connect_to_receivers (ACE_CString *sender_device_name,
                            ACE_CString *flow_protocol_str,
                            ACE_CString *protocol,
                            ACE_CString *host_address,
                            AVStreams::MMDevice_ptr sender_mmdevice_obj,
                            Recv_Obj_Ref_Set *recv_obj_ref_set,
                            StreamCtrl_Map &streamctrl_map,
                            CORBA::Environment&);
  //Method that sets up connections between the sender and receivers
  
  int bind_to_sender (ACE_CString *sender_device_name,
                      ACE_CString *receiver_device_name,
                      AVStreams::MMDevice_ptr &sender_mmdevice_obj,
                      AVStreams::MMDevice_ptr receiver_mmdevice_obj, 
                      CORBA::Environment&);
  // Bind receiver to the sender
  
  int connect_to_sender (ACE_CString *sender_device_name,
                         ACE_CString *receiver_device_name,
                         ACE_CString *flow_protocol_str,
                         ACE_CString *protocol,
                         ACE_CString *host_address,
                         AVStreams::MMDevice_ptr &sender_mmdevice_obj,
                         AVStreams::MMDevice_ptr receiver_mmdevice_obj,
                         StreamCtrl_Map &streamctrl_map,
                         CORBA::Environment &ACE_TRY_ENV);
  // Connect the receiver with the sender

  int disconnect (StreamEndpoint_Set *endpoint_set,
                  StreamCtrl_Map *streamctrl_map,
                  CORBA::Environment&);
  // Disconnect all the streams

  int disconnect (AVStreams::flowSpec &flowspec,
                  StreamEndpoint_Set *endpoint_set,
                  StreamCtrl_Map *streamctrl_map,
                  CORBA::Environment&);
  // Disconnect all the streams
    
 protected:
  int create_recv_obj_ref_list (CosNaming::BindingList &bl,
                                ACE_CString *sender_device_name,
                                Recv_Obj_Ref_Set &recv_obj_ref_set,
                                CORBA::Environment& ACE_TRY_ENV);
  // Retrieve the receiver device names and the corresponding object
  // references and store them in the recv_obj_ref_set
  
  TAO_Naming_Client my_naming_client_;
  // The Naming Service client.
  
  CORBA::ORB_var orb_;
  PortableServer::POA_var poa_;
  
};

#endif /*CONNECTION_SETUP_HELPER_H*/