|
|
@ -1763,7 +1763,7 @@ bool CPhoneDevice::TakeVideoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
|
|
|
|
if (netHandle == 0)
|
|
|
|
if (netHandle == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Wait about 10s
|
|
|
|
// Wait about 10s
|
|
|
|
for (int idx = 0; idx < 84; idx++)
|
|
|
|
for (int idx = 0; idx < 128; idx++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(128));
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(128));
|
|
|
|
netHandle = GetEthnetHandle();
|
|
|
|
netHandle = GetEthnetHandle();
|
|
|
@ -1792,12 +1792,7 @@ bool CPhoneDevice::TakeVideoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
|
|
|
|
// SetStaticIp();
|
|
|
|
// SetStaticIp();
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(256));
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(256));
|
|
|
|
|
|
|
|
|
|
|
|
struct in_addr addr;
|
|
|
|
std::string ip = GetIpStr(localPhotoInfo.ip);
|
|
|
|
char ip[32] = { 0 };
|
|
|
|
|
|
|
|
addr.s_addr = localPhotoInfo.ip;
|
|
|
|
|
|
|
|
strcpy(ip, inet_ntoa(addr));
|
|
|
|
|
|
|
|
// strcpy(netPhotoInfo.outputPath, path.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VendorCtrl* vendorCtrl = MakeVendorCtrl(localPhotoInfo.vendor, localPhotoInfo.channel, ip, localPhotoInfo.userName, localPhotoInfo.password, netHandle);
|
|
|
|
VendorCtrl* vendorCtrl = MakeVendorCtrl(localPhotoInfo.vendor, localPhotoInfo.channel, ip, localPhotoInfo.userName, localPhotoInfo.password, netHandle);
|
|
|
|
if (vendorCtrl == NULL)
|
|
|
|
if (vendorCtrl == NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1864,62 +1859,98 @@ bool CPhoneDevice::TakeVideoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
|
|
|
|
|
|
|
|
|
|
|
|
bool CPhoneDevice::StartPushStreaming(IDevice::PHOTO_INFO& photoInfo, const std::string& url, std::vector<IDevice::OSD_INFO>& osds, std::shared_ptr<PowerControl> powerCtrlPtr)
|
|
|
|
bool CPhoneDevice::StartPushStreaming(IDevice::PHOTO_INFO& photoInfo, const std::string& url, std::vector<IDevice::OSD_INFO>& osds, std::shared_ptr<PowerControl> powerCtrlPtr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
if (photoInfo.mediaType == XY_MEDIA_TYPE_STREAM)
|
|
|
|
if (photoInfo.mediaType == XY_MEDIA_TYPE_STREAM)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::map<uint8_t, std::shared_ptr<Streaming> >::iterator it = m_streamings.find(photoInfo.channel);
|
|
|
|
time_t ts = time(NULL);
|
|
|
|
if (it != m_streamings.end())
|
|
|
|
uint32_t waitTime = photoInfo.selfTestingTime;
|
|
|
|
|
|
|
|
if(!GpioControl::GetSelftestStatus(waitTime))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
it->second->stop();
|
|
|
|
m_isSelfTesting.store(true);
|
|
|
|
it->second.reset();
|
|
|
|
waitTime = (waitTime != 0) ? (waitTime * 1024) : 10240;
|
|
|
|
m_streamings.erase(it);
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(waitTime));
|
|
|
|
|
|
|
|
m_isSelfTesting.store(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NET_PHOTO_INFO netPhotoInfo = { 0, 0 };
|
|
|
|
XYLOG(XYLOG_SEVERITY_DEBUG, "Ethernet Power ON");
|
|
|
|
if (photoInfo.vendor == 1)
|
|
|
|
std::shared_ptr<PowerControl> ethernetPowerCtrl = std::make_shared<EthernetPowerCtrl>(1);
|
|
|
|
|
|
|
|
// std::shared_ptr<PowerControl> ethernetPowerCtrl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
net_handle_t netHandle = GetEthnetHandle();
|
|
|
|
|
|
|
|
if (netHandle == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Hai Kang
|
|
|
|
// Wait about 10s
|
|
|
|
netPhotoInfo.authType = HTTP_AUTH_TYPE_DIGEST;
|
|
|
|
for (int idx = 0; idx < 84; idx++)
|
|
|
|
snprintf(netPhotoInfo.url, sizeof(netPhotoInfo.url), "/ISAPI/Streaming/channels/1/picture?");
|
|
|
|
{
|
|
|
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(128));
|
|
|
|
|
|
|
|
netHandle = GetEthnetHandle();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (netHandle != 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (photoInfo.vendor == 2)
|
|
|
|
|
|
|
|
|
|
|
|
if (netHandle == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Hang Yu
|
|
|
|
// timeout
|
|
|
|
strcpy(netPhotoInfo.url, "/cgi-bin/snapshot.cgi");
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Ethernet not existing CH=%u PR=%X PHOTOID=%u", (uint32_t)photoInfo.channel, (uint32_t)photoInfo.preset, photoInfo.photoId);
|
|
|
|
|
|
|
|
#ifdef NDEBUG
|
|
|
|
|
|
|
|
TakePhotoCb(0, localPhotoInfo, "", 0);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (photoInfo.vendor == 3)
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Yu Shi
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "Ethernet is Available CH=%u PR=%X PHOTOID=%u", (uint32_t)photoInfo.channel, (uint32_t)photoInfo.preset, photoInfo.photoId);
|
|
|
|
netPhotoInfo.authType = HTTP_AUTH_TYPE_DIGEST;
|
|
|
|
|
|
|
|
int streamSid = 0; // should put into config
|
|
|
|
|
|
|
|
// rtsp://192.168.0.13:554/media/video1
|
|
|
|
|
|
|
|
snprintf(netPhotoInfo.url, sizeof(netPhotoInfo.url), "/media/video%u", (uint32_t)photoInfo.cameraId);
|
|
|
|
|
|
|
|
// strcpy(netPhotoInfo.url, "rtsp://192.168.50.224/live/0");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (photoInfo.vendor == 5)
|
|
|
|
|
|
|
|
|
|
|
|
// SetStaticIp();
|
|
|
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(256));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::map<uint8_t, STREAMING_CONTEXT>::iterator it = m_streamings.find(photoInfo.channel);
|
|
|
|
|
|
|
|
if (it != m_streamings.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Hang Yu - New
|
|
|
|
it->second.stream->stop();
|
|
|
|
netPhotoInfo.authType = HTTP_AUTH_TYPE_BASIC;
|
|
|
|
it->second.stream.reset();
|
|
|
|
// http://192.168.1.46/Snapshot/%u/RemoteImageCapture?ImageFormat=2&HorizontalPixel=1920&VerticalPixel=1080
|
|
|
|
it->second.powerCtrl.reset();
|
|
|
|
// http://192.168.1.101/Snapshot/1/2/RemoteImageCaptureV2?ImageFormat=jpg
|
|
|
|
it->second.ethernetPowerCtrl.reset();
|
|
|
|
// http://192.168.1.101/Snapshot/1/1/RemoteImageCaptureV2?ImageFormat=jpg
|
|
|
|
m_streamings.erase(it);
|
|
|
|
snprintf(netPhotoInfo.url, sizeof(netPhotoInfo.url), "/Snapshot/%u/1/RemoteImageCaptureV2?ImageFormat=jpg", (uint32_t)photoInfo.cameraId);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
|
|
std::string ip = GetIpStr(photoInfo.ip);
|
|
|
|
|
|
|
|
VendorCtrl* vendorCtrl = MakeVendorCtrl(photoInfo.vendor, photoInfo.channel, ip, photoInfo.userName, photoInfo.password, netHandle);
|
|
|
|
|
|
|
|
if (vendorCtrl == NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Vendor(%u) not Supported CH=%u PR=%X PHOTOID=%u", (uint32_t)photoInfo.vendor, (uint32_t)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId);
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Vendor(%u) not Supported CH=%u PR=%X PHOTOID=%u", (uint32_t)photoInfo.vendor, (uint32_t)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId);
|
|
|
|
TakePhotoCb(0, photoInfo, "", 0);
|
|
|
|
TakePhotoCb(0, photoInfo, "", 0);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string streamingUrl = vendorCtrl->GetStreamingUrl(photoInfo.cameraId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (streamingUrl.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Invalid Streaming URL CH=%u PR=%X PHOTOID=%u", (uint32_t)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId);
|
|
|
|
|
|
|
|
TakePhotoCb(0, photoInfo, "", 0);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
StreamForwarder* forwarder = new StreamForwarder();
|
|
|
|
StreamForwarder* forwarder = new StreamForwarder();
|
|
|
|
m_streamings[photoInfo.channel] = std::shared_ptr<Streaming>((Streaming*)forwarder);
|
|
|
|
|
|
|
|
// Initialize with RTSP input and RTMP output
|
|
|
|
// Initialize with RTSP input and RTMP output
|
|
|
|
if (!forwarder->initialize(std::string(netPhotoInfo.url), url)) {
|
|
|
|
if (!forwarder->initialize(streamingUrl, url)) {
|
|
|
|
std::cerr << "Failed to initialize stream forwarder" << std::endl;
|
|
|
|
std::cerr << "Failed to initialize stream forwarder" << std::endl;
|
|
|
|
|
|
|
|
delete forwarder;
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STREAMING_CONTEXT ctx;
|
|
|
|
|
|
|
|
ctx.stream = std::shared_ptr<Streaming>((Streaming*)forwarder);
|
|
|
|
|
|
|
|
ctx.powerCtrl = powerCtrlPtr;
|
|
|
|
|
|
|
|
ctx.ethernetPowerCtrl = ethernetPowerCtrl;
|
|
|
|
|
|
|
|
m_streamings[photoInfo.channel] = ctx;
|
|
|
|
|
|
|
|
|
|
|
|
// Optional: Set callback to process video frames
|
|
|
|
// Optional: Set callback to process video frames
|
|
|
|
#if 0
|
|
|
|
#if 0
|
|
|
|
forwarder->setFrameCallback([](uint8_t* data, int linesize, int width, int height) {
|
|
|
|
forwarder->setFrameCallback([](uint8_t* data, int linesize, int width, int height) {
|
|
|
@ -1942,12 +1973,14 @@ bool CPhoneDevice::StartPushStreaming(IDevice::PHOTO_INFO& photoInfo, const std:
|
|
|
|
auto it = m_streamings.find(photoInfo.channel);
|
|
|
|
auto it = m_streamings.find(photoInfo.channel);
|
|
|
|
if (it != m_streamings.end())
|
|
|
|
if (it != m_streamings.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
it->second->stop();
|
|
|
|
it->second.stream->stop();
|
|
|
|
it->second.reset();
|
|
|
|
it->second.stream.reset();
|
|
|
|
|
|
|
|
it->second.powerCtrl.reset();
|
|
|
|
|
|
|
|
it->second.ethernetPowerCtrl.reset();
|
|
|
|
m_streamings.erase(it);
|
|
|
|
m_streamings.erase(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|