smart_player_sdk_x64.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace Vinno.vCloud.FIS.CrossPlatform.Windows.RTMPSDK
  4. {
  5. public class NTSmartPlayerSDK_x64
  6. {
  7. /*
  8. * Init
  9. *
  10. * flag目前传0,后面扩展用
  11. * pReserve传NULL,扩展用
  12. *
  13. * 成功返回 NT_ERC_OK
  14. */
  15. [DllImport(@"x64\SmartPlayerSDK.dll")]
  16. public static extern UInt32 NT_SP_Init(UInt32 flag, IntPtr pReserve);
  17. /*
  18. * Uninit
  19. *
  20. * 这个是最后一个调用的接口
  21. *
  22. * 成功返回 NT_ERC_OK
  23. */
  24. [DllImport(@"x64\SmartPlayerSDK.dll")]
  25. public static extern UInt32 NT_SP_UnInit();
  26. /*
  27. * Open
  28. *
  29. * flag目前传0,后面扩展用
  30. * pReserve传NULL,扩展用
  31. * hwnd 绘制画面用的窗口
  32. *
  33. * 获取Handle
  34. *
  35. * 成功返回 NT_ERC_OK
  36. */
  37. [DllImport(@"x64\SmartPlayerSDK.dll")]
  38. public static extern UInt32 NT_SP_Open(out IntPtr pHandle, IntPtr hwnd, UInt32 flag, IntPtr pReserve);
  39. /*
  40. * Close
  41. *
  42. * 调用这个接口之后handle失效
  43. *
  44. * 成功返回 NT_ERC_OK
  45. */
  46. [DllImport(@"x64\SmartPlayerSDK.dll")]
  47. public static extern UInt32 NT_SP_Close(IntPtr handle);
  48. /*
  49. * 设置事件回调,如果想监听事件的话,建议调用Open成功后,就调用这个接口
  50. */
  51. [DllImport(@"x64\SmartPlayerSDK.dll")]
  52. public static extern UInt32 NT_SP_SetEventCallBack(IntPtr handle, IntPtr call_back_data, SP_SDKEventCallBack call_back);
  53. /*
  54. * 设置视频大小回调接口
  55. */
  56. [DllImport(@"x64\SmartPlayerSDK.dll")]
  57. public static extern UInt32 NT_SP_SetVideoSizeCallBack(IntPtr handle, IntPtr callbackdata, SP_SDKVideoSizeCallBack call_back);
  58. /*
  59. * 设置视频回调, 吐视频数据出来
  60. * frame_format: 只能是NT_SP_E_VIDEO_FRAME_FORMAT_RGB32, NT_SP_E_VIDEO_FRAME_FROMAT_I420
  61. */
  62. [DllImport(@"x64\SmartPlayerSDK.dll")]
  63. public static extern UInt32 NT_SP_SetVideoFrameCallBack(IntPtr handle, Int32 frame_format,
  64. IntPtr callbackdata, SP_SDKVideoFrameCallBack call_back);
  65. /*
  66. * 设置视频回调, 吐视频数据出来, 可以指定吐出来的视频宽高
  67. * handle: 播放句柄
  68. * scale_width:缩放宽度(必须是偶数,建议是 16 的倍数)
  69. * scale_height:缩放高度(必须是偶数)
  70. * scale_filter_mode: 缩放质量, 0 的话 SDK 将使用默认值, 目前可设置范围为[1, 3], 值越大 缩放质量越好,但越耗性能
  71. * frame_format: 只能是NT_SP_E_VIDEO_FRAME_FORMAT_RGB32, NT_SP_E_VIDEO_FRAME_FROMAT_I420
  72. * 成功返回NT_ERC_OK
  73. */
  74. [DllImport(@"x64\SmartPlayerSDK.dll")]
  75. public static extern UInt32 NT_SP_SetVideoFrameCallBackV2(IntPtr handle,
  76. Int32 scale_width, Int32 scale_height,
  77. Int32 scale_filter_mode, Int32 frame_format,
  78. IntPtr call_back_data, SP_SDKVideoFrameCallBack call_back);
  79. /*
  80. * 设置绘制视频帧时,视频帧时间戳回调
  81. * 注意如果当前播放流是纯音频,那么将不会回调,这个仅在有视频的情况下才有效
  82. */
  83. [DllImport(@"x64\SmartPlayerSDK.dll")]
  84. public static extern UInt32 NT_SP_SetRenderVideoFrameTimestampCallBack(IntPtr handle,
  85. IntPtr callbackdata, SP_SDKRenderVideoFrameTimestampCallBack call_back);
  86. /*
  87. * 设置音频PCM帧回调, 吐PCM数据出来,目前每帧大小是10ms.
  88. */
  89. [DllImport(@"x64\SmartPlayerSDK.dll")]
  90. public static extern UInt32 NT_SP_SetAudioPCMFrameCallBack(IntPtr handle,
  91. IntPtr call_back_data, SP_SDKAudioPCMFrameCallBack call_back);
  92. /*
  93. * 设置用户数据回调
  94. */
  95. [DllImport(@"x64\SmartPlayerSDK.dll")]
  96. public static extern UInt32 NT_SP_SetUserDataCallBack(IntPtr handle,
  97. IntPtr call_back_data, SP_SDKUserDataCallBack call_back);
  98. /*
  99. * 设置视频sei数据回调
  100. */
  101. [DllImport(@"x64\SmartPlayerSDK.dll")]
  102. public static extern UInt32 NT_SP_SetSEIDataCallBack(IntPtr handle,
  103. IntPtr call_back_data, SP_SDKSEIDataCallBack call_back);
  104. /*
  105. * 开始播放,传URL进去
  106. */
  107. [DllImport(@"x64\SmartPlayerSDK.dll")]
  108. public static extern UInt32 NT_SP_Start(IntPtr handle, [MarshalAs(UnmanagedType.LPStr)] String url,
  109. IntPtr callbackdata, SP_SDKStartPlayCallBack call_back);
  110. /*
  111. * 停止播放
  112. */
  113. [DllImport(@"x64\SmartPlayerSDK.dll")]
  114. public static extern UInt32 NT_SP_Stop(IntPtr handle);
  115. //新接口++
  116. /*
  117. * 设置URL
  118. * 成功返回NT_ERC_OK
  119. */
  120. [DllImport(@"x64\SmartPlayerSDK.dll")]
  121. public static extern UInt32 NT_SP_SetURL(IntPtr handle, [MarshalAs(UnmanagedType.LPStr)] String url);
  122. /*
  123. * 设置解密key,目前只用来解密rtmp加密流
  124. * key: 解密密钥
  125. * size: 密钥长度
  126. * 成功返回NT_ERC_OK
  127. */
  128. [DllImport(@"x64\SmartPlayerSDK.dll")]
  129. public static extern UInt32 NT_SP_SetKey(IntPtr handle, byte[] key, UInt32 size);
  130. /*
  131. * 设置解密向量,目前只用来解密rtmp加密流
  132. * iv: 解密向量
  133. * size: 向量长度
  134. * 成功返回NT_ERC_OK
  135. */
  136. [DllImport(@"x64\SmartPlayerSDK.dll")]
  137. public static extern UInt32 NT_SP_SetDecryptionIV(IntPtr handle, byte[] iv, UInt32 size);
  138. /*
  139. * handle: 播放句柄
  140. * hwnd: 这个要传入真正用来绘制的窗口句柄
  141. * is_support: 如果支持的话 *is_support 为1, 不支持的话为0
  142. * 接口调用成功返回NT_ERC_OK
  143. */
  144. [DllImport(@"x64\SmartPlayerSDK.dll")]
  145. public static extern UInt32 NT_SP_IsSupportD3DRender(IntPtr handle, IntPtr hwnd, ref Int32 is_support);
  146. /*
  147. * 设置绘制窗口句柄,如果在调用Open时设置过,那这个接口可以不调用
  148. * 如果在调用Open时设置为NULL,那么这里可以设置一个绘制窗口句柄给播放器
  149. * 成功返回NT_ERC_OK
  150. */
  151. [DllImport(@"x64\SmartPlayerSDK.dll")]
  152. public static extern UInt32 NT_SP_SetRenderWindow(IntPtr handle, IntPtr hwnd);
  153. /*
  154. * 设置视频画面的填充模式,如填充整个绘制窗口、等比例填充绘制窗口,如不设置,默认填充整个绘制窗口
  155. * handle: 播放句柄
  156. * mode: 0: 填充整个绘制窗口; 1: 等比例填充绘制窗口, 默认值是0
  157. * 成功返回NT_ERC_OK
  158. */
  159. [DllImport(@"x64\SmartPlayerSDK.dll")]
  160. public static extern UInt32 NT_SP_SetRenderScaleMode(IntPtr handle, Int32 mode);
  161. /*
  162. * 设置是否播放出声音,这个和静音接口是有区别的
  163. * 这个接口的主要目的是为了用户设置了外部PCM回调接口后,又不想让SDK播放出声音时使用
  164. * is_output_auido_device: 1: 表示允许输出到音频设备,默认是1, 0:表示不允许输出. 其他值接口返回失败
  165. * 成功返回NT_ERC_OK
  166. */
  167. [DllImport(@"x64\SmartPlayerSDK.dll")]
  168. public static extern UInt32 NT_SP_SetIsOutputAudioDevice(IntPtr handle, Int32 is_output_auido_device);
  169. /*
  170. * 开始播放, 注意NT_SP_StartPlay和NT_SP_Start不能混用,要么使用NT_SP_StartPlay, 要么使用NT_SP_Start.
  171. * NT_SP_Start和NT_SP_Stop是老接口,不推荐用。请使用NT_SP_StartPlay和NT_SP_StopPlay新接口
  172. */
  173. [DllImport(@"x64\SmartPlayerSDK.dll")]
  174. public static extern UInt32 NT_SP_StartPlay(IntPtr handle);
  175. /*
  176. * 停止播放
  177. */
  178. [DllImport(@"x64\SmartPlayerSDK.dll")]
  179. public static extern UInt32 NT_SP_StopPlay(IntPtr handle);
  180. /*
  181. * 设置是否录视频,默认的话,如果视频源有视频就录,没有就没得录, 但有些场景下可能不想录制视频,只想录音频,所以增加个开关
  182. *
  183. * is_record_video: 1 表示录制视频, 0 表示不录制视频, 默认是1
  184. */
  185. [DllImport(@"x64\SmartPlayerSDK.dll")]
  186. public static extern UInt32 NT_SP_SetRecorderVideo(IntPtr handle, Int32 is_record_video);
  187. /*
  188. * 设置是否录音频,默认的话,如果视频源有音频就录,没有就没得录, 但有些场景下可能不想录制音频,只想录视频,所以增加个开关
  189. *
  190. * is_record_audio: 1 表示录制音频, 0 表示不录制音频, 默认是1
  191. */
  192. [DllImport(@"x64\SmartPlayerSDK.dll")]
  193. public static extern UInt32 NT_SP_SetRecorderAudio(IntPtr handle, Int32 is_record_audio);
  194. /*
  195. * 设置本地录像目录, 必须是英文目录,否则会失败
  196. */
  197. [DllImport(@"x64\SmartPlayerSDK.dll")]
  198. public static extern UInt32 NT_SP_SetRecorderDirectory(IntPtr handle, [MarshalAs(UnmanagedType.LPStr)] String dir);
  199. /*
  200. * 设置单个录像文件最大大小, 当超过这个值的时候,将切割成第二个文件
  201. * size: 单位是KB(1024Byte), 当前范围是 [5MB-800MB], 超出将被设置到范围内
  202. */
  203. [DllImport(@"x64\SmartPlayerSDK.dll")]
  204. public static extern UInt32 NT_SP_SetRecorderFileMaxSize(IntPtr handle, UInt32 size);
  205. /*
  206. * 设置录像文件名生成规则
  207. */
  208. [DllImport(@"x64\SmartPlayerSDK.dll", EntryPoint = "NT_SP_SetRecorderFileNameRuler", CallingConvention = CallingConvention.StdCall)]
  209. public static extern UInt32 NT_SP_SetRecorderFileNameRuler(IntPtr handle, ref NT_SP_RecorderFileNameRuler ruler);
  210. /*
  211. * 设置录像回调接口
  212. */
  213. [DllImport(@"x64\SmartPlayerSDK.dll")]
  214. public static extern UInt32 NT_SP_SetRecorderCallBack(IntPtr handle,
  215. IntPtr call_back_data, SP_SDKRecorderCallBack call_back);
  216. /*
  217. * 设置录像时音频转AAC编码的开关, aac比较通用,sdk增加其他音频编码(比如speex, pcmu, pcma等)转aac的功能.
  218. * is_transcode: 设置为1的话,如果音频编码不是aac,则转成aac, 如果是aac,则不做转换. 设置为0的话,则不做任何转换. 默认是0.
  219. * 注意: 转码会增加性能消耗
  220. */
  221. [DllImport(@"x64\SmartPlayerSDK.dll")]
  222. public static extern UInt32 NT_SP_SetRecorderAudioTranscodeAAC(IntPtr handle, Int32 is_transcode);
  223. /*
  224. * 启动录像
  225. */
  226. [DllImport(@"x64\SmartPlayerSDK.dll")]
  227. public static extern UInt32 NT_SP_StartRecorder(IntPtr handle);
  228. /*
  229. * 停止录像
  230. */
  231. [DllImport(@"x64\SmartPlayerSDK.dll")]
  232. public static extern UInt32 NT_SP_StopRecorder(IntPtr handle);
  233. /*
  234. * 设置拉流时,吐视频数据的回调
  235. */
  236. [DllImport(@"x64\SmartPlayerSDK.dll")]
  237. public static extern UInt32 NT_SP_SetPullStreamVideoDataCallBack(IntPtr handle, IntPtr call_back_data, SP_SDKPullStreamVideoDataCallBack call_back);
  238. /*
  239. * 设置拉流时,吐音频数据的回调
  240. */
  241. [DllImport(@"x64\SmartPlayerSDK.dll")]
  242. public static extern UInt32 NT_SP_SetPullStreamAudioDataCallBack(IntPtr handle, IntPtr call_back_data, SP_SDKPullStreamAudioDataCallBack call_back);
  243. /*
  244. * 设置拉流时音频转AAC编码的开关, aac比较通用,sdk增加其他音频编码(比如speex, pcmu, pcma等)转aac的功能.
  245. * is_transcode: 设置为1的话,如果音频编码不是aac,则转成aac, 如果是aac,则不做转换. 设置为0的话,则不做任何转换. 默认是0.
  246. * 注意: 转码会增加性能消耗
  247. */
  248. [DllImport(@"x64\SmartPlayerSDK.dll")]
  249. public static extern UInt32 NT_SP_SetPullStreamAudioTranscodeAAC(IntPtr handle, Int32 is_transcode);
  250. /*
  251. * 启动拉流
  252. */
  253. [DllImport(@"x64\SmartPlayerSDK.dll")]
  254. public static extern UInt32 NT_SP_StartPullStream(IntPtr handle);
  255. /*
  256. * 停止拉流
  257. */
  258. [DllImport(@"x64\SmartPlayerSDK.dll")]
  259. public static extern UInt32 NT_SP_StopPullStream(IntPtr handle);
  260. /*
  261. * 绘制窗口大小改变时,必须调用
  262. */
  263. [DllImport(@"x64\SmartPlayerSDK.dll")]
  264. public static extern UInt32 NT_SP_OnWindowSize(IntPtr handle, Int32 cx, Int32 cy);
  265. /*
  266. * 万能接口, 设置参数, 大多数问题, 这些接口都能解决
  267. */
  268. [DllImport(@"x64\SmartPlayerSDK.dll")]
  269. public static extern UInt32 NT_SP_SetParam(IntPtr handle, UInt32 id, IntPtr pData);
  270. /*
  271. * 万能接口, 得到参数, 大多数问题,这些接口都能解决
  272. */
  273. [DllImport(@"x64\SmartPlayerSDK.dll")]
  274. public static extern UInt32 NT_SP_GetParam(IntPtr handle, UInt32 id, IntPtr pData);
  275. /*
  276. * 设置buffer,最小0ms
  277. */
  278. [DllImport(@"x64\SmartPlayerSDK.dll")]
  279. public static extern UInt32 NT_SP_SetBuffer(IntPtr handle, Int32 buffer);
  280. /*
  281. * 静音接口,1为静音,0为不静音
  282. */
  283. [DllImport(@"x64\SmartPlayerSDK.dll")]
  284. public static extern UInt32 NT_SP_SetMute(IntPtr handle, Int32 is_mute);
  285. /*
  286. * 设置播放音量, 范围是[0, 100], 0是静音,100是最大音量, 默认是100
  287. */
  288. [DllImport(@"x64\SmartPlayerSDK.dll")]
  289. public static extern UInt32 NT_SP_SetAudioVolume(IntPtr handle, Int32 volume);
  290. /*
  291. * 设置RTSP TCP 模式, 1为TCP, 0为UDP, 仅RTSP有效
  292. */
  293. [DllImport(@"x64\SmartPlayerSDK.dll")]
  294. public static extern UInt32 NT_SP_SetRTSPTcpMode(IntPtr handle, Int32 isUsingTCP);
  295. /*
  296. * 设置RTSP超时时间, timeout单位为秒,必须大于0
  297. */
  298. [DllImport(@"x64\SmartPlayerSDK.dll")]
  299. public static extern UInt32 NT_SP_SetRtspTimeout(IntPtr handle, Int32 timeout);
  300. /*
  301. * [NOTE] 对于RTSP来说,有些可能支持rtp over udp方式,有些可能支持使用rtp over tcp方式.
  302. * 为了方便使用,有些场景下可以开启自动尝试切换开关, 打开后如果udp无法播放,sdk会自动尝试tcp, 如果tcp方式播放不了,sdk会自动尝试udp.
  303. * is_auto_switch_tcp_udp: 如果设置1的话, sdk将在tcp和udp之间尝试切换播放,如果设置为0,则不尝试切换.
  304. */
  305. [DllImport(@"x64\SmartPlayerSDK.dll")]
  306. public static extern UInt32 NT_SP_SetRtspAutoSwitchTcpUdp(IntPtr handle, Int32 is_auto_switch_tcp_udp);
  307. /*
  308. * 设置秒开, 1为秒开, 0为不秒开
  309. */
  310. [DllImport(@"x64\SmartPlayerSDK.dll")]
  311. public static extern UInt32 NT_SP_SetFastStartup(IntPtr handle, Int32 isFastStartup);
  312. /*
  313. * 设置低延时播放模式,默认是正常播放模式
  314. * mode: 1为低延时模式, 0为正常模式,其他只无效
  315. * 接口调用成功返回NT_ERC_OK
  316. */
  317. [DllImport(@"x64\SmartPlayerSDK.dll")]
  318. public static extern UInt32 NT_SP_SetLowLatencyMode(IntPtr handle, Int32 mode);
  319. /*
  320. * 检查是否支持H264硬解码
  321. * 如果支持的话返回NT_ERC_OK
  322. */
  323. [DllImport(@"x64\SmartPlayerSDK.dll")]
  324. public static extern UInt32 NT_SP_IsSupportH264HardwareDecoder();
  325. /*
  326. * 检查是否支持H265硬解码
  327. * 如果支持的话返回NT_ERC_OK
  328. */
  329. [DllImport(@"x64\SmartPlayerSDK.dll")]
  330. public static extern UInt32 NT_SP_IsSupportH265HardwareDecoder();
  331. /*
  332. * 设置H264硬解
  333. * is_hardware_decoder: 1:表示硬解, 0:表示不用硬解
  334. * reserve: 保留参数, 当前传0就好
  335. * 成功返回NT_ERC_OK
  336. */
  337. [DllImport(@"x64\SmartPlayerSDK.dll")]
  338. public static extern UInt32 NT_SP_SetH264HardwareDecoder(IntPtr handle, Int32 is_hardware_decoder, Int32 reserve);
  339. /*
  340. * 设置H265硬解
  341. * is_hardware_decoder: 1:表示硬解, 0:表示不用硬解
  342. * reserve: 保留参数, 当前传0就好
  343. * 成功返回NT_ERC_OK
  344. */
  345. [DllImport(@"x64\SmartPlayerSDK.dll")]
  346. public static extern UInt32 NT_SP_SetH265HardwareDecoder(IntPtr handle, Int32 is_hardware_decoder, Int32 reserve);
  347. /*
  348. * 设置只解码视频关键帧
  349. * is_only_dec_key_frame: 1:表示只解码关键帧, 0:表示都解码, 默认是0
  350. * 成功返回NT_ERC_OK
  351. */
  352. [DllImport(@"x64\SmartPlayerSDK.dll")]
  353. public static extern UInt32 NT_SP_SetOnlyDecodeVideoKeyFrame(IntPtr handle, Int32 is_only_dec_key_frame);
  354. /*
  355. *上下反转(垂直反转)
  356. *is_flip: 1:表示反转, 0:表示不反转
  357. */
  358. [DllImport(@"x64\SmartPlayerSDK.dll")]
  359. public static extern UInt32 NT_SP_SetFlipVertical(IntPtr handle, Int32 is_flip);
  360. /*
  361. *水平反转
  362. *is_flip: 1:表示反转, 0:表示不反转
  363. */
  364. [DllImport(@"x64\SmartPlayerSDK.dll")]
  365. public static extern UInt32 NT_SP_SetFlipHorizontal(IntPtr handle, Int32 is_flip);
  366. /*
  367. * 设置旋转,顺时针旋转
  368. * degress: 设置0, 90, 180, 270度有效,其他值无效
  369. * 注意:除了0度,其他角度播放会耗费更多CPU
  370. * 接口调用成功返回NT_ERC_OK
  371. */
  372. [DllImport(@"x64\SmartPlayerSDK.dll")]
  373. public static extern UInt32 NT_SP_SetRotation(IntPtr handle, Int32 degress);
  374. /*
  375. * 在使用D3D绘制的情况下,给绘制窗口上画一个logo, logo的绘制由视频帧驱动, 必须传入argb图像
  376. * argb_data: argb图像数据, 如果传null的话,将清除之前设置的logo
  377. * argb_stride: argb图像每行的步长(一般都是image_width*4)
  378. * image_width: argb图像宽度
  379. * image_height: argb图像高度
  380. * left: 绘制位置的左边x
  381. * top: 绘制位置的顶部y
  382. * render_width: 绘制的宽度
  383. * render_height: 绘制的高度
  384. */
  385. [DllImport(@"x64\SmartPlayerSDK.dll")]
  386. public static extern UInt32 NT_SP_SetRenderARGBLogo(IntPtr handle,
  387. IntPtr argb_data, Int32 argb_stride,
  388. Int32 image_width, Int32 image_height,
  389. Int32 left, Int32 top,
  390. Int32 render_width, Int32 render_height);
  391. /*
  392. * 设置下载速度上报, 默认不上报下载速度
  393. * is_report: 上报开关, 1: 表上报. 0: 表示不上报. 其他值无效.
  394. * report_interval: 上报时间间隔(上报频率),单位是秒,最小值是1秒1次. 如果小于1且设置了上报,将调用失败
  395. * 注意:如果设置上报的话,请设置SetEventCallBack, 然后在回调函数里面处理这个事件.
  396. * 上报事件是:NT_SP_E_EVENT_ID_DOWNLOAD_SPEED
  397. * 这个接口必须在StartXXX之前调用
  398. * 成功返回NT_ERC_OK
  399. */
  400. [DllImport(@"x64\SmartPlayerSDK.dll")]
  401. public static extern UInt32 NT_SP_SetReportDownloadSpeed(IntPtr handle, Int32 is_report, Int32 report_interval);
  402. /*
  403. * 主动获取下载速度
  404. * speed: 返回下载速度,单位是Byte/s
  405. * (注意:这个接口必须在startXXX之后调用,否则会失败)
  406. * 成功返回NT_ERC_OK
  407. */
  408. [DllImport(@"x64\SmartPlayerSDK.dll")]
  409. public static extern UInt32 NT_SP_GetDownloadSpeed(IntPtr handle, ref Int32 speed);
  410. /*
  411. * 获取视频时长
  412. * 对于直播的话,没有时长,调用结果未定义
  413. * 点播的话,如果获取成功返回NT_ERC_OK, 如果SDK还在解析中,则返回NT_ERC_SP_NEED_RETRY
  414. */
  415. [DllImport(@"x64\SmartPlayerSDK.dll")]
  416. public static extern UInt32 NT_SP_GetDuration(IntPtr handle, ref Int64 duration);
  417. /*
  418. * 获取当前播放时间戳, 单位是毫秒(ms)
  419. * 注意:这个时间戳是视频源的时间戳,只支持点播. 直播不支持.
  420. * 成功返回NT_ERC_OK
  421. */
  422. [DllImport(@"x64\SmartPlayerSDK.dll")]
  423. public static extern UInt32 NT_SP_GetPlaybackPos(IntPtr handle, ref Int64 pos);
  424. /*
  425. * 获取当前拉流时间戳, 单位是毫秒(ms)
  426. * 注意:这个时间戳是视频源的时间戳,只支持点播. 直播不支持.
  427. * 成功返回NT_ERC_OK
  428. */
  429. [DllImport(@"x64\SmartPlayerSDK.dll")]
  430. public static extern UInt32 NT_SP_GetPullStreamPos(IntPtr handle, ref Int64 pos);
  431. /*
  432. * 设置播放位置,单位是毫秒(ms)
  433. * 注意:直播不支持,这个接口用于点播
  434. * 成功返回NT_ERC_OK
  435. */
  436. [DllImport(@"x64\SmartPlayerSDK.dll")]
  437. public static extern UInt32 NT_SP_SetPos(IntPtr handle, Int64 pos);
  438. /*
  439. * 暂停播放
  440. * isPause: 1表示暂停, 0表示恢复播放, 其他错误
  441. * 注意:直播不存在暂停的概念,所以直播不支持,这个接口用于点播
  442. * 成功返回NT_ERC_OK
  443. */
  444. [DllImport(@"x64\SmartPlayerSDK.dll")]
  445. public static extern UInt32 NT_SP_Pause(IntPtr handle, Int32 isPause);
  446. /*
  447. * 切换URL
  448. * url:要切换的url
  449. * switch_pos: 切换到新url以后,设置的播放位置, 默认请填0, 这个只对设置播放位置的点播url有效, 直播url无效
  450. * reserve: 保留参数
  451. * 注意: 1. 如果切换的url和正在播放的url相同,sdk则不做任何处理
  452. * 调用前置条件: 已经成功调用了 StartPlay, StartRecorder, StartPullStream 三个中的任意一个接口
  453. * 成功返回NT_ERC_OK
  454. */
  455. [DllImport(@"x64\SmartPlayerSDK.dll")]
  456. public static extern UInt32 NT_SP_SwitchURL(IntPtr handle, [MarshalAs(UnmanagedType.LPStr)] String url, Int64 switch_pos, Int32 reserve);
  457. /*
  458. * 捕获图片
  459. * file_name_utf8: 文件名称,utf8编码
  460. * call_back_data: 回调时用户自定义数据
  461. * call_back: 回调函数,用来通知用户截图已经完成或者失败
  462. * 成功返回 NT_ERC_OK
  463. * 只有在播放时调用才可能成功,其他情况下调用,返回错误.
  464. * 因为生成PNG文件比较耗时,一般需要几百毫秒,为防止CPU过高,SDK会限制截图请求数量,当超过一定数量时,
  465. * 调用这个接口会返回NT_ERC_SP_TOO_MANY_CAPTURE_IMAGE_REQUESTS. 这种情况下, 请延时一段时间,等SDK处理掉一些请求后,再尝试.
  466. */
  467. [DllImport(@"x64\SmartPlayerSDK.dll")]
  468. public static extern UInt32 NT_SP_CaptureImage(IntPtr handle, IntPtr file_name_utf8,
  469. IntPtr call_back_data, SP_SDKCaptureImageCallBack call_back);
  470. /*
  471. * 使用GDI绘制RGB32数据
  472. * 32位的rgb格式, r, g, b各占8, 另外一个字节保留, 内存字节格式为: bb gg rr xx, 主要是和windows位图匹配, 在小端模式下,按DWORD类型操作,最高位是xx, 依次是rr, gg, bb
  473. * 为了保持和windows位图兼容,步长(image_stride)必须是width_*4
  474. * handle: 播放器句柄
  475. * hdc: 绘制dc
  476. * x_dst: 绘制面左上角x坐标
  477. * y_dst: 绘制面左上角y坐标
  478. * dst_width: 要绘制的宽度
  479. * dst_height: 要绘制的高度
  480. * x_src: 源图像x位置
  481. * y_src: 原图像y位置
  482. * rgb32_data: rgb32数据,格式参见前面的注释说明
  483. * rgb32_data_size: 数据大小
  484. * image_width: 图像实际宽度
  485. * image_height: 图像实际高度
  486. * image_stride: 图像步长
  487. */
  488. [DllImport(@"x64\SmartPlayerSDK.dll")]
  489. public static extern UInt32 NT_SP_GDIDrawRGB32(IntPtr handle, IntPtr hdc,
  490. Int32 x_dst, Int32 y_dst,
  491. Int32 dst_width, Int32 dst_height,
  492. Int32 x_src, Int32 y_src,
  493. Int32 src_width, Int32 src_height,
  494. IntPtr rgb32_data, UInt32 rgb32_data_size,
  495. Int32 image_width, Int32 image_height,
  496. Int32 image_stride);
  497. /*
  498. * 设置授权Key
  499. *
  500. * reserve1: 请传0
  501. * reserve2: 请传NULL
  502. * 成功返回: NT_ERC_OK
  503. */
  504. [DllImport(@"x64\SmartPlayerSDK.dll")]
  505. public static extern UInt32 NT_SP_SetSDKClientKey([MarshalAs(UnmanagedType.LPStr)] String cid, [MarshalAs(UnmanagedType.LPStr)] String key, Int32 reserve1, IntPtr reserve2);
  506. }
  507. }