From 7b014dbf419deeab462fed0a0b0e9ff421d72c26 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 4 Aug 2017 08:23:45 +0000 Subject: [PATCH 1/3] Apply fixes from StyleCI --- magna.php | 4 ++-- songs.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/magna.php b/magna.php index c236362f..f2dcd0da 100755 --- a/magna.php +++ b/magna.php @@ -90,7 +90,7 @@ $calls = []; $updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout foreach ($calls as $key => $call) { if ($call->getOutputState() >= \danog\MadelineProto\VoIP::AUDIO_STATE_CREATED) { - $call->setBitrate(100*1000); + $call->setBitrate(100 * 1000); try { $MadelineProto->messages->sendMessage(['peer' => $call->getOtherID(), 'message' => 'Emojis: '.implode('', $call->getVisualization())]); } catch (\danog\MadelineProto\RPCErrorException $e) { @@ -104,7 +104,7 @@ $calls = []; switch ($update['update']['_']) { case 'updatePhoneCall': if (is_object($update['update']['phone_call']) && isset($update['update']['phone_call']->madeline) && $update['update']['phone_call']->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_INCOMING) { - include('songs.php'); + include 'songs.php'; $update['update']['phone_call']->configuration['enable_NS'] = false; $update['update']['phone_call']->configuration['enable_AGC'] = false; $update['update']['phone_call']->configuration['enable_AEC'] = false; diff --git a/songs.php b/songs.php index 0f7f961f..19b5068b 100644 --- a/songs.php +++ b/songs.php @@ -3,7 +3,7 @@ $songs = [ 'Aronchupa - Little Swing' => 'input.raw', 'Parov Stelar - Booty Swing' => 'inputa.raw', - 'Parov Stelar - All night' => 'inpute.raw', + 'Parov Stelar - All night' => 'inpute.raw', 'Caravan Palace - Lone Digger' => 'inputb.raw', // 'Swingrowers - Butterfly' => 'inputc.raw', 'Postmodern Jukebox - Thrift Shop' => 'inputd.raw', From b598a02b8eab12fe2f736464c887c8e8d5adb39b Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 5 Aug 2017 17:41:36 +0200 Subject: [PATCH 2/3] Improved bitrate settings in @magnaluna and made sure shared config is actually parsed --- magna.php | 8 +++++++- songs.php | 8 ++++---- src/danog/MadelineProto/VoIP/AuthKeyHandler.php | 12 +++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/magna.php b/magna.php index f2dcd0da..80eafedb 100755 --- a/magna.php +++ b/magna.php @@ -90,7 +90,6 @@ $calls = []; $updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout foreach ($calls as $key => $call) { if ($call->getOutputState() >= \danog\MadelineProto\VoIP::AUDIO_STATE_CREATED) { - $call->setBitrate(100 * 1000); try { $MadelineProto->messages->sendMessage(['peer' => $call->getOtherID(), 'message' => 'Emojis: '.implode('', $call->getVisualization())]); } catch (\danog\MadelineProto\RPCErrorException $e) { @@ -108,6 +107,13 @@ $calls = []; $update['update']['phone_call']->configuration['enable_NS'] = false; $update['update']['phone_call']->configuration['enable_AGC'] = false; $update['update']['phone_call']->configuration['enable_AEC'] = false; + $update['update']['phone_call']->configuration['shared_config'] = [ + 'audio_init_bitrate' => 40*1000, + 'audio_max_bitrate' => 50*1000, + 'audio_min_bitrate' => 15*1000, + //'audio_bitrate_step_decr' => 0, + //'audio_bitrate_step_incr' => 2000, + ]; $update['update']['phone_call']->parseConfig(); if ($update['update']['phone_call']->accept() === false) { echo 'DID NOT ACCEPT A CALL'; diff --git a/songs.php b/songs.php index 19b5068b..b7033f76 100644 --- a/songs.php +++ b/songs.php @@ -2,10 +2,10 @@ $songs = [ 'Aronchupa - Little Swing' => 'input.raw', - 'Parov Stelar - Booty Swing' => 'inputa.raw', - 'Parov Stelar - All night' => 'inpute.raw', - 'Caravan Palace - Lone Digger' => 'inputb.raw', +// 'Parov Stelar - Booty Swing' => 'inputa.raw', +// 'Parov Stelar - All night' => 'inpute.raw', +// 'Caravan Palace - Lone Digger' => 'inputb.raw', // 'Swingrowers - Butterfly' => 'inputc.raw', - 'Postmodern Jukebox - Thrift Shop' => 'inputd.raw', +// 'Postmodern Jukebox - Thrift Shop' => 'inputd.raw', ]; shuffle($songs); diff --git a/src/danog/MadelineProto/VoIP/AuthKeyHandler.php b/src/danog/MadelineProto/VoIP/AuthKeyHandler.php index 5369b03c..a7a5129d 100644 --- a/src/danog/MadelineProto/VoIP/AuthKeyHandler.php +++ b/src/danog/MadelineProto/VoIP/AuthKeyHandler.php @@ -134,6 +134,9 @@ trait AuthKeyHandler } $this->calls[$params['id']]->setVisualization($visualization); + $this->calls[$params['id']]->configuration['shared_config'] = array_merge($this->method_call('phone.getCallConfig', [], ['datacenter' => $this->datacenter->curdc]), $this->calls[$params['id']]->configuration['shared_config']); + $this->calls[$params['id']]->configuration['endpoints'] = array_merge([$params['connection']], $params['alternative_connections'], $this->calls[$params['id']]->configuration['endpoints']); + $this->calls[$params['id']]->configuration = array_merge([ 'recv_timeout' => $this->config['call_receive_timeout_ms'] / 1000, 'init_timeout' => $this->config['call_connect_timeout_ms'] / 1000, @@ -146,8 +149,6 @@ trait AuthKeyHandler 'auth_key' => $key, 'network_type' => \danog\MadelineProto\VoIP::NET_TYPE_ETHERNET, - 'shared_config' => $this->method_call('phone.getCallConfig', [], ['datacenter' => $this->datacenter->curdc]), - 'endpoints' => array_merge([$res['connection']], $res['alternative_connections']), ], $this->calls[$params['id']]->configuration); $this->calls[$params['id']]->parseConfig(); $res = $this->calls[$params['id']]->startTheMagic(); @@ -195,6 +196,8 @@ trait AuthKeyHandler } $this->calls[$params['id']]->setVisualization($visualization); + $this->calls[$params['id']]->configuration['shared_config'] = array_merge($this->method_call('phone.getCallConfig', [], ['datacenter' => $this->datacenter->curdc]), $this->calls[$params['id']]->configuration['shared_config']); + $this->calls[$params['id']]->configuration['endpoints'] = array_merge([$params['connection']], $params['alternative_connections'], $this->calls[$params['id']]->configuration['endpoints']); $this->calls[$params['id']]->configuration = array_merge([ 'recv_timeout' => $this->config['call_receive_timeout_ms'] / 1000, @@ -208,9 +211,8 @@ trait AuthKeyHandler 'auth_key' => $key, 'network_type' => \danog\MadelineProto\VoIP::NET_TYPE_ETHERNET, - 'shared_config' => $this->method_call('phone.getCallConfig', [], ['datacenter' => $this->datacenter->curdc]), - 'endpoints' => array_merge([$params['connection']], $params['alternative_connections']), ], $this->calls[$params['id']]->configuration); + var_dump($this->calls[$params['id']]->configuration); $this->calls[$params['id']]->parseConfig(); return $this->calls[$params['id']]->startTheMagic(); @@ -270,7 +272,7 @@ trait AuthKeyHandler \danog\MadelineProto\Logger::log(['Setting rating for call '.$call['id'].'...'], \danog\MadelineProto\Logger::VERBOSE); $this->method_call('phone.setCallRating', ['peer' => $call, 'rating' => $rating['rating'], 'comment' => $rating['comment']], ['datacenter' => $this->datacenter->curdc]); } - if ($need_debug) { + if ($need_debug) {//} && isset($this->calls[$call['id']]->storage['not_modified'])) { \danog\MadelineProto\Logger::log(['Saving debug data for call '.$call['id'].'...'], \danog\MadelineProto\Logger::VERBOSE); $this->method_call('phone.saveCallDebug', ['peer' => $call, 'debug' => $this->calls[$call['id']]->getDebugLog()], ['datacenter' => $this->datacenter->curdc]); } From 6f4c25d47f2a99518e6e35c798635078cfdf8f95 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 5 Aug 2017 15:41:58 +0000 Subject: [PATCH 3/3] Apply fixes from StyleCI --- magna.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/magna.php b/magna.php index 80eafedb..df26c046 100755 --- a/magna.php +++ b/magna.php @@ -108,9 +108,9 @@ $calls = []; $update['update']['phone_call']->configuration['enable_AGC'] = false; $update['update']['phone_call']->configuration['enable_AEC'] = false; $update['update']['phone_call']->configuration['shared_config'] = [ - 'audio_init_bitrate' => 40*1000, - 'audio_max_bitrate' => 50*1000, - 'audio_min_bitrate' => 15*1000, + 'audio_init_bitrate' => 40 * 1000, + 'audio_max_bitrate' => 50 * 1000, + 'audio_min_bitrate' => 15 * 1000, //'audio_bitrate_step_decr' => 0, //'audio_bitrate_step_incr' => 2000, ];