diff --git a/src/danog/MadelineProto/Connection.php b/src/danog/MadelineProto/Connection.php index 00dc3081..9406e0cf 100644 --- a/src/danog/MadelineProto/Connection.php +++ b/src/danog/MadelineProto/Connection.php @@ -156,7 +156,6 @@ var_dump(is_null($this->{$name})); $this->obfuscated['decryption']->setKey(substr($reversed, 0, 32)); $this->obfuscated['decryption']->setIV(substr($reversed, 32, 16)); - $random = substr_replace( $random, substr( diff --git a/src/danog/MadelineProto/Logger.php b/src/danog/MadelineProto/Logger.php index f6c3ddcf..e7b54d75 100644 --- a/src/danog/MadelineProto/Logger.php +++ b/src/danog/MadelineProto/Logger.php @@ -105,7 +105,11 @@ class Logger self::$BIG_ENDIAN = (pack('L', 1) === pack('N', 1)); self::$bigint = PHP_INT_SIZE < 8; if (class_exists('\danog\MadelineProto\VoIP')) { - \Threaded::extend('\danog\MadelineProto\VoIP'); + try { + \Threaded::extend('\danog\MadelineProto\VoIP'); + } catch (\RuntimeException $e) { + + } } self::$colors[self::ULTRA_VERBOSE] = implode(';', [self::foreground['light_gray'], self::set['dim']]); self::$colors[self::VERBOSE] = implode(';', [self::foreground['green'], self::set['bold']]); diff --git a/src/danog/MadelineProto/VoIP/AuthKeyHandler.php b/src/danog/MadelineProto/VoIP/AuthKeyHandler.php index 2414ed18..df75cfe7 100644 --- a/src/danog/MadelineProto/VoIP/AuthKeyHandler.php +++ b/src/danog/MadelineProto/VoIP/AuthKeyHandler.php @@ -93,24 +93,26 @@ trait AuthKeyHandler $this->calls[$params['id']]['controller']->setRemoteEndpoints(array_merge([$res['connection']], $res['alternative_connections']), $params['protocol']['udp_p2p']); $this->calls[$params['id']]['controller']->start(); $this->calls[$params['id']]['controller']->connect(); - /* - $samplerate = 48000; - $period = 1 / $samplerate; - $writePeriod = $period * 960; - var_dump($writePeriod); + var_dump($this->calls[$params['id']]['controller']); + while ($this->calls[$params['id']]['controller']->getState() !== \danog\MadelineProto\VoIP::STATE_ESTABLISHED); + while ($this->calls[$params['id']]['controller']->getOutputState() !== \danog\MadelineProto\VoIP::AUDIO_STATE_RUNNING); + + $writePeriod = $this->calls[$params['id']]['controller']->getInputParams()["writePeriod"]; + $samplesSize = $this->calls[$params['id']]['controller']->getInputParams()["samplesSize"]; + var_dump('SENDING DAT'); $f = fopen('output.raw', 'r'); $time = microtime(true); while (!feof($f)) { - usleep( - (int) (($writePeriod - - (microtime(true) - $time) // Time it took me to write frames - ) * 1000000) + usleep((int) + ($writePeriod - + (microtime(true) - $time) // Time it took me to write frames + ) ); $time = microtime(true); - $this->calls[$params['id']]['controller']->writeFrames(stream_get_contents($f, 960 * 2)); + $this->calls[$params['id']]['controller']->writeSamples(stream_get_contents($f, $samplesSize)); } - */ + $this->handle_pending_updates(); }