2424// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2525// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2626// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27- package sippy
27+
28+ package rtp_proxy
2829
2930import (
3031 "bufio"
3132 "net"
3233 "strconv"
3334 "strings"
3435
36+ "github.com/sippy/go-b2bua/sippy"
37+ "github.com/sippy/go-b2bua/sippy/rtp_proxy/types"
3538 "github.com/sippy/go-b2bua/sippy/net"
3639 "github.com/sippy/go-b2bua/sippy/types"
3740)
@@ -43,7 +46,7 @@ func NewRtpProxyClient(opts *rtpProxyClientOpts) sippy_types.RtpProxyClient {
4346type Rtp_proxy_client_base struct {
4447 heir sippy_types.RtpProxyClient
4548 opts * rtpProxyClientOpts
46- transport rtp_proxy_transport
49+ transport rtp_proxy_types. RtpProxyTransport
4750 online bool
4851 sbind_supported bool
4952 tnot_supported bool
@@ -59,17 +62,8 @@ type Rtp_proxy_client_base struct {
5962 ptransmitted int64
6063}
6164
62- type rtp_proxy_transport interface {
63- address () net.Addr
64- get_rtpc_delay () float64
65- is_local () bool
66- send_command (string , func (string ))
67- shutdown ()
68- reconnect (net.Addr , * sippy_net.HostPort )
69- }
70-
7165func (self * Rtp_proxy_client_base ) IsLocal () bool {
72- return self .transport .is_local ()
66+ return self .transport .Is_local ()
7367}
7468
7569func (self * Rtp_proxy_client_base ) IsOnline () bool {
@@ -100,7 +94,7 @@ func (self *Rtp_proxy_client_base) me() sippy_types.RtpProxyClient {
10094}
10195
10296func (self * Rtp_proxy_client_base ) Address () net.Addr {
103- return self .transport .address ()
97+ return self .transport .Address ()
10498}
10599
106100func NewRtp_proxy_client_base (heir sippy_types.RtpProxyClient , opts * rtpProxyClientOpts ) * Rtp_proxy_client_base {
@@ -130,18 +124,18 @@ func (self *Rtp_proxy_client_base) Start() error {
130124}
131125
132126func (self * Rtp_proxy_client_base ) SendCommand (cmd string , cb func (string )) {
133- self .transport .send_command (cmd , cb )
127+ self .transport .Send_command (cmd , cb )
134128}
135129
136130func (self * Rtp_proxy_client_base ) Reconnect (addr net.Addr , bind_addr * sippy_net.HostPort ) {
137- self .transport .reconnect (addr , bind_addr )
131+ self .transport .Reconnect (addr , bind_addr )
138132}
139133
140134func (self * Rtp_proxy_client_base ) version_check () {
141135 if self .shut_down {
142136 return
143137 }
144- self .transport .send_command ("V" , self .version_check_reply )
138+ self .transport .Send_command ("V" , self .version_check_reply )
145139}
146140
147141func (self * Rtp_proxy_client_base ) version_check_reply (version string ) {
@@ -153,7 +147,7 @@ func (self *Rtp_proxy_client_base) version_check_reply(version string) {
153147 } else if self .online {
154148 self .me ().GoOffline ()
155149 } else {
156- StartTimeoutWithSpread (self .version_check , nil , self .opts .hrtb_retr_ival , 1 , self .opts .logger , 0.1 )
150+ sippy . StartTimeoutWithSpread (self .version_check , nil , self .opts .hrtb_retr_ival , 1 , self .opts .logger , 0.1 )
157151 }
158152}
159153
@@ -162,7 +156,7 @@ func (self *Rtp_proxy_client_base) heartbeat() {
162156 if self .shut_down {
163157 return
164158 }
165- self .transport .send_command ("Ib" , self .heartbeat_reply )
159+ self .transport .Send_command ("Ib" , self .heartbeat_reply )
166160}
167161
168162func (self * Rtp_proxy_client_base ) heartbeat_reply (stats string ) {
@@ -198,7 +192,7 @@ func (self *Rtp_proxy_client_base) heartbeat_reply(stats string) {
198192 }
199193 self .me ().UpdateActive (active_sessions , sessions_created , active_streams , preceived , ptransmitted )
200194 }
201- StartTimeoutWithSpread (self .heartbeat , nil , self .opts .hrtb_ival , 1 , self .opts .logger , 0.1 )
195+ sippy . StartTimeoutWithSpread (self .heartbeat , nil , self .opts .hrtb_ival , 1 , self .opts .logger , 0.1 )
202196}
203197
204198func (self * Rtp_proxy_client_base ) GoOnline () {
@@ -222,7 +216,7 @@ func (self *Rtp_proxy_client_base) GoOffline() {
222216 //print "go_offline", self.address, self.online
223217 if self .online {
224218 self .online = false
225- StartTimeoutWithSpread (self .version_check , nil , self .opts .hrtb_retr_ival , 1 , self .opts .logger , 0.1 )
219+ sippy . StartTimeoutWithSpread (self .version_check , nil , self .opts .hrtb_retr_ival , 1 , self .opts .logger , 0.1 )
226220 }
227221}
228222
@@ -259,7 +253,7 @@ func (self *Rtp_proxy_client_base) Shutdown() {
259253 return
260254 }
261255 self .shut_down = true
262- self .transport .shutdown ()
256+ self .transport .Shutdown ()
263257}
264258
265259func (self * Rtp_proxy_client_base ) IsShutDown () bool {
@@ -271,7 +265,7 @@ func (self *Rtp_proxy_client_base) GetOpts() sippy_types.RtpProxyClientOpts {
271265}
272266
273267func (self * Rtp_proxy_client_base ) GetRtpcDelay () float64 {
274- return self .transport .get_rtpc_delay ()
268+ return self .transport .Get_rtpc_delay ()
275269}
276270
277271type rtppCapsChecker struct {
@@ -297,7 +291,7 @@ func newRtppCapsChecker(rtpc *Rtp_proxy_client_base) *rtppCapsChecker {
297291 attr := it .attr // For some reason the it.attr cannot be passed into the following
298292 // function directly - the resulting value is always that of the
299293 // last 'it.attr' value.
300- rtpc .transport .send_command ("VF " + it .vers , func (res string ) { self .caps_query_done (res , attr ) })
294+ rtpc .transport .Send_command ("VF " + it .vers , func (res string ) { self .caps_query_done (res , attr ) })
301295 }
302296 return self
303297}
0 commit comments