# Path: sippy/SdpOrigin.py
# class SdpOrigin(object):
#     _session_id = int(random() * time() * 1000.0)
#     username = None
#     session_id = None
#     version = None
#     network_type = None
#     address_type = None
#     address = None
#     session_id = None
# 
#     def __init__(self, body = None, cself = None):
#         if body != None:
#             self.username, self.session_id, self.version, self.network_type, self.address_type, self.address = body.split()
#         elif cself == None:
#             self.username = '-'
#             self.session_id = SdpOrigin._session_id
#             SdpOrigin._session_id += 1
#             self.version = self.session_id
#             self.network_type = 'IN'
#             self.address_type = 'IP4'
#             self.address = SipConf.my_address
#         else:
#             self.username = cself.username
#             self.session_id = cself.session_id
#             self.version = cself.version
#             self.network_type = cself.network_type
#             self.address_type = cself.address_type
#             self.address = cself.address
# 
#     def __str__(self):
#         return '%s %s %s %s %s %s' % (self.username, self.session_id, self.version, self.network_type, self.address_type, self.address)
# 
#     def localStr(self, local_addr = None, local_port = None):
#         if local_addr != None and 'my' in dir(self.address):
#             if local_addr.startswith('['):
#                 address_type = 'IP6'
#                 local_addr = local_addr[1:-1]
#             else:
#                 address_type = 'IP4'
#             return '%s %s %s %s %s %s' % (self.username, self.session_id, self.version, self.network_type, address_type, local_addr)
#         return '%s %s %s %s %s %s' % (self.username, self.session_id, self.version, self.network_type, self.address_type, self.address)
# 
#     def getCopy(self):
#         return self.__class__(cself = self)
# 
# Path: sippy/Core/Exceptions.py
# def dump_exception(msg, f = sys.stdout, extra = None):
#     exc_type, exc_value, exc_traceback = sys.exc_info()
#     if isinstance(exc_value, StdException):
#         cus_traceback = exc_value.traceback
#     else:
#         if hasattr(exc_value, 'traceback'):
#             exc_traceback = exc_value.traceback
#         cus_traceback = None
#     f.write('%s @%s[%d] %s:\n' % (datetime.now(), sys.argv[0], os.getpid(), msg))
#     f.write(SEPT)
#     if cus_traceback != None:
#         f.write('Traceback (most recent call last):\n')
#         print_list(cus_traceback, file = f)
#         f.write(format_exception_only(exc_type, exc_value)[0])
#     else:
#         print_exception(exc_type, exc_value, exc_traceback, file = f)
#     f.write(SEPT)
#     if extra != None:
#         f.write(extra)
#         f.write(SEPT)
#     f.flush()


from sippy.SdpOrigin import SdpOrigin
from hashlib import md5
from random import random
from time import time
    from _thread import get_ident
    from thread import get_ident
from sippy.Core.Exceptions import dump_exception
from sippy.Core.EventDispatcher import ED2
    from sippy.Time.Timeout import Timeout
    from sippy.Rtp_proxy_client import Rtp_proxy_client
import sys
        result_callback(cb_args, rtpps, *cpo.callback_parameters)

    def __play(self, result, rtpps, prompt_name, times, result_callback, index):
        from_tag, to_tag = self.gettags(rtpps)
        command = 'P%d %s %s %s %s %s' % (times, '%s-%d' % (rtpps.call_id, index), prompt_name, self.codecs, from_tag, to_tag)
        rtpps.rtp_proxy_client.send_command(command, rtpps.command_result, result_callback)

    def _play(self, rtpps, prompt_name, times = 1, result_callback = None, index = 0):
        if not self.session_exists:
            ED2.callFromThread(rtpps.command_result, None, result_callback)
            return
        otherside = self.getother(rtpps)
        if not otherside.session_exists:
            otherside.update(rtpps, '0.0.0.0', 0, self.__play, '', index, 'IP4', prompt_name, times, result_callback, index)
            return
        self.__play(None, rtpps, prompt_name, times, result_callback, index)

    def _stop_play(self, rtpps, result_callback = None, index = 0):
        if not self.session_exists:
            ED2.callFromThread(rtpps.command_result, None, result_callback)
            return
        from_tag, to_tag = self.gettags(rtpps)
        command = 'S %s %s %s' % ('%s-%d' % (rtpps.call_id, index), from_tag, to_tag)
        rtpps.rtp_proxy_client.send_command(command, rtpps.command_result, result_callback)

    def _on_sdp_change(self, rtpps, sdp_body, result_callback, en_excpt):
        sects = []
        try:
            sdp_body.parse()
        except Exception as exception:

# Path: sippy/SdpOrigin.py
# class SdpOrigin(object):
#     _session_id = int(random() * time() * 1000.0)
#     username = None
#     session_id = None
#     version = None
#     network_type = None
#     address_type = None
#     address = None
#     session_id = None
# 
#     def __init__(self, body = None, cself = None):
#         if body != None:
#             self.username, self.session_id, self.version, self.network_type, self.address_type, self.address = body.split()
#         elif cself == None:
#             self.username = '-'
#             self.session_id = SdpOrigin._session_id
#             SdpOrigin._session_id += 1
#             self.version = self.session_id
#             self.network_type = 'IN'
#             self.address_type = 'IP4'
#             self.address = SipConf.my_address
#         else:
#             self.username = cself.username
#             self.session_id = cself.session_id
#             self.version = cself.version
#             self.network_type = cself.network_type
#             self.address_type = cself.address_type
#             self.address = cself.address
# 
#     def __str__(self):
#         return '%s %s %s %s %s %s' % (self.username, self.session_id, self.version, self.network_type, self.address_type, self.address)
# 
#     def localStr(self, local_addr = None, local_port = None):
#         if local_addr != None and 'my' in dir(self.address):
#             if local_addr.startswith('['):
#                 address_type = 'IP6'
#                 local_addr = local_addr[1:-1]
#             else:
#                 address_type = 'IP4'
#             return '%s %s %s %s %s %s' % (self.username, self.session_id, self.version, self.network_type, address_type, local_addr)
#         return '%s %s %s %s %s %s' % (self.username, self.session_id, self.version, self.network_type, self.address_type, self.address)
# 
#     def getCopy(self):
#         return self.__class__(cself = self)
# 
# Path: sippy/Core/Exceptions.py
# def dump_exception(msg, f = sys.stdout, extra = None):
#     exc_type, exc_value, exc_traceback = sys.exc_info()
#     if isinstance(exc_value, StdException):
#         cus_traceback = exc_value.traceback
#     else:
#         if hasattr(exc_value, 'traceback'):
#             exc_traceback = exc_value.traceback
#         cus_traceback = None
#     f.write('%s @%s[%d] %s:\n' % (datetime.now(), sys.argv[0], os.getpid(), msg))
#     f.write(SEPT)
#     if cus_traceback != None:
#         f.write('Traceback (most recent call last):\n')
#         print_list(cus_traceback, file = f)
#         f.write(format_exception_only(exc_type, exc_value)[0])
#     else:
#         print_exception(exc_type, exc_value, exc_traceback, file = f)
#     f.write(SEPT)
#     if extra != None:
#         f.write(extra)
#         f.write(SEPT)
#     f.flush()


# Path: sippy/Rtp_proxy_session.py
from sippy.SdpOrigin import SdpOrigin
from hashlib import md5
from random import random
from time import time
    from _thread import get_ident
    from thread import get_ident
from sippy.Core.Exceptions import dump_exception
from sippy.Core.EventDispatcher import ED2
    from sippy.Time.Timeout import Timeout
    from sippy.Rtp_proxy_client import Rtp_proxy_client
import sys

        result_callback(cb_args, rtpps, *cpo.callback_parameters)

    def __play(self, result, rtpps, prompt_name, times, result_callback, index):
        from_tag, to_tag = self.gettags(rtpps)
        command = 'P%d %s %s %s %s %s' % (times, '%s-%d' % (rtpps.call_id, index), prompt_name, self.codecs, from_tag, to_tag)
        rtpps.rtp_proxy_client.send_command(command, rtpps.command_result, result_callback)

    def _play(self, rtpps, prompt_name, times = 1, result_callback = None, index = 0):
        if not self.session_exists:
            ED2.callFromThread(rtpps.command_result, None, result_callback)
            return
        otherside = self.getother(rtpps)
        if not otherside.session_exists:
            otherside.update(rtpps, '0.0.0.0', 0, self.__play, '', index, 'IP4', prompt_name, times, result_callback, index)
            return
        self.__play(None, rtpps, prompt_name, times, result_callback, index)

    def _stop_play(self, rtpps, result_callback = None, index = 0):
        if not self.session_exists:
            ED2.callFromThread(rtpps.command_result, None, result_callback)
            return
        from_tag, to_tag = self.gettags(rtpps)
        command = 'S %s %s %s' % ('%s-%d' % (rtpps.call_id, index), from_tag, to_tag)
        rtpps.rtp_proxy_client.send_command(command, rtpps.command_result, result_callback)

    def _on_sdp_change(self, rtpps, sdp_body, result_callback, en_excpt):
        sects = []
        try:
            sdp_body.parse()
        except Exception as exception:

            dump_exception('can\'t parse SDP body', extra = sdp_body.content)