auditing_req.h 104 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128
  1. #pragma once
  2. #include <sstream>
  3. #include <string>
  4. #include <vector>
  5. #include "Poco/Dynamic/Struct.h"
  6. #include "Poco/JSON/Object.h"
  7. #include "request/bucket_req.h"
  8. #include "request/object_req.h"
  9. namespace qcloud_cos {
  10. class Location {
  11. public:
  12. Location() : m_mask(0x00000000u) {}
  13. virtual ~Location() {}
  14. void SetX(const float x) {
  15. m_mask |= 0x00000001u;
  16. m_x = x;
  17. }
  18. void SetY(const float y) {
  19. m_mask |= 0x00000002u;
  20. m_y = y;
  21. }
  22. void SetWidth(const float width) {
  23. m_mask |= 0x00000004u;
  24. m_width = width;
  25. }
  26. void SetHeight(const float height) {
  27. m_mask |= 0x00000008u;
  28. m_height = height;
  29. }
  30. void SetRotate(const float rotate) {
  31. m_mask |= 0x00000010u;
  32. m_rotate = rotate;
  33. }
  34. float GetX() const { return m_x; }
  35. float GetY() const { return m_y; }
  36. float GetWidth() const { return m_width; }
  37. float GetHeight() const { return m_height; }
  38. float GetRotate() const { return m_rotate; }
  39. bool HasX() const { return (m_mask & 0x00000001u) != 0; }
  40. bool HasY() const { return (m_mask & 0x00000002u) != 0; }
  41. bool HasWidth() const { return (m_mask & 0x00000004u) != 0; }
  42. bool HasHeight() const { return (m_mask & 0x00000008u) != 0; }
  43. bool HasRotate() const { return (m_mask & 0x00000010u) != 0; }
  44. std::string to_string() const {
  45. std::stringstream ss;
  46. if (HasX()) { ss << " x: " << std::to_string(m_x); }
  47. if (HasY()) { ss << " y: " << std::to_string(m_y); }
  48. if (HasWidth()) { ss << " width: " << std::to_string(m_width); }
  49. if (HasHeight()) { ss << " height: " << std::to_string(m_height); }
  50. if (HasRotate()) { ss << " rotate: " << std::to_string(m_rotate); }
  51. return ss.str();
  52. }
  53. private:
  54. uint64_t m_mask;
  55. float m_x; // 该参数用于返回检测框左上角位置的横坐标(x)所在的像素位置,结合剩余参数可唯一确定检测框的大小和位置
  56. float m_y; // 该参数用于返回检测框左上角位置的纵坐标(y)所在的像素位置,结合剩余参数可唯一确定检测框的大小和位置
  57. float m_width; // 该参数用于返回检测框的宽度(由左上角出发在 x 轴向右延伸的长度),结合剩余参数可唯一确定检测框的大小和位置
  58. float m_height; // 该参数用于返回检测框的高度(由左上角出发在 y 轴向下延伸的长度),结合剩余参数可唯一确定检测框的大小和位置
  59. float m_rotate; // 该参数用于返回检测框的旋转角度,该参数结合 X 和 Y 两个坐标参数可唯一确定检测框的具体位置;取值:0-360(角度制),方向为逆时针旋转
  60. };
  61. class OcrResult {
  62. public:
  63. OcrResult() : m_mask(0x00000000u) {}
  64. virtual ~OcrResult() {}
  65. void SetText(const std::string& text) {
  66. m_mask |= 0x00000001u;
  67. m_text = text;
  68. }
  69. void SetKeyWords(const std::vector<std::string>& key_words) {
  70. m_mask |= 0x00000002u;
  71. m_key_words = key_words;
  72. }
  73. void AddKeyWord(const std::string& key_word) {
  74. m_mask |= 0x00000002u;
  75. m_key_words.push_back(key_word);
  76. }
  77. void SetLocation(const Location& location) {
  78. m_mask |= 0x00000004u;
  79. m_location = location;
  80. }
  81. std::string GetText() const { return m_text; }
  82. std::vector<std::string> GetKeyWords() const { return m_key_words; }
  83. Location GetLocation() const { return m_location; }
  84. bool HasText() const { return (m_mask & 0x00000001u) != 0; }
  85. bool HasKeyWords() const { return (m_mask & 0x00000002u) != 0; }
  86. bool HasLocation() const { return (m_mask & 0x00000004u) != 0; }
  87. std::string to_string() const {
  88. std::stringstream ss;
  89. if (HasText()) {
  90. ss << " text: " << m_text;
  91. }
  92. if (HasKeyWords()) {
  93. for (std::vector<std::string>::const_iterator it = m_key_words.begin();
  94. it != m_key_words.end(); ++it) {
  95. if (it == m_key_words.begin()) {
  96. ss << " keywords: " << it->c_str();
  97. continue;
  98. }
  99. ss << "," << it->c_str();
  100. }
  101. }
  102. if (HasLocation()) {
  103. ss << " Location: " << m_location.to_string();
  104. }
  105. return ss.str();
  106. }
  107. private:
  108. uint64_t m_mask;
  109. std::string m_text; // 图片 OCR 文本识别出的具体文本内容
  110. std::vector<std::string> m_key_words; // 在当前审核场景下命中的关键词
  111. Location m_location; // 该参数用于返回 OCR 检测框在图片中的位置(左上角 xy 坐标、长宽、旋转角度),以方便快速定位识别文字的相关信息
  112. };
  113. class ObjectResults {
  114. public:
  115. ObjectResults() : m_mask(0x00000000u) {}
  116. virtual ~ObjectResults() {}
  117. void SetName(const std::string& name) {
  118. m_mask |= 0x00000001u;
  119. m_name = name;
  120. }
  121. void SetLocation(const Location& location) {
  122. m_mask |= 0x00000002u;
  123. m_location = location;
  124. }
  125. std::string GetName() const { return m_name; }
  126. Location GetLocation() const { return m_location; }
  127. bool HasName() const { return (m_mask & 0x00000001u) != 0; }
  128. bool HasLocation() const { return (m_mask & 0x00000002u) != 0; }
  129. std::string to_string() const {
  130. std::stringstream ss;
  131. if (HasName()) {
  132. ss << " name: " << m_name;
  133. }
  134. if (HasLocation()) {
  135. ss << " location: " << m_location.to_string();
  136. }
  137. return ss.str();
  138. }
  139. private:
  140. uint64_t m_mask;
  141. std::string m_name; // 识别出的实体名称
  142. Location m_location; // 检测结果在图片中的位置信息
  143. };
  144. class RecognitionResult {
  145. public:
  146. RecognitionResult() : m_mask(0x00000000u) {}
  147. virtual ~RecognitionResult() {}
  148. void SetLable(const std::string& label) {
  149. m_mask |= 0x00000001u;
  150. m_Label = label;
  151. }
  152. void SetScore(const int score) {
  153. m_mask |= 0x00000002u;
  154. m_score = score;
  155. }
  156. void SetStartTime(const int start_time) {
  157. m_mask |= 0x00000004u;
  158. m_start_time = start_time;
  159. }
  160. void SetEndTime(const int end_time) {
  161. m_mask |= 0x00000008u;
  162. m_end_time = end_time;
  163. }
  164. std::string GetLabel() const { return m_Label; }
  165. int GetScore() const { return m_score; }
  166. int GetStartTime() const { return m_start_time; }
  167. int GetEndTime() const { return m_end_time; }
  168. bool HasLabel() const { return (m_mask & 0x00000001u) != 0; }
  169. bool HasScore() const { return (m_mask & 0x00000002u) != 0; }
  170. bool HasStartTime() const { return (m_mask & 0x00000004u) != 0; }
  171. bool HasEndTime() const { return (m_mask & 0x00000008u) != 0; }
  172. std::string to_string() const {
  173. std::stringstream ss;
  174. if (HasLabel()) { ss << " label: " << m_Label; }
  175. if (HasScore()) { ss << " score: " << m_score; }
  176. if (HasStartTime()) { ss << " start_time: " << m_start_time; }
  177. if (HasEndTime()) { ss << " end_time: " << m_end_time; }
  178. return ss.str();
  179. }
  180. private:
  181. uint64_t m_mask;
  182. std::string m_Label; // 该字段表示对应的识别结果类型信息
  183. int m_score; // 该字段表示审核结果命中审核信息的置信度,取值范围:0(置信度最低)-100(置信度最高),越高代表音频越有可能属于当前返回的标签
  184. int m_start_time; // 该字段表示对应标签的片段在音频文件内的开始时间,单位为毫秒。注意:此字段可能未返回,表示取不到有效值
  185. int m_end_time; // 该字段表示对应标签的片段在音频文件内的结束时间,单位为毫秒。注意:此字段可能未返回,表示取不到有效值
  186. };
  187. class LibResults {
  188. public:
  189. LibResults() : m_mask(0x00000000u) {}
  190. virtual ~LibResults() {}
  191. void SetLibType(const int lib_type) {
  192. m_mask |= 0x00000001u;
  193. m_lib_type = lib_type;
  194. }
  195. void SetLibName(const std::string& lib_name) {
  196. m_mask |= 0x00000002u;
  197. m_lib_name = lib_name;
  198. }
  199. void SetKeyWords(const std::vector<std::string>& key_words) {
  200. m_mask |= 0x00000004u;
  201. m_key_words = key_words;
  202. }
  203. void AddKeyWord(const std::string& keyword) {
  204. m_mask |= 0x00000004u;
  205. m_key_words.push_back(keyword);
  206. }
  207. int GetLibType() const { return m_lib_type; }
  208. std::string GetLibName() const { return m_lib_name; }
  209. std::vector<std::string> GetKeyWords() const { return m_key_words; }
  210. bool HasLibType() const { return (m_mask & 0x00000001u) != 0; }
  211. bool HasLibName() const { return (m_mask & 0x00000001u) != 0; }
  212. bool HasKeyWords() const { return (m_mask & 0x00000001u) != 0; }
  213. std::string to_string() const {
  214. std::stringstream ss;
  215. if (HasLibType()) {
  216. ss << " lib_type: " << m_lib_type;
  217. }
  218. if (HasLibName()) {
  219. ss << " lib_name: " << m_lib_name;
  220. }
  221. if (HasKeyWords()) {
  222. for (std::vector<std::string>::const_iterator it = m_key_words.begin();
  223. it != m_key_words.end(); ++it) {
  224. if (it == m_key_words.begin()) {
  225. ss << " keywords: " << it->c_str();
  226. continue;
  227. }
  228. ss << "," << it->c_str();
  229. }
  230. }
  231. return ss.str();
  232. }
  233. private:
  234. uint64_t m_mask;
  235. int m_lib_type; // 命中的风险库类型,取值为1(预设黑白库)和2(自定义风险库)
  236. std::string m_lib_name; // 命中的风险库名称
  237. std::vector<std::string> m_key_words; // 命中的库中关键词
  238. };
  239. class SceneResultInfo {
  240. public:
  241. SceneResultInfo() : m_mask(0x00000000u) {}
  242. virtual ~SceneResultInfo() {}
  243. void SetCode(const int code) {
  244. m_mask |= 0x00000001u;
  245. m_code = code;
  246. }
  247. void SetMsg(const std::string &msg) {
  248. m_mask |= 0x00000002u;
  249. m_msg = msg;
  250. }
  251. void SetHitFlag(const int hit_flag) {
  252. m_mask |= 0x00000004u;
  253. m_hit_flag = hit_flag;
  254. }
  255. void SetScore(const int score) {
  256. m_mask |= 0x00000008u;
  257. m_score = score;
  258. }
  259. void SetLabel(const std::string& label) {
  260. m_mask |= 0x00000010u;
  261. m_label = label;
  262. }
  263. void SetCategory(const std::string& category) {
  264. m_mask |= 0x00000020u;
  265. m_category = category;
  266. }
  267. void SetSubLabel(const std::string& sub_label) {
  268. m_mask |= 0x00000040u;
  269. m_sub_label = sub_label;
  270. }
  271. void SetCount(const int count) {
  272. m_mask |= 0x00000080u;
  273. m_count = count;
  274. }
  275. void SetOcrResults(const std::vector<OcrResult>& ocr_results) {
  276. m_mask |= 0x00000100u;
  277. m_ocr_results = ocr_results;
  278. }
  279. void AddOcrResults(const OcrResult& ocr_results) {
  280. m_mask |= 0x00000100u;
  281. m_ocr_results.push_back(ocr_results);
  282. }
  283. void SetObjectResults(const ObjectResults& object_results) {
  284. m_mask |= 0x00000200u;
  285. m_object_results = object_results;
  286. }
  287. void SetKeyWords(const std::vector<std::string>& key_words) {
  288. m_mask |= 0x00000400u;
  289. m_key_words = key_words;
  290. }
  291. void AddKeyWord(const std::string& key_word) {
  292. m_mask |= 0x00000400u;
  293. m_key_words.push_back(key_word);
  294. }
  295. void SetLibResult(const std::vector<LibResults>& results) {
  296. m_mask |= 0x00000800u;
  297. m_lib_results = results;
  298. }
  299. void AddLibResult(const LibResults& results) {
  300. m_mask |= 0x00000800u;
  301. m_lib_results.push_back(results);
  302. }
  303. void SetSpeakerResults(const std::vector<RecognitionResult>& results) {
  304. m_mask |= 0x00001000u;
  305. m_speaker_results = results;
  306. }
  307. void AddSpeakerResult(const RecognitionResult& result) {
  308. m_mask |= 0x00001000u;
  309. m_speaker_results.push_back(result);
  310. }
  311. void SetRecognitionResults(const std::vector<RecognitionResult>& results) {
  312. m_mask |= 0x00002000u;
  313. m_recognition_results = results;
  314. }
  315. void AddRecognitionResult(const RecognitionResult& result) {
  316. m_mask |= 0x00002000u;
  317. m_recognition_results.push_back(result);
  318. }
  319. int GetCode() const { return m_code; }
  320. int GetHitFlag() const { return m_hit_flag; }
  321. std::string GetMsg() const { return m_msg; }
  322. int GetScore() const { return m_score; }
  323. std::string GetLabel() const { return m_label; }
  324. std::string GetCategory() const { return m_category; }
  325. std::string GetSubLabel() const { return m_sub_label; }
  326. int GetCount() const { return m_count; }
  327. std::vector<OcrResult> GetOcrResults() const { return m_ocr_results; }
  328. ObjectResults GetObjectResults() const { return m_object_results; }
  329. std::vector<std::string> GetKeyWords() const { return m_key_words; }
  330. std::vector<LibResults> GetLibResults() const { return m_lib_results; }
  331. std::vector<RecognitionResult> GetRecognitionResults() const { return m_recognition_results; }
  332. std::vector<RecognitionResult> GetSpeakerResults() const { return m_speaker_results; }
  333. bool HasCode() const { return (m_mask & 0x00000001u) != 0; }
  334. bool HasMsg() const { return (m_mask & 0x00000002u) != 0; }
  335. bool HasHitFlag() const { return (m_mask & 0x00000004u) != 0; }
  336. bool HasScore() const { return (m_mask & 0x00000008u) != 0; }
  337. bool HasLabel() const { return (m_mask & 0x00000010u) != 0; }
  338. bool HasCategory() const { return (m_mask & 0x00000020u) != 0; }
  339. bool HasSubLabel() const { return (m_mask & 0x00000040u) != 0; }
  340. bool HasCount() const { return (m_mask & 0x00000080u) != 0; }
  341. bool HasOcrResults() const { return (m_mask & 0x00000100u) != 0; }
  342. bool HasObjectresults() const { return (m_mask & 0x00000200u) != 0; }
  343. bool HasKeyWords() const { return (m_mask & 0x00000400u) != 0; }
  344. bool HasLibResults() const { return (m_mask & 0x00000800u) != 0; }
  345. bool HasSpeakerResults() const { return (m_mask & 0x00001000u) != 0; }
  346. bool HasRecognitionResults() const { return (m_mask & 0x00002000u) != 0; }
  347. std::string to_string() const {
  348. std::stringstream ss;
  349. if (HasCode()) { ss << " code: " << std::to_string(m_code); }
  350. if (HasMsg()) { ss << " msg: " << m_msg; }
  351. if (HasHitFlag()) { ss << " hit_flag: " << std::to_string(m_hit_flag); }
  352. if (HasScore()) { ss << " score: " << std::to_string(m_score); }
  353. if (HasLabel()) { ss << " label: " << m_label; }
  354. if (HasCategory()) { ss << " category: " << m_category; }
  355. if (HasSubLabel()) { ss << " sub_label: " << m_sub_label; }
  356. if (HasCount()) { ss << " count: " << m_count; }
  357. if (HasOcrResults()) {
  358. for (std::vector<OcrResult>::const_iterator it = m_ocr_results.begin();
  359. it != m_ocr_results.end(); ++it) {
  360. ss << " ocr_result: {" << it->to_string() << "}";
  361. }
  362. }
  363. if (HasObjectresults()) { ss << " object_result: {" << m_object_results.to_string() << "}"; }
  364. if (HasKeyWords()) {
  365. for (std::vector<std::string>::const_iterator it = m_key_words.begin();
  366. it != m_key_words.end(); ++it) {
  367. if (it == m_key_words.begin()) {
  368. ss << " keywords: " << it->c_str();
  369. continue;
  370. }
  371. ss << "," << it->c_str();
  372. }
  373. }
  374. if (HasLibResults()) {
  375. for (std::vector<LibResults>::const_iterator it = m_lib_results.begin();
  376. it != m_lib_results.end(); ++it) {
  377. if (it == m_lib_results.begin()) {
  378. ss << " lib_results: " << it->to_string();
  379. continue;
  380. }
  381. ss << "," << it->to_string();
  382. }
  383. }
  384. if (HasSpeakerResults()) {
  385. for (std::vector<RecognitionResult>::const_iterator it = m_speaker_results.begin();
  386. it != m_speaker_results.end(); ++it) {
  387. if (it == m_speaker_results.begin()) {
  388. ss << " speaker_results: " << it->to_string();
  389. continue;
  390. }
  391. ss << "," << it->to_string();
  392. }
  393. }
  394. if (HasRecognitionResults()) {
  395. for (std::vector<RecognitionResult>::const_iterator it = m_recognition_results.begin();
  396. it != m_recognition_results.end(); ++it) {
  397. if (it == m_recognition_results.begin()) {
  398. ss << " recognition_results: " << it->to_string();
  399. continue;
  400. }
  401. ss << "," << it->to_string();
  402. }
  403. }
  404. return ss.str();
  405. }
  406. private:
  407. uint64_t m_mask;
  408. int m_code; // 单个审核场景的错误码,0为成功,其他为失败
  409. std::string m_msg; // 具体错误信息,如正常为OK
  410. int m_hit_flag; // 是否命中该审核分类,0表示未命中,1表示命中,2表示疑似
  411. int m_score; // 该字段表示审核结果命中审核信息的置信度,取值范围:0(置信度最低)-100(置信度最高),越高代表该内容越有可能属于当前返回审核信息
  412. // 其中0 - 60分表示图片正常,61 - 90分表示图片疑似敏感,91 - 100分表示图片确定敏感
  413. std::string m_label; // 该字段表示该截图的综合结果标签(可能为 SubLabel,可能为人物名字等)
  414. std::string m_category; // 该字段为Label的子集,表示审核命中的具体审核类别。例如 Sexy,表示色情标签中的性感类别
  415. std::string m_sub_label; // 该字段表示审核命中的具体子标签,例如:Porn 下的 SexBehavior 子标签。 可能为空,表示未命中字段
  416. int m_count; // 命中审核分类的截图数量
  417. std::vector<OcrResult> m_ocr_results; // OCR 文本识别的详细检测结果,包括文本坐标信息、文本识别结果等信息,有相关违规内容时返回
  418. ObjectResults m_object_results; // 识别出的实体详细检测结果,包括实体名和在图片中的详细位置
  419. std::vector<std::string> m_key_words; // 当前审核场景下命中的关键词
  420. std::vector<LibResults> m_lib_results; // 该字段用于返回基于风险库识别的结果。注意:未命中风险库中样本时,此字段不返回。
  421. std::vector<RecognitionResult> m_speaker_results; // 该字段表示声纹的识别详细结果。注意:未开启该功能时不返回该字段。
  422. std::vector<RecognitionResult> m_recognition_results; // 该字段表示未成年的识别详细结果。注意:未开启该功能时不返回该字段。
  423. };
  424. class UserInfo {
  425. public:
  426. UserInfo(): m_mask(0x00000000u) {}
  427. virtual ~UserInfo() {}
  428. void SetTokenId(const std::string& token_id) {
  429. m_mask |= 0x00000001u;
  430. m_token_id = token_id;
  431. }
  432. void SetNickName(const std::string& nick_name) {
  433. m_mask |= 0x00000002u;
  434. m_nick_name = nick_name;
  435. }
  436. void SetDeviceId(const std::string& device_id) {
  437. m_mask |= 0x00000004u;
  438. m_device_id = device_id;
  439. }
  440. void SetAppId(const std::string& app_id) {
  441. m_mask |= 0x00000008u;
  442. m_app_id = app_id;
  443. }
  444. void SetRoom(const std::string& room) {
  445. m_mask |= 0x00000010u;
  446. m_room = room;
  447. }
  448. void SetIp(const std::string& ip) {
  449. m_mask |= 0x00000020u;
  450. m_ip = ip;
  451. }
  452. void SetType(const std::string& type) {
  453. m_mask |= 0x00000040u;
  454. m_type = type;
  455. }
  456. void SetReceiveTokenId(const std::string& token_id) {
  457. m_mask |= 0x00000080u;
  458. m_receive_token_id = token_id;
  459. }
  460. void SetGender(const std::string& gender) {
  461. m_mask |= 0x00000100u;
  462. m_gender = gender;
  463. }
  464. void SetLevel(const std::string& level) {
  465. m_mask |= 0x00000200u;
  466. m_level = level;
  467. }
  468. void SetRole(const std::string& role) {
  469. m_mask |= 0x00000400u;
  470. m_role = role;
  471. }
  472. std::string GetTokenId() const { return m_token_id; }
  473. std::string GetNickName() const { return m_nick_name; }
  474. std::string GetDeviceId() const { return m_device_id; }
  475. std::string GetAppId() const { return m_app_id; }
  476. std::string GetRoom() const { return m_device_id; }
  477. std::string GetIp() const { return m_ip; }
  478. std::string GetType() const { return m_type; }
  479. std::string GetReceiveTokenId() const { return m_receive_token_id; }
  480. std::string GetGender() const { return m_gender; }
  481. std::string GetLevel() const { return m_level; }
  482. std::string GetRole() const { return m_role;}
  483. bool HasTokenId() const { return (m_mask & 0x00000001u) != 0; }
  484. bool HasNickName() const { return (m_mask & 0x00000002u) != 0; }
  485. bool HasDeviceId() const { return (m_mask & 0x00000004u) != 0; }
  486. bool HasAppId() const { return (m_mask & 0x00000008u) != 0; }
  487. bool HasRoom() const { return (m_mask & 0x00000010u) != 0; }
  488. bool HasIp() const { return (m_mask & 0x00000020u) != 0; }
  489. bool HasType() const { return (m_mask & 0x00000040u) != 0; }
  490. bool HasReceiveTokenId() const { return (m_mask & 0x00000080u) != 0; }
  491. bool HasGender() const { return (m_mask & 0x00000100u) != 0; }
  492. bool HasLevel() const { return (m_mask & 0x00000200u) != 0; }
  493. bool HasRole() const { return (m_mask & 0x00000400u) != 0; }
  494. std::string to_string() const {
  495. std::stringstream ss;
  496. if (HasTokenId()) { ss << " token_id: " << m_token_id; }
  497. if (HasNickName()) { ss << " nick_name: " << m_nick_name; }
  498. if (HasDeviceId()) { ss << " device_id: " << m_device_id; }
  499. if (HasAppId()) { ss << " app_id: " << m_app_id; }
  500. if (HasRoom()) { ss << " room: " << m_room; }
  501. if (HasIp()) { ss << " ip: " << m_ip; }
  502. if (HasType()) { ss << " type: " << m_type; }
  503. if (HasReceiveTokenId()) { ss << " receive_token_id: " << m_receive_token_id; }
  504. if (HasGender()) { ss << " gender: " << m_gender; }
  505. if (HasLevel()) { ss << " level: " << m_level; }
  506. if (HasRole()) { ss << " role: " << m_role; }
  507. return ss.str();
  508. }
  509. private:
  510. uint64_t m_mask;
  511. std::string m_token_id; // 用户业务 TokenId,长度不超过128字节
  512. std::string m_nick_name; // 用户业务 Nickname,长度不超过128字节
  513. std::string m_device_id; // 用户业务 DeviceId,长度不超过128字节
  514. std::string m_app_id; // 用户业务 AppId,长度不超过128字节
  515. std::string m_room; // 用户业务 room,长度不超过128字节
  516. std::string m_ip; // 用户业务 IP,长度不超过128字节
  517. std::string m_type; // 用户业务 type,长度不超过128字节
  518. std::string m_receive_token_id; // 接收消息的用户账号,长度不超过128字节
  519. std::string m_gender; // 一般用于表示性别信息,长度不超过128字节
  520. std::string m_level; // 一般用于表示等级信息,长度不超过128字节
  521. std::string m_role; // 一般用于表示角色信息,长度不超过128字节
  522. };
  523. class SegmentResult {
  524. public:
  525. SegmentResult() : m_mask(0x00000000) {}
  526. virtual ~SegmentResult() {}
  527. void SetUrl(const std::string &url) {
  528. m_mask |= 0x00000001u;
  529. m_url = url;
  530. }
  531. void SetSnapShotTime(int snap_shot_time) {
  532. m_mask |= 0x00000002u;
  533. m_snap_shot_time = snap_shot_time;
  534. }
  535. void SetOffsetTime(int offset_time) {
  536. m_mask |= 0x00000004u;
  537. m_offset_time = offset_time;
  538. }
  539. void SetDuration(int duration) {
  540. m_mask |= 0x00000008u;
  541. m_duration = duration;
  542. }
  543. void SetText(const std::string& text) {
  544. m_mask |= 0x00000010u;
  545. m_text = text;
  546. }
  547. void SetLabel(const std::string& label) {
  548. m_mask |= 0x00000020u;
  549. m_label = label;
  550. }
  551. void SetResult(int result) {
  552. m_mask |= 0x00000040u;
  553. m_result = result;
  554. }
  555. void SetPornInfo(const SceneResultInfo& porn_info) {
  556. m_mask |= 0x00000080u;
  557. m_porn_info = porn_info;
  558. }
  559. void SetAdsInfo(const SceneResultInfo& ads_info) {
  560. m_mask |= 0x00000100u;
  561. m_ads_info = ads_info;
  562. }
  563. void SetIllegalInfo(const SceneResultInfo& illegal_info) {
  564. m_mask |= 0x00000200u;
  565. m_illegal_info = illegal_info;
  566. }
  567. void SetAbuseInfo(const SceneResultInfo& abuse_info) {
  568. m_mask |= 0x00000400u;
  569. m_abuse_info = abuse_info;
  570. }
  571. void SetPoliticsInfo(const SceneResultInfo& politics_info) {
  572. m_mask |= 0x00000800u;
  573. m_politics_info = politics_info;
  574. }
  575. void SetTerrorismInfo(const SceneResultInfo& terrorism_info) {
  576. m_mask |= 0x00001000u;
  577. m_terrorism_info = terrorism_info;
  578. }
  579. void SetStartByte(int start_byte) {
  580. m_mask |= 0x00002000u;
  581. m_start_byte = start_byte;
  582. }
  583. void SetTeenagerInfo(const SceneResultInfo& teenager_info) {
  584. m_mask |= 0x00004000u;
  585. m_teenager_info = teenager_info;
  586. }
  587. void SetLanguageResults(const std::vector<RecognitionResult>& results) {
  588. m_mask |= 0x00008000u;
  589. m_language_results = results;
  590. }
  591. void AddLanguageResults(const RecognitionResult& result) {
  592. m_mask |= 0x00008000u;
  593. m_language_results.push_back(result);
  594. }
  595. const std::string& GetUrl() const { return m_url; }
  596. int GetSnapShotTime() const { return m_snap_shot_time; }
  597. int GetOffsetTime() const { return m_offset_time; }
  598. int GetDuration() const { return m_duration; }
  599. const std::string& GetText() const { return m_text; }
  600. const std::string& GetLabel() const { return m_label; }
  601. int GetResult() const { return m_result; }
  602. const SceneResultInfo& GetPornInfo() const { return m_porn_info; }
  603. const SceneResultInfo& GetAdsInfo() const { return m_ads_info; }
  604. const SceneResultInfo& GetIllegalInfo() const { return m_illegal_info; }
  605. const SceneResultInfo& GetAbuseInfo() const { return m_abuse_info; }
  606. const SceneResultInfo& GetPoliticsInfo() const { return m_politics_info; }
  607. const SceneResultInfo& GetTerrorismInfo() const { return m_terrorism_info; }
  608. const SceneResultInfo& GetTeenagerInfo() const { return m_teenager_info; }
  609. const std::vector<RecognitionResult>& GetLanguageResults() const { return m_language_results; }
  610. int GetStartByte() const { return m_start_byte; }
  611. bool HasUrl() const { return (m_mask & 0x00000001) != 0; }
  612. bool HasSnapShotTime() const { return (m_mask & 0x00000002) != 0; }
  613. bool HasOffsetTime() const { return (m_mask & 0x00000004) != 0; }
  614. bool HasDuration() const { return (m_mask & 0x00000008) != 0; }
  615. bool HasText() const { return (m_mask & 0x00000010) != 0; }
  616. bool HasLabel() const { return (m_mask & 0x00000020) != 0; }
  617. bool HasResult() const { return (m_mask & 0x00000040) != 0; }
  618. bool HasPornInfo() const { return (m_mask & 0x00000080) != 0; }
  619. bool HasAdsInfo() const { return (m_mask & 0x00000100) != 0; }
  620. bool HasIllegalInfo() const { return (m_mask & 0x00000200) != 0; }
  621. bool HasAbuseInfo() const { return (m_mask & 0x00000400) != 0; }
  622. bool HasPoliticsInfo() const { return (m_mask & 0x00000800) != 0; }
  623. bool HasTerrorismInfo() const { return (m_mask & 0x00001000) != 0; }
  624. bool HasStartByte() const { return (m_mask & 0x00002000) != 0; }
  625. bool HasTeenagerInfo() const { return (m_mask & 0x00004000) != 0;}
  626. bool HasLanguageResults() const { return (m_mask & 0x00008000u) != 0; }
  627. std::string to_string() const {
  628. std::stringstream ss;
  629. if (HasUrl()) { ss << " url: " << m_url; }
  630. if (HasSnapShotTime()) { ss << " snap_shot_time: " << m_snap_shot_time; }
  631. if (HasOffsetTime()) { ss << " offset_time: " << std::to_string(m_offset_time); }
  632. if (HasDuration()) { ss << " duration: " << m_duration; }
  633. if (HasText()) { ss << " text: " << m_text; }
  634. if (HasLabel()) { ss << " label: " << m_label; }
  635. if (HasResult()) { ss << " result: " << m_result; }
  636. if (HasStartByte()) { ss << " start_type: " << std::to_string(m_start_byte); }
  637. if (HasPornInfo()) { ss << " porn_info: {" << m_porn_info.to_string() << "}"; }
  638. if (HasAdsInfo()) { ss << " ads_info: {" << m_ads_info.to_string() << "}"; }
  639. if (HasIllegalInfo()) { ss << " illegal_info: {" << m_illegal_info.to_string() << "}"; }
  640. if (HasAbuseInfo()) { ss << " abuse_info: {" << m_abuse_info.to_string() << "}"; }
  641. if (HasPoliticsInfo()) { ss << " politics_info: {" << m_politics_info.to_string() << "}"; }
  642. if (HasTerrorismInfo()) { ss << " terrorism_info: {" << m_terrorism_info.to_string() << "}"; }
  643. if (HasTeenagerInfo()) {ss << " teenager_info: {" << m_teenager_info.to_string() << "}"; }
  644. if (HasLanguageResults()) {
  645. for (std::vector<RecognitionResult>::const_iterator it = m_language_results.begin();
  646. it != m_language_results.end(); ++it) {
  647. ss << "\n language_result: {\n" << it->to_string() << "} ";
  648. }
  649. }
  650. return ss.str();
  651. }
  652. private:
  653. uint64_t m_mask;
  654. std::string m_url; // 截图/音频片段的访问地址
  655. int m_snap_shot_time; // 截图位于视频中的时间,单位毫秒
  656. int m_offset_time; // 当前声音片段位于视频中的饿时间,单位毫秒
  657. int m_duration; // 当前声音片段的时长,单位毫秒
  658. std::string m_text; // 文本识别结果
  659. std::string m_label; // 检测结果中优先级最高的恶意标签
  660. int m_result; // 审核结果,0(审核正常),1 (判定为违规敏感文件),2(疑似敏感,建议人工复核)
  661. SceneResultInfo m_porn_info; // 审核场景为涉黄的审核结果信息
  662. SceneResultInfo m_ads_info; // 审核场景为广告引导的审核结果信息
  663. SceneResultInfo m_illegal_info; // 审核场景为违法的审核结果信息
  664. SceneResultInfo m_abuse_info; // 审核场景为谩骂的审核结果信息
  665. SceneResultInfo m_politics_info; // 审核场景为违法的审核结果信息
  666. SceneResultInfo m_terrorism_info; // 审核场景为谩骂的审核结果信息
  667. SceneResultInfo m_teenager_info; // 审核场景为未成年的审核结果信息
  668. std::vector<RecognitionResult> m_language_results; // 该字段表示音频中语种的识别结果
  669. int m_start_byte; // 该分片位于文本中的起始位置信息
  670. };
  671. class Labels {
  672. public:
  673. Labels() : m_mask(0x00000000) {}
  674. virtual ~Labels() {}
  675. void SetPornInfo(const SceneResultInfo& porn_info) {
  676. m_mask |= 0x00000001u;
  677. m_porn_info = porn_info;
  678. }
  679. void SetAdsInfo(const SceneResultInfo& ads_info) {
  680. m_mask |= 0x00000002u;
  681. m_ads_info = ads_info;
  682. }
  683. void SetIllegalInfo(const SceneResultInfo& illegal_info) {
  684. m_mask |= 0x00000004u;
  685. m_illegal_info = illegal_info;
  686. }
  687. void SetAbuseInfo(const SceneResultInfo& abuse_info) {
  688. m_mask |= 0x00000008u;
  689. m_abuse_info = abuse_info;
  690. }
  691. void SetPoliticsInfo(const SceneResultInfo& politics_info) {
  692. m_mask |= 0x00000010u;
  693. m_politics_info = politics_info;
  694. }
  695. void SetTerrorismInfo(const SceneResultInfo& terrorism_info) {
  696. m_mask |= 0x00000020u;
  697. m_terrorism_info = terrorism_info;
  698. }
  699. const SceneResultInfo& GetPornInfo() const { return m_porn_info; }
  700. const SceneResultInfo& GetAdsInfo() const { return m_ads_info; }
  701. const SceneResultInfo& GetIllegalInfo() const { return m_illegal_info; }
  702. const SceneResultInfo& GetAbuseInfo() const { return m_abuse_info; }
  703. const SceneResultInfo& GetPoliticsInfo() const { return m_politics_info; }
  704. const SceneResultInfo& GetTerrorismInfo() const { return m_terrorism_info; }
  705. bool HasPornInfo() const { return (m_mask & 0x00000001u) != 0; }
  706. bool HasAdsInfo() const { return (m_mask & 0x00000002u) != 0; }
  707. bool HasIllegalInfo() const { return (m_mask & 0x00000004u) != 0; }
  708. bool HasAbuseInfo() const { return (m_mask & 0x00000008u) != 0; }
  709. bool HasPoliticsInfo() const { return (m_mask & 0x00000010u) != 0; }
  710. bool HasTerrorismInfo() const { return (m_mask & 0x00000020u) != 0; }
  711. std::string to_string() const {
  712. std::stringstream ss;
  713. if (HasPornInfo()) { ss << " porn_info: {" << m_porn_info.to_string() << "}"; }
  714. if (HasAdsInfo()) { ss << " ads_info: {" << m_ads_info.to_string() << "}"; }
  715. if (HasIllegalInfo()) { ss << " illegal_info: {" << m_illegal_info.to_string() << "}"; }
  716. if (HasAbuseInfo()) { ss << " abuse_info: {" << m_abuse_info.to_string() << "}"; }
  717. if (HasPoliticsInfo()) { ss << " politics_info: {" << m_politics_info.to_string() << "}"; }
  718. if (HasTerrorismInfo()) { ss << " terrorism_info: {" << m_terrorism_info.to_string() << "}"; }
  719. return ss.str();
  720. }
  721. private:
  722. uint64_t m_mask;
  723. SceneResultInfo m_porn_info; // 审核场景为涉黄的审核结果信息
  724. SceneResultInfo m_ads_info; // 审核场景为广告引导的审核结果信息
  725. SceneResultInfo m_illegal_info; // 审核场景为违法的审核结果信息
  726. SceneResultInfo m_abuse_info; // 审核场景为谩骂的审核结果信息
  727. SceneResultInfo m_politics_info; // 审核场景为违法的审核结果信息
  728. SceneResultInfo m_terrorism_info; // 审核场景为谩骂的审核结果信息
  729. };
  730. class ListResult {
  731. public:
  732. ListResult() : m_mask(0x00000000) {}
  733. virtual ~ListResult() {}
  734. void SetListType(const int list_type) {
  735. m_mask |= 0x00000001u;
  736. m_list_type = list_type;
  737. }
  738. void SetListName(const std::string& list_name) {
  739. m_mask |= 0x00000002u;
  740. m_list_name = list_name;
  741. }
  742. void SetEntity(const std::string& entity) {
  743. m_mask |= 0x00000004u;
  744. m_entity = entity;
  745. }
  746. int GetListType() const { return m_list_type; }
  747. std::string GetListName() const { return m_list_name; }
  748. std::string GetEntity() const { return m_entity; }
  749. bool HasListType() const { return (m_mask & 0x00000001u) != 0; }
  750. bool HasListName() const { return (m_mask & 0x00000002u) != 0; }
  751. bool HasEntity() const { return (m_mask & 0x00000004u) != 0; }
  752. std::string to_string() const {
  753. std::stringstream ss;
  754. if (HasListType()) { ss << " list_type: {" << std::to_string(m_list_type) << "}"; }
  755. if (HasListName()) { ss << " list_name: {" << m_list_name << "}"; }
  756. if (HasEntity()) { ss << " entity: {" << m_entity << "}"; }
  757. return ss.str();
  758. }
  759. private:
  760. uint64_t m_mask;
  761. int m_list_type; // 命中的名单类型,取值为0(白名单)和1(黑名单)。
  762. std::string m_list_name; // 命中的名单名称。
  763. std::string m_entity; // 命中了名单中的哪条内容。
  764. };
  765. class ListInfo {
  766. public:
  767. ListInfo() : m_mask(0x00000000) {}
  768. virtual ~ListInfo() {}
  769. void SetListResults(const std::vector<ListResult>& list_results) {
  770. m_mask |= 0x00000001u;
  771. m_list_results = list_results;
  772. }
  773. void AddListResult(const ListResult& list_result) {
  774. m_list_results.push_back(list_result);
  775. }
  776. std::vector<ListResult> GetListResult() const { return m_list_results; }
  777. bool HasListResult() const { return (m_mask & 0x00000001u) != 0; }
  778. std::string to_string() const {
  779. std::stringstream ss;
  780. if (HasListResult()) {
  781. for (std::vector<ListResult>::const_iterator it = m_list_results.begin();
  782. it != m_list_results.end(); ++it) {
  783. ss << "list_results: " << it->to_string() << std::endl;
  784. }
  785. }
  786. return ss.str();
  787. }
  788. private:
  789. uint64_t m_mask;
  790. std::vector<ListResult> m_list_results; //命中的所有名单结果
  791. };
  792. class Result {
  793. public:
  794. Result() : m_mask(0x00000000) {}
  795. virtual ~Result() {}
  796. void SetUrl(const std::string& url) {
  797. m_mask |= 0x00000001u;
  798. m_url = url;
  799. }
  800. void SetPageNumber(const int page_number) {
  801. m_mask |= 0x00000002u;
  802. m_page_number = page_number;
  803. }
  804. void SetSheetNumber(const int sheet_number) {
  805. m_mask |= 0x00000004u;
  806. m_sheet_number = sheet_number;
  807. }
  808. void SetText(const std::string& text) {
  809. m_mask |= 0x00000008u;
  810. m_text = text;
  811. }
  812. void SetLabel(const std::string& label) {
  813. m_mask |= 0x00000010u;
  814. m_label = label;
  815. }
  816. void SetSuggestion(const int suggestion) {
  817. m_mask |= 0x00000020u;
  818. m_suggestion = suggestion;
  819. }
  820. void SetPornInfo(const SceneResultInfo& porn_info) {
  821. m_mask |= 0x00000040u;
  822. m_porn_info = porn_info;
  823. }
  824. void SetAdsInfo(const SceneResultInfo& ads_info) {
  825. m_mask |= 0x00000080u;
  826. m_ads_info = ads_info;
  827. }
  828. void SetIllegalInfo(const SceneResultInfo& illegal_info) {
  829. m_mask |= 0x00000100u;
  830. m_illegal_info = illegal_info;
  831. }
  832. void SetAbuseInfo(const SceneResultInfo& abuse_info) {
  833. m_mask |= 0x00000200u;
  834. m_abuse_info = abuse_info;
  835. }
  836. void SetPoliticsInfo(const SceneResultInfo& politics_info) {
  837. m_mask |= 0x00000400u;
  838. m_politics_info = politics_info;
  839. }
  840. void SetTerrorismInfo(const SceneResultInfo& terrorism_info) {
  841. m_mask |= 0x00000800u;
  842. m_terrorism_info = terrorism_info;
  843. }
  844. int SetPageNumber() const { return m_page_number; }
  845. int SetSheetNumber() const { return m_sheet_number; }
  846. const std::string& SetText() const { return m_text; }
  847. const std::string& SetLabel() const { return m_label; }
  848. int SetSuggestion() const { return m_suggestion; }
  849. const SceneResultInfo& GetPornInfo() const { return m_porn_info; }
  850. const SceneResultInfo& GetAdsInfo() const { return m_ads_info; }
  851. const SceneResultInfo& GetIllegalInfo() const { return m_illegal_info; }
  852. const SceneResultInfo& GetAbuseInfo() const { return m_abuse_info; }
  853. const SceneResultInfo& GetPoliticsInfo() const { return m_politics_info; }
  854. const SceneResultInfo& GetTerrorismInfo() const { return m_terrorism_info; }
  855. bool HasUrl() const { return (m_mask & 0x00000001u) != 0; }
  856. bool HasPageNumber() const { return (m_mask & 0x00000002u) != 0; }
  857. bool HasSheetNumber() const { return (m_mask & 0x00000004u) != 0; }
  858. bool HasText() const { return (m_mask & 0x00000008u) != 0; }
  859. bool HasLabel() const { return (m_mask & 0x00000010u) != 0; }
  860. bool HasSuggestion() const { return (m_mask & 0x00000020u) != 0; }
  861. bool HasPornInfo() const { return (m_mask & 0x00000040u) != 0; }
  862. bool HasAdsInfo() const { return (m_mask & 0x00000080u) != 0; }
  863. bool HasIllegalInfo() const { return (m_mask & 0x00000100u) != 0; }
  864. bool HasAbuseInfo() const { return (m_mask & 0x00000200u) != 0; }
  865. bool HasPoliticsInfo() const { return (m_mask & 0x00000400u) != 0; }
  866. bool HasTerrorismInfo() const { return (m_mask & 0x00000800u) != 0; }
  867. std::string to_string() const {
  868. std::stringstream ss;
  869. if (HasUrl()) { ss << "url: {" << m_url << "}" << std::endl; }
  870. if (HasPageNumber()) { ss << "page_number: " << std::to_string(m_page_number) << std::endl; }
  871. if (HasSheetNumber()) { ss << "sheet_number: " << std::to_string(m_sheet_number) << std::endl; }
  872. if (HasText()) { ss << "text: {" << m_text << "} " << std::endl; }
  873. if (HasLabel()) { ss << "label: " << m_label << std::endl; }
  874. if (HasSuggestion()) { ss << "suggestion: " << std::to_string(m_suggestion) << std::endl; }
  875. if (HasPornInfo()) { ss << "porn_info: {" << m_porn_info.to_string() << "}" << std::endl; }
  876. if (HasAdsInfo()) { ss << "ads_info: {" << m_ads_info.to_string() << "}" << std::endl; }
  877. if (HasIllegalInfo()) { ss << "illegal_info: {" << m_illegal_info.to_string() << "}" << std::endl; }
  878. if (HasAbuseInfo()) { ss << "abuse_info: {" << m_abuse_info.to_string() << "}" << std::endl; }
  879. if (HasPoliticsInfo()) { ss << "politics_info: {" << m_politics_info.to_string() << "}" << std::endl; }
  880. if (HasTerrorismInfo()) { ss << "terrorism_info: {" << m_terrorism_info.to_string() << "}" << std::endl; }
  881. return ss.str();
  882. }
  883. private:
  884. uint64_t m_mask;
  885. std::string m_url; // 截图/音频片段的访问地址
  886. int m_page_number; // 截图位于视频中的时间,单位毫秒
  887. int m_sheet_number; // 当前声音片段位于视频中的饿时间,单位毫秒
  888. std::string m_text; // 文本识别结果
  889. std::string m_label; // 检测结果中优先级最高的恶意标签
  890. int m_suggestion; // 审核结果,0(审核正常),1 (判定为违规敏感文件),2(疑似敏感,建议人工复核)
  891. SceneResultInfo m_porn_info; // 审核场景为涉黄的审核结果信息
  892. SceneResultInfo m_ads_info; // 审核场景为广告引导的审核结果信息
  893. SceneResultInfo m_illegal_info; // 审核场景为违法的审核结果信息
  894. SceneResultInfo m_abuse_info; // 审核场景为谩骂的审核结果信息
  895. SceneResultInfo m_politics_info; // 审核场景为违法的审核结果信息
  896. SceneResultInfo m_terrorism_info; // 审核场景为谩骂的审核结果信息
  897. };
  898. class PageSegment {
  899. public:
  900. PageSegment() : m_mask(0x00000000u) {}
  901. virtual ~PageSegment() {}
  902. void SetResults(const std::vector<Result>& results) {
  903. m_mask |= 0x00000001u;
  904. m_results = results;
  905. }
  906. void AddResult(const Result& result) {
  907. m_mask |= 0x00000001u;
  908. m_results.push_back(result);
  909. }
  910. std::vector<Result> GetResults() const { return m_results; }
  911. bool HasResults() const { return (m_mask & 0x00000001u) != 0; }
  912. std::string to_string() const {
  913. std::stringstream ss;
  914. if (HasResults()) {
  915. for (std::vector<Result>::const_iterator it = m_results.begin();
  916. it != m_results.end(); ++it) {
  917. ss << "\nresults: {\n" << it->to_string() << "} ";
  918. }
  919. }
  920. return ss.str();
  921. }
  922. private:
  923. uint64_t m_mask;
  924. std::vector<Result> m_results;
  925. };
  926. class AuditingJobsDetail {
  927. public:
  928. AuditingJobsDetail() : m_mask(0x00000000u) {}
  929. virtual ~AuditingJobsDetail() {}
  930. void SetCode(const std::string& code) {
  931. m_mask |= 0x00000001u;
  932. m_code = code;
  933. }
  934. void SetMessage(const std::string& message) {
  935. m_mask |= 0x00000002u;
  936. m_message = message;
  937. }
  938. void SetDataId(const std::string& data_id) {
  939. m_mask |= 0x00000004u;
  940. m_data_id = data_id;
  941. }
  942. void SetJobId(const std::string& job_id) {
  943. m_mask |= 0x00000008u;
  944. m_job_id = job_id;
  945. }
  946. void SetState(const std::string& state) {
  947. m_mask |= 0x00000010u;
  948. m_state = state;
  949. }
  950. void SetCreationTime(const std::string& creation_time) {
  951. m_mask |= 0x00000020u;
  952. m_creation_time = creation_time;
  953. }
  954. void SetUserInfo(const UserInfo& user_info) {
  955. m_mask |= 0x00000040u;
  956. m_user_info = user_info;
  957. }
  958. std::string GetCode() const { return m_code; }
  959. std::string GetMessage() const { return m_message; }
  960. std::string GetDataId() const { return m_data_id; }
  961. std::string GetJobId() const { return m_job_id; }
  962. std::string GetState() const { return m_state; }
  963. std::string GetCreationTime() const { return m_creation_time; }
  964. UserInfo getUserInfo() const { return m_user_info; }
  965. bool HasCode() const { return (m_mask & 0x00000001u) != 0; }
  966. bool HasMessage() const { return (m_mask & 0x00000002u) != 0; }
  967. bool HasDataId() const { return (m_mask & 0x00000004u) != 0; }
  968. bool HasJobId() const { return (m_mask & 0x00000008u) != 0; }
  969. bool HasState() const { return (m_mask & 0x00000010u) != 0; }
  970. bool HasCreationTime() const { return (m_mask & 0x00000020u) != 0; }
  971. bool HasUserInfo() const { return (m_mask & 0x00000040u) != 0; }
  972. std::string to_string() const {
  973. std::stringstream ss;
  974. if (HasCode()) {
  975. ss << "code: " << m_code << std::endl;
  976. }
  977. if (HasMessage()) {
  978. ss << "message: " << m_message << std::endl;
  979. }
  980. if (HasDataId()) {
  981. ss << "data_id: " << m_data_id << std::endl;
  982. }
  983. if (HasJobId()) {
  984. ss << "job_id: " << m_job_id << std::endl;
  985. }
  986. if (HasState()) {
  987. ss << "state: " << m_state << std::endl;
  988. }
  989. if (HasCreationTime()) {
  990. ss << "creation_time: " << m_creation_time << std::endl;
  991. }
  992. if (HasUserInfo()) {
  993. ss << "user_info: {" << m_user_info.to_string() << "}" << std::endl;
  994. }
  995. return ss.str();
  996. }
  997. protected:
  998. uint64_t m_mask;
  999. std::string m_code; // 错误码,只有 State 为 Failed 时有意义
  1000. std::string m_message; // 错误描述,只有 State 为 Failed 时有意义
  1001. std::string m_data_id; // 提交任务时设置了DataId参数时返回,返回原始内容,长度限制为512字节
  1002. std::string m_job_id; // 新创建任务的 ID
  1003. std::string m_state; // 任务的状态,为 Submitted、Auditing、Success、Failed其中一个
  1004. std::string m_creation_time; // 任务的创建时间
  1005. UserInfo m_user_info; // 用户业务字段。创建任务时未设置UserInfo则无此字段
  1006. };
  1007. class ImageAuditingJobsDetail : public AuditingJobsDetail {
  1008. public:
  1009. ImageAuditingJobsDetail() : AuditingJobsDetail() {}
  1010. virtual ~ImageAuditingJobsDetail() {
  1011. }
  1012. void SetObject(const std::string& object) {
  1013. m_mask |= 0x00000080u;
  1014. m_object = object;
  1015. }
  1016. void SetUrl(const std::string& url) {
  1017. m_mask |= 0x00000100u;
  1018. m_url = url;
  1019. }
  1020. void SetCompressionResult(int compression_result) {
  1021. m_mask |= 0x00000200u;
  1022. m_compression_result = compression_result;
  1023. }
  1024. void SetText(const std::string& text) {
  1025. m_mask |= 0x00000400u;
  1026. m_text = text;
  1027. }
  1028. void SetLabel(const std::string& label) {
  1029. m_mask |= 0x00000800u;
  1030. m_label = label;
  1031. }
  1032. void SetResult(int result) {
  1033. m_mask |= 0x00001000u;
  1034. m_result = result;
  1035. }
  1036. void SetCategory(const std::string& category) {
  1037. m_mask |= 0x00002000u;
  1038. m_category = category;
  1039. }
  1040. void SetSubLabel(const std::string& sub_label) {
  1041. m_mask |= 0x00004000u;
  1042. m_sub_label = sub_label;
  1043. }
  1044. void SetPornInfo(const SceneResultInfo& porn_info) {
  1045. m_mask |= 0x00008000u;
  1046. m_porn_info = porn_info;
  1047. }
  1048. void SetAdsInfo(const SceneResultInfo& ads_info) {
  1049. m_mask |= 0x00010000u;
  1050. m_ads_info = ads_info;
  1051. }
  1052. void SetIllegalInfo(const SceneResultInfo& illegal_info) {
  1053. m_mask |= 0x00020000u;
  1054. m_illegal_info = illegal_info;
  1055. }
  1056. void SetAbuseInfo(const SceneResultInfo& abuse_info) {
  1057. m_mask |= 0x00040000u;
  1058. m_abuse_info = abuse_info;
  1059. }
  1060. void SetPoliticsInfo(const SceneResultInfo& politics_info) {
  1061. m_mask |= 0x00080000u;
  1062. m_politics_info = politics_info;
  1063. }
  1064. void SetTerrorismInfo(const SceneResultInfo& terrorism_info) {
  1065. m_mask |= 0x00100000u;
  1066. m_terrorism_info = terrorism_info;
  1067. }
  1068. void SetUserInfo(const UserInfo& user_info) {
  1069. m_mask |= 0x00200000u;
  1070. m_user_info = user_info;
  1071. }
  1072. void SetForbitState(const int forbit_state) {
  1073. m_mask |= 0x00400000u;
  1074. m_forbid_state = forbit_state;
  1075. }
  1076. void SetListInfo(const ListInfo& list_info) {
  1077. m_mask |= 0x00800000u;
  1078. m_list_info = list_info;
  1079. }
  1080. std::string GetObject() const { return m_object; }
  1081. std::string GetUrl() const { return m_url; }
  1082. int GetCompressionResult() const { return m_compression_result; }
  1083. std::string GetText() const { return m_text; }
  1084. std::string GetLabel() const { return m_label; }
  1085. int GetResult() const { return m_result; }
  1086. std::string GetCategory() const { return m_category; }
  1087. std::string GetSubLabel() const { return m_sub_label; }
  1088. SceneResultInfo GetPornInfo() const { return m_porn_info; }
  1089. SceneResultInfo GetAdsInfo() const { return m_ads_info; }
  1090. SceneResultInfo GetIllegalInfo() const { return m_illegal_info; }
  1091. SceneResultInfo GetAbuseInfo() const { return m_abuse_info; }
  1092. SceneResultInfo GetPoliticsInfo() const { return m_politics_info; }
  1093. SceneResultInfo GetTerrorismInfo() const { return m_terrorism_info; }
  1094. bool HasObject() const { return (m_mask & 0x00000080u) != 0; }
  1095. bool HasUrl() const { return (m_mask & 0x00000100u) != 0; }
  1096. bool HasCompressionResult() const { return (m_mask & 0x00000200u) != 0; }
  1097. bool HasText() const { return (m_mask & 0x00000400u) != 0; }
  1098. bool HasLabel() const { return (m_mask & 0x00000800u) != 0; }
  1099. bool HasResult() const { return (m_mask & 0x00001000u) != 0; }
  1100. bool HasCategory() const { return (m_mask & 0x00002000u) != 0; }
  1101. bool HasSubLabel() const { return (m_mask & 0x00004000u) != 0; }
  1102. bool HasPornInfo() const { return (m_mask & 0x00008000u) != 0; }
  1103. bool HasAdsInfo() const { return (m_mask & 0x00010000u) != 0; }
  1104. bool HasIllegalInfo() const { return (m_mask & 0x00020000u) != 0; }
  1105. bool HasAbuseInfo() const { return (m_mask & 0x00040000u) != 0; }
  1106. bool HasPoliticsInfo() const { return (m_mask & 0x00080000u) != 0; }
  1107. bool HasTerrorismInfo() const { return (m_mask & 0x00100000u) != 0; }
  1108. bool HasUserInfo() const { return (m_mask & 0x00200000u) != 0; }
  1109. bool HasForbidState() const { return (m_mask & 0x00400000u) != 0; }
  1110. bool HasListInfo() const { return (m_mask & 0x00800000u) != 0; }
  1111. std::string to_string() const {
  1112. std::stringstream ss;
  1113. ss << AuditingJobsDetail::to_string();
  1114. if (HasObject()) {
  1115. ss << "object: " << m_object << std::endl;
  1116. }
  1117. if (HasUrl()) {
  1118. ss << "url: " << m_url << std::endl;
  1119. }
  1120. if (HasCompressionResult()) {
  1121. ss << "compression_result: " << std::to_string(m_compression_result) << std::endl;
  1122. }
  1123. if (HasText()) {
  1124. ss << "text: " << m_text << std::endl;
  1125. }
  1126. if (HasLabel()) {
  1127. ss << "label: " << m_label << std::endl;
  1128. }
  1129. if (HasResult()) {
  1130. ss << "result: " << std::to_string(m_result) << std::endl;
  1131. }
  1132. if (HasCategory()) {
  1133. ss << "category: " << m_category << std::endl;
  1134. }
  1135. if (HasSubLabel()) {
  1136. ss << "sub_label: " << m_sub_label << std::endl;
  1137. }
  1138. if (HasPornInfo()) {
  1139. ss << "porn_info: {" << m_porn_info.to_string() << "}" << std::endl;
  1140. }
  1141. if (HasAdsInfo()) {
  1142. ss << "ads_info: {" << m_ads_info.to_string() << "}" << std::endl;
  1143. }
  1144. if (HasIllegalInfo()) {
  1145. ss << "illegal_info: {" << m_illegal_info.to_string() << "}" << std::endl;
  1146. }
  1147. if (HasAbuseInfo()) {
  1148. ss << "abuse_info: {" << m_abuse_info.to_string() << "}" << std::endl;
  1149. }
  1150. if (HasPoliticsInfo()) {
  1151. ss << "politics_info: {" << m_politics_info.to_string() << "}" << std::endl;
  1152. }
  1153. if (HasTerrorismInfo()) {
  1154. ss << "terrorism_info: {" << m_terrorism_info.to_string() << "}" << std::endl;
  1155. }
  1156. if (HasSubLabel()) {
  1157. ss << "sub_label: " << m_sub_label << std::endl;
  1158. }
  1159. if (HasUserInfo()) {
  1160. ss << "user_info: " << m_user_info.to_string() << std::endl;
  1161. }
  1162. if (HasForbidState()) {
  1163. ss << "forbid_state: " << std::to_string(m_forbid_state) << std::endl;
  1164. }
  1165. if (HasListInfo()) {
  1166. ss << "list_info: " << m_list_info.to_string() << std::endl;
  1167. }
  1168. return ss.str();
  1169. }
  1170. private:
  1171. std::string m_object; // 本次审核的文件名称,创建任务使用Object时返回
  1172. std::string m_url; // 本次审核的文件链接,创建任务使用 Url 时返回
  1173. int m_compression_result; // 图片是否被压缩处理,值为 0(未压缩),1(正常压缩)
  1174. std::string m_text; // 图片中检测的文字内容(OCR),当审核策略开启文本内容检测时返回
  1175. std::string m_label; // 检测结果中所对应的优先级最高的恶意标签,返回值:Normal:正常,Porn:色情,Ads:广告等
  1176. int m_result; // 检测结果,有效值:0(审核正常),1 (判定为违规敏感文件),2(疑似敏感,建议人工复核)
  1177. std::string m_category; // Label字段子集,表示审核命中的具体审核类别。例如 Sexy,表示色情标签中的性感类别
  1178. std::string m_sub_label; // 命中的二级标签结果
  1179. SceneResultInfo m_porn_info; // 审核场景为涉黄的审核结果信息
  1180. SceneResultInfo m_ads_info; // 审核场景为广告引导的审核结果信息
  1181. SceneResultInfo m_illegal_info; // 审核场景为违法的审核结果信息
  1182. SceneResultInfo m_abuse_info; // 审核场景为谩骂的审核结果信息
  1183. SceneResultInfo m_politics_info; // 审核场景为违法的审核结果信息
  1184. SceneResultInfo m_terrorism_info; // 审核场景为谩骂的审核结果信息
  1185. SceneResultInfo m_quality_info; // 审核场景为低质量的审核结果信息
  1186. UserInfo m_user_info; // 用户业务字段。创建任务未设置 UserInfo 时无此字段。
  1187. int m_forbid_state; // 若设置了自动冻结,该字段表示图片文件的冻结状态。0:未冻结,1:已被冻结,2:已转移文件
  1188. ListInfo m_list_info; // 账号黑白名单结果。
  1189. };
  1190. class VideoAuditingJobsDetail : public AuditingJobsDetail {
  1191. public:
  1192. VideoAuditingJobsDetail() : AuditingJobsDetail() {}
  1193. virtual ~VideoAuditingJobsDetail() {}
  1194. void SetObject(const std::string& object) {
  1195. m_mask |= 0x00000080u;
  1196. m_object = object;
  1197. }
  1198. void SetUrl(const std::string& url) {
  1199. m_mask |= 0x00000100u;
  1200. m_url = url;
  1201. }
  1202. void SetSnapShotCount(const std::string& snap_shot_count) {
  1203. m_mask |= 0x00000200u;
  1204. m_snap_shot_count = snap_shot_count;
  1205. }
  1206. void SetLabel(const std::string& label) {
  1207. m_mask |= 0x00000400u;
  1208. m_label = label;
  1209. }
  1210. void SetResult(int result) {
  1211. m_mask |= 0x00000800u;
  1212. m_result = result;
  1213. }
  1214. void SetSnapShot(const std::vector<SegmentResult>& snap_shot) {
  1215. m_mask |= 0x00002000u;
  1216. m_snap_shot = snap_shot;
  1217. }
  1218. void SetAudioSection(const std::vector<SegmentResult>& audio_section) {
  1219. m_mask |= 0x00004000u;
  1220. m_audio_section = audio_section;
  1221. }
  1222. void SetPornInfo(const SceneResultInfo& porn_info) {
  1223. m_mask |= 0x00008000u;
  1224. m_porn_info = porn_info;
  1225. }
  1226. void SetAdsInfo(const SceneResultInfo& ads_info) {
  1227. m_mask |= 0x00010000u;
  1228. m_ads_info = ads_info;
  1229. }
  1230. void SetIllegalInfo(const SceneResultInfo& illegal_info) {
  1231. m_mask |= 0x00020000u;
  1232. m_illegal_info = illegal_info;
  1233. }
  1234. void SetAbuseInfo(const SceneResultInfo& abuse_info) {
  1235. m_mask |= 0x00040000u;
  1236. m_abuse_info = abuse_info;
  1237. }
  1238. void SetPoliticsInfo(const SceneResultInfo& politics_info) {
  1239. m_mask |= 0x00080000u;
  1240. m_politics_info = politics_info;
  1241. }
  1242. void SetTerrorismInfo(const SceneResultInfo& terrorism_info) {
  1243. m_mask |= 0x00100000u;
  1244. m_terrorism_info = terrorism_info;
  1245. }
  1246. void AddSnapShot(const SegmentResult& snap_shot) {
  1247. m_mask |= 0x00200000u;
  1248. m_snap_shot.push_back(snap_shot);
  1249. }
  1250. void AddAudioSection(const SegmentResult audio_section) {
  1251. m_mask |= 0x00400000u;
  1252. m_audio_section.push_back(audio_section);
  1253. }
  1254. void SetUserInfo(const UserInfo& user_info) {
  1255. m_mask |= 0x00800000u;
  1256. m_user_info = user_info;
  1257. }
  1258. void SetForbitState(const int forbit_state) {
  1259. m_mask |= 0x01000000u;
  1260. m_forbid_state = forbit_state;
  1261. }
  1262. void SetListInfo(const ListInfo& list_info) {
  1263. m_mask |= 0x02000000u;
  1264. m_list_info = list_info;
  1265. }
  1266. std::string GetObject() const { return m_object; }
  1267. std::string GetUrl() const { return m_url; }
  1268. std::string GetSnapShotCount() const { return m_snap_shot_count; }
  1269. std::string GetLabel() const { return m_label; }
  1270. int GetResult() const { return m_result; }
  1271. std::vector<SegmentResult> GetSnapShot() const { return m_snap_shot; }
  1272. std::vector<SegmentResult> GetAudioSection() const { return m_audio_section; }
  1273. SceneResultInfo GetPornInfo() const { return m_porn_info; }
  1274. SceneResultInfo GetAdsInfo() const { return m_ads_info; }
  1275. SceneResultInfo GetIllegalInfo() const { return m_illegal_info; }
  1276. SceneResultInfo GetAbuseInfo() const { return m_abuse_info; }
  1277. SceneResultInfo GetPoliticsInfo() const { return m_politics_info; }
  1278. SceneResultInfo GetTerrorismInfo() const { return m_terrorism_info; }
  1279. UserInfo GetUserInfo() const { return m_user_info; }
  1280. int GetForbidState() const { return m_forbid_state; }
  1281. ListInfo GetListInfo() const { return m_list_info; }
  1282. bool HasObject() const { return (m_mask & 0x00000080u) != 0; }
  1283. bool HasUrl() const { return (m_mask & 0x00000100u) != 0; }
  1284. bool HasSnapShotCount() const { return (m_mask & 0x00000200u) != 0; }
  1285. bool HasLabel() const { return (m_mask & 0x00000400u) != 0; }
  1286. bool HasResult() const { return (m_mask & 0x00000800u) != 0; }
  1287. bool HasSnapShot() const { return (m_mask & 0x00002000u) != 0; }
  1288. bool HasAudioSection() const { return (m_mask & 0x00004000u) != 0; }
  1289. bool HasPornInfo() const { return (m_mask & 0x00008000u) != 0; }
  1290. bool HasAdsInfo() const { return (m_mask & 0x00010000u) != 0; }
  1291. bool HasIllegalInfo() const { return (m_mask & 0x00020000u) != 0; }
  1292. bool HasAbuseInfo() const { return (m_mask & 0x00040000u) != 0; }
  1293. bool HasPoliticsInfo() const { return (m_mask & 0x00080000u) != 0; }
  1294. bool HasTerrorismInfo() const { return (m_mask & 0x00100000u) != 0; }
  1295. bool HasUserInfo() const { return (m_mask & 0x00200000u) != 0; }
  1296. bool HasForbidState() const { return (m_mask & 0x00400000u) != 0; }
  1297. bool HasListInfo() const { return (m_mask & 0x00800000u) != 0; }
  1298. std::string to_string() const {
  1299. std::stringstream ss;
  1300. ss << AuditingJobsDetail::to_string();
  1301. if (HasObject()) {
  1302. ss << "object:" << m_object << std::endl;
  1303. }
  1304. if (HasUrl()) {
  1305. ss << "url: " << m_url << std::endl;
  1306. }
  1307. if (HasSnapShotCount()) {
  1308. ss << "SnapShotCount: " << m_snap_shot_count << std::endl;
  1309. }
  1310. if (HasLabel()) {
  1311. ss << "label: " << m_label << std::endl;
  1312. }
  1313. if (HasResult()) {
  1314. ss << "Result: " << std::to_string(m_result) << std::endl;
  1315. }
  1316. if (HasPornInfo()) {
  1317. ss << "porn_info: {" << m_porn_info.to_string() << "}" << std::endl;
  1318. }
  1319. if (HasAdsInfo()) {
  1320. ss << "ads_info: {" << m_ads_info.to_string() << "}" << std::endl;
  1321. }
  1322. if (HasIllegalInfo()) {
  1323. ss << "illegal_info: {" << m_illegal_info.to_string() << "}" << std::endl;
  1324. }
  1325. if (HasAbuseInfo()) {
  1326. ss << "abuse_info: {" << m_abuse_info.to_string() << "}" << std::endl;
  1327. }
  1328. if (HasPoliticsInfo()) {
  1329. ss << "politics_info: {" << m_politics_info.to_string() << "}" << std::endl;
  1330. }
  1331. if (HasTerrorismInfo()) {
  1332. ss << "terrorism_info: {" << m_terrorism_info.to_string() << "}" << std::endl;
  1333. }
  1334. if (HasSnapShot()) {
  1335. for (std::vector<SegmentResult>::const_iterator it = m_snap_shot.begin();
  1336. it != m_snap_shot.end(); ++it) {
  1337. ss << "snap_shot: {" << it->to_string() << "}" << std::endl;
  1338. }
  1339. }
  1340. if (HasAudioSection()) {
  1341. for (std::vector<SegmentResult>::const_iterator it = m_audio_section.begin();
  1342. it != m_audio_section.end(); ++it) {
  1343. ss << "audio_section: " << it->to_string() << std::endl;
  1344. }
  1345. }
  1346. if (HasUserInfo()) {
  1347. ss << "user_info: " << m_user_info.to_string() << std::endl;
  1348. }
  1349. if (HasForbidState()) {
  1350. ss << "forbid_state: " << std::to_string(m_forbid_state) << std::endl;
  1351. }
  1352. if (HasListInfo()) {
  1353. ss << "list_info: " << m_list_info.to_string() << std::endl;
  1354. }
  1355. return ss.str();
  1356. }
  1357. private:
  1358. std::string m_object; // 本次审核的文件名称,创建任务使用Object时返回
  1359. std::string m_url; // 本次审核的文件链接,创建任务使用 Url 时返回
  1360. std::string m_snap_shot_count; // 视频截图总数量
  1361. std::string m_label; // 检测结果中所对应的优先级最高的恶意标签,返回值:Normal:正常,Porn:色情,Ads:广告等
  1362. int m_result; // 检测结果,有效值:0(审核正常),1 (判定为违规敏感文件),2(疑似敏感,建议人工复核)
  1363. SceneResultInfo m_porn_info; // 审核场景为涉黄的审核结果信息
  1364. SceneResultInfo m_ads_info; // 审核场景为广告引导的审核结果信息
  1365. SceneResultInfo m_illegal_info; // 审核场景为违法的审核结果信息
  1366. SceneResultInfo m_abuse_info; // 审核场景为谩骂的审核结果信息
  1367. SceneResultInfo m_politics_info; // 审核场景为违法的审核结果信息
  1368. SceneResultInfo m_terrorism_info; // 审核场景为谩骂的审核结果信息
  1369. std::vector<SegmentResult> m_snap_shot; // 视频画面截图的审核结果
  1370. std::vector<SegmentResult> m_audio_section; // 视频中声音的审核结果
  1371. UserInfo m_user_info; // 用户业务字段。创建任务未设置 UserInfo 时无此字段。
  1372. int m_forbid_state; // 若设置了自动冻结,该字段表示视频文件的冻结状态。0:未冻结,1:已被冻结,2:已转移文件
  1373. ListInfo m_list_info; // 账号黑白名单结果。
  1374. };
  1375. class AudioAuditingJobsDetail : public AuditingJobsDetail {
  1376. public:
  1377. AudioAuditingJobsDetail() {}
  1378. virtual ~AudioAuditingJobsDetail() {}
  1379. void SetObject(const std::string& object) {
  1380. m_mask |= 0x00000080u;
  1381. m_object = object;
  1382. }
  1383. void SetUrl(const std::string& url) {
  1384. m_mask |= 0x00000100u;
  1385. m_url = url;
  1386. }
  1387. void SetLabel(const std::string& label) {
  1388. m_mask |= 0x00000200u;
  1389. m_label = label;
  1390. }
  1391. void SetResult(int result) {
  1392. m_mask |= 0x00000400u;
  1393. m_result = result;
  1394. }
  1395. void SetAudioText(const std::string& audio_text) {
  1396. m_mask |= 0x00000800u;
  1397. m_audio_text = audio_text;
  1398. }
  1399. void SetPornInfo(const SceneResultInfo& porn_info) {
  1400. m_mask |= 0x00001000u;
  1401. m_porn_info = porn_info;
  1402. }
  1403. void SetAdsInfo(const SceneResultInfo& ads_info) {
  1404. m_mask |= 0x00002000u;
  1405. m_ads_info = ads_info;
  1406. }
  1407. void SetIllegalInfo(const SceneResultInfo& illegal_info) {
  1408. m_mask |= 0x00004000u;
  1409. m_illegal_info = illegal_info;
  1410. }
  1411. void SetAbuseInfo(const SceneResultInfo& abuse_info) {
  1412. m_mask |= 0x00008000u;
  1413. m_abuse_info = abuse_info;
  1414. }
  1415. void SetPoliticsInfo(const SceneResultInfo& politics_info) {
  1416. m_mask |= 0x00010000u;
  1417. m_politics_info = politics_info;
  1418. }
  1419. void SetTerrorismInfo(const SceneResultInfo& terrorism_info) {
  1420. m_mask |= 0x00020000u;
  1421. m_terrorism_info = terrorism_info;
  1422. }
  1423. void SetSection(const std::vector<SegmentResult>& section) {
  1424. m_mask |= 0x00040000u;
  1425. m_section = section;
  1426. }
  1427. void AddSection(const SegmentResult& section) {
  1428. m_mask |= 0x00040000u;
  1429. m_section.push_back(section);
  1430. }
  1431. void SetTeenagerInfo(const SceneResultInfo& teenager_info) {
  1432. m_mask |= 0x00080000u;
  1433. m_teenager_info = teenager_info;
  1434. }
  1435. void SetSubLabel(const std::string& label) {
  1436. m_mask |= 0x00100000u;
  1437. m_sub_label = label;
  1438. }
  1439. void SetUserInfo(const UserInfo& user_info) {
  1440. m_mask |= 0x00200000u;
  1441. m_user_info = user_info;
  1442. }
  1443. void SetForbitState(const int forbit_state) {
  1444. m_mask |= 0x00400000u;
  1445. m_forbid_state = forbit_state;
  1446. }
  1447. void SetListInfo(const ListInfo& list_info) {
  1448. m_mask |= 0x00800000u;
  1449. m_list_info = list_info;
  1450. }
  1451. std::string GetObject() const { return m_object; }
  1452. std::string GetUrl() const { return m_url; }
  1453. std::string GetLabel() const { return m_label; }
  1454. int GetResult() const { return m_result; }
  1455. std::string GetAudioText() const { return m_audio_text; }
  1456. SceneResultInfo GetPornInfo() const { return m_porn_info; }
  1457. SceneResultInfo GetAdsInfo() const { return m_ads_info; }
  1458. SceneResultInfo GetIllegalInfo() const { return m_illegal_info; }
  1459. SceneResultInfo GetAbuseInfo() const { return m_abuse_info; }
  1460. SceneResultInfo GetPoliticsInfo() const { return m_politics_info; }
  1461. SceneResultInfo GetTerrorismInfo() const { return m_terrorism_info; }
  1462. std::vector<SegmentResult> GetSection() const { return m_section; }
  1463. SceneResultInfo GetTeenagerInfo() const { return m_teenager_info; }
  1464. std::string GetSubLabel() const { return m_sub_label; }
  1465. UserInfo GetUserInfo() const { return m_user_info; }
  1466. int GetForbidState() const { return m_forbid_state; }
  1467. ListInfo GetListInfo() const { return m_list_info; }
  1468. bool HasObject() const { return (m_mask & 0x00000080u) != 0; }
  1469. bool HasUrl() const { return (m_mask & 0x00000100u) != 0; }
  1470. bool HasLabel() const { return (m_mask & 0x00000200u) != 0; }
  1471. bool HasResult() const { return (m_mask & 0x00000400u) != 0; }
  1472. bool HasAudioText() const { return (m_mask & 0x00000800u) != 0; }
  1473. bool HasPornInfo() const { return (m_mask & 0x00001000u) != 0; }
  1474. bool HasAdsInfo() const { return (m_mask & 0x00002000u) != 0; }
  1475. bool HasIllegalInfo() const { return (m_mask & 0x00004000u) != 0; }
  1476. bool HasAbuseInfo() const { return (m_mask & 0x00008000u) != 0; }
  1477. bool HasPoliticsInfo() const { return (m_mask & 0x00010000u) != 0; }
  1478. bool HasTerrorismInfo() const { return (m_mask & 0x00020000u) != 0; }
  1479. bool HasSection() const { return (m_mask & 0x00040000u) != 0; }
  1480. bool HasTeenagerInfo() const { return (m_mask & 0x00080000u) != 0; }
  1481. bool HasSubLabel() const { return (m_mask & 0x00100000u) != 0; }
  1482. bool HasUserInfo() const { return (m_mask & 0x00200000u) != 0; }
  1483. bool HasForbidState() const { return (m_mask & 0x00400000u) != 0; }
  1484. bool HasListInfo() const { return (m_mask & 0x00800000u) != 0; }
  1485. std::string to_string() const {
  1486. std::stringstream ss;
  1487. ss << AuditingJobsDetail::to_string();
  1488. if (HasObject()) {
  1489. ss << "object:" << m_object << std::endl;
  1490. }
  1491. if (HasUrl()) {
  1492. ss << "url: " << m_url << std::endl;
  1493. }
  1494. if (HasLabel()) {
  1495. ss << "label: " << m_label << std::endl;
  1496. }
  1497. if (HasResult()) {
  1498. ss << "result: " << std::to_string(m_result) << std::endl;
  1499. }
  1500. if (HasAudioText()) {
  1501. ss << "audio_text: " << m_audio_text << std::endl;
  1502. }
  1503. if (HasPornInfo()) {
  1504. ss << "porn_info: {" << m_porn_info.to_string() << "}" << std::endl;
  1505. }
  1506. if (HasAdsInfo()) {
  1507. ss << "ads_info: {" << m_ads_info.to_string() << "}" << std::endl;
  1508. }
  1509. if (HasIllegalInfo()) {
  1510. ss << "illegal_info: {" << m_illegal_info.to_string() << "}" << std::endl;
  1511. }
  1512. if (HasAbuseInfo()) {
  1513. ss << "abuse_info: {" << m_abuse_info.to_string() << "}" << std::endl;
  1514. }
  1515. if (HasPoliticsInfo()) {
  1516. ss << "politics_info: {" << m_politics_info.to_string() << "}" << std::endl;
  1517. }
  1518. if (HasTerrorismInfo()) {
  1519. ss << "terrorism_info: {" << m_terrorism_info.to_string() << "}" << std::endl;
  1520. }
  1521. if (HasTeenagerInfo()) {
  1522. ss << "teenager_info: {" << m_teenager_info.to_string() << "}" << std::endl;
  1523. }
  1524. if (HasSection()) {
  1525. for (std::vector<SegmentResult>::const_iterator it = m_section.begin();
  1526. it != m_section.end(); ++it) {
  1527. ss << "section: {" << it->to_string() << "}" << std::endl;
  1528. }
  1529. }
  1530. if (HasSubLabel()) {
  1531. ss << "sub_label: " << m_sub_label << std::endl;
  1532. }
  1533. if (HasUserInfo()) {
  1534. ss << "user_info: " << m_user_info.to_string() << std::endl;
  1535. }
  1536. if (HasForbidState()) {
  1537. ss << "forbid_state: " << std::to_string(m_forbid_state) << std::endl;
  1538. }
  1539. if (HasListInfo()) {
  1540. ss << "list_info: " << m_list_info.to_string() << std::endl;
  1541. }
  1542. return ss.str();
  1543. }
  1544. private:
  1545. std::string m_object; // 本次审核的文件名称,创建任务使用Object时返回
  1546. std::string m_url; // 本次审核的文件链接,创建任务使用 Url 时返回
  1547. std::string m_label; // 检测结果中所对应的优先级最高的恶意标签,返回值:Normal:正常,Porn:色情,Ads:广告等
  1548. int m_result; // 检测结果,有效值:0(审核正常),1 (判定为违规敏感文件),2(疑似敏感,建议人工复核)
  1549. std::string m_audio_text; // 音频文件中已识别的对应文本内容
  1550. SceneResultInfo m_porn_info; // 审核场景为涉黄的审核结果信息
  1551. SceneResultInfo m_ads_info; // 审核场景为广告引导的审核结果信息
  1552. SceneResultInfo m_illegal_info; // 审核场景为违法的审核结果信息
  1553. SceneResultInfo m_abuse_info; // 审核场景为谩骂的审核结果信息
  1554. SceneResultInfo m_politics_info; // 审核场景为违法的审核结果信息
  1555. SceneResultInfo m_terrorism_info; // 审核场景为谩骂的审核结果信息
  1556. SceneResultInfo m_teenager_info; // 审核场景为未成年的审核结果信息
  1557. std::vector<SegmentResult> m_section; // 音频(文本)审核中对音频(文本)片段的审核结果
  1558. std::string m_sub_label; // 该字段表示审核命中的具体子标签。注意:该字段可能返回空
  1559. UserInfo m_user_info; // 用户业务字段。创建任务未设置 UserInfo 时无此字段。
  1560. int m_forbid_state; // 若设置了自动冻结,该字段表示音频文件的冻结状态。0:未冻结,1:已被冻结,2:已转移文件
  1561. ListInfo m_list_info; // 账号黑白名单结果。
  1562. };
  1563. class TextAuditingJobsDetail : public AuditingJobsDetail{
  1564. public:
  1565. TextAuditingJobsDetail() {}
  1566. virtual ~TextAuditingJobsDetail() {}
  1567. void SetObject(const std::string& object) {
  1568. m_mask |= 0x00000080u;
  1569. m_object = object;
  1570. }
  1571. void SetContent(const std::string& content) {
  1572. m_mask |= 0x00000100u;
  1573. m_content = content;
  1574. }
  1575. void SetSectionCount(const int section_count) {
  1576. m_mask |= 0x00000200u;
  1577. m_section_count = section_count;
  1578. }
  1579. void SetLabel(const std::string& label) {
  1580. m_mask |= 0x00000400u;
  1581. m_label = label;
  1582. }
  1583. void SetResult(int result) {
  1584. m_mask |= 0x00000800u;
  1585. m_result = result;
  1586. }
  1587. void SetPornInfo(const SceneResultInfo& porn_info) {
  1588. m_mask |= 0x00001000u;
  1589. m_porn_info = porn_info;
  1590. }
  1591. void SetAdsInfo(const SceneResultInfo& ads_info) {
  1592. m_mask |= 0x00002000u;
  1593. m_ads_info = ads_info;
  1594. }
  1595. void SetIllegalInfo(const SceneResultInfo& illegal_info) {
  1596. m_mask |= 0x00004000u;
  1597. m_illegal_info = illegal_info;
  1598. }
  1599. void SetAbuseInfo(const SceneResultInfo& abuse_info) {
  1600. m_mask |= 0x00008000u;
  1601. m_abuse_info = abuse_info;
  1602. }
  1603. void SetPoliticsInfo(const SceneResultInfo& politics_info) {
  1604. m_mask |= 0x00010000u;
  1605. m_politics_info = politics_info;
  1606. }
  1607. void SetTerrorismInfo(const SceneResultInfo& terrorism_info) {
  1608. m_mask |= 0x00020000u;
  1609. m_terrorism_info = terrorism_info;
  1610. }
  1611. void SetSection(const std::vector<SegmentResult>& section) {
  1612. m_mask |= 0x00040000u;
  1613. m_section = section;
  1614. }
  1615. void AddSection(const SegmentResult& section) {
  1616. m_mask |= 0x00040000u;
  1617. m_section.push_back(section);
  1618. }
  1619. void SetUserInfo(const UserInfo& user_info) {
  1620. m_mask |= 0x00080000u;
  1621. m_user_info = user_info;
  1622. }
  1623. void SetForbitState(const int forbit_state) {
  1624. m_mask |= 0x00100000u;
  1625. m_forbid_state = forbit_state;
  1626. }
  1627. void SetListInfo(const ListInfo& list_info) {
  1628. m_mask |= 0x00200000u;
  1629. m_list_info = list_info;
  1630. }
  1631. std::string GetObject() const { return m_object; }
  1632. std::string GetContent() const { return m_content; }
  1633. int GetSectionContent() const { return m_section_count; }
  1634. std::string GetLabel() const { return m_label; }
  1635. int GetResult() const { return m_result; }
  1636. SceneResultInfo GetPornInfo() const { return m_porn_info; }
  1637. SceneResultInfo GetAdsInfo() const { return m_ads_info; }
  1638. SceneResultInfo GetIllegalInfo() const { return m_illegal_info; }
  1639. SceneResultInfo GetAbuseInfo() const { return m_abuse_info; }
  1640. SceneResultInfo GetPoliticsInfo() const { return m_politics_info; }
  1641. SceneResultInfo GetTerrorismInfo() const { return m_terrorism_info; }
  1642. std::vector<SegmentResult> GetSection() const { return m_section; }
  1643. UserInfo GetUserInfo() const { return m_user_info; }
  1644. int GetForbidState() const { return m_forbid_state; }
  1645. ListInfo GetListInfo() const { return m_list_info; }
  1646. bool HasObject() const { return (m_mask & 0x00000080u) != 0; }
  1647. bool HasContent() const { return (m_mask & 0x00000100u) != 0; }
  1648. bool HasSectionCount() const { return (m_mask & 0x00000200u) != 0; }
  1649. bool HasLabel() const { return (m_mask & 0x00000400u) != 0; }
  1650. bool HasResult() const { return (m_mask & 0x00000800u) != 0; }
  1651. bool HasPornInfo() const { return (m_mask & 0x00001000u) != 0; }
  1652. bool HasAdsInfo() const { return (m_mask & 0x00002000u) != 0; }
  1653. bool HasIllegalInfo() const { return (m_mask & 0x00004000u) != 0; }
  1654. bool HasAbuseInfo() const { return (m_mask & 0x00008000u) != 0; }
  1655. bool HasPoliticsInfo() const { return (m_mask & 0x00010000u) != 0; }
  1656. bool HasTerrorismInfo() const { return (m_mask & 0x00020000u) != 0; }
  1657. bool HasSection() const { return (m_mask & 0x00040000u) != 0; }
  1658. bool HasUserInfo() const { return (m_mask & 0x00800000u) != 0; }
  1659. bool HasForbidState() const { return (m_mask & 0x01000000u) != 0; }
  1660. bool HasListInfo() const { return (m_mask & 0x02000000u) != 0; }
  1661. std::string to_string() const {
  1662. std::stringstream ss;
  1663. ss << AuditingJobsDetail::to_string();
  1664. if (HasObject()) {
  1665. ss << "object:" << m_object << std::endl;
  1666. }
  1667. if (HasContent()) {
  1668. ss << "content: " << m_content << std::endl;
  1669. }
  1670. if (HasLabel()) {
  1671. ss << "label: " << m_label << std::endl;
  1672. }
  1673. if (HasResult()) {
  1674. ss << "result: " << std::to_string(m_result) << std::endl;
  1675. }
  1676. if (HasSectionCount()) {
  1677. ss << "section_count: " << std::to_string(m_section_count) << std::endl;
  1678. }
  1679. if (HasPornInfo()) {
  1680. ss << "porn_info: {" << m_porn_info.to_string() << "}" << std::endl;
  1681. }
  1682. if (HasAdsInfo()) {
  1683. ss << "ads_info: {" << m_ads_info.to_string() << "}" << std::endl;
  1684. }
  1685. if (HasIllegalInfo()) {
  1686. ss << "illegal_info: {" << m_illegal_info.to_string() << "}" << std::endl;
  1687. }
  1688. if (HasAbuseInfo()) {
  1689. ss << "abuse_info: {" << m_abuse_info.to_string() << "}" << std::endl;
  1690. }
  1691. if (HasPoliticsInfo()) {
  1692. ss << "politics_info: {" << m_politics_info.to_string() << "}" << std::endl;
  1693. }
  1694. if (HasTerrorismInfo()) {
  1695. ss << "terrorism_info: {" << m_terrorism_info.to_string() << "}" << std::endl;
  1696. }
  1697. if (HasSection()) {
  1698. for (std::vector<SegmentResult>::const_iterator it = m_section.begin();
  1699. it != m_section.end(); ++it) {
  1700. ss << "section: {" << it->to_string() << "}" << std::endl;
  1701. }
  1702. }
  1703. if (HasUserInfo()) {
  1704. ss << "user_info: " << m_user_info.to_string() << std::endl;
  1705. }
  1706. if (HasForbidState()) {
  1707. ss << "forbid_state: " << std::to_string(m_forbid_state) << std::endl;
  1708. }
  1709. if (HasListInfo()) {
  1710. ss << "list_info: " << m_list_info.to_string() << std::endl;
  1711. }
  1712. return ss.str();
  1713. }
  1714. private:
  1715. std::string m_object; // 本次审核的文件名称,创建任务使用Object时返回
  1716. std::string m_content; // 文本内容的Base64编码,创建任务使用Content时返回
  1717. int m_section_count; // 审核文本的分片数,默认为1
  1718. std::string m_label; // 检测结果中所对应的优先级最高的恶意标签,返回值:Normal:正常,Porn:色情,Ads:广告等
  1719. int m_result; // 检测结果,有效值:0(审核正常),1 (判定为违规敏感文件),2(疑似敏感,建议人工复核)
  1720. SceneResultInfo m_porn_info; // 审核场景为涉黄的审核结果信息
  1721. SceneResultInfo m_ads_info; // 审核场景为广告引导的审核结果信息
  1722. SceneResultInfo m_illegal_info; // 审核场景为违法的审核结果信息
  1723. SceneResultInfo m_abuse_info; // 审核场景为谩骂的审核结果信息
  1724. SceneResultInfo m_politics_info; // 审核场景为违法的审核结果信息
  1725. SceneResultInfo m_terrorism_info; // 审核场景为谩骂的审核结果信息
  1726. std::vector<SegmentResult> m_section; // 文本审核中对文本片段的审核结果
  1727. UserInfo m_user_info; // 用户业务字段。创建任务未设置 UserInfo 时无此字段。
  1728. int m_forbid_state; // 若设置了自动冻结,该字段表示文件的冻结状态。0:未冻结,1:已被冻结,2:已转移文件
  1729. ListInfo m_list_info; // 账号黑白名单结果。
  1730. };
  1731. class DocumentAuditingJobsDetail : public AuditingJobsDetail {
  1732. public:
  1733. DocumentAuditingJobsDetail() {}
  1734. virtual ~DocumentAuditingJobsDetail() {}
  1735. void SetObject(const std::string& object) {
  1736. m_mask |= 0x00000080u;
  1737. m_object = object;
  1738. }
  1739. void SetUrl(const std::string& url) {
  1740. m_mask |= 0x00000100u;
  1741. m_url = url;
  1742. }
  1743. void SetLabel(const std::string& label) {
  1744. m_mask |= 0x00000200u;
  1745. m_label = label;
  1746. }
  1747. void SetSuggestion(int suggestion) {
  1748. m_mask |= 0x00000400u;
  1749. m_suggestion = suggestion;
  1750. }
  1751. void SetPageCount(const int page_count) {
  1752. m_mask |= 0x00000800u;
  1753. m_page_count = page_count;
  1754. }
  1755. void SetLabels(const Labels& labels) {
  1756. m_mask |= 0x00001000u;
  1757. m_labels = labels;
  1758. }
  1759. void SetPageSegment(const PageSegment& page_segment) {
  1760. m_mask |= 0x00002000u;
  1761. m_page_segment = page_segment;
  1762. }
  1763. void SetUserInfo(const UserInfo& user_info) {
  1764. m_mask |= 0x00004000u;
  1765. m_user_info = user_info;
  1766. }
  1767. void SetForbitState(const int forbit_state) {
  1768. m_mask |= 0x00008000u;
  1769. m_forbid_state = forbit_state;
  1770. }
  1771. void SetListInfo(const ListInfo& list_info) {
  1772. m_mask |= 0x00010000u;
  1773. m_list_info = list_info;
  1774. }
  1775. std::string GetObject() const { return m_object; }
  1776. std::string GetUrl() const { return m_url; }
  1777. std::string GetLabel() const { return m_label; }
  1778. int GetSuggestion() const { return m_suggestion; }
  1779. int GetPageCount() const { return m_page_count; }
  1780. Labels GetLabels() const { return m_labels; }
  1781. PageSegment GetPageSegment() const { return m_page_segment; }
  1782. UserInfo GetUserInfo() const { return m_user_info; }
  1783. int GetForbidState() const { return m_forbid_state; }
  1784. ListInfo GetListInfo() const { return m_list_info; }
  1785. bool HasObject() const { return (m_mask & 0x00000080u) != 0; }
  1786. bool HasUrl() const { return (m_mask & 0x00000100u) != 0; }
  1787. bool HasLabel() const { return (m_mask & 0x00000200u) != 0; }
  1788. bool HasSuggestion() const { return (m_mask & 0x00000400u) != 0; }
  1789. bool HasPageCount() const { return (m_mask & 0x00000800u) != 0; }
  1790. bool HasLabels() const { return (m_mask & 0x00001000u) != 0; }
  1791. bool HasPageSegment() const { return (m_mask & 0x00002000u) != 0; }
  1792. bool HasUserInfo() const { return (m_mask & 0x00004000u) != 0; }
  1793. bool HasForbidState() const { return (m_mask & 0x00080000u) != 0; }
  1794. bool HasListInfo() const { return (m_mask & 0x00100000u) != 0; }
  1795. std::string to_string() const {
  1796. std::stringstream ss;
  1797. ss << AuditingJobsDetail::to_string();
  1798. if (HasObject()) {
  1799. ss << "object:" << m_object << std::endl;
  1800. }
  1801. if (HasUrl()) {
  1802. ss << "url: " << m_url << std::endl;
  1803. }
  1804. if (HasLabel()) {
  1805. ss << "label: " << m_label << std::endl;
  1806. }
  1807. if (HasSuggestion()) {
  1808. ss << "suggestion: " << std::to_string(m_suggestion) << std::endl;
  1809. }
  1810. if (HasPageCount()) {
  1811. ss << "page_count: " << std::to_string(m_page_count) << std::endl;
  1812. }
  1813. if (HasLabels()) {
  1814. ss << "labels: {" << m_labels.to_string() << "}" << std::endl;
  1815. }
  1816. if (HasPageSegment()) {
  1817. ss << "page_segment: {" << m_page_segment.to_string() << "}" << std::endl;
  1818. }
  1819. if (HasUserInfo()) {
  1820. ss << "user_info: " << m_user_info.to_string() << std::endl;
  1821. }
  1822. if (HasForbidState()) {
  1823. ss << "forbid_state: " << std::to_string(m_forbid_state) << std::endl;
  1824. }
  1825. if (HasListInfo()) {
  1826. ss << "list_info: " << m_list_info.to_string() << std::endl;
  1827. }
  1828. return ss.str();
  1829. }
  1830. private:
  1831. std::string m_object; // 本次审核的文件名称,创建任务使用Object时返回
  1832. std::string m_url; // 本次审核的文件链接,创建任务使用 Url 时返回
  1833. std::string m_label; // 检测结果中所对应的优先级最高的恶意标签,返回值:Normal:正常,Porn:色情,Ads:广告等
  1834. int m_suggestion; // 文档审核的检测结果,有效值:0(审核正常),1 (判定为违规敏感文件),2(疑似敏感,建议人工复核)
  1835. int m_page_count; // 文档审核会将文档转图片进行审核,该字段表示文档转换图片数
  1836. Labels m_labels; // 命中的审核场景及对应的结果
  1837. PageSegment m_page_segment; // 文档转换为图片后,具体每张图片的审核结果信息
  1838. UserInfo m_user_info; // 用户业务字段。创建任务未设置 UserInfo 时无此字段。
  1839. int m_forbid_state; // 若设置了自动冻结,该字段表示文件的冻结状态。0:未冻结,1:已被冻结,2:已转移文件
  1840. ListInfo m_list_info; // 账号黑白名单结果。
  1841. };
  1842. class WebPageAuditingJobsDetail : public AuditingJobsDetail{
  1843. public:
  1844. WebPageAuditingJobsDetail() {}
  1845. virtual ~WebPageAuditingJobsDetail() {}
  1846. void SetUrl(const std::string& url) {
  1847. m_mask |= 0x00000080u;
  1848. m_url = url;
  1849. }
  1850. void SetLabel(const std::string& label) {
  1851. m_mask |= 0x00000100u;
  1852. m_label = label;
  1853. }
  1854. void SetSuggestion(int suggestion) {
  1855. m_mask |= 0x00000200u;
  1856. m_suggestion = suggestion;
  1857. }
  1858. void SetPageCount(const int page_count) {
  1859. m_mask |= 0x00000400u;
  1860. m_page_count = page_count;
  1861. }
  1862. void SetImageResults(const PageSegment& image_results) {
  1863. m_mask |= 0x00000800u;
  1864. m_image_results = image_results;
  1865. }
  1866. void SetTextResults(const PageSegment& text_results) {
  1867. m_mask |= 0x00001000u;
  1868. m_text_results = text_results;
  1869. }
  1870. void SetHighLightHtml(const std::string& high_light_html) {
  1871. m_mask |= 0x00002000u;
  1872. m_high_light_html = high_light_html;
  1873. }
  1874. void SetLabels(const Labels& labels) {
  1875. m_mask |= 0x00004000u;
  1876. m_labels = labels;
  1877. }
  1878. void SetUserInfo(const UserInfo& user_info) {
  1879. m_mask |= 0x00008000u;
  1880. m_user_info = user_info;
  1881. }
  1882. void SetListInfo(const ListInfo& list_info) {
  1883. m_mask |= 0x00010000u;
  1884. m_list_info = list_info;
  1885. }
  1886. std::string GetUrl() const { return m_url; }
  1887. std::string GetLabel() const { return m_label; }
  1888. int GetSuggestion() const { return m_suggestion; }
  1889. int GetPageCount() const { return m_page_count; }
  1890. Labels GetLabels() const { return m_labels; }
  1891. PageSegment GetImageResults() const { return m_image_results; }
  1892. PageSegment GetTextResults() const { return m_text_results; }
  1893. std::string GetHighLightHtml() const { return m_high_light_html; }
  1894. UserInfo GetUserInfo() const { return m_user_info; }
  1895. ListInfo GetListInfo() const { return m_list_info; }
  1896. bool HasUrl() const { return (m_mask & 0x00000080u) != 0; }
  1897. bool HasLabel() const { return (m_mask & 0x00000100u) != 0; }
  1898. bool HasSuggestion() const { return (m_mask & 0x00000200u) != 0; }
  1899. bool HasPageCount() const { return (m_mask & 0x00000400u) != 0; }
  1900. bool HasImageResults() const { return (m_mask & 0x00000800u) != 0; }
  1901. bool HasTextResults() const { return (m_mask & 0x00001000u) != 0; }
  1902. bool HasHighLightHtml() const { return (m_mask & 0x00002000u) != 0; }
  1903. bool HasLabels() const { return (m_mask & 0x00004000u) != 0; }
  1904. bool HasUserInfo() const { return (m_mask & 0x00080000u) != 0; }
  1905. bool HasListInfo() const { return (m_mask & 0x00100000u) != 0; }
  1906. std::string to_string() const {
  1907. std::stringstream ss;
  1908. ss << AuditingJobsDetail::to_string();
  1909. if (HasUrl()) {
  1910. ss << "url: " << m_url << std::endl;
  1911. }
  1912. if (HasLabel()) {
  1913. ss << "label: " << m_label << std::endl;
  1914. }
  1915. if (HasSuggestion()) {
  1916. ss << "suggestion: " << std::to_string(m_suggestion) << std::endl;
  1917. }
  1918. if (HasPageCount()) {
  1919. ss << "page_count: " << std::to_string(m_page_count) << std::endl;
  1920. }
  1921. if (HasImageResults()) {
  1922. ss << " image_results: {" << m_image_results.to_string() << "}" << std::endl;
  1923. }
  1924. if (HasTextResults()) {
  1925. ss << " text_results: {" << m_text_results.to_string() << "}" << std::endl;
  1926. }
  1927. if (HasHighLightHtml()) {
  1928. ss << " high_light_html: " << m_high_light_html << std::endl;
  1929. }
  1930. if (HasLabels()) {
  1931. ss << "labels: {" << m_labels.to_string() << "}" << std::endl;
  1932. }
  1933. if (HasUserInfo()) {
  1934. ss << "user_info: " << m_user_info.to_string() << std::endl;
  1935. }
  1936. if (HasListInfo()) {
  1937. ss << "list_info: " << m_list_info.to_string() << std::endl;
  1938. }
  1939. return ss.str();
  1940. }
  1941. private:
  1942. std::string m_url; // 本次审核的文件链接,创建任务使用 Url 时返回
  1943. std::string m_label; // 检测结果中所对应的优先级最高的恶意标签,返回值:Normal:正常,Porn:色情,Ads:广告等
  1944. int m_suggestion; // 网页审核的检测结果,有效值:0(审核正常),1 (判定为违规敏感文件),2(疑似敏感,建议人工复核)
  1945. int m_page_count; // 网页审核会将网页中的图片链接和文本分开送审,该字段表示送审的链接和文本总数量。
  1946. PageSegment m_image_results; // 网页内图片的审核结果
  1947. PageSegment m_text_results; // 网页内文本的审核结果
  1948. std::string m_high_light_html; // 对违规关键字高亮处理的 Html 网页内容,请求内容指定 ReturnHighlightHtml 时返回
  1949. Labels m_labels; // 命中的审核场景及对应的结果
  1950. UserInfo m_user_info; // 用户业务字段。创建任务未设置 UserInfo 时无此字段。
  1951. ListInfo m_list_info; // 账号黑白名单结果。
  1952. };
  1953. class AuditingInput {
  1954. public:
  1955. AuditingInput() : m_mask(0x00000000u) {}
  1956. void SetObject(const std::string& object) {
  1957. m_mask |= 0x00000001u;
  1958. m_object = object;
  1959. }
  1960. void SetUrl(const std::string& url) {
  1961. m_mask |= 0x00000002u;
  1962. m_url = url;
  1963. }
  1964. void SetInterval(const int interval) {
  1965. m_mask |= 0x00000004u;
  1966. m_interval = interval;
  1967. }
  1968. void SetMaxFrames(const int max_frames) {
  1969. m_mask |= 0x00000008u;
  1970. m_max_frames = max_frames;
  1971. }
  1972. void SetDataId(const std::string& data_id) {
  1973. m_mask |= 0x00000010u;
  1974. m_data_id = data_id;
  1975. }
  1976. void SetLargeImageDetect(const int large_image_detect) {
  1977. m_mask |= 0x00000020u;
  1978. m_large_image_detect = large_image_detect;
  1979. }
  1980. void SetUserInfo(const UserInfo& user_info) {
  1981. m_mask |= 0x00000040u;
  1982. m_user_info = user_info;
  1983. }
  1984. void SetContent(const std::string& content) {
  1985. m_mask |= 0x00000080u;
  1986. m_content = content;
  1987. }
  1988. void SetType(const std::string& type) {
  1989. m_mask |= 0x00000100u;
  1990. m_type = type;
  1991. }
  1992. std::string GetObject() const { return m_object; }
  1993. std::string GetUrl() const { return m_url; }
  1994. int GetInterval() const { return m_interval; }
  1995. int GetMaxFrames() const { return m_max_frames; }
  1996. int GetLargeImageDetect() const { return m_large_image_detect; }
  1997. std::string GetDataId() const { return m_data_id; }
  1998. UserInfo GetUserInfo() const { return m_user_info; }
  1999. std::string GetContent() const { return m_content; }
  2000. std::string GetType() const { return m_type; }
  2001. bool HasObject() const { return (m_mask & 0x00000001u) != 0; }
  2002. bool HasUrl() const { return (m_mask & 0x00000002u) != 0; }
  2003. bool HasInterval() const { return (m_mask & 0x00000004) != 0; }
  2004. bool HasMaxFrames() const { return (m_mask & 0x00000008u) != 0;}
  2005. bool HasDataId() const { return (m_mask & 0x00000010u) != 0; }
  2006. bool HasLargeImageDetect() const { return (m_mask & 0x00000020u) != 0; }
  2007. bool HasUserInfo() const { return (m_mask & 0x00000040u) != 0; }
  2008. bool HasContent() const { return (m_mask & 0x00000080u) != 0; }
  2009. bool HasType() const { return (m_mask & 0x00000100u) != 0; }
  2010. private:
  2011. uint64_t m_mask;
  2012. std::string m_object; // 存储在 COS 存储桶中的文件名称
  2013. std::string m_url; // 文件的链接地址, object 和 url 只能选择其中其中
  2014. int m_interval; // 截帧频率,GIF专用,默认为5,表示从第1帧(包含)开始间隔5帧截取一帧
  2015. int m_max_frames; // 最大截帧数量,GIF 图检测专用,默认值为5,表示只截取 GIF 的5帧图片进行审核,必须大于0
  2016. std::string m_data_id; // 图片标识,该字段在结果中返回原始内容,长度限制为512字节
  2017. int m_large_image_detect; // 对于超过大小限制的图片是否进行压缩后再审核,取值为: 0(不压缩),1(压缩)。默认为0
  2018. UserInfo m_user_info; // 用户业务字段
  2019. std::string m_content; // 文本审核时传入的纯文本信息
  2020. std::string m_type; // 文档审核的文档文件类型
  2021. };
  2022. class SnapShotConf {
  2023. public:
  2024. SnapShotConf() : m_mask(0x00000000u) {}
  2025. void SetMode(const std::string& mode) {
  2026. m_mask |= 0x00000001u;
  2027. m_mode = mode;
  2028. }
  2029. void SetCount(const int count) {
  2030. m_mask |= 0x00000002u;
  2031. m_count = count;
  2032. }
  2033. void SetTimeIterval(const float time_interval) {
  2034. m_mask = 0x00000004u;
  2035. m_time_interval = time_interval;
  2036. }
  2037. std::string GetMode() const { return m_mode; }
  2038. int GetCount() const { return m_count; }
  2039. float GetTimeInterval() const { return m_time_interval; }
  2040. bool HasMode() const { return (m_mask & 0x00000001u) != 0; }
  2041. bool HasCount() const { return (m_mask & 0x00000002u) != 0; }
  2042. bool HasTimeInterval() const { return (m_mask & 0x00000004u) != 0; }
  2043. std::string to_string() const {
  2044. std::stringstream ss;
  2045. if (HasMode()) { ss << "mode: " << m_mode; }
  2046. if (HasCount()) { ss << " count: " << std::to_string(m_count); }
  2047. if (HasTimeInterval()) { ss << " time_interval: " << std::to_string(m_time_interval); }
  2048. return ss.str();
  2049. };
  2050. private:
  2051. uint64_t m_mask;
  2052. std::string m_mode; // 截帧模式, 默认为Interval,取值为Interval、Average、Fps,// 详见https://cloud.tencent.com/document/product/436/47316
  2053. int m_count; // 视频截帧数量
  2054. float m_time_interval; // 视频截帧频率,单位为秒,支持精准到毫秒
  2055. };
  2056. class Freeze {
  2057. public:
  2058. Freeze() : m_mask(0x00000000u) {}
  2059. void SetPornScore(const int porn_score) {
  2060. m_mask |= 0x00000001u;
  2061. m_porn_score = porn_score;
  2062. }
  2063. void SetAdsScore(const int ads_score) {
  2064. m_mask |= 0x00000002u;
  2065. m_ads_score = ads_score;
  2066. }
  2067. int GetPornSocre() const { return m_porn_score; }
  2068. int GetAdsSocre() const { return m_ads_score; }
  2069. bool HasPornScore() const { return (m_mask & 0x00000001u) != 0; }
  2070. bool HasAdsScore() const { return (m_mask & 0x00000002u) != 0;}
  2071. std::string to_string() const {
  2072. std::stringstream ss;
  2073. if (HasPornScore()) { ss << "porn_score: " << std::to_string(m_porn_score); }
  2074. if (HasAdsScore()) { ss << " ads_score: " << std::to_string(m_ads_score); }
  2075. return ss.str();
  2076. }
  2077. private:
  2078. uint64_t m_mask;
  2079. int m_porn_score; // 取值为[0,100],表示当色情审核结果大于或等于该分数时,自动进行冻结操作。不填写则表示不自动冻结,默认值为空。
  2080. int m_ads_score; // 取值为[0,100],表示当广告审核结果大于或等于该分数时,自动进行冻结操作。不填写则表示不自动冻结,默认值为空。
  2081. };
  2082. class Conf {
  2083. public:
  2084. Conf() : m_mask(0x00000000u) {}
  2085. void SetBizType(const std::string& biz_type) {
  2086. m_mask |= 0x00000001u;
  2087. m_biz_type = biz_type;
  2088. }
  2089. void SetDetectType(const std::string& detect_type) {
  2090. m_mask |= 0x00000002u;
  2091. m_biz_type = detect_type;
  2092. }
  2093. void SetSnapShot(const SnapShotConf snap_shot) {
  2094. m_mask |= 0x00000004u;
  2095. m_snap_shot = snap_shot;
  2096. }
  2097. void SetCallBack(const std::string callback) {
  2098. m_mask = m_mask | 0x00000008u;
  2099. m_callback = callback;
  2100. }
  2101. void SetCallBackVersion(const std::string callbcak_version) {
  2102. m_mask = m_mask | 0x00000010u;
  2103. m_callback_version = callbcak_version;
  2104. }
  2105. void SetDetectContent(const int detect_content) {
  2106. m_mask = m_mask | 0x00000020u;
  2107. m_detect_content = detect_content;
  2108. }
  2109. void SetReturnHighlightHtml(const bool return_highlight_html) {
  2110. m_mask = m_mask | 0x00000040u;
  2111. m_return_highlight_html = return_highlight_html;
  2112. }
  2113. void SetAsync(const int async) {
  2114. m_mask = m_mask | 0x00000080u;
  2115. m_async = async;
  2116. }
  2117. void SetFreeze(const Freeze& freeze) {
  2118. m_mask = m_mask | 0x00000200u;
  2119. m_freeze = freeze;
  2120. }
  2121. std::string GetBizType() const { return m_biz_type;}
  2122. std::string GetDetectType() const { return m_biz_type; }
  2123. SnapShotConf GetSnapShot() const { return m_snap_shot; }
  2124. std::string GetCallBack() const { return m_callback; }
  2125. std::string GetCallBackVersion() const { return m_callback_version; }
  2126. int GetDetectContent() const { return m_detect_content; }
  2127. bool GetReturnHighlightHtml() const { return m_return_highlight_html; }
  2128. int GetAsync() const { return m_async; }
  2129. Freeze GetFreeze() const { return m_freeze; }
  2130. bool HasBizType() const { return (m_mask & 0x00000001u) != 0; }
  2131. bool HasDetectType() const { return (m_mask & 0x00000002u) != 0;}
  2132. bool HasSnapShot() const { return (m_mask & 0x00000004u) != 0; }
  2133. bool HasCallback() const { return (m_mask & 0x00000008u) != 0; }
  2134. bool HasCallbackVersion() const { return (m_mask & 0x00000010u) != 0; }
  2135. bool HasDetectContent() const { return (m_mask & 0x00000020u) != 0; }
  2136. bool HasReturnHighlightHtml() const { return (m_mask & 0x00000040u) != 0; }
  2137. bool HasAsync() const { return (m_mask & 0x00000080u) != 0; }
  2138. bool HasFreeze() const { return (m_mask & 0x00000020u) != 0; }
  2139. std::string to_string() const {
  2140. std::stringstream ss;
  2141. ss << "biz_type: " << m_biz_type
  2142. << ", detect_type: " << m_detect_type
  2143. << ", snap_shot: " << m_snap_shot.to_string()
  2144. << ", callback: " << m_callback
  2145. << ", callbcak_version: " << m_callback_version
  2146. << ", detect_content: " << m_detect_content
  2147. << ", return_highlight_html: " << m_return_highlight_html
  2148. << ", async: " << m_async
  2149. << ", freeze: " << m_freeze.to_string();
  2150. return ss.str();
  2151. }
  2152. private:
  2153. uint64_t m_mask;
  2154. std::string m_biz_type; // 审核策略的唯一标识
  2155. std::string m_detect_type; // 审核的场景类型 有效值:Porn(涉黄)、Ads(广告)等,可以传入多种类型
  2156. SnapShotConf m_snap_shot; // 审核视频截帧配置
  2157. std::string m_callback; // 回调规则
  2158. std::string m_callback_version; // 回调内容结构,有效值为Simple、Detail,默认Simple
  2159. int m_detect_content; // 指定是否审核视频声音,0 指审核视频截图,1 审核视频截图和声音,默认为0
  2160. bool m_return_highlight_html; // 网页审核时,是否需要高亮网页耶的违规文本
  2161. int m_async; // 是否异步进行审核,0:同步返回结果,1:异步进行审核。默认值为 0。
  2162. Freeze m_freeze; // 可通过该字段,设置根据审核结果给出的不同分值,对图片进行自动冻结,仅当input中审核的图片为object时有效
  2163. };
  2164. class GetImageAuditingReq : public ObjectReq {
  2165. public:
  2166. GetImageAuditingReq(const std::string& bucket_name)
  2167. : ObjectReq(bucket_name, "") {
  2168. AddParam("ci-process", "sensitive-content-recognition");
  2169. SetMethod("GET");
  2170. SetHttps();
  2171. }
  2172. virtual ~GetImageAuditingReq() {}
  2173. // COS 存储桶中的图片文件名称,需要审核图片文件对象
  2174. void SetObjectKey(const std::string& object_name) {
  2175. SetObjectName(object_name);
  2176. }
  2177. // 审核策略biz-type,不设置自动使用默认审核策略
  2178. void SetBizType(const std::string& biz_type) {
  2179. AddParam("biz-type", biz_type);
  2180. }
  2181. // 审核场景类型,有效值:porn(涉黄)、ads(广告)等,可以传入多种类型,不同类型以逗号分隔
  2182. void SetDetectType(const std::string& detect_type) {
  2183. AddParam("detect-type", detect_type);
  2184. }
  2185. // 审核图片Url,可为任意公网可访问图片链接
  2186. // 设置了detect-url时,默认审核detect-url,无需填写ObjectKey
  2187. // 不设置detect-url时,默认审核ObjectKey
  2188. void SetDetectUrl(const std::string& detect_url) {
  2189. AddParam("detect-url", detect_url);
  2190. }
  2191. // 审核GIF动图时,使用该参数截帧审核
  2192. // 例如值设为5,则表示从第1帧开始截取,每隔5帧截取一帧,默认值5
  2193. void SetInterval(int interval) {
  2194. AddParam("interval", std::to_string(interval));
  2195. }
  2196. // 审核动图时最大截帧数量,默认为5
  2197. void SetMaxFrames(int max_frames) {
  2198. AddParam("max-frames", std::to_string(max_frames));
  2199. }
  2200. // 对于超过大小限制的图片是否进行压缩后再审核,取值为: 0(不压缩),1(压缩)。默认为0。
  2201. void SetLargeImageDetect(int large_image_detect) {
  2202. AddParam("large-image-detect", std::to_string(large_image_detect));
  2203. }
  2204. // 图片标识,该字段返回原始内容,长度限制为512字节
  2205. void SetDataId(const std::string& data_id) {
  2206. AddParam("dataid", data_id);
  2207. }
  2208. // 异步审核参数,取值 0:同步返回结果,1:异步进行审核,默认为0。
  2209. void SetAsync(int async) {
  2210. AddParam("async", std::to_string(async));
  2211. }
  2212. // 审核结果(Detail版本)以回调形式发送至您的回调地址,异步审核时生效,支持以 http:// 或者 https:// 开头的地址,例如: http://www.callback.com。
  2213. void SetCallback(const std::string callback) {
  2214. AddParam("callback", callback);
  2215. }
  2216. };
  2217. class BatchImageAuditingReq : public BucketReq {
  2218. public:
  2219. BatchImageAuditingReq(const std::string& bucket_name)
  2220. : BucketReq(bucket_name) {
  2221. SetMethod("POST");
  2222. SetPath("/image/auditing");
  2223. SetHttps();
  2224. AddHeader("Content-Type", "application/xml");
  2225. }
  2226. virtual ~BatchImageAuditingReq() {}
  2227. void SetConf(const Conf& conf) { m_conf = conf; }
  2228. void SetBizType(const std::string& biz_type) { m_conf.SetBizType(biz_type); }
  2229. void SetDetectType(const std::string& detect_type) { m_conf.SetDetectType(detect_type); }
  2230. void AddInput(const AuditingInput& input) { m_inputs.push_back(input); }
  2231. void SetInputs(const std::vector<AuditingInput>& inputs) { m_inputs = inputs; }
  2232. virtual bool GenerateRequestBody(std::string* body) const;
  2233. private:
  2234. std::vector<AuditingInput> m_inputs; // 需要审核的内容,传入多个Input则审核多个内容
  2235. Conf m_conf; // 审核配置规则配置
  2236. };
  2237. class DescribeAuditingJobReq : public BucketReq {
  2238. public:
  2239. DescribeAuditingJobReq(const std::string& bucket_name)
  2240. : BucketReq(bucket_name) {
  2241. SetMethod("GET");
  2242. SetHttps();
  2243. }
  2244. virtual ~DescribeAuditingJobReq() {}
  2245. void SetJobId(const std::string& job_id) { m_path += "/" + job_id; }
  2246. };
  2247. class DescribeImageAuditingJobReq : public DescribeAuditingJobReq {
  2248. public:
  2249. DescribeImageAuditingJobReq(const std::string& bucket_name)
  2250. : DescribeAuditingJobReq(bucket_name) {
  2251. SetPath("/image/auditing");
  2252. }
  2253. virtual ~DescribeImageAuditingJobReq() {}
  2254. };
  2255. class CreateAuditingJobReq : public BucketReq {
  2256. public:
  2257. CreateAuditingJobReq(const std::string& bucket_name)
  2258. : BucketReq(bucket_name) {
  2259. SetMethod("POST");
  2260. SetHttps();
  2261. AddHeader("Content-Type", "application/xml");
  2262. }
  2263. virtual ~CreateAuditingJobReq() {}
  2264. void SetInput(const AuditingInput& input) { m_input = input; }
  2265. void SetConf(const Conf& conf) { m_conf = conf; }
  2266. virtual bool GenerateRequestBody(std::string* body) const ;
  2267. protected:
  2268. AuditingInput m_input; // 需要审核的内容
  2269. Conf m_conf; // 审核配置规则
  2270. };
  2271. class CreateVideoAuditingJobReq : public CreateAuditingJobReq {
  2272. public:
  2273. CreateVideoAuditingJobReq(const std::string& bucket_name)
  2274. : CreateAuditingJobReq(bucket_name) {
  2275. SetPath("/video/auditing");
  2276. }
  2277. virtual ~CreateVideoAuditingJobReq() {}
  2278. void SetBizType(const std::string& biz_type) { m_conf.SetBizType(biz_type); }
  2279. void SetDetectType(const std::string& detect_type) { m_conf.SetDetectType(detect_type); }
  2280. void SetSnapShot(const SnapShotConf& snap_shot) { m_conf.SetSnapShot(snap_shot); }
  2281. void SetCallBack(const std::string& callback) { m_conf.SetCallBack(callback); }
  2282. void SetCallBackVersion(const std::string& callback_version) { m_conf.SetCallBackVersion(callback_version); }
  2283. void SetDetectContent(const int detect_content) { m_conf.SetDetectContent(detect_content); }
  2284. void SetObject(const std::string& object) { m_input.SetObject(object); }
  2285. void SetUrl(const std::string& url) { m_input.SetUrl(url); }
  2286. void SetDataId(const std::string& data_id) { m_input.SetDataId(data_id); }
  2287. void SetUserInfo(const UserInfo& user_info) { m_input.SetUserInfo(user_info); }
  2288. };
  2289. class DescribeVideoAuditingJobReq : public DescribeAuditingJobReq {
  2290. public:
  2291. DescribeVideoAuditingJobReq(const std::string& bucket_name)
  2292. : DescribeAuditingJobReq(bucket_name) {
  2293. SetPath("/video/auditing");
  2294. }
  2295. virtual ~DescribeVideoAuditingJobReq() {}
  2296. };
  2297. class CreateAudioAuditingJobReq : public CreateAuditingJobReq {
  2298. public:
  2299. CreateAudioAuditingJobReq(const std::string& bucket_name)
  2300. : CreateAuditingJobReq(bucket_name) {
  2301. SetPath("/audio/auditing");
  2302. }
  2303. virtual ~CreateAudioAuditingJobReq() {}
  2304. void SetBizType(const std::string& biz_type) { m_conf.SetBizType(biz_type); }
  2305. void SetDetectType(const std::string& detect_type) { m_conf.SetDetectType(detect_type); }
  2306. void SetCallBack(const std::string& callback) { m_conf.SetCallBack(callback); }
  2307. void SetCallBackVersion(const std::string& callback_version) { m_conf.SetCallBackVersion(callback_version); }
  2308. void SetObject(const std::string& object) { m_input.SetObject(object); }
  2309. void SetUrl(const std::string& url) { m_input.SetUrl(url); }
  2310. void SetDataId(const std::string& data_id) { m_input.SetDataId(data_id); }
  2311. void SetUserInfo(const UserInfo& user_info) { m_input.SetUserInfo(user_info); }
  2312. };
  2313. class DescribeAudioAuditingJobReq : public DescribeAuditingJobReq {
  2314. public:
  2315. DescribeAudioAuditingJobReq(const std::string& bucket_name)
  2316. : DescribeAuditingJobReq(bucket_name) {
  2317. SetPath("/audio/auditing");
  2318. }
  2319. virtual ~DescribeAudioAuditingJobReq() {}
  2320. };
  2321. class CreateTextAuditingJobReq : public CreateAuditingJobReq {
  2322. public:
  2323. CreateTextAuditingJobReq(const std::string& bucket_name)
  2324. : CreateAuditingJobReq(bucket_name) {
  2325. SetPath("/text/auditing");
  2326. }
  2327. virtual ~CreateTextAuditingJobReq() {}
  2328. void SetBizType(const std::string& biz_type) { m_conf.SetBizType(biz_type); }
  2329. void SetDetectType(const std::string& detect_type) { m_conf.SetDetectType(detect_type); }
  2330. void SetCallBack(const std::string& callback) { m_conf.SetCallBack(callback); }
  2331. void SetCallBackVersion(const std::string& callback_version) { m_conf.SetCallBackVersion(callback_version); }
  2332. void SetObject(const std::string& object) { m_input.SetObject(object); }
  2333. void SetUrl(const std::string& url) { m_input.SetUrl(url); }
  2334. void SetDataId(const std::string& data_id) { m_input.SetDataId(data_id); }
  2335. void SetContent(const std::string& content) { m_input.SetContent(content); }
  2336. void SetUserInfo(const UserInfo& user_info) { m_input.SetUserInfo(user_info); }
  2337. };
  2338. class DescribeTextAuditingJobReq : public DescribeAuditingJobReq {
  2339. public:
  2340. DescribeTextAuditingJobReq(const std::string& bucket_name)
  2341. : DescribeAuditingJobReq(bucket_name) {
  2342. SetPath("/text/auditing");
  2343. }
  2344. virtual ~DescribeTextAuditingJobReq() {}
  2345. };
  2346. class CreateDocumentAuditingJobReq : public CreateAuditingJobReq {
  2347. public:
  2348. CreateDocumentAuditingJobReq(const std::string& bucket_name)
  2349. : CreateAuditingJobReq(bucket_name) {
  2350. SetPath("/document/auditing");
  2351. }
  2352. virtual ~CreateDocumentAuditingJobReq() {}
  2353. void SetBizType(const std::string& biz_type) { m_conf.SetBizType(biz_type); }
  2354. void SetDetectType(const std::string& detect_type) { m_conf.SetDetectType(detect_type); }
  2355. void SetCallBack(const std::string& callback) { m_conf.SetCallBack(callback); }
  2356. void SetObject(const std::string& object) { m_input.SetObject(object); }
  2357. void SetUrl(const std::string& url) { m_input.SetUrl(url); }
  2358. void SetDataId(const std::string& data_id) { m_input.SetDataId(data_id); }
  2359. void SetUserInfo(const UserInfo& user_info) { m_input.SetUserInfo(user_info); }
  2360. void SetType(const std::string& type) { m_input.SetType(type); };
  2361. };
  2362. class DescribeDocumentAuditingJobReq : public DescribeAuditingJobReq {
  2363. public:
  2364. DescribeDocumentAuditingJobReq(const std::string& bucket_name)
  2365. : DescribeAuditingJobReq(bucket_name) {
  2366. SetPath("/document/auditing");
  2367. }
  2368. virtual ~DescribeDocumentAuditingJobReq() {}
  2369. };
  2370. class CreateWebPageAuditingJobReq : public CreateAuditingJobReq {
  2371. public:
  2372. CreateWebPageAuditingJobReq(const std::string& bucket_name)
  2373. : CreateAuditingJobReq(bucket_name) {
  2374. SetPath("/webpage/auditing");
  2375. }
  2376. virtual ~CreateWebPageAuditingJobReq() {}
  2377. void SetDetectType(const std::string& detect_type) { m_conf.SetDetectType(detect_type); }
  2378. void SetCallBack(const std::string& callback) { m_conf.SetCallBack(callback); }
  2379. void SetReturnHighligthHtml(const bool return_highlight_html) {
  2380. m_conf.SetReturnHighlightHtml(return_highlight_html);
  2381. }
  2382. void SetObject(const std::string& object) { m_input.SetObject(object); }
  2383. void SetDataId(const std::string& data_id) { m_input.SetDataId(data_id); }
  2384. void SetUserInfo(const UserInfo& user_info) { m_input.SetUserInfo(user_info); }
  2385. void SetUrl(const std::string& url) { m_input.SetUrl(url); }
  2386. };
  2387. class DescribeWebPageAuditingJobReq : public DescribeAuditingJobReq {
  2388. public:
  2389. DescribeWebPageAuditingJobReq(const std::string& bucket_name)
  2390. : DescribeAuditingJobReq(bucket_name) {
  2391. SetPath("/webpage/auditing");
  2392. }
  2393. virtual ~DescribeWebPageAuditingJobReq() {}
  2394. };
  2395. }