赞
踩
get_rtsp_url
c接口,增加测试程序;#include "ipconvif.h" #include <iostream> using namespace std; int main() { char buf1[1024] = {0}; char buf2[1024] = {0}; int ret = get_rtsp_url(buf1, buf2, "192.21.1.201", "admin", "123cpucpu"); if (ret != 0) { std::cout << "not find" << std::endl; } return 0; }
from cffi import FFI import os import sys ffi = FFI() ffi.cdef(''' int get_rtsp_url(char* rtsp_url1, char* rtsp_url2, const char *ip, const char *username, const char *password); ''') LIB_NAME = 'libipconvif.so' class Ipconvif(): def __init__(self, ip, username, passwd): self.rtsp_url1 = ffi.new("char[]", 1024) # first url self.rtsp_url2 = ffi.new("char[]", 1024) # second url self.ip = ffi.new("char[]", ip.encode()) self.username = ffi.new("char[]", username.encode()) self.passwd = ffi.new("char[]", passwd.encode()) self.lib = None self.load_library() def load_library(self): lib_path = LIB_NAME if os.path.exists(lib_path): self.lib = ffi.dlopen(lib_path) return True return False def get_rtsp_url(self): self.lib.get_rtsp_url(self.rtsp_url1, self.rtsp_url2, self.ip, self.username, self.passwd) return ffi.string(self.rtsp_url1), ffi.string(self.rtsp_url2) if __name__ == "__main__": ipc = Ipconvif('192.21.1.201', 'admin', '123cpucpu') urls = ipc.get_rtsp_url(); print(urls[0]) print(urls[1])
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。