Example:
<?php
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';
$MadelineProto = new \danog\MadelineProto\API('session.madeline');
$MadelineProto->start();
$MadelineProto->requestCall('@username', video: true)->play(new RemoteUrl('https://paste.daniil.it/oncall.webm'));
$MadelineProto->joinGroupCall('@mygroup')->play(new RemoteUrl('https://paste.daniil.it/oncall.webm'));
See examples/bot.php for a full example!
See the call documentation » for more info, and try the open-source magnaluna video webradio », which plays a video (including youtube videos WITHOUT ffmpeg/yt-dlp, 100% webhost support) in one-to-one calls, in the video chats and conference calls whose links you send it, and in the video chats of all its groups!
Test the new features live with magnaluna on Telegram: @magicalcrazypony! Call it, send it /call, or send it the link of a group call or conference call to join, or use the /join command in a group to create or join a group call.
Features:
- Video calls: play WebM/MKV files with VP8, VP9, H.264, H.265 (or AV1, in one-to-one calls) video and OPUS audio into any call: frames are demuxed in pure PHP and sent as-is, with no transcoding. Start a video call with
requestCall($user, video: true).- Screen sharing: play a video as a screen share alongside the camera stream with
MediaDestination::Presentation.- Group calls (video chats and livestreams): create (also scheduled and RTMP livestreams), join (also as a channel or via an invite link), stream audio and video, share the screen, record, and manage them: title, invites and invite links, muting, volume, raised hands, server-side recording, kicking participants, in-call messages and reactions.
- Livestreams: record stream mode livestreams (including RTMP ones), using the new pure PHP
Mp4 demuxer, and publish RTMP livestreams with getGroupCallStreamRtmpUrl.- Live stories: start a live story with
startLive, stream into it, comment, and handle Telegram Stars donations.- End-to-end encrypted conference calls: create them, join them via link or invitation, invite users, verify the key emojis, send end-to-end encrypted in-call messages and remove participants (rekeying the call), or upgrade a one-to-one call with
migrateCallToConference.- Call recording:
setOutput records a participant's microphone, camera and screen share into a Matroska (or OGG OPUS) file with a fixed set of tracks, and setOutputFolder records every participant into a directory, starting a new file whenever their streams change. Recordings are written in pure PHP, without decoding anything.- New
CallStreams update, emitted whenever the streams a participant sends (or their codecs) change, and whenever a recording ends.- All call types now implement the common
Call interface (and the multi-party ones MultiCall), with the same playlist, mute, screen sharing and recording controls: PrivateCall (with VoIP kept as an alias), GroupCall, LiveStory and ConferenceCall.- New
GroupCall, GroupCallParticipants, GroupCallMessage, GroupCallMessagesDeleted, LiveStory, LiveStoryMessage and ConferenceCallMessage updates.- Messages have new
getCall, canRequestCall, requestCall and getCallDenialReason methods, to start (or get) the call of a private chat, or the video chat of a group or channel; CallNotAllowedException explains why a call can't be started. $message->requestCall()->join() works in every chat, since joining an outgoing one-to-one call does nothing.- Calls survive restarts: playlists (continuing the current WebM/OGG file where it left off), hold files (which now loop) and recordings are saved in the session.
- Resumable uploads: interrupted uploads of files, URLs, Telegram files and resumable streams (encrypted ones included) are resumed after a restart, without uploading the already uploaded parts again.
- Resumable method calls: interrupted method calls and
send* calls uploading such files are resumed after a restart, until their upload completes (can be disabled with the new resumeInterruptedCalls file setting).- Resumable download streams:
downloadToReturnedStream and Media::getStream now return a ResumableDownloadStream, which can be serialized, and resumes downloading from where it left off.- Through IPC, calls without callbacks are sent again when the IPC server restarts.
- Added support for communities.
- Any OGG OPUS file (mono or stereo, with any frame size) can now be played into calls as-is, not only the ones created by MadelineProto: no more need to pre-convert them with
@libtgvoip_bot or Ogg::convert.- Update to layer 231.
Fixes:
- Fix downloads without a size not closing the connection
- Fix
getInputClientProxy on null- Fix inline query button conversion in keyboard buttons
- Fix sending media with a TTL
- Upgrade to phpseclib 4, keeping sessions created with phpseclib 3 loadable
- File reference improvements
- Fix updates received while the event handler is starting being handled again in an endless loop, using all the memory, if the event handler failed to start
- Fix uploads with a cancellation through IPC, and IPC cancellations no longer block the event loop
- Fix encrypted downloads starting from a non-zero offset
- Cancelled uploads no longer throw errors into the event loop
The latest official MadelineProto phars are now downloadable through @madelineprotophar as well.
Full TL changelog: https://github.com/danog/MadelineProto/releases/tag/8.8.8