cast.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // Package cast provides the Chrome DevTools Protocol
  2. // commands, types, and events for the Cast domain.
  3. //
  4. // A domain for interacting with Cast, Presentation API, and Remote Playback
  5. // API functionalities.
  6. //
  7. // Generated by the cdproto-gen command.
  8. package cast
  9. // Code generated by cdproto-gen. DO NOT EDIT.
  10. import (
  11. "context"
  12. "github.com/chromedp/cdproto/cdp"
  13. )
  14. // EnableParams starts observing for sinks that can be used for tab
  15. // mirroring, and if set, sinks compatible with |presentationUrl| as well. When
  16. // sinks are found, a |sinksUpdated| event is fired. Also starts observing for
  17. // issue messages. When an issue is added or removed, an |issueUpdated| event is
  18. // fired.
  19. type EnableParams struct {
  20. PresentationURL string `json:"presentationUrl,omitempty"`
  21. }
  22. // Enable starts observing for sinks that can be used for tab mirroring, and
  23. // if set, sinks compatible with |presentationUrl| as well. When sinks are
  24. // found, a |sinksUpdated| event is fired. Also starts observing for issue
  25. // messages. When an issue is added or removed, an |issueUpdated| event is
  26. // fired.
  27. //
  28. // See: https://chromedevtools.github.io/devtools-protocol/tot/Cast#method-enable
  29. //
  30. // parameters:
  31. func Enable() *EnableParams {
  32. return &EnableParams{}
  33. }
  34. // WithPresentationURL [no description].
  35. func (p EnableParams) WithPresentationURL(presentationURL string) *EnableParams {
  36. p.PresentationURL = presentationURL
  37. return &p
  38. }
  39. // Do executes Cast.enable against the provided context.
  40. func (p *EnableParams) Do(ctx context.Context) (err error) {
  41. return cdp.Execute(ctx, CommandEnable, p, nil)
  42. }
  43. // DisableParams stops observing for sinks and issues.
  44. type DisableParams struct{}
  45. // Disable stops observing for sinks and issues.
  46. //
  47. // See: https://chromedevtools.github.io/devtools-protocol/tot/Cast#method-disable
  48. func Disable() *DisableParams {
  49. return &DisableParams{}
  50. }
  51. // Do executes Cast.disable against the provided context.
  52. func (p *DisableParams) Do(ctx context.Context) (err error) {
  53. return cdp.Execute(ctx, CommandDisable, nil, nil)
  54. }
  55. // SetSinkToUseParams sets a sink to be used when the web page requests the
  56. // browser to choose a sink via Presentation API, Remote Playback API, or Cast
  57. // SDK.
  58. type SetSinkToUseParams struct {
  59. SinkName string `json:"sinkName"`
  60. }
  61. // SetSinkToUse sets a sink to be used when the web page requests the browser
  62. // to choose a sink via Presentation API, Remote Playback API, or Cast SDK.
  63. //
  64. // See: https://chromedevtools.github.io/devtools-protocol/tot/Cast#method-setSinkToUse
  65. //
  66. // parameters:
  67. //
  68. // sinkName
  69. func SetSinkToUse(sinkName string) *SetSinkToUseParams {
  70. return &SetSinkToUseParams{
  71. SinkName: sinkName,
  72. }
  73. }
  74. // Do executes Cast.setSinkToUse against the provided context.
  75. func (p *SetSinkToUseParams) Do(ctx context.Context) (err error) {
  76. return cdp.Execute(ctx, CommandSetSinkToUse, p, nil)
  77. }
  78. // StartDesktopMirroringParams starts mirroring the desktop to the sink.
  79. type StartDesktopMirroringParams struct {
  80. SinkName string `json:"sinkName"`
  81. }
  82. // StartDesktopMirroring starts mirroring the desktop to the sink.
  83. //
  84. // See: https://chromedevtools.github.io/devtools-protocol/tot/Cast#method-startDesktopMirroring
  85. //
  86. // parameters:
  87. //
  88. // sinkName
  89. func StartDesktopMirroring(sinkName string) *StartDesktopMirroringParams {
  90. return &StartDesktopMirroringParams{
  91. SinkName: sinkName,
  92. }
  93. }
  94. // Do executes Cast.startDesktopMirroring against the provided context.
  95. func (p *StartDesktopMirroringParams) Do(ctx context.Context) (err error) {
  96. return cdp.Execute(ctx, CommandStartDesktopMirroring, p, nil)
  97. }
  98. // StartTabMirroringParams starts mirroring the tab to the sink.
  99. type StartTabMirroringParams struct {
  100. SinkName string `json:"sinkName"`
  101. }
  102. // StartTabMirroring starts mirroring the tab to the sink.
  103. //
  104. // See: https://chromedevtools.github.io/devtools-protocol/tot/Cast#method-startTabMirroring
  105. //
  106. // parameters:
  107. //
  108. // sinkName
  109. func StartTabMirroring(sinkName string) *StartTabMirroringParams {
  110. return &StartTabMirroringParams{
  111. SinkName: sinkName,
  112. }
  113. }
  114. // Do executes Cast.startTabMirroring against the provided context.
  115. func (p *StartTabMirroringParams) Do(ctx context.Context) (err error) {
  116. return cdp.Execute(ctx, CommandStartTabMirroring, p, nil)
  117. }
  118. // StopCastingParams stops the active Cast session on the sink.
  119. type StopCastingParams struct {
  120. SinkName string `json:"sinkName"`
  121. }
  122. // StopCasting stops the active Cast session on the sink.
  123. //
  124. // See: https://chromedevtools.github.io/devtools-protocol/tot/Cast#method-stopCasting
  125. //
  126. // parameters:
  127. //
  128. // sinkName
  129. func StopCasting(sinkName string) *StopCastingParams {
  130. return &StopCastingParams{
  131. SinkName: sinkName,
  132. }
  133. }
  134. // Do executes Cast.stopCasting against the provided context.
  135. func (p *StopCastingParams) Do(ctx context.Context) (err error) {
  136. return cdp.Execute(ctx, CommandStopCasting, p, nil)
  137. }
  138. // Command names.
  139. const (
  140. CommandEnable = "Cast.enable"
  141. CommandDisable = "Cast.disable"
  142. CommandSetSinkToUse = "Cast.setSinkToUse"
  143. CommandStartDesktopMirroring = "Cast.startDesktopMirroring"
  144. CommandStartTabMirroring = "Cast.startTabMirroring"
  145. CommandStopCasting = "Cast.stopCasting"
  146. )