文档首页/ 视频直播 Live/ 云直播API参考/ 拉流管理/ 修改直播拉流转推任务 - ModifyPullTask
更新时间:2026-06-03 GMT+08:00

修改直播拉流转推任务 - ModifyPullTask

功能介绍

修改直播拉流转推任务,仅当source_type为PullVodPushLive的任务生效

调用方法

请参见如何调用API

授权信息

账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。

  • 如果使用角色与策略授权,具体权限要求请参见权限和授权项
  • 如果使用身份策略授权,当前API调用无需身份策略权限。

URI

PUT /v1/{project_id}/pull/stream/task

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID,获取方法请参考获取项目ID

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token,使用Token鉴权方式时必填。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

表3 请求Body参数

参数

是否必选

参数类型

描述

task_id

String

参数解释

任务ID

约束限制

不涉及

取值范围

不涉及

默认取值

不涉及

status

String

参数解释

任务状态

约束限制

不涉及

取值范围

  • pause 停用

  • enable 启用

默认取值

不涉及

source_urls

Array of strings

参数解释

拉流源URL

约束限制

数组长度为[1,30]

vod_loop_time

String

参数解释

视频播放循环次数

约束限制

仅当source_type为PullVodPushLive生效

取值范围

  • -1:无限循环,以结束时间为准。

  • N:按文件列表播放N轮,以播放完成和结束时间先到的为准。

  • 不传、为空("")时,按缺省值生效。

默认取值

-1

vod_refresh_type

String

参数解释

视频地址路径更新source_urls后的生效形式

约束限制

仅当source_type为PullVodPushLive生效

取值范围

  • immediate_new_source:立即播放新的文件源

  • continue_from_file_start:从上次断流URL文件重新播放(更新任务时有效)

  • continue_from_break_point:从上次断流URL文件断流位置重新播放(更新任务时有效)

默认取值

immediate_new_source

vod_start_video_index

Integer

参数解释

播放文件索引,从0开始表示第一个文件,最大值 len(source_urls)-1

约束限制

仅当source_type为PullVodPushLive生效

默认取值

0

取值范围:

0~2147483647

start_time

String

参数解释

任务启动时间

约束限制

  • 时间格式:"2006-01-02T15:04:05Z"

  • 必须小于结束时间,缺省为当前时间

取值范围

不涉及

默认取值

不涉及

end_time

String

参数解释

任务结束时间

约束限制

  • 时间格式:"2006-01-02T15:04:05Z"

  • 必须大于开始时间,至多为开始时间+7天

取值范围

不涉及

默认取值

不涉及

vod_start_video_time

Integer

参数解释

指定从上述指定文件的第几秒开始播放

约束限制

仅当source_type为PullVodPushLive生效

默认取值

0

取值范围:

0~2147483647

callback_events

Array of strings

参数解释

要回调的事件列表(不填则回调全部)

  • TaskStart:任务启动回调

  • TaskExit:任务停止回调

  • VodSourceFileStart:仅PullVodPushLive可用,文件启动切换

  • VodSourceFileFinish:仅PullVodPushLive可用,文件播放完毕

  • ResetTaskConfig:仅PullVodPushLive可用,任务更新

  • TaskAlarm:用于告警事件通知

约束限制

不涉及

响应参数

状态码:200

表4 响应Body参数

参数

参数类型

描述

task_id

String

参数解释

任务ID

取值范围

不涉及

request_id

String

参数解释

请求ID

取值范围

不涉及

状态码:400

表5 响应Body参数

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误描述

request_id

String

请求id

请求示例

PUT https://{endpoint}/v1/{project_id}/pull/stream/task

{
  "task_id" : "xxxxxxxxxx",
  "status" : "pause",
  "source_urls" : [ "rtmp://play.example.huawei.com/live/stream1" ],
  "start_time" : "2018-05-19T18:00:00Z",
  "end_time" : "2018-05-19T21:00:00Z",
  "vod_loop_time" : "-1",
  "vod_refresh_type" : "immediate_new_source",
  "vod_start_video_index" : 0,
  "vod_start_video_time" : 0,
  "callback_events" : [ "TaskStart", "VodSourceFileStart", "VodSourceFileFinish", "ResetTaskConfig", "TaskExit", "TaskAlarm" ]
}

响应示例

状态码:200

修改直播拉流转推任务成功

{
  "task_id" : "7864b3dc-e92f-42db-a754-08e627b6d8dd",
  "request_id" : "85968475-e92f-42db-a754-08e627b6d8dd"
}

状态码:400

修改直播拉流转推任务失败

{
  "error_code" : "LIVE.100011001",
  "error_msg" : "Request Illegal",
  "request_id" : "85968475-e92f-42db-a754-08e627b6d8dd"
}

SDK代码示例

SDK代码示例如下。

 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
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.live.v1.region.LiveRegion;
import com.huaweicloud.sdk.live.v1.*;
import com.huaweicloud.sdk.live.v1.model.*;

import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.ArrayList;

public class ModifyPullTaskSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        LiveClient client = LiveClient.newBuilder()
                .withCredential(auth)
                .withRegion(LiveRegion.valueOf("<YOUR REGION>"))
                .build();
        ModifyPullTaskRequest request = new ModifyPullTaskRequest();
        ModifyLivePullStreamTask body = new ModifyLivePullStreamTask();
        List<ModifyLivePullStreamTask.CallbackEventsEnum> listbodyCallbackEvents = new ArrayList<>();
        listbodyCallbackEvents.add(ModifyLivePullStreamTask.CallbackEventsEnum.fromValue("TaskStart"));
        listbodyCallbackEvents.add(ModifyLivePullStreamTask.CallbackEventsEnum.fromValue("VodSourceFileStart"));
        listbodyCallbackEvents.add(ModifyLivePullStreamTask.CallbackEventsEnum.fromValue("VodSourceFileFinish"));
        listbodyCallbackEvents.add(ModifyLivePullStreamTask.CallbackEventsEnum.fromValue("ResetTaskConfig"));
        listbodyCallbackEvents.add(ModifyLivePullStreamTask.CallbackEventsEnum.fromValue("TaskExit"));
        listbodyCallbackEvents.add(ModifyLivePullStreamTask.CallbackEventsEnum.fromValue("TaskAlarm"));
        List<String> listbodySourceUrls = new ArrayList<>();
        listbodySourceUrls.add("rtmp://play.example.huawei.com/live/stream1");
        body.withCallbackEvents(listbodyCallbackEvents);
        body.withVodStartVideoTime(0);
        body.withEndTime(OffsetDateTime.parse("2018-05-19T21:00:00Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME));
        body.withStartTime(OffsetDateTime.parse("2018-05-19T18:00:00Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME));
        body.withVodStartVideoIndex(0);
        body.withVodRefreshType(ModifyLivePullStreamTask.VodRefreshTypeEnum.fromValue("immediate_new_source"));
        body.withVodLoopTime("-1");
        body.withSourceUrls(listbodySourceUrls);
        body.withStatus(ModifyLivePullStreamTask.StatusEnum.fromValue("pause"));
        body.withTaskId("xxxxxxxxxx");
        request.withBody(body);
        try {
            ModifyPullTaskResponse response = client.modifyPullTask(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
 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
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdklive.v1.region.live_region import LiveRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdklive.v1 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = LiveClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(LiveRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ModifyPullTaskRequest()
        listCallbackEventsbody = [
            "TaskStart",
            "VodSourceFileStart",
            "VodSourceFileFinish",
            "ResetTaskConfig",
            "TaskExit",
            "TaskAlarm"
        ]
        listSourceUrlsbody = [
            "rtmp://play.example.huawei.com/live/stream1"
        ]
        request.body = ModifyLivePullStreamTask(
            callback_events=listCallbackEventsbody,
            vod_start_video_time=0,
            end_time="2018-05-19T21:00:00Z",
            start_time="2018-05-19T18:00:00Z",
            vod_start_video_index=0,
            vod_refresh_type="immediate_new_source",
            vod_loop_time="-1",
            source_urls=listSourceUrlsbody,
            status="pause",
            task_id="xxxxxxxxxx"
        )
        response = client.modify_pull_task(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 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
package main

import (
	"fmt"
	"time"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/sdktime"
    live "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/live/v1"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/live/v1/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/live/v1/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth, err := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        SafeBuild()

    if err != nil {
        fmt.Println(err)
        return
    }

    hcClient, err := live.LiveClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()


    if err != nil {
        fmt.Println(err)
        return
    }

    client := live.NewLiveClient(hcClient)

    request := &model.ModifyPullTaskRequest{}
	var listCallbackEventsbody = []model.ModifyLivePullStreamTaskCallbackEvents{
        model.GetModifyLivePullStreamTaskCallbackEventsEnum().TASK_START,
	    model.GetModifyLivePullStreamTaskCallbackEventsEnum().VOD_SOURCE_FILE_START,
	    model.GetModifyLivePullStreamTaskCallbackEventsEnum().VOD_SOURCE_FILE_FINISH,
	    model.GetModifyLivePullStreamTaskCallbackEventsEnum().RESET_TASK_CONFIG,
	    model.GetModifyLivePullStreamTaskCallbackEventsEnum().TASK_EXIT,
	    model.GetModifyLivePullStreamTaskCallbackEventsEnum().TASK_ALARM,
    }
	var listSourceUrlsbody = []string{
        "rtmp://play.example.huawei.com/live/stream1",
    }
	vodStartVideoTimeModifyLivePullStreamTask:= int32(0)
	dateTimeEndTime, _ := time.ParseInLocation("2006-01-02T15:04:05Z", "2018-05-19T21:00:00Z", time.UTC)
	endTimeModifyLivePullStreamTask:= sdktime.SdkTime(dateTimeEndTime)
	dateTimeStartTime, _ := time.ParseInLocation("2006-01-02T15:04:05Z", "2018-05-19T18:00:00Z", time.UTC)
	startTimeModifyLivePullStreamTask:= sdktime.SdkTime(dateTimeStartTime)
	vodStartVideoIndexModifyLivePullStreamTask:= int32(0)
	vodRefreshTypeModifyLivePullStreamTask:= model.GetModifyLivePullStreamTaskVodRefreshTypeEnum().IMMEDIATE_NEW_SOURCE
	vodLoopTimeModifyLivePullStreamTask:= "-1"
	statusModifyLivePullStreamTask:= model.GetModifyLivePullStreamTaskStatusEnum().PAUSE
	request.Body = &model.ModifyLivePullStreamTask{
		CallbackEvents: &listCallbackEventsbody,
		VodStartVideoTime: &vodStartVideoTimeModifyLivePullStreamTask,
		EndTime: &endTimeModifyLivePullStreamTask,
		StartTime: &startTimeModifyLivePullStreamTask,
		VodStartVideoIndex: &vodStartVideoIndexModifyLivePullStreamTask,
		VodRefreshType: &vodRefreshTypeModifyLivePullStreamTask,
		VodLoopTime: &vodLoopTimeModifyLivePullStreamTask,
		SourceUrls: &listSourceUrlsbody,
		Status: &statusModifyLivePullStreamTask,
		TaskId: "xxxxxxxxxx",
	}
	response, err := client.ModifyPullTask(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

修改直播拉流转推任务成功

400

修改直播拉流转推任务失败

错误码

请参见错误码