soapcalls

package
v2.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMatchingFileType = errors.New("no matching file type")
	ErrZombieCallbacks    = errors.New("zombie callbacks, we should ignore those")
)
View Source
var (
	ErrSetMuteInput = errors.New("setMuteSoapBuild input error. Was expecting 0 or 1.")
)
View Source
var (
	ErrWrongDMR = errors.New("something broke somewhere - wrong DMR URL?")
)

Functions

func EventNotifyParser

func EventNotifyParser(xmlbody string) (string, string, error)

EventNotifyParser parses the Notify messages from the DMR device.

func GetFriendlyName

func GetFriendlyName(ctx context.Context, dmr string) (string, error)

GetFriendlyName returns the friendly name value for a the specific DMR url.

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 Options

type Options struct {
	LogOutput      io.Writer
	Ctx            context.Context
	DMR            string
	Media          string
	Subs           string
	Mtype          string
	ListenAddr     string
	FFmpegPath     string
	FFmpegSubsPath string
	Transcode      bool
	Seek           bool
	FFmpegSeek     int
}

type States

type States struct {
	PreviousState string
	NewState      string
	ProcessStop   bool
}

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

func NewTVPayload(o *Options) (*TVPayload, error)

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

func (p *TVPayload) CreateMRstate(uuid string)

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

func (p *TVPayload) DeleteMRstate(uuid string)

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) Gapless

func (p *TVPayload) Gapless() (string, error)

Gapless requests our device's media info and returns the Next URI.

func (*TVPayload) GetMuteSoapCall

func (p *TVPayload) GetMuteSoapCall() (string, error)

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

func (p *TVPayload) GetPositionInfo() ([]string, error)

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

func (p *TVPayload) GetProcessStop(uuid string) (bool, error)

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

func (p *TVPayload) GetProtocolInfo() error

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

func (p *TVPayload) GetTransportInfo() ([]string, error)

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

func (p *TVPayload) GetVolumeSoapCall() (int, error)

GetVolumeSoapCall returns tue volume level for our device.

func (*TVPayload) ListenAddress

func (p *TVPayload) ListenAddress() string

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) Log

func (p *TVPayload) Log() *zerolog.Logger

func (*TVPayload) PlayPauseStopSoapCall

func (p *TVPayload) PlayPauseStopSoapCall(action string) error

PlayPauseStopSoapCall builds and sends the AVTransport actions for Play Pause and Stop.

func (*TVPayload) RefreshLoopUUIDSoapCall

func (p *TVPayload) RefreshLoopUUIDSoapCall(uuid, timeout string)

RefreshLoopUUIDSoapCall refreshes the UUID.

func (*TVPayload) SeekSoapCall

func (p *TVPayload) SeekSoapCall(reltime string) error

SeekSoapCall builds and sends the AVTransport actions for Seek.

func (*TVPayload) SendtoTV

func (p *TVPayload) SendtoTV(action string) error

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 (p *TVPayload) SetContext(ctx context.Context)

func (*TVPayload) SetMuteSoapCall

func (p *TVPayload) SetMuteSoapCall(number string) error

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

func (p *TVPayload) SetProcessStopTrue(uuid string)

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

func (p *TVPayload) SetVolumeSoapCall(v string) error

SetVolumeSoapCall sets the desired volume level.

func (*TVPayload) SubscribeSoapCall

func (p *TVPayload) SubscribeSoapCall(uuidInput string) error

SubscribeSoapCall send a SUBSCRIBE request to the DMR device. If we explicitly pass the UUID, then we refresh it instead.

func (*TVPayload) UnsubscribeSoapCall

func (p *TVPayload) UnsubscribeSoapCall(uuid string) error

UnsubscribeSoapCall sends an UNSUBSCRIBE request to the DMR device and cleans up any stored states for the provided UUID.

func (*TVPayload) UpdateMRstate

func (p *TVPayload) UpdateMRstate(previous, new, uuid string) bool

UpdateMRstate updates the mediaRenderersStates map with the state. Returns true or false to verify that the actual update took place.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL