Documentation
¶
Index ¶
- Variables
- func EventNotifyParser(xmlbody string) (string, string, error)
- func GetFriendlyName(ctx context.Context, dmr string) (string, error)
- type DMRextracted
- func DMRextractor(ctx context.Context, dmrurl string) (*DMRextracted, error)
- func LoadDevicesFromLocation(ctx context.Context, dmrurl string) ([]*DMRextracted, error)
- func ParseAllDMRFromXML(xmlbody []byte, baseURL *url.URL) ([]*DMRextracted, error)
- func ParseDMRFromXML(xmlbody []byte, baseURL *url.URL) (*DMRextracted, error)
- type Options
- type States
- type TVPayload
- func (p *TVPayload) CreateMRstate(uuid string)
- func (p *TVPayload) DeleteMRstate(uuid string)
- func (p *TVPayload) Gapless() (string, error)
- func (p *TVPayload) GetMuteSoapCall() (string, error)
- func (p *TVPayload) GetPositionInfo() ([]string, error)
- func (p *TVPayload) GetProcessStop(uuid string) (bool, error)
- func (p *TVPayload) GetProtocolInfo() error
- func (p *TVPayload) GetTransportInfo() ([]string, error)
- func (p *TVPayload) GetVolumeSoapCall() (int, error)
- func (p *TVPayload) ListenAddress() string
- func (p *TVPayload) Log() *zerolog.Logger
- func (p *TVPayload) PlayPauseStopSoapCall(action string) error
- func (p *TVPayload) RefreshLoopUUIDSoapCall(uuid, timeout string)
- func (p *TVPayload) SeekSoapCall(reltime string) error
- func (p *TVPayload) SendtoTV(action string) error
- func (p *TVPayload) SetContext(ctx context.Context)
- func (p *TVPayload) SetMuteSoapCall(number string) error
- func (p *TVPayload) SetProcessStopTrue(uuid string)
- func (p *TVPayload) SetVolumeSoapCall(v string) error
- func (p *TVPayload) SubscribeSoapCall(uuidInput string) error
- func (p *TVPayload) UnsubscribeSoapCall(uuid string) error
- func (p *TVPayload) UpdateMRstate(previous, new, uuid string) bool
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoMatchingFileType = errors.New("no matching file type") ErrZombieCallbacks = errors.New("zombie callbacks, we should ignore those") )
var (
ErrSetMuteInput = errors.New("setMuteSoapBuild input error. Was expecting 0 or 1.")
)
var (
ErrWrongDMR = errors.New("something broke somewhere - wrong DMR URL?")
)
Functions ¶
func EventNotifyParser ¶
EventNotifyParser parses the Notify messages from the DMR device.
Types ¶
type DMRextracted ¶
type DMRextracted struct {
AvtransportControlURL string
AvtransportEventSubURL string
RenderingControlURL string
ConnectionManagerURL string
FriendlyName string
UDN string
}
DMRextracted stores the services urls and device identification
func DMRextractor ¶
func DMRextractor(ctx context.Context, dmrurl string) (*DMRextracted, error)
DMRextractor extracts the services URLs from the main DMR xml.
func LoadDevicesFromLocation ¶ added in v2.1.0
func LoadDevicesFromLocation(ctx context.Context, dmrurl string) ([]*DMRextracted, error)
LoadDevicesFromLocation fetches XML from a UPnP location URL and returns all devices that have AVTransport service (for multi-device setups).
func ParseAllDMRFromXML ¶ added in v2.1.0
func ParseAllDMRFromXML(xmlbody []byte, baseURL *url.URL) ([]*DMRextracted, error)
ParseAllDMRFromXML parses DMR XML data and extracts service URLs from ALL devices that have AVTransport service. This handles multi-device setups where a single UPnP root may expose multiple MediaRenderers.
func ParseDMRFromXML ¶ added in v2.1.0
func ParseDMRFromXML(xmlbody []byte, baseURL *url.URL) (*DMRextracted, error)
ParseDMRFromXML parses DMR XML data and extracts service URLs. It searches the root device and all embedded devices recursively to find the device with AVTransport service.
type TVPayload ¶
type TVPayload struct {
Logger zerolog.Logger
LogOutput io.Writer
CurrentTimers map[string]*time.Timer
InitialMediaRenderersStates map[string]bool
MediaRenderersStates map[string]*States
FFmpegSeek int
FFmpegPath string
FFmpegSubsPath string
EventURL string
ControlURL string
MediaURL string
MediaType string
MediaPath string
SubtitlesURL string
CallbackURL string
ConnectionManagerURL string
RenderingControlURL string
Transcode bool
Seekable bool
// contains filtered or unexported fields
}
TVPayload is the heart of Go2TV. We pass that type to the webserver. We need to explicitly initialize it.
func NewTVPayload ¶
NewTVPayload creates a new TVPayload based on the provided options. It initializes the context if not already set, extracts UPnP service URLs, generates a random callback path, and determines the listen address. It returns a pointer to the created TVPayload or an error if any step fails.
func (*TVPayload) CreateMRstate ¶
CreateMRstate initializes the media renderer state for a given UUID. It locks the TVPayload to ensure thread safety, sets the initial state to true, and creates a new States instance for the media renderer.
func (*TVPayload) DeleteMRstate ¶
DeleteMRstate removes the media renderer state associated with the given UUID from both InitialMediaRenderersStates and MediaRenderersStates maps. It ensures that the operation is thread-safe by acquiring a lock on the TVPayload's mutex.
func (*TVPayload) GetMuteSoapCall ¶
GetMuteSoapCall sends a SOAP request to the TV to get the current mute status. It constructs the SOAP request, sends it to the TV, and parses the response.
func (*TVPayload) GetPositionInfo ¶
GetPositionInfo retrieves the position information of the TV. It returns a slice of strings containing the track duration and relative time, or an error if the operation fails.
func (*TVPayload) GetProcessStop ¶
GetProcessStop checks if the process stop flag is set for a given media renderer identified by the UUID. It returns true if the process stop flag is set, or an error if the media renderer is not in the initial state.
func (*TVPayload) GetProtocolInfo ¶
GetProtocolInfo retrieves the protocol information from the device. It constructs a SOAP request, sends it to the device, and processes the response.
func (*TVPayload) GetTransportInfo ¶
GetTransportInfo retrieves the transport information from the TV device. It returns a slice of strings containing the current transport state, status, and speed, or an error if the operation fails.
func (*TVPayload) GetVolumeSoapCall ¶
GetVolumeSoapCall returns tue volume level for our device.
func (*TVPayload) ListenAddress ¶
ListenAddress extracts and returns the host component from the MediaURL field of the TVPayload struct. It parses the MediaURL as a URL and retrieves the host part of it. If the MediaURL is not a valid URL, it returns an empty string.
func (*TVPayload) PlayPauseStopSoapCall ¶
PlayPauseStopSoapCall builds and sends the AVTransport actions for Play Pause and Stop.
func (*TVPayload) RefreshLoopUUIDSoapCall ¶
RefreshLoopUUIDSoapCall refreshes the UUID.
func (*TVPayload) SeekSoapCall ¶
SeekSoapCall builds and sends the AVTransport actions for Seek.
func (*TVPayload) SendtoTV ¶
SendtoTV is a higher level method that gracefully handles the various states when communicating with the DMR devices.
func (*TVPayload) SetContext ¶ added in v2.1.0
func (*TVPayload) SetMuteSoapCall ¶
SetMuteSoapCall sends a SOAP request to set the mute state of the TV. It constructs the SOAP request, sets the necessary headers, and sends the request to the TV's RenderingControlURL. The function logs the request and response details for debugging purposes.
func (*TVPayload) SetProcessStopTrue ¶
SetProcessStopTrue sets the ProcessStop field to true for the media renderer identified by the given UUID. It locks the TVPayload's mutex to ensure thread-safe access to the MediaRenderersStates map.
func (*TVPayload) SetVolumeSoapCall ¶
SetVolumeSoapCall sets the desired volume level.
func (*TVPayload) SubscribeSoapCall ¶
SubscribeSoapCall send a SUBSCRIBE request to the DMR device. If we explicitly pass the UUID, then we refresh it instead.
func (*TVPayload) UnsubscribeSoapCall ¶
UnsubscribeSoapCall sends an UNSUBSCRIBE request to the DMR device and cleans up any stored states for the provided UUID.
func (*TVPayload) UpdateMRstate ¶
UpdateMRstate updates the mediaRenderersStates map with the state. Returns true or false to verify that the actual update took place.