2 #include "orbsvcs/AV/AVStreams_i.h"
3 #include "ace/High_Res_Timer.h"
4 #include "ace/OS_NS_strings.h"
6 //TimeStamp Protocol Object
8 TimeStamp_Protocol_Object::TimeStamp_Protocol_Object (TAO_AV_Callback
*callback
,
9 TAO_AV_Transport
*transport
)
10 :TAO_AV_Protocol_Object (callback
,transport
)
13 "TimeStamp_Protocol_Object::TimeStamp_Protocol_Object\n"));
14 ACE_NEW (this->frame_
,
17 this->frame_
->size (4 * this->transport_
->mtu ());
22 TimeStamp_Protocol_Object::handle_input ()
24 ssize_t n
= this->transport_
->recv (this->frame_
->rd_ptr (),
25 this->frame_
->size ());
27 ACE_ERROR_RETURN ((LM_ERROR
,"TAO_AV_UDP_Flow_Handler::handle_input recv failed\n"),-1);
29 ACE_ERROR_RETURN ((LM_ERROR
,"TAO_AV_UDP_Flow_Handler::handle_input connection closed\n"),-1);
30 this->frame_
->wr_ptr (this->frame_
->rd_ptr () + n
);
32 return this->callback_
->receive_frame (this->frame_
);
36 // TimeStamp_Protocol_Object::handle_input ()
40 // int n = this->transport_->recv (&iov, iovcnt);
42 // int frame_size = BUFSIZ;
45 // ACE_Message_Block* prev;
47 // while (n >= frame_size)
49 // ACE_DEBUG ((LM_DEBUG,
50 // "(%N|%l) Frame Size %d %d\n",
54 // ACE_Message_Block* mb = 0;
55 // ACE_NEW_RETURN (mb,
56 // ACE_Message_Block(frame_size),
59 // ACE_OS::memmove (mb->rd_ptr (), iov.iov_base, frame_size);
60 // mb->wr_ptr (mb->rd_ptr () + frame_size);
62 // // iov_base += frame_size;
83 // ACE_DEBUG ((LM_DEBUG,
84 // "(%N|%l) Frame Size %d\n",
86 // ACE_OS::memmove (this->frame_->rd_ptr (), iov.iov_base, n);
87 // this->frame_->wr_ptr (this->frame_->rd_ptr () + n);
91 // ACE_DEBUG ((LM_DEBUG,
92 // "(%N|%l) Frame Size %d\n",
95 // ACE_Message_Block* mb = 0;
96 // ACE_NEW_RETURN (mb,
97 // ACE_Message_Block (frame_size),
100 // ACE_OS::memmove (mb->rd_ptr (), iov.iov_base, n);
101 // mb->wr_ptr (mb->rd_ptr () + n);
105 // ACE_DEBUG ((LM_DEBUG,
106 // "IOVEC SIZE %d %d\n",
111 // ACE_ERROR_RETURN ((LM_ERROR,"TAO_AV_TCP_Flow_Handler::handle_input recv failed\n"),-1);
113 // ACE_ERROR_RETURN ((LM_ERROR,"TAO_AV_TCP_Flow_Handler::handle_input connection closed\n"),-1);
115 // return this->callback_->receive_frame (this->frame_);
118 /// send a data frame.
120 TimeStamp_Protocol_Object::send_frame (ACE_Message_Block
*frame
,
123 ACE_DEBUG ((LM_DEBUG
,
124 "TimeStamp_Protocol_Object::send_frame\n"));
126 ACE_Message_Block
* timestamp
;
127 ACE_NEW_RETURN (timestamp
,
128 ACE_Message_Block (BUFSIZ
),
131 ACE_hrtime_t now
= ACE_OS::gethrtime ();
133 ACE_UINT64 usec
= now
;
134 ACE_UINT32 val_1
= ACE_CU64_TO_CU32 (usec
);
135 ACE_DEBUG ((LM_DEBUG
,
136 "Time Stamp %u usecs\n",
139 ACE_OS::memcpy (timestamp
->wr_ptr (), &now
, sizeof (now
));
140 timestamp
->wr_ptr (sizeof (now
));
142 frame
->cont (timestamp
);
144 ssize_t result
= this->transport_
->send (frame
);
151 TimeStamp_Protocol_Object::send_frame (iovec
const* iov
,
155 return this->transport_
->send (iov
,iovcnt
);
159 TimeStamp_Protocol_Object::send_frame (const char* buf
,
162 int result
= this->transport_
->send (buf
, len
, 0);
170 TimeStamp_Protocol_Object::destroy ()
172 this->callback_
->handle_destroy ();
177 TimeStamp_Protocol_Factory::TimeStamp_Protocol_Factory ()
181 TimeStamp_Protocol_Factory::~TimeStamp_Protocol_Factory ()
186 TimeStamp_Protocol_Factory::init (int, ACE_TCHAR
**)
188 ACE_DEBUG ((LM_DEBUG
,
189 "TimeStamp_Protocol_Factory::init\n"));
194 TimeStamp_Protocol_Factory::match_protocol (const char *flow_string
)
196 ACE_DEBUG ((LM_DEBUG
,
197 "TimeStamp_Protocol_Factory::match_protocol\n"));
198 if (ACE_OS::strcasecmp (flow_string
,"TS") == 0)
203 TAO_AV_Protocol_Object
*
204 TimeStamp_Protocol_Factory::make_protocol_object (TAO_FlowSpec_Entry
*entry
,
205 TAO_Base_StreamEndPoint
*endpoint
,
206 TAO_AV_Flow_Handler
*handler
,
207 TAO_AV_Transport
*transport
)
209 TAO_AV_Callback
*callback
= 0;
210 endpoint
->get_callback (entry
->flowname (),
214 TimeStamp_Protocol_Object
*object
= 0;
215 ACE_NEW_RETURN (object
,
216 TimeStamp_Protocol_Object (callback
,
219 callback
->open (object
,
221 endpoint
->set_protocol_object (entry
->flowname (),
226 ACE_FACTORY_DEFINE (TAO_TS
, TimeStamp_Protocol_Factory
)
227 ACE_STATIC_SVC_DEFINE (TimeStamp_Protocol_Factory
,
228 ACE_TEXT ("TimeStamp_Protocol_Factory"),
230 &ACE_SVC_NAME (TimeStamp_Protocol_Factory
),
231 ACE_Service_Type::DELETE_THIS
|
232 ACE_Service_Type::DELETE_OBJ
,