live

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2016 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Overview

阿里云直播API 文档信息:https://help.aliyun.com/document_detail/27191.html?spm=0.0.0.0.60u2Ny @author cbping

Index

Constants

View Source
const (
	//action
	DescribeLiveStreamsPublishListAction    = "DescribeLiveStreamsPublishList"
	DescribeLiveStreamsOnlineListAction     = "DescribeLiveStreamsOnlineList"
	DescribeLiveStreamsBlockListAction      = "DescribeLiveStreamsBlockList"
	DescribeLiveStreamsControlHistoryAction = "DescribeLiveStreamsControlHistory"
	DescribeLiveStreamOnlineUserNumAction   = "DescribeLiveStreamOnlineUserNum"
	ForbidLiveStreamAction                  = "ForbidLiveStream"
	ResumeLiveStreamAction                  = "ResumeLiveStream"
	SetLiveStreamsNotifyUrlConfigAction     = "SetLiveStreamsNotifyUrlConfig"

	//直播中心服务器域名
	DefaultVideoCenter = "video-center.alivecdn.com"
)
View Source
const (
	DefualtStreamTimeout = time.Hour * 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Live

type Live struct {
	// contains filtered or unexported fields
}

Live 直播接口控制器

每一个实例都固定对应一个Cdn,并且无法更改。

方法名以"WithApp"结尾代表可以更改请求中  "应用名字(AppName)",否则按默认的(初始化时设置的AppName)。
如果为空,代表忽略参数AppName

@author cbping

func NewLive

func NewLive(cert *client.Credentials, domainName, appName string, streamCert *StreamCredentials) *Live

新建"直播接口控制器" @param cert 请求凭证 @param domainName 加速域名 @param appname 应用名字 @param streamCert 直播流推流凭证

func (*Live) ForbidLiveStream

func (l *Live) ForbidLiveStream(appName, streamName string, liveStreamType string, resumeTime *time.Time, resp interface{}) (err error)

ForbidLiveStream 禁止流 StreamName String 是 流名称 LiveStreamType String 是 用于指定主播推流还是客户端拉流, 目前支持"publisher" (主播推送) ResumeTime String 否 恢复流的时间 UTC时间 格式:2015-12-01T17:37:00Z

func (*Live) ForbidLiveStreamWithPublisher

func (l *Live) ForbidLiveStreamWithPublisher(streamName string, resumeTime *time.Time, resp interface{}) (err error)

@see ForbidLiveStream

func (*Live) ForbidLiveStreamWithPublisherWithApp added in v0.2.0

func (l *Live) ForbidLiveStreamWithPublisherWithApp(appName, streamName string, resumeTime *time.Time, resp interface{}) (err error)

@see ForbidLiveStream

func (*Live) GetAppName

func (l *Live) GetAppName() (appname string)

func (*Live) GetDomainName

func (l *Live) GetDomainName() (domainName string)

func (*Live) GetStream

func (l *Live) GetStream(streamName string) *Stream

GetStream 获取直播流 @describe 每一次都生成新的流实例,不检查流名的唯一性,并且同一个名字会生成不同的实例的,

所以,使用时候,请自行确保流名的唯一性

func (*Live) ResumeLiveStream

func (l *Live) ResumeLiveStream(appName, streamName string, liveStreamType string, resp interface{}) (err error)

ResumeLiveStream 恢复流

func (*Live) ResumeLiveStreamWithPublisher

func (l *Live) ResumeLiveStreamWithPublisher(streamName string, resp interface{}) (err error)

@see ResumeLiveStream

func (*Live) ResumeLiveStreamWithPublisherWithApp added in v0.2.0

func (l *Live) ResumeLiveStreamWithPublisherWithApp(appName, streamName string, resp interface{}) (err error)

@see ResumeLiveStream

func (*Live) SetAction

func (l *Live) SetAction(action string) *Live

修改默认或者说全局 action(操作名称类别)

func (*Live) SetAppName

func (l *Live) SetAppName(appname string) *Live

修改默认或者说全局 appname(应用名)

func (*Live) SetDebug

func (l *Live) SetDebug(debug bool) *Live

func (*Live) SetStreamCredentials

func (l *Live) SetStreamCredentials(streamCert *StreamCredentials) *Live

修改默认或者说全局 StreamCredentials(流签名凭证)

func (*Live) SetStreamsNotifyUrlConfig

func (l *Live) SetStreamsNotifyUrlConfig(notifyUrl string, resp interface{}) (err error)

SetStreamsNotifyUrlConfig 设置回调链接 Action String 是 操作接口名,系统规定参数,取值:SetLiveStreamsNotifyUrlConfig DomainName String 是 您的加速域名 NotifyUrl String 是 设置直播流信息推送到的URL地址,必须以http://开头;

func (*Live) SetVideoCenter added in v0.2.0

func (l *Live) SetVideoCenter(videoCenterDns string) *Live

修改默认或者说全局 videoCenterDns(对应的直播推流域名)

func (*Live) StreamOnlineUserNum

func (l *Live) StreamOnlineUserNum(streamName string, resp interface{}) (err error)

@see StreamOnlineUserNumWithApp

func (*Live) StreamOnlineUserNumWithApp

func (l *Live) StreamOnlineUserNumWithApp(appname string, streamName string, resp interface{}) (err error)

StreamOnlineUserNumWithApp 获取在线人数 @appname 应用名 为空时,忽略此参数 @link https://help.aliyun.com/document_detail/27195.html?spm=0.0.0.0.n6eAJJ

func (*Live) StreamsBlockList

func (l *Live) StreamsBlockList(resp interface{}) (err error)

StreamsBlockList 获取黑名单 @link https://help.aliyun.com/document_detail/27193.html?spm=0.0.0.0.96SCaE

func (*Live) StreamsControlHistory

func (l *Live) StreamsControlHistory(startTime, endTime time.Time, resp interface{}) (err error)

@see StreamsControlHistoryWithApp

func (*Live) StreamsControlHistoryWithApp

func (l *Live) StreamsControlHistoryWithApp(appname string, startTime, endTime time.Time, resp interface{}) (err error)

StreamsControlHistoryWithApp 获取控制历史 @appname 应用名 为空时,忽略此参数 @link https://help.aliyun.com/document_detail/27194.html?spm=0.0.0.0.4DUTT7

func (*Live) StreamsOnlineList

func (l *Live) StreamsOnlineList(resp interface{}) (err error)

@see StreamsOnlineListWithApp

func (*Live) StreamsOnlineListWithApp

func (l *Live) StreamsOnlineListWithApp(appname string, resp interface{}) (err error)

StreamsOnlineListWithApp 获取在线流 @appname 应用名 为空时,忽略此参数 @link https://help.aliyun.com/document_detail/27192.html?spm=0.0.0.0.7uWhjM

func (*Live) StreamsPublishList

func (l *Live) StreamsPublishList(startTime, endTime time.Time, resp interface{}) (err error)

@see StreamsPublishListWithApp

func (*Live) StreamsPublishListWithApp

func (l *Live) StreamsPublishListWithApp(appname string, startTime, endTime time.Time, resp interface{}) (err error)

StreamsPublishListWithApp 获取推流列表 @appname 应用名 为空时,忽略此参数 @startTime 开始时间 @endTime 结束时间 @link https://help.aliyun.com/document_detail/27191.html?spm=0.0.0.0.Dm58D2

type LiveRequest

type LiveRequest struct {
	*client.CDNRequest
	DomainName string
	AppName    string
}

LiveRequest 直播请求信息

func NewLiveRequest

func NewLiveRequest(action, domainName, appname string) (l *LiveRequest)

func (*LiveRequest) Clone

func (l *LiveRequest) Clone() interface{}

func (*LiveRequest) Sign

func (l *LiveRequest) Sign(cert *client.Credentials)

func (*LiveRequest) StructToArgs

func (l *LiveRequest) StructToArgs()

type LiveStreamControlInfo

type LiveStreamControlInfo struct {
	StreamName string //	流的名字
	ClientIP   string //	用户端的IP地址
	Action     string //	执行的操作名称
	TimeStamp  string //	操作执行的时间 UTC时间
}

直播流的操作记录

type LiveStreamOnlineInfo

type LiveStreamOnlineInfo struct {
	DomainName  string //
	AppName     string //
	StreamName  string //
	PublishTime string //
	PublishUrl  string //
}

type LiveStreamOnlineUserNumInfo

type LiveStreamOnlineUserNumInfo struct {
	StreamUrl  string //直播流的URL
	UserNumber int64  //	直播流的在线人数
}

type OnlineInfoResponse

type OnlineInfoResponse struct {
	client.Response
	OnlineUserInfo  OnlineUserInfo
	TotalUserNumber int64
}

type OnlineUserInfo

type OnlineUserInfo struct {
	LiveStreamOnlineUserNumInfo []LiveStreamOnlineInfo
}

type OnlineUserNum

type OnlineUserNum struct {
	TotalUserNumber int64                         //	所有流的用户数总和
	OnlineUserInfo  []LiveStreamOnlineUserNumInfo //每条直播流的用户数信息
}

RTMP直播流的在线人数

type Stream

type Stream struct {
	StreamName string //video-name
	// contains filtered or unexported fields
}

Stream 直播流 包括推流地址,流的播放地址,流的在线状态和在线人数等基本信息

推流地址:rtmp://video-center.alivecdn.com/appName/streamName?vhost=CDN video-center.alivecdn.com是直播中心服务器,允许自定义, 例如您的域名是live.yourcompany.com,可以设置DNS,将您的域名CNAME指向video-center.alivecdn.com即可; AppName是应用名称,支持自定义,可以更改; StreamName是流名称,支持自定义,可以更改; vhost参数是最终在边缘节点播放的域名,即你的加速域名。

@author cbping

func (*Stream) Blocked added in v0.2.0

func (s *Stream) Blocked() bool

Blocked 是否在黑名单中 -------------------------------------------------------------------------------

func (*Stream) ForbidPush

func (s *Stream) ForbidPush() (err error)

ForbidPush 禁止推流 -------------------------------------------------------------------------------

func (*Stream) HlsLiveUrls

func (s *Stream) HlsLiveUrls() (url string)

HLS 直播播放地址 --------------------------------------------------------------------------------

func (*Stream) HttpFlvLiveUrls

func (s *Stream) HttpFlvLiveUrls() (url string)

FLV 直播播放地址 --------------------------------------------------------------------------------

func (*Stream) InitOrUpdate

func (s *Stream) InitOrUpdate()

-------------------------------------------------------------------------------

func (*Stream) Online

func (s *Stream) Online() bool

在线状态 -------------------------------------------------------------------------------

func (*Stream) OnlineUserNum

func (s *Stream) OnlineUserNum() (num int64)

OnlineUserNum 获取在线人数 如果流不是在线状态,返回0 -------------------------------------------------------------------------------

func (*Stream) ResumePush

func (s *Stream) ResumePush() (err error)

ResumePush 恢复推流 -------------------------------------------------------------------------------

func (*Stream) RtmpLiveUrls

func (s *Stream) RtmpLiveUrls() (url string)

RTMP 直播播放地址 --------------------------------------------------------------------------------

func (*Stream) RtmpPublishUrl

func (s *Stream) RtmpPublishUrl() (url string)

RTMP 推流地址 如果开启了直播流鉴权,签名失效后,会重新生成新的有效的推流地址 -------------------------------------------------------------------------------

func (*Stream) String

func (s *Stream) String() (str string)

String 返回流的基本信息

type StreamCredentials

type StreamCredentials struct {
	PrivateKey string //privatekey
	Timeout    time.Duration
}

StreamCredentials 流的地址信息的签名凭证

func NewStreamCredentials

func NewStreamCredentials(privateKey string, timeout time.Duration) *StreamCredentials

NewStreamCredentials 新建凭证

func (*StreamCredentials) Clone

type StreamListResponse added in v0.2.0

type StreamListResponse struct {
	client.Response
	DomainName string     //流所属加速域名
	StreamUrls StreamUrls //	流完整URL地址
}

-------------------------------------------------------------------------------

type StreamUrls added in v0.2.0

type StreamUrls struct {
	StreamUrl []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL