Skip to content

Commit

Permalink
支持提交和获取音频审核任务
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnnqin committed Oct 8, 2021
1 parent 95b952a commit fbef488
Show file tree
Hide file tree
Showing 17 changed files with 490 additions and 59 deletions.
16 changes: 15 additions & 1 deletion QCloudCSharpSDK/COSXML/CosXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ public interface CosXml
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
SensitiveCencorJobResult SubmitVideoCensorJob(SubmitVideoCensorJobRequest request);
SubmitCensorJobResult SubmitVideoCensorJob(SubmitVideoCensorJobRequest request);

/// <summary>
/// 获取视频审核任务结果
Expand All @@ -1074,6 +1074,20 @@ public interface CosXml
/// <returns></returns>
GetVideoCensorJobResult GetVideoCensorJob(GetVideoCensorJobRequest request);

/// <summary>
/// 提交音频审核任务
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
SubmitCensorJobResult SubmitAudioCensorJob(SubmitAudioCensorJobRequest request);

/// <summary>
/// 获取音频审核任务结果
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
GetAudioCensorJobResult GetAudioCensorJob(GetAudioCensorJobRequest request);

/// <summary>
/// 获取媒体bucket列表
/// </summary>
Expand Down
26 changes: 24 additions & 2 deletions QCloudCSharpSDK/COSXML/CosXmlServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,10 +1078,10 @@ public GetMediaInfoResult GetMediaInfo(GetMediaInfoRequest request)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public SensitiveCencorJobResult SubmitVideoCensorJob(SubmitVideoCensorJobRequest request)
public SubmitCensorJobResult SubmitVideoCensorJob(SubmitVideoCensorJobRequest request)
{
request.Region = this.GetConfig().Region;
return Execute(request, new SensitiveCencorJobResult());
return Execute(request, new SubmitCensorJobResult());
}

/// <summary>
Expand All @@ -1095,6 +1095,28 @@ public GetVideoCensorJobResult GetVideoCensorJob(GetVideoCensorJobRequest reques
return Execute(request, new GetVideoCensorJobResult());
}

/// <summary>
/// 提交音频审核任务
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public SubmitCensorJobResult SubmitAudioCensorJob(SubmitAudioCensorJobRequest request)
{
request.Region = this.GetConfig().Region;
return Execute(request, new SubmitCensorJobResult());
}

/// <summary>
/// 获取音频审核任务结果
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public GetAudioCensorJobResult GetAudioCensorJob(GetAudioCensorJobRequest request)
{
request.Region = this.GetConfig().Region;
return Execute(request, new GetAudioCensorJobResult());
}

/// <summary>
/// 获取媒体bucket列表
/// </summary>
Expand Down
26 changes: 26 additions & 0 deletions QCloudCSharpSDK/COSXML/Model/CI/GetAudioCensorJobRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;

using System.Text;
using COSXML.Common;
using COSXML.Model.Object;
using COSXML.Model.Tag;
using COSXML.CosException;
using COSXML.Utils;

namespace COSXML.Model.CI
{
/// <summary>
/// 查询音频审核任务
/// <see href="https://cloud.tencent.com/document/product/436/54064"/>
/// </summary>
public sealed class GetAudioCensorJobRequest : CIRequest
{
public GetAudioCensorJobRequest(string bucket, string JobId)
: base(bucket)
{
this.method = CosRequestMethod.GET;
this.SetRequestPath("/audio/auditing/" + JobId);
}
}
}
22 changes: 22 additions & 0 deletions QCloudCSharpSDK/COSXML/Model/CI/GetAudioCensorJobResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.IO;
using System.Collections.Generic;
using COSXML.Model.Tag;
using COSXML.Transfer;

namespace COSXML.Model.CI
{
/// <summary>
/// 查询音频审核结果
/// </summary>
public sealed class GetAudioCensorJobResult : CosDataResult<AudioCensorResult>
{
/// <summary>
/// 音频审核结果
/// </summary>
/// <value></value>
public AudioCensorResult resultStruct {
get {return _data; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace COSXML.Model.CI
{
/// <summary>
/// 提交视频审核任务
/// 查询视频审核任务
/// <see href="https://cloud.tencent.com/document/product/436/47316"/>
/// </summary>
public sealed class GetVideoCensorJobRequest : CIRequest
Expand Down
2 changes: 1 addition & 1 deletion QCloudCSharpSDK/COSXML/Model/CI/GetVideoCensorJobResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace COSXML.Model.CI
{
/// <summary>
/// 图片审核结果
/// 视频审核结果
/// </summary>
public sealed class GetVideoCensorJobResult : CosDataResult<VideoCensorResult>
{
Expand Down
67 changes: 67 additions & 0 deletions QCloudCSharpSDK/COSXML/Model/CI/SubmitAudioCensorJobRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;

using System.Text;
using COSXML.Common;
using COSXML.Model.Object;
using COSXML.Model.Tag;
using COSXML.CosException;
using COSXML.Utils;

namespace COSXML.Model.CI
{
/// <summary>
/// 提交音频审核任务
/// <see href="https://cloud.tencent.com/document/product/436/54063"/>
/// </summary>
public sealed class SubmitAudioCensorJobRequest : CIRequest
{
public AudioCencorJobInfo audioCencorJobInfo;
public SubmitAudioCensorJobRequest(string bucket)
: base(bucket)
{
audioCencorJobInfo = new AudioCencorJobInfo();
this.method = CosRequestMethod.POST;
this.SetRequestPath("/audio/auditing");
this.SetRequestHeader("Content-Type", "application/xml");
audioCencorJobInfo.input = new AudioCencorJobInfo.Input();
audioCencorJobInfo.conf = new AudioCencorJobInfo.Conf();
}

public void SetCensorObject(string key)
{
audioCencorJobInfo.input.obj = key;
}

public void SetCensorUrl(string url)
{
audioCencorJobInfo.input.url = url;
}

public void SetDetectType(string detectType)
{
audioCencorJobInfo.conf.detectType = detectType;
}

public void SetCallback(string callbackUrl)
{
audioCencorJobInfo.conf.callback = callbackUrl;
}

public void SetCallbackVersion(string callbackVersion)
{
audioCencorJobInfo.conf.callbackVersion = callbackVersion;
}

public void SetBizType(string BizType)
{
audioCencorJobInfo.conf.bizType = BizType;
}

public override Network.RequestBody GetRequestBody()
{
return GetXmlRequestBody(audioCencorJobInfo);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace COSXML.Model.CI
/// <summary>
///
/// </summary>
public sealed class SensitiveCencorJobResult : CosDataResult<CensorJobsResponse>
public sealed class SubmitCensorJobResult : CosDataResult<CensorJobsResponse>
{

/// <summary>
Expand Down
13 changes: 10 additions & 3 deletions QCloudCSharpSDK/COSXML/Model/CI/SubmitVideoCensorJobRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ public SubmitVideoCensorJobRequest(string bucket)
videoCencorJobInfo = new VideoCencorJobInfo();
this.method = CosRequestMethod.POST;
this.SetRequestPath("/video/auditing");
this.SetRequestHeader("Content-Type", "application/xml");
videoCencorJobInfo.input = new VideoCencorJobInfo.Input();
videoCencorJobInfo.conf = new VideoCencorJobInfo.Conf();
videoCencorJobInfo.conf.snapshot = new VideoCencorJobInfo.Snapshot();
}

// TODO clean this
public void SetDebugBody()
{
throw new CosClientException(1,Transfer.XmlBuilder.Serialize(videoCencorJobInfo));
}

public void SetCensorObject(string key)
{
videoCencorJobInfo.input.obj = key;
Expand Down Expand Up @@ -58,7 +65,7 @@ public void SetDetectContent(int detectContent)
videoCencorJobInfo.conf.detectContent = detectContent.ToString();
}

public void SetSnapshotCount(string count, float timeInterval)
public void SetSnapshotCount(string count)
{
videoCencorJobInfo.conf.snapshot.count = count;
}
Expand All @@ -68,9 +75,9 @@ public void SetSnapshotMode(string mode)
videoCencorJobInfo.conf.snapshot.mode = mode;
}

public void SetSnapshotTimeInterval(float timeInterval)
public void SetSnapshotTimeInterval(string timeInterval)
{
videoCencorJobInfo.conf.snapshot.timeInterval = timeInterval.ToString();
videoCencorJobInfo.conf.snapshot.timeInterval = timeInterval;
}

public override Network.RequestBody GetRequestBody()
Expand Down
2 changes: 1 addition & 1 deletion QCloudCSharpSDK/COSXML/Model/Object/PostObjectRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private PostObjectRequest(string bucket, string key)
this.method = CosRequestMethod.POST;
formStruct = new FormStruct();
formStruct.key = key;
this.headers.Add(CosRequestHeaderKey.CONTENT_TYPE, "multipart/form-data; boundary=" + MultipartRequestBody.BOUNDARY);
this.SetHeader(CosRequestHeaderKey.CONTENT_TYPE, "multipart/form-data; boundary=" + MultipartRequestBody.BOUNDARY);
this.needMD5 = false;
}

Expand Down
98 changes: 98 additions & 0 deletions QCloudCSharpSDK/COSXML/Model/Tag/AudioCensorJobInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;

namespace COSXML.Model.Tag
{
/// <summary>
/// 音频审核请求body
/// <see href="https://cloud.tencent.com/document/product/436/54063"/>
/// </summary>
[XmlRoot("Request")]
public sealed class AudioCencorJobInfo
{
[XmlElement("Input")]
public Input input;

[XmlElement("Conf")]
public Conf conf;

public string GetInfo()
{
StringBuilder stringBuilder = new StringBuilder("{Request:\n");

stringBuilder.Append(input.GetInfo()).Append("\n");

stringBuilder.Append(conf.GetInfo()).Append("\n");

stringBuilder.Append("}");

return stringBuilder.ToString();
}

public sealed class Input
{
[XmlElement("Object")]
public string obj;

[XmlElement("Url")]
public string url;

public string GetInfo()
{
StringBuilder stringBuilder = new StringBuilder("{Input:\n");
if (obj != null)
{
stringBuilder.Append("Object:" + obj + "\n");
}
if (url != null)
{
stringBuilder.Append("Url:" + url + "\n");
}
stringBuilder.Append("}");
return stringBuilder.ToString();
}
}


public sealed class Conf
{
[XmlElement("DetectType")]
public string detectType;

[XmlElement("Callback")]
public string callback;

[XmlElement("CallbackVersion")]
public string callbackVersion;

[XmlElement("BizType")]
public string bizType;

public string GetInfo()
{
StringBuilder stringBuilder = new StringBuilder("{Conf:\n");

stringBuilder.Append("DetectType:").Append(detectType).Append("\n");
if (callback != null)
{
stringBuilder.Append("Callback:").Append(callback).Append("\n");
}
if (callbackVersion != null)
{
stringBuilder.Append("CallbackVersion:").Append(callbackVersion).Append("\n");
}
if (bizType != null)
{
stringBuilder.Append("BizType:").Append(bizType).Append("\n");
}
stringBuilder.Append("}");

return stringBuilder.ToString();
}
}

}

}
Loading

0 comments on commit fbef488

Please sign in to comment.