castv2

package
v0.0.0-...-a1b9eeb Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package castv2 provides a low-level implementation of Google Cast V2 protocol.

Index

Constants

View Source
const (
	PlatformSenderID   = "sender-0"
	PlatformReceiverID = "receiver-0"
)

Sender and receiver IDs to use for platform messages.

View Source
const (
	NamespaceConnection = "urn:x-cast:com.google.cast.tp.connection"
	NamespaceHeartbeat  = "urn:x-cast:com.google.cast.tp.heartbeat"
	NamespaceReceiver   = "urn:x-cast:com.google.cast.receiver"
	NamespaceMedia      = "urn:x-cast:com.google.cast.media"
)

Reserved message namespaces for internal messages.

View Source
const (
	TypeConnect        = "CONNECT"
	TypeClose          = "CLOSE"
	TypePing           = "PING"
	TypePong           = "PONG"
	TypeGetStatus      = "GET_STATUS"
	TypeReceiverStatus = "RECEIVER_STATUS"
	TypeMediaStatus    = "MEDIA_STATUS"
	TypeLaunch         = "LAUNCH"
	TypeLoad           = "LOAD"
	TypePlay           = "PLAY"
	TypePause          = "PAUSE"
	TypeStop           = "STOP"
	TypeSeek           = "SEEK"
	TypeSetVolume      = "SET_VOLUME"
)

Cast application protocol message types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	// contains filtered or unexported fields
}

Channel represents a cast channel to the receiver device.

It also manages the virtual connections. If a messages will be sent to a new source and destination ID pair, a virtual connection will be automatically established and keeped alive.

func Dial

func Dial(addr *net.TCPAddr) (*Channel, error)

Dial connects to the remote receiver and returns a new Channel.

func (*Channel) Close

func (c *Channel) Close() error

Close terminates all established virtual connections and then closes the underying TLS connection.

func (*Channel) IsClosed

func (c *Channel) IsClosed() bool

IsClosed returns true if the underlying connection has been closed.

func (*Channel) Request

func (c *Channel) Request(srcID, descID, namespace string, req Request, respCh chan *Msg) error

Request sends a request

func (*Channel) Subscribe

func (c *Channel) Subscribe(ch chan *Msg) (uint64, error)

Subscribe registers a subscription to broadcast messages. It returns an identifier for identifying the subscription when unsubscribing.

func (*Channel) Unsubscribe

func (c *Channel) Unsubscribe(subID uint64) error

Unsubscribe unregisters the subscription and closes the subscription channel.

type Header struct {
	RequestID uint64 `json:"requestId,omitempty"`
	Type      string `json:"type"`
}

Header contains the required fields in most payload types.

func (*Header) SetRequestID

func (h *Header) SetRequestID(id uint64)

SetRequestID sets the requestId header.

type Msg

type Msg struct {
	SourceID      string
	DestinationID string
	Namespace     string
	Payload       string
}

Msg is a Cast V2 protocol data unit with textual payload.

func (*Msg) MarshalBinary

func (m *Msg) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*Msg) String

func (m *Msg) String() string

String implements the fmt.Stringer interface.

func (*Msg) UnmarshalBinary

func (m *Msg) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

type Request

type Request interface {
	SetRequestID(id uint64)
}

Request represents a request payload.

func NewRequest

func NewRequest(reqType string) Request

NewRequest returns a new request of given type.

Jump to

Keyboard shortcuts

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