Configuration API > BS2_SetRtspConfig


[+ 2.8.3] RTSP 설정을 저장합니다.

함수

#include "BS_API.h"
 
int BS2_SetRtspConfig(void* context, uint32_t deviceId, const BS2RtspConfig* config);

파라미터

  • [In] context : Context
  • [In] deviceId : 장치 식별자
  • [In] config : RTSP 설정 정보 포인터

반환값

성공적으로 수행될 경우 BS_SDK_SUCCESS를 반환하고, 에러가 발생할 경우 상응하는 에러 코드를 반환합니다.

샘플코드(C++)

sample_setrtspconfig.cpp
BS2RtspConfig config = { 0, };
 
config.enabled = true;
 
string acc = "myAccount";
memset(config.id, 0x0, BS2_USER_ID_SIZE);
memcpy(config.id, acc.c_str(), acc.size());
 
string pw = "myPassword";
memset(config.password, 0x0, BS2_USER_ID_SIZE);
memcpy(config.password, pw.c_str(), pw.size());
 
string addr = "192.168.0.10";	// rtsp://192.168.0.10
memset(config.address, 0x0, BS2_URL_SIZE);
memcpy(config.address, addr.c_str(), addr.size());
 
config.port = 554;
 
int sdkResult = BS2_SetRtspConfig(context, deviceID, &config);
if (BS_SDK_SUCCESS != sdkResult)
	printf("BS2_SetRtspConfig call failed: %d", sdkResult);

샘플코드(C#)

sample_setrtspconfig.cs
BS2RtspConfig config = Util.AllocateStructure<BS2RtspConfig>();
 
config.enabled = Convert.ToByte(1);
 
string strRTSPID = "myAccount";
byte[] arrRTSPID = Encoding.UTF8.GetBytes(strRTSPID);
Array.Clear(config.id, 0, BS2Environment.BS2_USER_ID_SIZE);
Array.Copy(arrRTSPID, 0, config.id, 0, arrRTSPID.Length);
 
string strRTSPPW = "myPassword";
byte[] arrRTSPPW = Encoding.UTF8.GetBytes(strRTSPPW);
Array.Clear(config.password, 0, BS2Environment.BS2_USER_ID_SIZE);
Array.Copy(arrRTSPPW, 0, config.password, 0, arrRTSPPW.Length);
 
string strIpAddr = "192.168.0.10";  // rtsp://192.168.0.10
byte[] arrIpAddr = Encoding.UTF8.GetBytes(strIpAddr);
Array.Clear(config.address, 0, BS2Environment.BS2_URL_SIZE);
Array.Copy(arrIpAddr, 0, config.address, 0, arrIpAddr.Length);
 
config.port = (ushort)554;
 
BS2ErrorCode result = (BS2ErrorCode)API.BS2_SetRtspConfig(sdkContext, deviceID, ref config);
if (result != BS2ErrorCode.BS_SDK_SUCCESS)
{
	Console.WriteLine("Got error({0}).", result);
}