Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ permissions:
packages: write

env:
# GHCR image, derived from the repo (e.g. ghcr.io/nikicat/tg-echo-service).
# GHCR image, derived from the repo (e.g. ghcr.io/nikicat/tg-echo).
# Assumes the repo owner/name are lowercase, as GHCR requires.
IMAGE: ghcr.io/${{ github.repository }}
# Published tag: the git tag name on a tag push, otherwise "latest" (master).
Expand Down
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
# ASM is needed to assemble openh264's aarch64 NEON .S files on arm64. openh264
# also ships x86 SIMD, but as NASM/YASM .asm (needs a separate assembler) which
# this build doesn't wire up, so x86_64 falls back to the portable C++ paths.
project(call_service LANGUAGES C CXX ASM)
project(tg-echo LANGUAGES C CXX ASM)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -238,17 +238,17 @@ set(TD_INSTALL_DIR "${CMAKE_SOURCE_DIR}/td-install")
list(APPEND CMAKE_PREFIX_PATH "${TD_INSTALL_DIR}")
find_package(Td REQUIRED)

# -- Our call_service binary --
add_executable(call_service main.cpp)
# -- Our tg-echo binary --
add_executable(tg-echo main.cpp)

target_link_libraries(call_service PRIVATE
target_link_libraries(tg-echo PRIVATE
tgcalls
Td::TdStatic
mp3lame
yuv # libyuv: I420 scaling for incoming-video recording (brings its include dir)
)

target_include_directories(call_service PRIVATE
target_include_directories(tg-echo PRIVATE
"${TGCALLS_DIR}"
"${TGCALLS_DIR}/tgcalls"
"${WEBRTC_DIR}"
Expand All @@ -257,7 +257,7 @@ target_include_directories(call_service PRIVATE
"${STUB_DIR}"
)

target_compile_definitions(call_service PRIVATE
target_compile_definitions(tg-echo PRIVATE
WEBRTC_POSIX
WEBRTC_LINUX
NDEBUG
Expand All @@ -267,7 +267,7 @@ target_compile_definitions(call_service PRIVATE
# Arch-specific WebRTC defines, mirroring what BuildWebRTC.cmake sets on the
# webrtc target so inline header code compiles the same way in this TU.
if(ANDROID_ABI STREQUAL "x86_64")
target_compile_definitions(call_service PRIVATE HAVE_SSE2)
target_compile_definitions(tg-echo PRIVATE HAVE_SSE2)
elseif(ANDROID_ABI STREQUAL "arm64-v8a")
target_compile_definitions(call_service PRIVATE WEBRTC_ARCH_ARM64 WEBRTC_HAS_NEON)
target_compile_definitions(tg-echo PRIVATE WEBRTC_ARCH_ARM64 WEBRTC_HAS_NEON)
endif()
10 changes: 5 additions & 5 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ RUN cmake --build build -j$(nproc) --target tgcalls

# App source (only this layer rebuilds on main.cpp changes)
COPY main.cpp .
RUN cmake --build build -j$(nproc) --target call_service
RUN strip -s build/call_service
RUN cmake --build build -j$(nproc) --target tg-echo
RUN strip -s build/tg-echo

# Collect the binary's shared-library closure (minus the glibc core the runtime
# base already ships) into a flat dir. The runtime stage drops these into
Expand All @@ -58,7 +58,7 @@ RUN strip -s build/call_service
# would clobber, breaking the dynamic linker. This keeps the runtime minimal
# without hand-listing version-suffixed Debian packages, identically on amd64/arm64.
RUN mkdir -p /rootfs && \
ldd build/call_service | awk '/=> \//{print $3}' | sort -u | \
ldd build/tg-echo | awk '/=> \//{print $3}' | sort -u | \
grep -vE '/(ld-linux.*|libc|libm|libdl|libpthread|librt|libresolv|libgcc_s)\.so' | \
xargs -I{} cp -L {} /rootfs/

Expand All @@ -76,6 +76,6 @@ WORKDIR /app
# libs (and their soname links) without touching system lib dirs.
COPY --from=builder /rootfs/ /usr/local/lib/
RUN ldconfig
COPY --from=builder /src/build/call_service .
COPY --from=builder /src/build/tg-echo .

ENTRYPOINT ["./call_service"]
ENTRYPOINT ["./tg-echo"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Nikolay Bryskin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ else
endif
export CMAKE_BUILD_PARALLEL_LEVEL

IMAGE ?= docker.io/nikicat/tg-echo-service
IMAGE ?= docker.io/nikicat/tg-echo

# Extra flags for the main image build. CI injects layer-cache flags here
# (e.g. --layers --cache-from/--cache-to <registry>); empty for local builds.
Expand Down Expand Up @@ -45,10 +45,10 @@ configure: build/Makefile
build/Makefile: CMakeLists.txt tdlib
cmake -B build -DCMAKE_BUILD_TYPE=$(BUILD_TYPE)

# Build call_service binary
build: build/call_service
# Build tg-echo binary
build: build/tg-echo

build/call_service: build/Makefile main.cpp
build/tg-echo: build/Makefile main.cpp
cmake --build build -j$(CMAKE_BUILD_PARALLEL_LEVEL)

# Generate a test prompt (440Hz beeps, MP3). Override count: make prompt BEEPS=2
Expand All @@ -73,12 +73,12 @@ glados-prompt:
# Run the service (requires API_ID and API_HASH env vars)
run: build prompt
mkdir -p recordings
./build/call_service
./build/tg-echo

# Run the already-built binary, skipping the build/prompt prerequisites
run-only:
mkdir -p recordings
./build/call_service
./build/tg-echo

image-tools:
podman build --build-arg BASE_IMAGE=$(BASE_IMAGE) -t $(IMAGE)-tools:$(TAG) -f Containerfile.tools .
Expand Down
28 changes: 28 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Third-party licenses

The original source in this repository (`main.cpp`, `video_platform.cpp`, the
`stub/` helpers, and the build glue) is licensed under the MIT License — see
[LICENSE](LICENSE).

It is built against, and statically links, several vendored dependencies
(under `vendor/`) that carry their own licenses. The most important one is
**tgcalls (LGPL v3)**: because the resulting binary links it, any binary you
distribute must remain relinkable against a modified tgcalls, per the LGPL.
If you only run the service yourself, this does not apply.

| Dependency | Upstream | License |
|------------|----------|---------|
| tgcalls | [TGX-Android/tgcalls](https://github.com/TGX-Android/tgcalls) | LGPL v3 |
| WebRTC | [TGX-Android/webrtc](https://github.com/TGX-Android/webrtc) | BSD-3-Clause |
| TDLib | [tdlib/td](https://github.com/tdlib/td) | Boost Software License 1.0 |
| abseil-cpp | [abseil/abseil-cpp](https://github.com/abseil/abseil-cpp) | Apache-2.0 |
| libsrtp | [cisco/libsrtp](https://github.com/cisco/libsrtp) | BSD-3-Clause |
| usrsctp | [sctplab/usrsctp](https://github.com/sctplab/usrsctp) | BSD-3-Clause |
| openh264 | [cisco/openh264](https://github.com/cisco/openh264) | BSD-2-Clause |
| rnnoise | [xiph/rnnoise](https://github.com/xiph/rnnoise) | BSD-3-Clause |
| crc32c | [google/crc32c](https://github.com/google/crc32c) | BSD-3-Clause |
| libevent | [TGX-Android/libevent](https://github.com/TGX-Android/libevent) | BSD-3-Clause |
| libyuv | [chromium/libyuv](https://chromium.googlesource.com/libyuv/libyuv) | BSD-3-Clause |

Each dependency's full license text is available in its respective directory
under `vendor/`.
Loading