Documentation
¶
Overview ¶
Package proxy provides a reverse proxy for Enigma2 streams with HEAD request support.
Index ¶
- func GetListenAddr() string
- func GetReceiverHost() string
- func GetTargetURL() string
- func IsEnabled() bool
- func IsTranscodingEnabled() bool
- type Config
- type Server
- type Transcoder
- func (t *Transcoder) IsGPUEnabled() bool
- func (t *Transcoder) ProxyToGPUTranscoder(ctx context.Context, w http.ResponseWriter, r *http.Request, sourceURL string) error
- func (t *Transcoder) TranscodeStream(ctx context.Context, w http.ResponseWriter, r *http.Request, targetURL string) error
- func (t *Transcoder) TranscodeStreamRust(ctx context.Context, w http.ResponseWriter, r *http.Request, targetURL string) error
- type TranscoderConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetListenAddr ¶
func GetListenAddr() string
GetListenAddr returns the listen address from environment or default.
func GetReceiverHost ¶ added in v1.6.0
func GetReceiverHost() string
GetReceiverHost returns the receiver host from XG2G_OWI_BASE. Extracts hostname/IP from base URL (e.g., "http://10.10.55.64" -> "10.10.55.64")
func GetTargetURL ¶
func GetTargetURL() string
GetTargetURL returns the target URL from environment (optional). If not provided, proxy will use Smart Detection with receiver host.
func IsEnabled ¶
func IsEnabled() bool
IsEnabled checks if the proxy is enabled via environment variable.
func IsTranscodingEnabled ¶ added in v1.3.0
func IsTranscodingEnabled() bool
IsTranscodingEnabled checks if audio transcoding is enabled via environment variable. Default: true (enabled by default for iOS Safari compatibility) Set XG2G_ENABLE_AUDIO_TRANSCODING=false to disable
Types ¶
type Config ¶
type Config struct {
// ListenAddr is the address to listen on (e.g., ":18000")
ListenAddr string
// TargetURL is the URL to proxy requests to (e.g., "http://10.10.55.57:17999")
// Optional: If not provided, uses StreamDetector with ReceiverHost
TargetURL string
// ReceiverHost is the receiver hostname/IP for Smart Detection fallback
// Required if TargetURL is not provided
ReceiverHost string
// StreamDetector enables smart port detection (8001 vs 17999)
// Optional: If provided, overrides TargetURL for optimal routing
StreamDetector *openwebif.StreamDetector
// Logger is the logger instance to use
Logger zerolog.Logger
}
Config holds the configuration for the proxy server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a reverse proxy server for Enigma2 streams.
type Transcoder ¶ added in v1.3.0
type Transcoder struct {
Config TranscoderConfig // Public for access from proxy handler
// contains filtered or unexported fields
}
Transcoder handles audio transcoding for streams.
func NewTranscoder ¶ added in v1.3.0
func NewTranscoder(config TranscoderConfig, logger zerolog.Logger) *Transcoder
NewTranscoder creates a new audio transcoder.
func (*Transcoder) IsGPUEnabled ¶ added in v1.5.0
func (t *Transcoder) IsGPUEnabled() bool
IsGPUEnabled returns whether GPU transcoding is enabled.
func (*Transcoder) ProxyToGPUTranscoder ¶ added in v1.5.0
func (t *Transcoder) ProxyToGPUTranscoder(ctx context.Context, w http.ResponseWriter, r *http.Request, sourceURL string) error
ProxyToGPUTranscoder forwards the stream request to the GPU transcoder service. The GPU transcoder handles full video+audio transcoding with VAAPI hardware acceleration.
func (*Transcoder) TranscodeStream ¶ added in v1.3.0
func (t *Transcoder) TranscodeStream(ctx context.Context, w http.ResponseWriter, r *http.Request, targetURL string) error
TranscodeStream transcodes the audio of a stream from the target URL. It proxies the request to the target, pipes it through ffmpeg for audio transcoding, and streams the result back to the client.
func (*Transcoder) TranscodeStreamRust ¶ added in v1.6.0
func (t *Transcoder) TranscodeStreamRust(ctx context.Context, w http.ResponseWriter, r *http.Request, targetURL string) error
TranscodeStreamRust transcodes audio using the native Rust remuxer. This provides zero-latency audio remuxing without spawning external processes.
Architecture:
Input: MPEG-TS with MP2/AC3 audio from Enigma2 Pipeline: Demux → Decode → Encode (AAC-LC) → Mux Output: MPEG-TS with AAC audio for iOS Safari
Performance:
- Latency: ~39µs per 192KB chunk (vs 200-500ms with FFmpeg)
- Throughput: 4.94 GB/s
- CPU: <0.1%
- Memory: <1MB per stream
type TranscoderConfig ¶ added in v1.3.0
type TranscoderConfig struct {
Enabled bool // Whether transcoding is enabled
Codec string // Target audio codec (aac, mp3)
Bitrate string // Audio bitrate (e.g., "192k")
Channels int // Number of audio channels (2 for stereo)
FFmpegPath string // Path to ffmpeg binary
GPUEnabled bool // Whether GPU transcoding is enabled
TranscoderURL string // URL of the GPU transcoder service
UseRustRemuxer bool // Whether to use native Rust remuxer instead of FFmpeg
}
TranscoderConfig holds configuration for audio transcoding.
func GetTranscoderConfig ¶ added in v1.3.0
func GetTranscoderConfig() TranscoderConfig
GetTranscoderConfig builds transcoder configuration from environment variables.