diff --git a/output.raw b/output.raw new file mode 100644 index 00000000..83277f65 Binary files /dev/null and b/output.raw differ diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 3fc814e5..afbd23db 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -527,7 +527,7 @@ class MTProto extends \Volatile 'allow_p2p' => false, // Should I accept p2p calls? 'incoming_callback' => 'default_incoming_call_callback', 'network_type' => 7, - 'log_file_path' => '/dev/stdout', + 'log_file_path' => '/tmp/logs,txt', 'stats_dump_file_path' => '/dev/stdout', ], 'threading' => [ diff --git a/src/danog/MadelineProto/VoIP/AuthKeyHandler.php b/src/danog/MadelineProto/VoIP/AuthKeyHandler.php index d645c209..5deed003 100644 --- a/src/danog/MadelineProto/VoIP/AuthKeyHandler.php +++ b/src/danog/MadelineProto/VoIP/AuthKeyHandler.php @@ -97,14 +97,27 @@ trait AuthKeyHandler $this->calls[$params['id']]['controller']->setRemoteEndpoints(array_merge([$res['connection']], $res['alternative_connections']), $this->settings['calls']['allow_p2p']); var_dump('start'); $this->calls[$params['id']]['controller']->start(); - readline(); + + $samplerate = 48000; + $period = 1/$samplerate; + $writePeriod = $period*960; + var_dump($writePeriod); var_dump('SENDING DAT'); $f = fopen('output.raw', 'r'); + $time = microtime(true); while (!feof($f)) { - var_dump('SENDING 960 frames'); - $this->calls[$params['id']]['controller']->writeFrames(stream_get_contents($f, 960 * 2)); + usleep( + ($writePeriod - + ($time - microtime(true)) // Time it took me to write frames + )*1000000 + ); + var_dump(($writePeriod - + ($time - microtime(true)) // Time it took me to write frames + )*1000000); + $time = microtime(true); + $this->calls[$params['id']]['controller']->writeFrames(stream_get_contents($f, 960)); } - + $this->handle_pending_updates(); }