导航菜单

页面标题

页面副标题

新暖心缘 v8.1.1 - StreamManager.java 源代码

正在查看: 新暖心缘 v8.1.1 应用的 StreamManager.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.qiniu.qvs;

import com.qiniu.common.QiniuException;
import com.qiniu.http.Client;
import com.qiniu.http.Response;
import com.qiniu.qvs.model.DynamicLiveRoute;
import com.qiniu.qvs.model.PatchOperation;
import com.qiniu.qvs.model.StaticLiveRoute;
import com.qiniu.qvs.model.Stream;
import com.qiniu.util.Auth;
import com.qiniu.util.StringMap;
import com.qiniu.util.UrlUtils;
import com.tencent.open.SocialConstants;

public class StreamManager {
    private final String apiServer;
    private final Auth auth;
    private final Client client;

    public StreamManager(Auth auth) {
        this(auth, "http://qvs.qiniuapi.com");
    }

    public Response createStream(String str, Stream stream) throws QiniuException {
        StringMap stringMap = new StringMap();
        stringMap.putNotNull("streamId", stream.getStreamID());
        stringMap.putNotNull(SocialConstants.PARAM_APP_DESC, stream.getDesc());
        stringMap.putNotNull("recordTemplateId", stream.getRecordTemplateId());
        stringMap.putNotNull("snapshotTemplateId", stream.getSnapShotTemplateId());
        return QvsResponse.post(String.format("%s/v1/namespaces/%s/streams", this.apiServer, str), stringMap, this.client, this.auth);
    }

    public Response deleteStream(String str, String str2) throws QiniuException {
        return QvsResponse.delete(String.format("%s/v1/namespaces/%s/streams/%s", this.apiServer, str, str2), this.client, this.auth);
    }

    public Response disableStream(String str, String str2) throws QiniuException {
        return QvsResponse.post(String.format("%s/v1/namespaces/%s/streams/%s/disabled", this.apiServer, str, str2), null, this.client, this.auth);
    }

    public Response dynamicPublishPlayURL(String str, String str2, DynamicLiveRoute dynamicLiveRoute) throws QiniuException {
        StringMap stringMap = new StringMap();
        stringMap.put("PublishIP", dynamicLiveRoute.getPublishIP());
        stringMap.put("PlayIP", dynamicLiveRoute.getPlayIP());
        stringMap.putNotNull("UrlExpireSec", Integer.valueOf(dynamicLiveRoute.getUrlExpireSec()));
        return QvsResponse.post(String.format("%s/v1/namespaces/%s/streams/%s/urls", this.apiServer, str, str2), stringMap, this.client, this.auth);
    }

    public Response enableStream(String str, String str2) throws QiniuException {
        return QvsResponse.post(String.format("%s/v1/namespaces/%s/streams/%s/enabled", this.apiServer, str, str2), null, this.client, this.auth);
    }

    public Response listStream(String str, int i8, int i9, int i10, String str2, String str3) throws QiniuException {
        return QvsResponse.get(UrlUtils.composeUrlWithQueries(String.format("%s/v1/namespaces/%s/streams", this.apiServer, str), new StringMap().put("offset", Integer.valueOf(i8)).put("line", Integer.valueOf(i9)).put("qtype", Integer.valueOf(i10)).putNotEmpty("prefix", str2).putNotEmpty("sortBy", str3)), this.client, this.auth);
    }

    public Response queryStream(String str, String str2) throws QiniuException {
        return QvsResponse.get(String.format("%s/v1/namespaces/%s/streams/%s", this.apiServer, str, str2), this.client, this.auth);
    }

    public Response queryStreamCover(String str, String str2) throws QiniuException {
        return QvsResponse.get(String.format("%s/v1/namespaces/%s/streams/%s/cover", this.apiServer, str, str2), this.client, this.auth);
    }

    public Response queryStreamPubHistories(String str, String str2, int i8, int i9, int i10, int i11) throws QiniuException {
        if (i8 > 0 && i9 >= 0 && (i8 < i9 || i9 == 0)) {
            return QvsResponse.get(UrlUtils.composeUrlWithQueries(String.format("%s/v1/namespaces/%s/streams/%s/pubhistories", this.apiServer, str, str2), new StringMap().put("start", Integer.valueOf(i8)).put("end", Integer.valueOf(i9)).putNotNull("offset", Integer.valueOf(i10)).putNotNull("line", Integer.valueOf(i11))), this.client, this.auth);
        }
        throw new QiniuException(new IllegalArgumentException("bad argument" + i8 + "," + i9));
    }

    public Response queryStreamRecordHistories(String str, String str2, int i8, int i9, int i10, String str3) throws QiniuException {
        if (i8 > 0 && i9 >= 0 && (i8 < i9 || i9 == 0)) {
            return QvsResponse.get(UrlUtils.composeUrlWithQueries(String.format("%s/v1/namespaces/%s/streams/%s/recordhistories", this.apiServer, str, str2), new StringMap().put("start", Integer.valueOf(i8)).put("end", Integer.valueOf(i9)).putNotNull("line", Integer.valueOf(i10)).putNotEmpty("marker", str3)), this.client, this.auth);
        }
        throw new QiniuException(new IllegalArgumentException("bad argument" + i8 + "," + i9));
    }

    public Response staticPublishPlayURL(String str, String str2, StaticLiveRoute staticLiveRoute) throws QiniuException {
        return QvsResponse.post(String.format("%s/v1/namespaces/%s/streams/%s/domain", this.apiServer, str, str2), new StringMap().put("Domain", staticLiveRoute.getDomain()).put("DomainType", staticLiveRoute.getDomainType()).putNotNull("UrlExpireSec", Integer.valueOf(staticLiveRoute.getUrlExpireSec())), this.client, this.auth);
    }

    public Response streamsSnapshots(String str, String str2, int i8, int i9, int i10, int i11, String str3) throws QiniuException {
        if (i8 > 0 && i9 >= 0 && (i8 < i9 || i9 == 0)) {
            return QvsResponse.get(UrlUtils.composeUrlWithQueries(String.format("%s/v1/namespaces/%s/streams/%s/snapshots", this.apiServer, str, str2), new StringMap().put("start", Integer.valueOf(i8)).put("end", Integer.valueOf(i9)).putNotNull("line", Integer.valueOf(i11)).putNotEmpty("marker", str3).put("type", Integer.valueOf(i10))), this.client, this.auth);
        }
        throw new QiniuException(new IllegalArgumentException("bad argument" + i8 + "," + i9));
    }

    public Response updateStream(String str, String str2, PatchOperation[] patchOperationArr) throws QiniuException {
        return QvsResponse.patch(String.format("%s/v1/namespaces/%s/streams/%s", this.apiServer, str, str2), new StringMap().put("operations", patchOperationArr), this.client, this.auth);
    }

    public StreamManager(Auth auth, String str) {
        this(auth, str, new Client());
    }

    public StreamManager(Auth auth, String str, Client client) {
        this.auth = auth;
        this.apiServer = str;
        this.client = client;
    }
}