/
conn_netstream_commander.go
99 lines (85 loc) · 2.95 KB
/
conn_netstream_commander.go
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
package rtmp
import (
"context"
"github.com/pkg/errors"
)
func (conn *defaultConn) OnStatus(ctx context.Context, chunkStreamID uint32, messageStreamID uint32, infoObject map[string]interface{}) error {
p := NewOnStatus(infoObject, conn.encodingAMFType)
b, err := p.MarshalBinary()
if err != nil {
return errors.Wrap(err, "failed to MarshalBinary")
}
var msgTypeID MessageTypeID
if conn.encodingAMFType == EncodingAMFTypeAMF0 {
msgTypeID = MessageTypeIDCommandAMF0
} else {
msgTypeID = MessageTypeIDCommandAMF3
}
m := NewMessage(
chunkStreamID,
msgTypeID,
conn.Timestamp(),
messageStreamID,
b,
)
_, err = conn.Writer().WriteMessage(m)
if err != nil {
return errors.Wrap(err, "failed to WriteMessage")
}
if err := conn.Writer().Flush(); err != nil {
return errors.Wrap(err, "failed to Flush Writer")
}
return nil
}
func (conn *defaultConn) Play(ctx context.Context, chunkStreamID uint32, messageStreamID uint32, streamName string, start uint32, duration uint32, reset bool) error {
panic("not implemented")
}
func (conn *defaultConn) Play2(ctx context.Context, chunkStreamID uint32, messageStreamID uint32, parameters map[string]interface{}) error {
panic("not implemented")
}
func (conn *defaultConn) DeleteStream(ctx context.Context, chunkStreamID uint32, messageStreamID uint32, streamID uint32) error {
panic("not implemented")
}
func (conn *defaultConn) CloseStream(ctx context.Context, chunkStreamID uint32, messageStreamID uint32, streamID uint32) error {
panic("not implemented")
}
func (conn *defaultConn) ReceiveAudio(ctx context.Context, chunkStreamID uint32, messageStreamID uint32, boolFlag bool) error {
panic("not implemented")
}
func (conn *defaultConn) ReceiveVideo(ctx context.Context, chunkStreamID uint32, messageStreamID uint32, boolFlag bool) error {
panic("not implemented")
}
func (conn *defaultConn) Publish(ctx context.Context, chunkStreamID uint32, messageStreamID uint32, publishingName string, publishingType PublishingType) error {
p := NewPublish(publishingName, publishingType, conn.encodingAMFType)
b, err := p.MarshalBinary()
if err != nil {
return errors.Wrap(err, "failed to MarshalBinary")
}
var msgTypeID MessageTypeID
if conn.encodingAMFType == EncodingAMFTypeAMF0 {
msgTypeID = MessageTypeIDCommandAMF0
} else {
msgTypeID = MessageTypeIDCommandAMF3
}
m := NewMessage(
chunkStreamID,
msgTypeID,
conn.Timestamp(),
messageStreamID,
b,
)
_, err = conn.Writer().WriteMessage(m)
if err != nil {
return errors.Wrap(err, "failed to WriteMessage")
}
if err := conn.Writer().Flush(); err != nil {
return errors.Wrap(err, "failed to Flush Writer")
}
return nil
}
func (conn *defaultConn) Seek(ctx context.Context, chunkStreamID uint32, messageStreamID uint32, milliSeconds uint32) error {
panic("not implemented")
}
func (conn *defaultConn) Pause(ctx context.Context, chunkStreamID uint32, messageStreamID uint32, pauseUnpauseFlag bool, milliSeconds uint32) error {
panic("not implemented")
}