Beispiel #1
0
	"time"

	"github.com/antongulenko/RTP/protocols"
)

var (
	Protocol     *pingProtocol
	MiniProtocol = protocols.NewMiniProtocol(Protocol)

	pingRand = rand.New(rand.NewSource(time.Now().Unix()))
)

// ======================= Packets =======================

const (
	codePing = protocols.Code(iota + 3)
	codePong
)

type PingPacket struct {
	Value int
}
type PongPacket struct {
	Value int
}

func (ping *PingPacket) PongValue() PongPacket {
	return PongPacket{ping.Pong()}
}

func (ping *PingPacket) Pong() int {
Beispiel #2
0
import (
	"encoding/gob"
	"fmt"

	"github.com/antongulenko/RTP/protocols"
	"github.com/antongulenko/RTP/protocols/amp"
)

var (
	Protocol     *ampControlProtocol
	MiniProtocol = protocols.NewMiniProtocol(Protocol)
)

const (
	CodeRedirectStream = protocols.Code(17 + iota)
	CodePauseStream
	CodeResumeStream
)

// ======================= Packets =======================

type RedirectStream struct {
	OldClient amp.ClientDescription
	NewClient amp.ClientDescription
}

type PauseStream struct {
	amp.ClientDescription
}
Beispiel #3
0
import (
	"encoding/gob"
	"fmt"
	"net"
	"strconv"

	"github.com/antongulenko/RTP/protocols"
)

var (
	Protocol     *ampProtocol
	MiniProtocol = protocols.NewMiniProtocol(Protocol)
)

const (
	CodeStartStream = protocols.Code(15 + iota)
	CodeStopStream
)

// ======================= Packets =======================

type ClientDescription struct {
	ReceiverHost string
	Port         int
}

type StartStream struct {
	ClientDescription
	MediaFile string
}
Beispiel #4
0
import (
	"encoding/gob"
	"fmt"
	"time"

	"github.com/antongulenko/RTP/protocols"
)

var (
	Protocol     *loadProtocol
	MiniProtocol = protocols.NewMiniProtocolTransport(Protocol, protocols.UdpTransportB(2048))
)

const (
	codeLoad   = protocols.Code(100)
	PacketSize = 105 // Reported by tcpdump, size of LoadPacket with empty Payload. Varies between 105-107.
)

type LoadPacket struct {
	Seq       uint
	Payload   []byte
	Timestamp time.Time
}

func (packet *LoadPacket) String() string {
	return fmt.Sprintf("Load(Seq %v, %v byte payload)", packet.Seq, len(packet.Payload))
}

func (packet *LoadPacket) PrintReceived() {
	now := time.Now()
Beispiel #5
0
package main

import (
	"encoding/gob"
	"fmt"
	"log"
	"time"

	"github.com/antongulenko/RTP/protocols"
)

const (
	CodeMeasureLatency = protocols.Code(20)
)

var (
	Protocol     *latencyProtocol
	MiniProtocol = protocols.NewMiniProtocol(Protocol)
)

type MeasureLatency struct {
	Sequence uint
	SendTime time.Time
}

type latencyProtocol struct {
}

func (*latencyProtocol) Name() string {
	return "Latency"
}
Beispiel #6
0
	"encoding/gob"
	"fmt"
	"time"

	"github.com/antongulenko/RTP/protocols"
)

var (
	Protocol     *heartbeatProtocol
	MiniProtocol = protocols.NewMiniProtocol(Protocol)
)

// ======================= Packets =======================

const (
	codeHeartbeat = protocols.Code(iota + 6)
	codeConfigureHeartbeat
)

type HeartbeatPacket struct {
	Token    int64
	Source   string
	TimeSent time.Time
	Seq      uint64
}

type ConfigureHeartbeatPacket struct {
	Token        int64
	TargetServer string
	Timeout      time.Duration
}
Beispiel #7
0
import (
	"encoding/gob"
	"fmt"
	"net"
	"strconv"

	"github.com/antongulenko/RTP/protocols"
)

var (
	Protocol     *pcpProtocol
	MiniProtocol = protocols.NewMiniProtocol(Protocol)
)

const (
	codeStartProxy = protocols.Code(10 + iota)
	codeStopProxy
	codeStartProxyPair
	codeStopProxyPair
	codeStartProxyPairResponse
)

// ======================= Packets =======================

type ProxyDescription struct {
	ListenAddr string
	TargetAddr string
}

type StartProxy struct {
	ProxyDescription