File: cast.go

package info (click to toggle)
golang-github-chromedp-cdproto 0.0~git20230109.6b041c6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,584 kB
  • sloc: makefile: 2
file content (169 lines) | stat: -rw-r--r-- 5,183 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// Package cast provides the Chrome DevTools Protocol
// commands, types, and events for the Cast domain.
//
// A domain for interacting with Cast, Presentation API, and Remote Playback
// API functionalities.
//
// Generated by the cdproto-gen command.
package cast

// Code generated by cdproto-gen. DO NOT EDIT.

import (
	"context"

	"github.com/chromedp/cdproto/cdp"
)

// EnableParams starts observing for sinks that can be used for tab
// mirroring, and if set, sinks compatible with |presentationUrl| as well. When
// sinks are found, a |sinksUpdated| event is fired. Also starts observing for
// issue messages. When an issue is added or removed, an |issueUpdated| event is
// fired.
type EnableParams struct {
	PresentationURL string `json:"presentationUrl,omitempty"`
}

// Enable starts observing for sinks that can be used for tab mirroring, and
// if set, sinks compatible with |presentationUrl| as well. When sinks are
// found, a |sinksUpdated| event is fired. Also starts observing for issue
// messages. When an issue is added or removed, an |issueUpdated| event is
// fired.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Cast#method-enable
//
// parameters:
func Enable() *EnableParams {
	return &EnableParams{}
}

// WithPresentationURL [no description].
func (p EnableParams) WithPresentationURL(presentationURL string) *EnableParams {
	p.PresentationURL = presentationURL
	return &p
}

// Do executes Cast.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandEnable, p, nil)
}

// DisableParams stops observing for sinks and issues.
type DisableParams struct{}

// Disable stops observing for sinks and issues.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Cast#method-disable
func Disable() *DisableParams {
	return &DisableParams{}
}

// Do executes Cast.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandDisable, nil, nil)
}

// SetSinkToUseParams sets a sink to be used when the web page requests the
// browser to choose a sink via Presentation API, Remote Playback API, or Cast
// SDK.
type SetSinkToUseParams struct {
	SinkName string `json:"sinkName"`
}

// SetSinkToUse sets a sink to be used when the web page requests the browser
// to choose a sink via Presentation API, Remote Playback API, or Cast SDK.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Cast#method-setSinkToUse
//
// parameters:
//
//	sinkName
func SetSinkToUse(sinkName string) *SetSinkToUseParams {
	return &SetSinkToUseParams{
		SinkName: sinkName,
	}
}

// Do executes Cast.setSinkToUse against the provided context.
func (p *SetSinkToUseParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandSetSinkToUse, p, nil)
}

// StartDesktopMirroringParams starts mirroring the desktop to the sink.
type StartDesktopMirroringParams struct {
	SinkName string `json:"sinkName"`
}

// StartDesktopMirroring starts mirroring the desktop to the sink.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Cast#method-startDesktopMirroring
//
// parameters:
//
//	sinkName
func StartDesktopMirroring(sinkName string) *StartDesktopMirroringParams {
	return &StartDesktopMirroringParams{
		SinkName: sinkName,
	}
}

// Do executes Cast.startDesktopMirroring against the provided context.
func (p *StartDesktopMirroringParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandStartDesktopMirroring, p, nil)
}

// StartTabMirroringParams starts mirroring the tab to the sink.
type StartTabMirroringParams struct {
	SinkName string `json:"sinkName"`
}

// StartTabMirroring starts mirroring the tab to the sink.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Cast#method-startTabMirroring
//
// parameters:
//
//	sinkName
func StartTabMirroring(sinkName string) *StartTabMirroringParams {
	return &StartTabMirroringParams{
		SinkName: sinkName,
	}
}

// Do executes Cast.startTabMirroring against the provided context.
func (p *StartTabMirroringParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandStartTabMirroring, p, nil)
}

// StopCastingParams stops the active Cast session on the sink.
type StopCastingParams struct {
	SinkName string `json:"sinkName"`
}

// StopCasting stops the active Cast session on the sink.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Cast#method-stopCasting
//
// parameters:
//
//	sinkName
func StopCasting(sinkName string) *StopCastingParams {
	return &StopCastingParams{
		SinkName: sinkName,
	}
}

// Do executes Cast.stopCasting against the provided context.
func (p *StopCastingParams) Do(ctx context.Context) (err error) {
	return cdp.Execute(ctx, CommandStopCasting, p, nil)
}

// Command names.
const (
	CommandEnable                = "Cast.enable"
	CommandDisable               = "Cast.disable"
	CommandSetSinkToUse          = "Cast.setSinkToUse"
	CommandStartDesktopMirroring = "Cast.startDesktopMirroring"
	CommandStartTabMirroring     = "Cast.startTabMirroring"
	CommandStopCasting           = "Cast.stopCasting"
)