Documentation
¶
Index ¶
- Constants
- Variables
- func DataChannelInitFileStream() *webrtc.DataChannelInit
- func Decode(in string, obj interface{}) error
- func Encode(obj interface{}) (string, error)
- func MustReadStream(stream io.Reader) (string, error)
- func S2EncodeStream(data []byte, dst io.Writer) error
- func StreamFile2FileInfo(fi StreamFile) os.FileInfo
- func StripSDP(originalSDP string) string
- type BandwithCalc
- type CompletionHandler
- type DataChannelFramer
- type FileStat
- type Frame
- func (*Frame) Descriptor() ([]byte, []int)
- func (m *Frame) GetT() int32
- func (m *Frame) Marshal() (dAtA []byte, err error)
- func (m *Frame) MarshalTo(dAtA []byte) (int, error)
- func (m *Frame) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Frame) ProtoMessage()
- func (m *Frame) Reset()
- func (f *Frame) SetT(t int32)
- func (m *Frame) Size() (n int)
- func (m *Frame) String() string
- func (m *Frame) Unmarshal(dAtA []byte) error
- func (m *Frame) XXX_DiscardUnknown()
- func (m *Frame) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Frame) XXX_Merge(src proto.Message)
- func (m *Frame) XXX_Size() int
- func (m *Frame) XXX_Unmarshal(b []byte) error
- type FrameData
- func (*FrameData) Descriptor() ([]byte, []int)
- func (m *FrameData) GetData() []byte
- func (m *FrameData) GetT() int32
- func (m *FrameData) Marshal() (dAtA []byte, err error)
- func (m *FrameData) MarshalTo(dAtA []byte) (int, error)
- func (m *FrameData) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*FrameData) ProtoMessage()
- func (m *FrameData) Reset()
- func (f *FrameData) SetT(t int32)
- func (m *FrameData) Size() (n int)
- func (m *FrameData) String() string
- func (m *FrameData) Unmarshal(dAtA []byte) error
- func (m *FrameData) XXX_DiscardUnknown()
- func (m *FrameData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *FrameData) XXX_Merge(src proto.Message)
- func (m *FrameData) XXX_Size() int
- func (m *FrameData) XXX_Unmarshal(b []byte) error
- type FrameEncoder
- type FrameEncoding
- type FrameError
- func (*FrameError) Descriptor() ([]byte, []int)
- func (m *FrameError) GetErr() string
- func (m *FrameError) GetT() int32
- func (m *FrameError) Marshal() (dAtA []byte, err error)
- func (m *FrameError) MarshalTo(dAtA []byte) (int, error)
- func (m *FrameError) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*FrameError) ProtoMessage()
- func (m *FrameError) Reset()
- func (f *FrameError) SetT(t int32)
- func (m *FrameError) Size() (n int)
- func (m *FrameError) String() string
- func (m *FrameError) Unmarshal(dAtA []byte) error
- func (m *FrameError) XXX_DiscardUnknown()
- func (m *FrameError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *FrameError) XXX_Merge(src proto.Message)
- func (m *FrameError) XXX_Size() int
- func (m *FrameError) XXX_Unmarshal(b []byte) error
- type FrameNewStream
- func (*FrameNewStream) Descriptor() ([]byte, []int)
- func (m *FrameNewStream) GetInfo() *StreamFile
- func (m *FrameNewStream) GetT() int32
- func (m *FrameNewStream) Marshal() (dAtA []byte, err error)
- func (m *FrameNewStream) MarshalTo(dAtA []byte) (int, error)
- func (m *FrameNewStream) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*FrameNewStream) ProtoMessage()
- func (m *FrameNewStream) Reset()
- func (f *FrameNewStream) SetT(t int32)
- func (m *FrameNewStream) Size() (n int)
- func (m *FrameNewStream) String() string
- func (m *FrameNewStream) Unmarshal(dAtA []byte) error
- func (m *FrameNewStream) XXX_DiscardUnknown()
- func (m *FrameNewStream) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *FrameNewStream) XXX_Merge(src proto.Message)
- func (m *FrameNewStream) XXX_Size() int
- func (m *FrameNewStream) XXX_Unmarshal(b []byte) error
- type Framer
- type JSONFrameEncoder
- type ProtobufFrameEncoder
- type ReadFileStreamer
- type ReadWriteFramer
- type ReceiveStreamer
- type Receiver
- type SendStreamer
- func (s *SendStreamer) AsyncStream(streamInfo os.FileInfo) error
- func (s *SendStreamer) OnClose()
- func (s *SendStreamer) OnMessage(msg webrtc.DataChannelMessage)
- func (s *SendStreamer) SetBandwithCalc(calc StreamBandwithCalculator)
- func (s *SendStreamer) SetDestinationPath(destpath string)
- func (s *SendStreamer) SetOutput(w io.Writer)
- func (s *SendStreamer) Stream(ctx context.Context, streamInfo os.FileInfo) error
- func (s *SendStreamer) StreamReader(ctx context.Context, reader io.Reader, info StreamFile) error
- func (s *SendStreamer) SubStream(streamInfo os.FileInfo, path string) error
- type Sender
- type Session
- func (s *Session) Close() error
- func (s *Session) CreateAnswer() error
- func (s *Session) CreateConnection(onConnectionStateChange func(connectionState webrtc.ICEConnectionState)) error
- func (s *Session) CreateOffer() error
- func (s *Session) OnDataChannel(handler func(d *webrtc.DataChannel))
- func (s *Session) ReadSDP() error
- func (s *Session) SetEncoding(enc FrameEncoding)
- type StreamBandwithCalculator
- type StreamFile
- func (*StreamFile) Descriptor() ([]byte, []int)
- func (s *StreamFile) FileMode() os.FileMode
- func (m *StreamFile) GetFullPath() string
- func (m *StreamFile) GetModTime() string
- func (m *StreamFile) GetMode() uint32
- func (m *StreamFile) GetName() string
- func (m *StreamFile) GetPath() string
- func (m *StreamFile) GetSizeLen() int64
- func (s *StreamFile) IsDir() bool
- func (m *StreamFile) Marshal() (dAtA []byte, err error)
- func (m *StreamFile) MarshalTo(dAtA []byte) (int, error)
- func (m *StreamFile) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*StreamFile) ProtoMessage()
- func (m *StreamFile) Reset()
- func (m *StreamFile) Size() (n int)
- func (m *StreamFile) String() string
- func (m *StreamFile) Unmarshal(dAtA []byte) error
- func (m *StreamFile) XXX_DiscardUnknown()
- func (m *StreamFile) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *StreamFile) XXX_Merge(src proto.Message)
- func (m *StreamFile) XXX_Size() int
- func (m *StreamFile) XXX_Unmarshal(b []byte) error
- type WriteFileStreamer
Constants ¶
const ( KB int64 = 1024 MB int64 = 1024 * 1024 GB int64 = 1024 * 1024 * 1024 )
const ( DatachannelLabelJsonstream = "jsonstream" DatachannelLabelProtobufstream = "protostream" )
const ( FRAME_NEWSTREAM = iota FRAME_DATA FRAME_OK FRAME_ERROR )
const ( SEND_BUFFER_SIZE = 16384 // 16 * 1024 SEND_BUFFER_AMOUNT_LOW_TRESHOLD = 524288 //512 * 1024 )
const ( SDP_OFFER_PROMPT = "Send this offer:" SDP_OFFER_WAITING_PROMPT = "Please, paste the remote offer:" SDP_ANSWER_PROMPT = "Send this answer:" SDP_ANSWER_WAITING_PROMPT = "Please, paste the remote answer:" )
Variables ¶
var ( ErrInvalidLengthFrame = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowFrame = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupFrame = fmt.Errorf("proto: unexpected end of group") )
var ( ICEServerList = []webrtc.ICEServer{ { URLs: []string{ "stun:stun.l.google.com:19302", }, }, } )
Functions ¶
func DataChannelInitFileStream ¶
func DataChannelInitFileStream() *webrtc.DataChannelInit
func MustReadStream ¶
MustReadStream blocks until input is received from the stream
func StreamFile2FileInfo ¶
func StreamFile2FileInfo(fi StreamFile) os.FileInfo
Types ¶
type BandwithCalc ¶
type BandwithCalc struct {
// contains filtered or unexported fields
}
func NewBandwithCalc ¶
func NewBandwithCalc(w io.Writer) *BandwithCalc
func (*BandwithCalc) Add ¶
func (b *BandwithCalc) Add(n uint64)
When adding bytes we calculate duration, to be more precise
func (*BandwithCalc) Finish ¶
func (b *BandwithCalc) Finish()
func (*BandwithCalc) NewStream ¶
func (b *BandwithCalc) NewStream(streamname string, n uint64)
type CompletionHandler ¶
type CompletionHandler func()
type DataChannelFramer ¶
type DataChannelFramer struct {
// contains filtered or unexported fields
}
func NewDataChannelFramer ¶
func NewDataChannelFramer(channel *webrtc.DataChannel) *DataChannelFramer
type FileStat ¶
type FileStat struct {
// contains filtered or unexported fields
}
func NewFileStat ¶
type Frame ¶
type Frame struct {
T int32 `protobuf:"varint,1,opt,name=T,proto3" json:"T,omitempty"`
}
func (*Frame) Descriptor ¶
func (*Frame) ProtoMessage ¶
func (*Frame) ProtoMessage()
func (*Frame) XXX_DiscardUnknown ¶
func (m *Frame) XXX_DiscardUnknown()
func (*Frame) XXX_Marshal ¶
func (*Frame) XXX_Unmarshal ¶
type FrameData ¶
type FrameData struct { T int32 `protobuf:"varint,1,opt,name=T,proto3" json:"T,omitempty"` Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"` }
func (*FrameData) Descriptor ¶
func (*FrameData) MarshalToSizedBuffer ¶
func (*FrameData) ProtoMessage ¶
func (*FrameData) ProtoMessage()
func (*FrameData) XXX_DiscardUnknown ¶
func (m *FrameData) XXX_DiscardUnknown()
func (*FrameData) XXX_Marshal ¶
func (*FrameData) XXX_Unmarshal ¶
type FrameEncoder ¶
type FrameEncoding ¶
type FrameEncoding int
const ( FrameEncodingJSON FrameEncoding = 0 FrameEncodingProto FrameEncoding = 1 )
type FrameError ¶
type FrameError struct { T int32 `protobuf:"varint,1,opt,name=T,proto3" json:"T,omitempty"` Err string `protobuf:"bytes,2,opt,name=Err,proto3" json:"Err,omitempty"` }
func (*FrameError) Descriptor ¶
func (*FrameError) Descriptor() ([]byte, []int)
func (*FrameError) GetErr ¶
func (m *FrameError) GetErr() string
func (*FrameError) GetT ¶
func (m *FrameError) GetT() int32
func (*FrameError) Marshal ¶
func (m *FrameError) Marshal() (dAtA []byte, err error)
func (*FrameError) MarshalToSizedBuffer ¶
func (m *FrameError) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*FrameError) ProtoMessage ¶
func (*FrameError) ProtoMessage()
func (*FrameError) Reset ¶
func (m *FrameError) Reset()
func (*FrameError) SetT ¶
func (f *FrameError) SetT(t int32)
func (*FrameError) Size ¶
func (m *FrameError) Size() (n int)
func (*FrameError) String ¶
func (m *FrameError) String() string
func (*FrameError) Unmarshal ¶
func (m *FrameError) Unmarshal(dAtA []byte) error
func (*FrameError) XXX_DiscardUnknown ¶
func (m *FrameError) XXX_DiscardUnknown()
func (*FrameError) XXX_Marshal ¶
func (m *FrameError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*FrameError) XXX_Merge ¶
func (m *FrameError) XXX_Merge(src proto.Message)
func (*FrameError) XXX_Size ¶
func (m *FrameError) XXX_Size() int
func (*FrameError) XXX_Unmarshal ¶
func (m *FrameError) XXX_Unmarshal(b []byte) error
type FrameNewStream ¶
type FrameNewStream struct { T int32 `protobuf:"varint,1,opt,name=T,proto3" json:"T,omitempty"` Info *StreamFile `protobuf:"bytes,3,opt,name=Info,proto3" json:"Info,omitempty"` }
func (*FrameNewStream) Descriptor ¶
func (*FrameNewStream) Descriptor() ([]byte, []int)
func (*FrameNewStream) GetInfo ¶
func (m *FrameNewStream) GetInfo() *StreamFile
func (*FrameNewStream) GetT ¶
func (m *FrameNewStream) GetT() int32
func (*FrameNewStream) Marshal ¶
func (m *FrameNewStream) Marshal() (dAtA []byte, err error)
func (*FrameNewStream) MarshalToSizedBuffer ¶
func (m *FrameNewStream) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*FrameNewStream) ProtoMessage ¶
func (*FrameNewStream) ProtoMessage()
func (*FrameNewStream) Reset ¶
func (m *FrameNewStream) Reset()
func (*FrameNewStream) SetT ¶
func (f *FrameNewStream) SetT(t int32)
func (*FrameNewStream) Size ¶
func (m *FrameNewStream) Size() (n int)
func (*FrameNewStream) String ¶
func (m *FrameNewStream) String() string
func (*FrameNewStream) Unmarshal ¶
func (m *FrameNewStream) Unmarshal(dAtA []byte) error
func (*FrameNewStream) XXX_DiscardUnknown ¶
func (m *FrameNewStream) XXX_DiscardUnknown()
func (*FrameNewStream) XXX_Marshal ¶
func (m *FrameNewStream) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*FrameNewStream) XXX_Merge ¶
func (m *FrameNewStream) XXX_Merge(src proto.Message)
func (*FrameNewStream) XXX_Size ¶
func (m *FrameNewStream) XXX_Size() int
func (*FrameNewStream) XXX_Unmarshal ¶
func (m *FrameNewStream) XXX_Unmarshal(b []byte) error
type Framer ¶
type Framer interface { // proto.Message protoiface.MessageV1 //protoreflect.ProtoMessage SetT(t int32) GetT() int32 }
func NewFrameByType ¶
type JSONFrameEncoder ¶
type JSONFrameEncoder struct { }
func (*JSONFrameEncoder) MarshalFramer ¶
func (enc *JSONFrameEncoder) MarshalFramer(f Framer, t int) ([]byte, error)
func (*JSONFrameEncoder) UnmarshalFramer ¶
func (enc *JSONFrameEncoder) UnmarshalFramer(data []byte) (Framer, error)
type ProtobufFrameEncoder ¶
type ProtobufFrameEncoder struct { }
func (*ProtobufFrameEncoder) MarshalFramer ¶
func (enc *ProtobufFrameEncoder) MarshalFramer(f Framer, t int) ([]byte, error)
func (*ProtobufFrameEncoder) UnmarshalFramer ¶
func (enc *ProtobufFrameEncoder) UnmarshalFramer(data []byte) (Framer, error)
type ReadFileStreamer ¶
type ReadWriteFramer ¶
type ReceiveStreamer ¶
type ReceiveStreamer struct { WriteFileStreamer ReadWriteFramer // FilesCount is number of files received, which can be read at the end of stream. Not safe to read during streaming FilesCount int // contains filtered or unexported fields }
func NewReceiveStreamer ¶
func NewReceiveStreamer(channel *webrtc.DataChannel, outputDir string, fwriter WriteFileStreamer) *ReceiveStreamer
func (*ReceiveStreamer) OnMessage ¶
func (s *ReceiveStreamer) OnMessage(msg webrtc.DataChannelMessage)
func (*ReceiveStreamer) OnOpen ¶
func (s *ReceiveStreamer) OnOpen()
func (*ReceiveStreamer) Stream ¶
func (s *ReceiveStreamer) Stream() (done chan struct{})
type Receiver ¶
type Receiver struct { Session Done chan struct{} // contains filtered or unexported fields }
Session is a receiver session
func NewReceiver ¶
func (*Receiver) DialReverse ¶
func (*Receiver) NewFileStreamer ¶
func (s *Receiver) NewFileStreamer(rootpath string) *ReceiveStreamer
func (*Receiver) NewFileStreamerWithWritter ¶
func (s *Receiver) NewFileStreamerWithWritter(rootpath string, fwriter WriteFileStreamer) *ReceiveStreamer
type SendStreamer ¶
type SendStreamer struct { ReadFileStreamer ReadWriteFramer Done chan struct{} DoneSending chan struct{} // contains filtered or unexported fields }
func NewSendStreamer ¶
func NewSendStreamer(channel *webrtc.DataChannel, rootpath string, freader ReadFileStreamer) *SendStreamer
func NewSendStreamer(channel *webrtc.DataChannel, streamInfo os.FileInfo, rootpath string, options ...SendStreamerOption) *SendStreamer {
func (*SendStreamer) AsyncStream ¶
func (s *SendStreamer) AsyncStream(streamInfo os.FileInfo) error
func (*SendStreamer) OnClose ¶
func (s *SendStreamer) OnClose()
func (*SendStreamer) OnMessage ¶
func (s *SendStreamer) OnMessage(msg webrtc.DataChannelMessage)
func (*SendStreamer) SetBandwithCalc ¶
func (s *SendStreamer) SetBandwithCalc(calc StreamBandwithCalculator)
SetBandwithCalc allows changing default bandwithcalc. Must be called before streaming
func (*SendStreamer) SetDestinationPath ¶
func (s *SendStreamer) SetDestinationPath(destpath string)
SetDestinationPath will prefix path on destination side.
func (*SendStreamer) SetOutput ¶
func (s *SendStreamer) SetOutput(w io.Writer)
func (*SendStreamer) StreamReader ¶
func (s *SendStreamer) StreamReader(ctx context.Context, reader io.Reader, info StreamFile) error
StreamReader is more generic function that can stream any io reader as file on other side
type Sender ¶
type Sender struct { Session // contains filtered or unexported fields }
Session is a sender session
func (*Sender) DialReverse ¶
func (*Sender) NewFileStreamer ¶
func (s *Sender) NewFileStreamer(dest string) (streamer *SendStreamer)
func (*Sender) NewFileStreamerWithReader ¶
func (s *Sender) NewFileStreamerWithReader(dest string, freader ReadFileStreamer) (streamer *SendStreamer)
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session contains common elements to perform send/receive
func NewSession ¶
New creates a new Session
func (*Session) CreateAnswer ¶
CreateAnswer set the local description and print the answer SDP
func (*Session) CreateConnection ¶
func (s *Session) CreateConnection(onConnectionStateChange func(connectionState webrtc.ICEConnectionState)) error
CreateConnection prepares a WebRTC connection
func (*Session) CreateOffer ¶
CreateOffer set the local description and print the offer SDP
func (*Session) OnDataChannel ¶
func (s *Session) OnDataChannel(handler func(d *webrtc.DataChannel))
OnDataChannel sets an OnDataChannel handler
func (*Session) SetEncoding ¶
func (s *Session) SetEncoding(enc FrameEncoding)
type StreamFile ¶
type StreamFile struct { Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` Path string `protobuf:"bytes,2,opt,name=Path,proto3" json:"Path,omitempty"` SizeLen int64 `protobuf:"varint,3,opt,name=SizeLen,proto3" json:"SizeLen,omitempty"` Mode uint32 `protobuf:"varint,4,opt,name=Mode,proto3" json:"Mode,omitempty"` ModTime string `protobuf:"bytes,5,opt,name=ModTime,proto3" json:"ModTime,omitempty"` FullPath string `protobuf:"bytes,6,opt,name=FullPath,proto3" json:"FullPath,omitempty"` }
func FileInfo2StreamFile ¶
func FileInfo2StreamFile(fi os.FileInfo, path string) StreamFile
func (*StreamFile) Descriptor ¶
func (*StreamFile) Descriptor() ([]byte, []int)
func (*StreamFile) FileMode ¶
func (s *StreamFile) FileMode() os.FileMode
func (*StreamFile) GetFullPath ¶
func (m *StreamFile) GetFullPath() string
func (*StreamFile) GetModTime ¶
func (m *StreamFile) GetModTime() string
func (*StreamFile) GetMode ¶
func (m *StreamFile) GetMode() uint32
func (*StreamFile) GetName ¶
func (m *StreamFile) GetName() string
func (*StreamFile) GetPath ¶
func (m *StreamFile) GetPath() string
func (*StreamFile) GetSizeLen ¶
func (m *StreamFile) GetSizeLen() int64
func (*StreamFile) IsDir ¶
func (s *StreamFile) IsDir() bool
func (*StreamFile) Marshal ¶
func (m *StreamFile) Marshal() (dAtA []byte, err error)
func (*StreamFile) MarshalToSizedBuffer ¶
func (m *StreamFile) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*StreamFile) ProtoMessage ¶
func (*StreamFile) ProtoMessage()
func (*StreamFile) Reset ¶
func (m *StreamFile) Reset()
func (*StreamFile) Size ¶
func (m *StreamFile) Size() (n int)
func (*StreamFile) String ¶
func (m *StreamFile) String() string
func (*StreamFile) Unmarshal ¶
func (m *StreamFile) Unmarshal(dAtA []byte) error
func (*StreamFile) XXX_DiscardUnknown ¶
func (m *StreamFile) XXX_DiscardUnknown()
func (*StreamFile) XXX_Marshal ¶
func (m *StreamFile) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*StreamFile) XXX_Merge ¶
func (m *StreamFile) XXX_Merge(src proto.Message)
func (*StreamFile) XXX_Size ¶
func (m *StreamFile) XXX_Size() int
func (*StreamFile) XXX_Unmarshal ¶
func (m *StreamFile) XXX_Unmarshal(b []byte) error