Пример #1
0
    def test_create(self):
        from shtoom.audio import getAudioDevice
        from twisted.internet.task import LoopingCall
        ae = self.assertEquals
        a_ = self.assert_

        dummymod = _dummy()
        dev = FakeDevice()

        def Device(dev=dev):
            return dev

        dummymod.Device = Device
        m = getAudioDevice(dummymod)
        m.close()
        m.selectDefaultFormat([
            PT_PCMU,
        ])

        ae(m.getDevice(), dev)
        a_(m.playout is None)
        m.close()
        a_(m.playout is None)
        m.reopen()
        m.close()
        a_(m.playout is None)
Пример #2
0
    def test_create(self):
        from shtoom.audio import getAudioDevice
        from twisted.internet.task import LoopingCall
        ae = self.assertEquals
        a_ = self.assert_

        dummymod = _dummy()
        dev = FakeDevice()
        def Device(dev=dev):
            return dev
        dummymod.Device = Device
        m = getAudioDevice(dummymod)
        m.close()
        m.selectDefaultFormat([PT_PCMU,])

        ae(m.getDevice(), dev)
        a_(m.playout is None)
        m.close()
        a_(m.playout is None)
        m.reopen()
        m.close()
        a_(m.playout is None)
Пример #3
0
def main():
    from twisted.python import threadable
    threadable.init(1)

    from shtoom.app.phone import Phone
    global app

    app = Phone()
    app.boot(args=sys.argv[1:])

    audioPref = app.getPref('audio')

    from twisted.python import log
    log.msg("Getting new audio device", system='phone')

    from shtoom.audio import getAudioDevice
    # XXX Aarrgh.
    app._audio = getAudioDevice()
    log.msg("Got new audio device %s :: %s" % (
        app._audio,
        type(app._audio),
    ))

    def run_it():
        app.start()

    def run_it_with_profiling():
        import profile
        p = profile.Profile()
        p.runcall(app.start)
        import tempfile
        (
            tmpfile,
            tmpfname,
        ) = tempfile.mkstemp(prefix='shtoomphone')
        p.dump_stats(tmpfname)
        del p

    run_it()
Пример #4
0
def main(Recorder = Recorder):
    from shtoom.audio import getAudioDevice
    from shtoom.rtp import formats
    from twisted.internet.task import LoopingCall
    from twisted.internet import reactor
    from twisted.python import log
    import sys
    log.startLogging(sys.stdout)

    dev = getAudioDevice()
    dev.close()
    if len(sys.argv) > 1:
        fmt = sys.argv[1]
        if not hasattr(formats, fmt):
            print "unknown PT marker %s"%(fmt)
            sys.exit(1)
        dev.selectDefaultFormat([getattr(formats,fmt),])
    else:
        dev.selectDefaultFormat([formats.PT_RAW,])
    rec = Recorder(dev, play=True)
    dev.reopen(mediahandler=rec.handle_media_sample)

    reactor.run()
Пример #5
0
def main(Recorder=Recorder):
    from shtoom.audio import getAudioDevice
    from shtoom.rtp import formats
    from twisted.internet.task import LoopingCall
    from twisted.internet import reactor
    from twisted.python import log
    import sys

    log.startLogging(sys.stdout)

    dev = getAudioDevice()
    dev.close()
    if len(sys.argv) > 1:
        fmt = sys.argv[1]
        if not hasattr(formats, fmt):
            print "unknown PT marker %s" % (fmt)
            sys.exit(1)
        dev.selectDefaultFormat([getattr(formats, fmt)])
    else:
        dev.selectDefaultFormat([formats.PT_RAW])
    rec = Recorder(dev, play=True)
    dev.reopen(mediahandler=rec.handle_media_sample)

    reactor.run()