int main() { HI_S32 s32Ret = HI_SUCCESS; HI_S_STREAM_INFO struStreamInfo; HI_NET_DEV_Init(); s32Ret = HI_NET_DEV_Login(&u32Handle, UNAME, PWORD, DHOST, DPORT); if (s32Ret != HI_SUCCESS) { HI_NET_DEV_DeInit(); return -1; } //HI_NET_DEV_SetEventCallBack(u32Handle, OnEventCallback, &a); HI_NET_DEV_SetStreamCallBack(u32Handle, (HI_ON_STREAM_CALLBACK)OnStreamCallback, NULL); //HI_NET_DEV_SetDataCallBack(u32Handle, OnDataCallback, &a); struStreamInfo.u32Channel = HI_NET_DEV_CHANNEL_1; struStreamInfo.blFlag = HI_TRUE;; struStreamInfo.u32Mode = HI_NET_DEV_STREAM_MODE_TCP; struStreamInfo.u8Type = HI_NET_DEV_STREAM_ALL; s32Ret = HI_NET_DEV_StartStream(u32Handle, &struStreamInfo); if (s32Ret != HI_SUCCESS) { HI_NET_DEV_Logout(u32Handle); u32Handle = 0; return -1; } EASY_MEDIA_INFO_T mediainfo; memset(&mediainfo, 0x00, sizeof(EASY_MEDIA_INFO_T)); mediainfo.u32VideoCodec = EASY_SDK_VIDEO_CODEC_H264; mediainfo.u32AudioCodec = EASY_SDK_AUDIO_CODEC_G711A;//默认摄像机输出PCMA mediainfo.u32AudioSamplerate = 8000; fPusherHandle = EasyPusher_Create(); EasyPusher_SetEventCallback(fPusherHandle, __EasyPusher_Callback, 0, NULL); EasyPusher_StartStream(fPusherHandle, SHOST, SPORT, SNAME, "admin", "admin", &mediainfo, 1024); while(1) { #ifdef _WIN32 Sleep(10); #else usleep(10*1000); #endif }; EasyPusher_StopStream(fPusherHandle); EasyPusher_Release(fPusherHandle); fPusherHandle = 0; HI_NET_DEV_StopStream(u32Handle); HI_NET_DEV_Logout(u32Handle); HI_NET_DEV_DeInit(); return 0; }
int main() { HI_S32 s32Ret = HI_SUCCESS; HI_S_STREAM_INFO struStreamInfo; HI_U32 a; HI_NET_DEV_Init(); s32Ret = HI_NET_DEV_Login(&u32Handle, CNAME, CPWORD, CHOST, CPORT); if (s32Ret != HI_SUCCESS) { HI_NET_DEV_DeInit(); return -1; } //HI_NET_DEV_SetEventCallBack(u32Handle, OnEventCallback, &a); HI_NET_DEV_SetStreamCallBack(u32Handle, (HI_ON_STREAM_CALLBACK)OnStreamCallback, &a); //HI_NET_DEV_SetDataCallBack(u32Handle, OnDataCallback, &a); struStreamInfo.u32Channel = HI_NET_DEV_CHANNEL_1; struStreamInfo.blFlag = HI_FALSE;//HI_FALSE; struStreamInfo.u32Mode = HI_NET_DEV_STREAM_MODE_TCP; struStreamInfo.u8Type = HI_NET_DEV_STREAM_ALL; s32Ret = HI_NET_DEV_StartStream(u32Handle, &struStreamInfo); if (s32Ret != HI_SUCCESS) { HI_NET_DEV_Logout(u32Handle); u32Handle = 0; return -1; } //创建EasyHLS Session fHlsHandle = EasyHLS_Session_Create(PLAYLIST_CAPACITY, ALLOW_CACHE, M3U8_VERSION); char subDir[64] = { 0 }; sprintf(subDir,"%s/",HLS_SESSION_NAME); EasyHLS_ResetStreamCache(fHlsHandle, HLS_ROOT_DIR, subDir, HLS_SESSION_NAME, TARGET_DURATION); printf("HLS URL:%s%s/%s.m3u8", HTTP_ROOT_URL, HLS_SESSION_NAME, HLS_SESSION_NAME); while(1) { #ifndef _WIN32 usleep(10*1000); #else Sleep(10); #endif }; EasyHLS_Session_Release(fHlsHandle); fHlsHandle = 0; HI_NET_DEV_StopStream(u32Handle); HI_NET_DEV_Logout(u32Handle); HI_NET_DEV_DeInit(); return 0; }
static __inline__ void bsm_login(bsm_service_t *bsm_srv) { char addr[MAX_IP_LEN]; int state, error = 0; int user_id = BSM_LOGOUT; proxy_sdk_t sdk_info; NMP_ASSERT(bsm_srv); if (proxy_get_device_private(bsm_srv->owner, DEV_PRI_PRX_SDK, &sdk_info)) { BUG(); } memset(addr, 0, sizeof(addr)); if (proxy_resolve_host_immediate((const char*)sdk_info.dev_host, addr, sizeof(addr))) { error = HI_NET_DEV_Login((HI_U32*)&user_id, sdk_info.username, sdk_info.password, addr, sdk_info.dev_port); } else show_warn("Device host '%s' unsolved.\n", sdk_info.dev_host); if (BSM_LOGOUT != user_id) { state = BSM_LOGIN; error = 0; show_debug("bsm_login() successful, user_id: %d\n", user_id); } else { state = BSM_LOGOUT; //error = ; if (strlen(addr)) { show_warn("bsm_login(deviceID:%d) failure[%s:%s @ %s:%d]. Error: %d\n", bsm_srv->owner->fastenings.dev_id, sdk_info.username, sdk_info.password, addr, sdk_info.dev_port, error); } } bsm_set_user_id(bsm_srv, user_id); bsm_set_state(bsm_srv, (BSM_STATE_E)state, error); return ; }
bool EasyCameraSource::cameraLogin() { //如果已登录,返回true if (fCameraLogin) return true; //登录到摄像机 HI_S32 s32Ret = HI_SUCCESS; s32Ret = HI_NET_DEV_Login(&m_u32Handle, sCameraUser, sCameraPassword, sCamera_IP, sCameraPort); if (s32Ret != HI_SUCCESS) { qtss_printf("HI_NET_DEV_Login Fail\n"); m_u32Handle = 0; return false; } else { HI_NET_DEV_SetReconnect(m_u32Handle, 5000); fCameraLogin = true; } return true; }
int main(int argc, char * argv[]) { int isActivated = 0; #ifndef _WIN32 signal(SIGPIPE, SIG_IGN); #endif #ifdef _WIN32 extern char* optarg; #endif int ch; ProgName = argv[0]; PrintUsage(); while ((ch = getopt(argc,argv, "hd:p:n:N:P:H:T:")) != EOF) { switch(ch) { case 'h': PrintUsage(); return 0; break; case 'd': ConfigIP =optarg; break; case 'p': ConfigPort =optarg; break; case 'n': ConfigName =optarg; break; case 'N': ConfigUName =optarg; break; case 'P': ConfigPWD =optarg; break; case 'H': ConfigDHost =optarg; break; case 'T': ConfigDPort =optarg; break; case '?': return 0; break; default: break; } } isActivated = EasyPusher_Activate(KEY); switch(isActivated) { case EASY_ACTIVATE_INVALID_KEY: printf("KEY is EASY_ACTIVATE_INVALID_KEY!\n"); break; case EASY_ACTIVATE_TIME_ERR: printf("KEY is EASY_ACTIVATE_TIME_ERR!\n"); break; case EASY_ACTIVATE_PROCESS_NAME_LEN_ERR: printf("KEY is EASY_ACTIVATE_PROCESS_NAME_LEN_ERR!\n"); break; case EASY_ACTIVATE_PROCESS_NAME_ERR: printf("KEY is EASY_ACTIVATE_PROCESS_NAME_ERR!\n"); break; case EASY_ACTIVATE_VALIDITY_PERIOD_ERR: printf("KEY is EASY_ACTIVATE_VALIDITY_PERIOD_ERR!\n"); break; case EASY_ACTIVATE_SUCCESS: printf("KEY is EASY_ACTIVATE_SUCCESS!\n"); break; } if(EASY_ACTIVATE_SUCCESS != isActivated) return -1; HI_S32 s32Ret = HI_SUCCESS; HI_S_STREAM_INFO struStreamInfo; HI_NET_DEV_Init(); s32Ret = HI_NET_DEV_Login(&u32Handle, ConfigUName, ConfigPWD, ConfigDHost, atoi(ConfigDPort)); if (s32Ret != HI_SUCCESS) { HI_NET_DEV_DeInit(); return -1; } //HI_NET_DEV_SetEventCallBack(u32Handle, OnEventCallback, &a); HI_NET_DEV_SetStreamCallBack(u32Handle, (HI_ON_STREAM_CALLBACK)OnStreamCallback, NULL); //HI_NET_DEV_SetDataCallBack(u32Handle, OnDataCallback, &a); struStreamInfo.u32Channel = HI_NET_DEV_CHANNEL_1; struStreamInfo.blFlag = HI_TRUE;; struStreamInfo.u32Mode = HI_NET_DEV_STREAM_MODE_TCP; struStreamInfo.u8Type = HI_NET_DEV_STREAM_ALL; s32Ret = HI_NET_DEV_StartStream(u32Handle, &struStreamInfo); if (s32Ret != HI_SUCCESS) { HI_NET_DEV_Logout(u32Handle); u32Handle = 0; return -1; } EASY_MEDIA_INFO_T mediainfo; memset(&mediainfo, 0x00, sizeof(EASY_MEDIA_INFO_T)); mediainfo.u32VideoCodec = EASY_SDK_VIDEO_CODEC_H264; mediainfo.u32VideoFps = 25; mediainfo.u32AudioCodec = EASY_SDK_AUDIO_CODEC_G711A;//SDK output Audio PCMA mediainfo.u32AudioSamplerate = 8000; mediainfo.u32AudioChannel = 1; fPusherHandle = EasyPusher_Create(); EasyPusher_SetEventCallback(fPusherHandle, __EasyPusher_Callback, 0, NULL); EasyPusher_StartStream(fPusherHandle, ConfigIP, atoi(ConfigPort), ConfigName, "admin", "admin", &mediainfo, 1024, false);//1M缓冲区 printf("Press Enter exit...\n"); getchar(); EasyPusher_StopStream(fPusherHandle); EasyPusher_Release(fPusherHandle); fPusherHandle = 0; HI_NET_DEV_StopStream(u32Handle); HI_NET_DEV_Logout(u32Handle); HI_NET_DEV_DeInit(); return 0; }
int main() { HI_S32 s32Ret = HI_SUCCESS; HI_S_STREAM_INFO struStreamInfo; HI_U32 a; HI_NET_DEV_Init(); s32Ret = HI_NET_DEV_Login(&u32Handle, UNAME, PWORD, DHOST, DPORT); if (s32Ret != HI_SUCCESS) { HI_NET_DEV_DeInit(); return -1; } //HI_NET_DEV_SetEventCallBack(u32Handle, OnEventCallback, &a); HI_NET_DEV_SetStreamCallBack(u32Handle, (HI_ON_STREAM_CALLBACK)OnStreamCallback, &a); //HI_NET_DEV_SetDataCallBack(u32Handle, OnDataCallback, &a); struStreamInfo.u32Channel = HI_NET_DEV_CHANNEL_1; struStreamInfo.blFlag = HI_FALSE;//HI_FALSE; struStreamInfo.u32Mode = HI_NET_DEV_STREAM_MODE_TCP; struStreamInfo.u8Type = HI_NET_DEV_STREAM_ALL; s32Ret = HI_NET_DEV_StartStream(u32Handle, &struStreamInfo); if (s32Ret != HI_SUCCESS) { HI_NET_DEV_Logout(u32Handle); u32Handle = 0; return -1; } WSADATA wsaData; WSAStartup(MAKEWORD(2,2), &wsaData); EASY_MEDIA_INFO_T mediainfo; memset(&mediainfo, 0x00, sizeof(EASY_MEDIA_INFO_T)); mediainfo.u32VideoCodec = 0x1C; pusherHandle = EasyPusher_Create(); EasyPusher_SetEventCallback(pusherHandle, __EasyPusher_Callback, 0, NULL); EasyPusher_StartStream(pusherHandle, SHOST, SPORT, "live.sdp", "admin", "admin", &mediainfo); printf("*** live streaming url:rtsp://%s:%d/live.sdp ***\n", SHOST, SPORT); while(1) { Sleep(10); }; EasyPusher_StopStream(pusherHandle); EasyPusher_Release(pusherHandle); pusherHandle = 0; HI_NET_DEV_StopStream(u32Handle); HI_NET_DEV_Logout(u32Handle); HI_NET_DEV_DeInit(); return 0; }