Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。
package nativecontrol
import (
"github.com/TNTcraftHIM/Piik/internal/app/mediaedge"
"github.com/TNTcraftHIM/Piik/internal/app/nativecapture"
"github.com/TNTcraftHIM/Piik/internal/app/remoteinput"
"github.com/TNTcraftHIM/Piik/internal/server/protocol"
"github.com/pion/webrtc/v4"
)
type requestEnvelope struct {
reportSourceCancellation bool
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
}
type responseEnvelope struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
}
type requestFailedResponse struct {
responseEnvelope
Code string `json:"code"`
}
type captureOptionsRequest requestEnvelope
type listSourcesRequest requestEnvelope
type sourcePreviewRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
Source nativecapture.CaptureTarget `json:"source"`
}
type qualitySettings = protocol.QualitySettings
type startShareRequest struct {
ReportSourceCancellation bool `json:"reportSourceCancellation,omitempty"`
ReportCaptureFailure bool `json:"reportCaptureFailure,omitempty"`
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
Source nativecapture.CaptureTarget `json:"source"`
Audio bool `json:"audio"`
MicrophoneMixing bool `json:"microphoneMixing,omitempty"`
RemoteInput bool `json:"remoteInput,omitempty"`
ExcludeAudio *nativecapture.CaptureTarget `json:"excludeAudio,omitempty"`
ShowCaptureBorder bool `json:"showCaptureBorder,omitempty"`
AdapterIndex uint32 `json:"adapterIndex"`
EncoderIndex uint32 `json:"encoderIndex"`
EdgeCapacity int `json:"edgeCapacity"`
Profile qualitySettings `json:"profile"`
Codec string `json:"codec"`
}
type microphoneRequest struct {
requestEnvelope
ShareID string `json:"shareId"`
Enabled *bool `json:"enabled,omitempty"`
Volume *float64 `json:"volume,omitempty"`
DeviceID *string `json:"deviceId,omitempty"`
}
type shareVolumeRequest struct {
requestEnvelope
ShareID string `json:"shareId"`
Volume *float64 `json:"volume"`
}
type remoteControlRequest struct {
requestEnvelope
ShareID string `json:"shareId"`
RequestID string `json:"requestId"`
Allow *bool `json:"allow"`
}
type remoteInputPeersRequest struct {
requestEnvelope
ShareID string `json:"shareId"`
Peers []protocol.RemoteInputPeer `json:"peers"`
}
type remoteControlPolicyRequest struct {
requestEnvelope
ShareID string `json:"shareId"`
Mode string `json:"mode"`
Password string `json:"password,omitempty"`
CoPlay bool `json:"coPlay,omitempty"`
}
type remoteControlStateEvent struct {
eventEnvelope
remoteinput.State
}
type remoteControlSimultaneousRequest struct {
requestEnvelope
ShareID string `json:"shareId"`
Enabled *bool `json:"enabled"`
}
type remoteStopShortcutRequest struct {
requestEnvelope
ShareID string `json:"shareId"`
Key int `json:"key,omitempty"`
}
type remoteStopShortcutResponse struct {
responseEnvelope
remoteinput.StopShortcut
}
type audioStateEvent struct {
eventEnvelope
SourceAudio bool `json:"sourceAudio"`
Microphone bool `json:"microphone"`
Failed bool `json:"failed"`
}
type updateShareRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
Profile qualitySettings `json:"profile"`
}
type replaceShareSourceRequest struct {
ReportSourceCancellation bool `json:"reportSourceCancellation,omitempty"`
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
Source nativecapture.CaptureTarget `json:"source"`
Audio bool `json:"audio"`
ExcludeAudio *nativecapture.CaptureTarget `json:"excludeAudio,omitempty"`
ShowCaptureBorder bool `json:"showCaptureBorder,omitempty"`
AdapterIndex uint32 `json:"adapterIndex"`
EncoderIndex uint32 `json:"encoderIndex"`
}
type stopShareRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
}
type pauseShareRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
Paused bool `json:"paused"`
}
type iceServer struct {
URLs []string `json:"urls"`
}
type prepareEdgeRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
ConnectionID string `json:"connectionId"`
SourceConnectionID string `json:"sourceConnectionId,omitempty"`
ICEServers []iceServer `json:"iceServers"`
Punched bool `json:"punched,omitempty"`
}
type prepareLocalEdgeRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
ConnectionID string `json:"connectionId"`
SourceConnectionID string `json:"sourceConnectionId,omitempty"`
Restart bool `json:"restart"`
}
type receiveOfferRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
ConnectionID string `json:"connectionId"`
EdgeCapacity int `json:"edgeCapacity"`
ICEServers []iceServer `json:"iceServers"`
SDP string `json:"sdp"`
ReuseReceiver bool `json:"reuseReceiver,omitempty"`
Punched bool `json:"punched,omitempty"`
}
type receiveCandidateRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
ConnectionID string `json:"connectionId"`
Candidate *webrtc.ICECandidateInit `json:"candidate"`
}
type closeReceiverRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
ConnectionID string `json:"connectionId"`
}
type stopReceiveRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
}
type edgeAnswerRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
ConnectionID string `json:"connectionId"`
SDP string `json:"sdp"`
OfferID string `json:"offerId,omitempty"`
}
type edgeCandidateRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
ConnectionID string `json:"connectionId"`
Candidate *webrtc.ICECandidateInit `json:"candidate"`
}
type closeEdgeRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Type string `json:"type"`
ShareID string `json:"shareId"`
ConnectionID string `json:"connectionId"`
}
type sourceListResponse struct {
responseEnvelope
Sources []nativecapture.CaptureTarget `json:"sources"`
}
type sourcePreviewResponse struct {
responseEnvelope
SourceKey string `json:"sourceKey"`
Mime string `json:"mime"`
Data string `json:"data"`
}
type captureOptionsResponse struct {
responseEnvelope
Adapters []nativecapture.Adapter `json:"adapters"`
}
type shareStartedResponse struct {
responseEnvelope
ShareID string `json:"shareId"`
Audio bool `json:"audio"`
SourceAudio *bool `json:"sourceAudio,omitempty"`
Codec string `json:"codec"`
}
type shareUpdatedResponse struct {
responseEnvelope
ShareID string `json:"shareId"`
}
type shareSourceReplacedResponse struct {
responseEnvelope
ShareID string `json:"shareId"`
}
type edgeOfferResponse struct {
responseEnvelope
ShareID string `json:"shareId"`
ConnectionID string `json:"connectionId"`
SDP string `json:"sdp"`
}
type receiveAnswerResponse struct {
responseEnvelope
ShareID string `json:"shareId"`
ConnectionID string `json:"connectionId"`
SDP string `json:"sdp"`
Audio bool `json:"audio"`
Codec string `json:"codec"`
Reused *bool `json:"reused,omitempty"`
}
type eventEnvelope struct {
Version int `json:"version"`
Type string `json:"type"`
ShareID string `json:"shareId"`
ConnectionID string `json:"connectionId,omitempty"`
PublicationGeneration string `json:"publicationGeneration,omitempty"`
}
type publicationIdentity struct {
requestEnvelope
ShareID string `json:"shareId"`
PublicationGeneration string `json:"publicationGeneration"`
ConnectionID string `json:"connectionId"`
}
type preparePublicationRequest struct {
publicationIdentity
ICEServers []iceServer `json:"iceServers"`
}
type publicationAnswerRequest struct {
publicationIdentity
SDP string `json:"sdp"`
}
type publicationCandidateRequest struct {
publicationIdentity
Candidate *webrtc.ICECandidateInit `json:"candidate"`
}
type publicationLayersRequest struct {
publicationIdentity
ActiveCount *int `json:"activeCount"`
}
type publicationResponse struct {
responseEnvelope
ShareID string `json:"shareId"`
PublicationGeneration string `json:"publicationGeneration"`
ConnectionID string `json:"connectionId"`
SDP string `json:"sdp,omitempty"`
Media mediaedge.PublicationMedia `json:"media"`
}
type publicationQualityEvent struct {
eventEnvelope
mediaedge.PublicationQualitySample
}
type captureStateEvent struct {
eventEnvelope
State string `json:"state"`
}
type edgeCandidateEvent struct {
eventEnvelope
Candidate *webrtc.ICECandidateInit `json:"candidate"`
}
type edgeStateEvent struct {
eventEnvelope
State string `json:"state"`
}
type edgePathEvent struct {
eventEnvelope
LocalType string `json:"localType"`
RemoteType string `json:"remoteType"`
NatTraversalPath string `json:"natTraversalPath"`
}
type edgeQualityEvent struct {
eventEnvelope
SampleTimestampMs int64 `json:"sampleTimestampMs"`
SampleWindowMs int64 `json:"sampleWindowMs"`
RTPStatsID string `json:"rtpStatsId"`
TrackIdentifier string `json:"trackIdentifier"`
State string `json:"state"`
Reason *string `json:"reason"`
IntervalFramesSent uint64 `json:"intervalFramesEncoded"` // Published v10 name for output frames.
FramesPerSecond float64 `json:"framesPerSecond"`
BitrateKbps float64 `json:"bitrateKbps"`
AvailableOutgoingKbps float64 `json:"availableOutgoingKbps"`
Width uint32 `json:"width"`
Height uint32 `json:"height"`
}
type shareEndedEvent struct {
Version int `json:"version"`
Type string `json:"type"`
ShareID string `json:"shareId"`
Failed bool `json:"failed"`
Failure *nativecapture.Failure `json:"failure,omitempty"`
}