-
Notifications
You must be signed in to change notification settings - Fork 6
/
opts.go
44 lines (35 loc) · 892 Bytes
/
opts.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
package rtsp
/*
#include "ffmpeg.h"
*/
import "C"
import (
"unsafe"
)
type StreamOption func(*Stream)
func WithTimeout(timeout string) StreamOption {
return func(stream *Stream) {
timeoutKey := C.CString("listen_timeout")
defer C.free(unsafe.Pointer(timeoutKey))
timeoutStr := C.CString(timeout)
defer C.free(unsafe.Pointer(timeoutStr))
C.av_dict_set(&stream.dictionary, timeoutKey, timeoutStr, 0)
}
}
func WithType(streamType Type) StreamOption {
return func(stream *Stream) {
transport := C.CString("rtsp_transport")
defer C.free(unsafe.Pointer(transport))
switch streamType {
case Tcp:
tcp := C.CString("tcp")
defer C.free(unsafe.Pointer(tcp))
C.av_dict_set(&stream.dictionary, transport, tcp, 0)
case Udp:
udp := C.CString("udp")
defer C.free(unsafe.Pointer(udp))
C.av_dict_set(&stream.dictionary, transport, udp, 0)
default:
}
}
}