Skip to content

Commit a9284cc

Browse files
author
lijing
committed
增加选流功能接口api
1 parent ddbe220 commit a9284cc

File tree

3 files changed

+123
-17
lines changed

3 files changed

+123
-17
lines changed

examples/ket.py

Lines changed: 88 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,60 @@
88
client = getKetClient("ket", "cn-beijing-6",use_ssl=False)
99

1010
uniqname = 'mytest'
11-
presetname = 'testpreset00'
11+
presetname = 'testpreset'
1212
appname = 'live'
1313
description = 'just a demo'
14-
presetType = 'avop'
14+
presettype = 4
1515
streamid = 'myteststreamid'
16+
taskid = 'd41d8cd98f00b204e9800998ecf8427e'
1617
outpull = 1
1718
srcurl = "rtmp://qa-ws.test-rtmplive.ks-cdn.com/live/20160819"
1819

1920
# 删除模板
20-
res = client.DelPreset(App=appname, UniqName=uniqname, Preset=presetname)
21-
print json.dumps(res)
21+
#res = client.DelPreset(App=appname, UniqName=uniqname, Preset=presetname)
22+
#print json.dumps(res)
2223

2324
# 创建模板
2425
param = {
2526
"UniqName": uniqname,
2627
"Preset": presetname,
28+
"PresetType": presettype,
2729
"Description": description,
2830
"App": appname,
2931
"Output": [
3032
{
31-
"format":
33+
"Idx": 0,
34+
"Overlay":[
35+
{
36+
"inputIdx": 0,
37+
}
38+
],
39+
"Amix":[
40+
{
41+
"inputIdx": 0,
42+
}
43+
]
44+
},
45+
{
46+
"Idx": 1,
47+
"Overlay":
48+
{
49+
"inputIdx": 0,
50+
},
51+
"Amix":
52+
{
53+
"inputIdx": 0,
54+
}
55+
},
56+
{
57+
"Idx": 2,
58+
"Video":
3259
{
33-
"output_format": 257,
34-
"abr": 70000,
35-
"vbr": 700000,
36-
"fr": 23
60+
"codec": "copy",
61+
},
62+
"Audio":
63+
{
64+
"codec": "copy",
3765
}
3866
}
3967
]
@@ -132,9 +160,55 @@
132160
end = "2017-06-20 00:00:00"
133161
t0 = time.strptime(start, "%Y-%m-%d %H:%M:%S")
134162
t1 = time.strptime(end, "%Y-%m-%d %H:%M:%S")
135-
StartUnixTime = int(time.mktime(t0))
136-
EndUnixTime = int(time.mktime(t1))
137-
Granularity = 5
138-
ResultType = 1
139-
res = client.GetLiveTransDuration(StartUnixTime, EndUnixTime, Granularity, ResultType)
163+
startunixtime = int(time.mktime(t0))
164+
endunixtime = int(time.mktime(t1))
165+
granularity = 5
166+
resulttype = 1
167+
res = client.GetLiveTransDuration(startunixtime, endunixtime, uniqname, granularity, resulttype)
168+
print json.dumps(res)
169+
170+
# 创建选流任务
171+
param4 = {
172+
"UniqName": uniqname,
173+
"App": appname,
174+
"Preset": presetname,
175+
"SrcInfo": [
176+
{
177+
"Url": "rtmp://host/app/outernetStreamForSwitch",
178+
"Idx": 0
179+
},
180+
{
181+
"Streamid": "streamForSwitch",
182+
"Idx": 1
183+
}
184+
],
185+
"DstInfo": [
186+
{
187+
"Streamid":"stream0ForMonitor",
188+
"Idx": 0
189+
},
190+
{
191+
"Streamid": "stream1ForSwitch",
192+
"Idx": 1
193+
},
194+
{
195+
"Streamid": "stream2ForSwitch",
196+
"Idx": 2
197+
}
198+
]
199+
}
200+
res = client.CreateDirectorTask(param4)
201+
print json.dumps(res)
202+
203+
#更新选流任务
204+
param4["TaskID"] = taskid
205+
res = client.UpdateDirectorTask(param4)
206+
print json.dumps(res)
207+
208+
#查询选流任务
209+
res = client.QueryDirectorTask(App=appname, UniqName=uniqname, TaskID=taskid)
210+
print json.dumps(res)
211+
212+
#删除选流任务
213+
res = client.DelDirectorTask(App=appname, UniqName=uniqname, TaskID=taskid)
140214
print json.dumps(res)

kscore/data/ket/2017-01-01/service-2.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,27 @@ operations:
9595
http:
9696
method: GET
9797

98-
shapes:
98+
CreateDirectorTask:
99+
name: CreateDirectorTask
100+
http:
101+
method: POST
102+
103+
UpdateDirectorTask:
104+
name: UpdateDirectorTask
105+
http:
106+
method: POST
107+
108+
DelDirectorTask:
109+
name: DelDirectorTask
110+
http:
111+
method: GET
112+
113+
QueryDirectorTask:
114+
name: QueryDirectorTask
115+
http:
116+
method: GET
117+
118+
shapes:
99119
App:
100120
type: string
101121
UniqName:

kscore/ket.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,20 @@ def UpdateLoop(self,param):
4949
def GetLoopList(self,App='live',UniqName='',StreamID=''):
5050
return self.client.get_loop_list(App=App,UniqName=UniqName,StreamID=StreamID)
5151

52-
def GetLiveTransDuration(self,StartUnixTime,EndUnixTime,Granularity=5,ResultType=1):
53-
return self.client.get_live_trans_duration(StartUnixTime=StartUnixTime,EndUnixTime=EndUnixTime,Granularity=Granularity,ResultType=ResultType)
52+
def GetLiveTransDuration(self,StartUnixTime,EndUnixTime,UniqName='',Granularity=5,ResultType=1):
53+
return self.client.get_live_trans_duration(UniqName=UniqName,StartUnixTime=StartUnixTime,EndUnixTime=EndUnixTime,Granularity=Granularity,ResultType=ResultType)
54+
55+
def CreateDirectorTask(self,param):
56+
return self.client.create_director_task(**param)
57+
58+
def UpdateDirectorTask(self,param):
59+
return self.client.update_director_task(**param)
60+
61+
def QueryDirectorTask(self,App='live',UniqName='',TaskID=''):
62+
return self.client.query_director_task(App=App, UniqName=UniqName, TaskID=TaskID)
63+
64+
def DelDirectorTask(self,App='live',UniqName='',TaskID=''):
65+
return self.client.del_director_task(App=App, UniqName=UniqName, TaskID=TaskID)
5466

5567
def getKetClient(service_name,region_name,use_ssl=False,ks_access_key_id=None, ks_secret_access_key=None):
5668
return KetClient(service_name,region_name,use_ssl,ks_access_key_id, ks_secret_access_key)

0 commit comments

Comments
 (0)