smart_player_sdk_x86.cs 24 KB

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