No description
Find a file
2026-01-03 19:02:55 +08:00
.forgejo/workflows refactor: update Go to 1.25, adopt any type for improved type safety, and add comprehensive logger tests. 2026-01-03 19:02:55 +08:00
assets refactor: embed static XML assets into the binary and update PKGBUILD to remove external asset installation. 2025-12-28 18:07:33 +08:00
cmd/gocast feat: implement cross-platform autostart functionality and update Gitea build workflow. 2025-12-28 18:40:14 +08:00
docs docs: add project guide documentation 2025-12-24 15:32:35 +08:00
internal refactor: update Go to 1.25, adopt any type for improved type safety, and add comprehensive logger tests. 2026-01-03 19:02:55 +08:00
packaging refactor: update Go to 1.25, adopt any type for improved type safety, and add comprehensive logger tests. 2026-01-03 19:02:55 +08:00
plugins refactor: embed static XML assets into the binary and update PKGBUILD to remove external asset installation. 2025-12-28 18:07:33 +08:00
tests refactor: update Go to 1.25, adopt any type for improved type safety, and add comprehensive logger tests. 2026-01-03 19:02:55 +08:00
.gitignore refactor: embed static XML assets into the binary and update PKGBUILD to remove external asset installation. 2025-12-28 18:07:33 +08:00
go.mod feat: implement cross-platform autostart functionality and update Gitea build workflow. 2025-12-28 18:40:14 +08:00
go.sum feat: implement cross-platform autostart functionality and update Gitea build workflow. 2025-12-28 18:40:14 +08:00
LICENSE feat: add initial CI/CD workflow, Arch Linux packaging, license, and assets 2025-12-24 20:09:25 +08:00
project_status.md docs: Add initial plugin documentation and update project status. 2025-12-24 15:05:18 +08:00
README.md refactor: update Go to 1.25, adopt any type for improved type safety, and add comprehensive logger tests. 2026-01-03 19:02:55 +08:00
RELEASE_CHECKLIST.md feat: add initial CI/CD workflow, Arch Linux packaging, license, and assets 2025-12-24 20:09:25 +08:00

GoCast

English | 简体中文

GoCast 是一个基于 Go 语言的轻量级 DLNA 媒体接收器,可以让你的电脑接收来自手机、平板等设备的投屏内容。

这是 Macast 项目的 Go 语言重新实现版本。

特性

  • 📱 DLNA协议支持 - 完整实现 UPnP AV 1.0 标准
  • 🎬 MPV播放器集成 - 使用强大的 MPV 播放器播放媒体
  • 🖥️ 系统托盘界面 - 简洁的托盘图标,一键启停服务
  • 🔄 双向状态同步 - DLNA 协议与播放器实时同步
  • 🌐 跨平台支持 - Windows、macOS、Linux
  • 轻量高效 - 纯 Go 实现,资源占用低

📦 安装

前置要求

  • Go 1.19+ (编译需要)
  • MPV 播放器 (运行时需要)
# Ubuntu/Debian
sudo apt install mpv

# macOS
brew install mpv

# Arch Linux
sudo pacman -S mpv

# Windows
# 从 https://mpv.io 下载安装

从源码编译

git clone https://github.com/你的用户名/GoCast.git
cd GoCast
go build -o bin/gocast ./cmd/gocast

🚀 使用方法

1. 启动 GoCast

./bin/gocast

程序将在系统托盘显示图标。

2. 启动服务

右键点击托盘图标,选择"启动服务"。

3. 投屏

在手机或平板上:

  • 打开支持 DLNA/UPnP 的应用
  • 选择投屏/播放到设备
  • 找到 "GoCast" 设备
  • 开始投屏!

支持的应用

  • Android: 图库、视频播放器、BiliBili、爱奇艺等
  • iOS: 照片、Safari需第三方 DLNA 应用)
  • 桌面浏览器: 通过 DLNA 扩展

📋 功能列表

  • SSDP 设备发现
  • DLNA 描述文件服务
  • SOAP 请求处理
  • AVTransport 服务(播放控制)
  • RenderingControl 服务(音量控制)
  • ConnectionManager 服务
  • MPV 播放器集成
  • 系统托盘 GUI
  • GENA 事件订阅(可选)
  • 多语言支持

🏗️ 项目结构

GoCast/
├── cmd/gocast/          # 主程序入口
├── internal/
│   ├── config/          # 配置管理
│   ├── dlna/            # DLNA 协议实现
│   ├── gui/             # 系统托盘 GUI
│   ├── renderer/        # 媒体渲染器MPV
│   ├── server/          # HTTP 服务器
│   ├── ssdp/            # SSDP 服务发现
│   └── utils/           # 工具函数
├── tests/               # 测试文件
├── assets/
│   ├── xml/             # DLNA XML 描述文件
│   └── icons/           # 图标资源
└── README.md

🧪 开发和测试

运行测试

# 运行所有测试
go test ./tests/... -v

# 运行特定测试
go test ./tests -run TestLoggerBasic

# 查看测试覆盖率
go test ./tests/... -cover

详细的测试说明请查看 tests/README.md

代码规范

项目遵循标准 Go 代码规范:

# 格式化代码
go fmt ./...

# 代码检查
go vet ./...

🛠️ 技术栈

  • 核心语言: Go 1.19+
  • 网络: 标准库 net/http
  • XML处理: encoding/xml
  • 托盘界面: github.com/getlantern/systray
  • 播放器: MPV (通过 IPC)

📝 配置

配置文件位置:

  • Linux: ~/.config/GoCast/config.json
  • macOS: ~/Library/Application Support/GoCast/config.json
  • Windows: %APPDATA%\GoCast\config.json

默认配置会自动生成,包括:

  • 设备名称
  • 端口设置
  • USN唯一标识符

🐛 常见问题

手机找不到设备?

  1. 确保手机和电脑在同一局域网
  2. 检查防火墙是否允许 UDP 1900 端口
  3. 重启服务(托盘菜单 → 停止服务 → 启动服务)

MPV 无法启动?

  1. 确认已安装 MPVmpv --version
  2. 检查 MPV 是否在 PATH 中
  3. 查看日志输出排查问题

播放卡顿?

  1. 尝试启用硬件解码
  2. 检查网络连接质量
  3. 降低播放质量

🤝 贡献

欢迎提交 Issue 和 Pull Request

📄 许可证

MIT License

🙏 致谢

  • Macast - 原始 Python 实现
  • MPV - 强大的媒体播放器
  • systray - 跨平台托盘库

📊 项目状态

当前版本v1.0.0

完成度: ~95%

已实现:

  • 完整的 DLNA 协议支持
  • MPV 播放器集成
  • 系统托盘 GUI
  • 跨平台支持

计划中:

  • 🔄 事件订阅优化
  • 🔄 多语言界面
  • 🔄 配置界面

Made with ❤️ using Go