@ -575,14 +575,16 @@ CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPa
CPhoneDevice : : ~ CPhoneDevice ( )
CPhoneDevice : : ~ CPhoneDevice ( )
{
{
std : : map < IDevice : : timer_uid_t , TIMER_CONTEXT * > timers ;
m_devLocker . lock ( ) ;
m_devLocker . lock ( ) ;
for ( auto it = mTimers . begin ( ) ; it ! = mTimers . end ( ) ; + + it )
mTimers . swap ( timers ) ;
m_devLocker . unlock ( ) ;
for ( auto it = timers . begin ( ) ; it ! = timers . end ( ) ; + + it )
{
{
timer_delete ( ( timer_t ) it - > first ) ;
timer_delete ( ( timer_t ) it - > first ) ;
delete it - > second ;
delete it - > second ;
}
}
mTimers . clear ( ) ;
timers . clear ( ) ;
m_devLocker . unlock ( ) ;
JNIEnv * env = NULL ;
JNIEnv * env = NULL ;
bool didAttachThread = false ;
bool didAttachThread = false ;
@ -1473,29 +1475,27 @@ IDevice::timer_uid_t CPhoneDevice::RegisterTimer(unsigned int timerType, unsigne
bool CPhoneDevice : : UnregisterTimer ( IDevice : : timer_uid_t uid )
bool CPhoneDevice : : UnregisterTimer ( IDevice : : timer_uid_t uid )
{
{
bool existed = false ;
TIMER_CONTEXT * timerContext = NULL ;
std : : map < IDevice : : timer_uid_t , TIMER_CONTEXT * > : : iterator it ;
m_devLocker . lock ( ) ;
m_devLocker . lock ( ) ;
std: : map < IDevice : : timer_uid_t , TIMER_CONTEXT * > : : iterator it = mTimers . find ( uid ) ;
it = mTimers . find ( uid ) ;
if ( it ! = mTimers . end ( ) )
if ( it ! = mTimers . end ( ) )
{
{
delete it - > second ;
timerContext = it - > second ;
mTimers . erase ( it ) ;
mTimers . erase ( it ) ;
m_devLocker . unlock ( ) ;
existed = true ;
}
}
else
{
m_devLocker . unlock ( ) ;
m_devLocker . unlock ( ) ;
}
if ( timerContext ! = NULL )
if ( existed )
{
{
ALOGI ( " UnregisterTimer: %lld " , uid ) ;
ALOGI ( " UnregisterTimer: %lld " , uid ) ;
timer_t timer = ( timer_t ) uid ;
timer_t timer = ( timer_t ) uid ;
int res = timer_delete ( timer ) ;
int res = timer_delete ( timer ) ;
delete timerContext ;
return true ;
}
}
return existed ;
return false ;
}
}
uint64_t CPhoneDevice : : RequestWakelock ( uint64_t timeout )
uint64_t CPhoneDevice : : RequestWakelock ( uint64_t timeout )
@ -1613,7 +1613,9 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
// Wait about 10s
// Wait about 10s
for ( int idx = 0 ; idx < 84 ; idx + + )
for ( int idx = 0 ; idx < 84 ; idx + + )
{
{
XYLOG ( XYLOG_SEVERITY_INFO , " Before GetEthnetHandle %d IMGID=%u " , idx , localPhotoInfo . photoId ) ;
netHandle = GetEthnetHandle ( ) ;
netHandle = GetEthnetHandle ( ) ;
XYLOG ( XYLOG_SEVERITY_INFO , " After GetEthnetHandle %d NetHandle=%llu IMGID=%u " , idx , netHandle , localPhotoInfo . photoId ) ;
if ( netHandle ! = 0 )
if ( netHandle ! = 0 )
{
{
break ;
break ;
@ -1626,22 +1628,20 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
// timeout
// timeout
m_ethernetFailures + + ;
m_ethernetFailures + + ;
# if !defined(NDEBUG) && defined(OUTPUT_DBG_INFO)
std : : string pwrStatus = powerCtrlPtr - > GetStatus ( ) ;
pwrStatus + = ethernetPowerCtrl - > GetStatus ( ) ;
XYLOG ( XYLOG_SEVERITY_ERROR , " Ethernet Not Existing CH=%u PR=%X PHOTOID=%u EthFailures=%u PWR:%s " ,
( uint32_t ) localPhotoInfo . channel , ( uint32_t ) localPhotoInfo . preset , localPhotoInfo . photoId , m_ethernetFailures , pwrStatus . c_str ( ) ) ;
# else
XYLOG ( XYLOG_SEVERITY_ERROR , " Ethernet Not Existing CH=%u PR=%X PHOTOID=%u EthFailures=%u " ,
XYLOG ( XYLOG_SEVERITY_ERROR , " Ethernet Not Existing CH=%u PR=%X PHOTOID=%u EthFailures=%u " ,
( uint32_t ) localPhotoInfo . channel , ( uint32_t ) localPhotoInfo . preset , localPhotoInfo . photoId , m_ethernetFailures ) ;
( uint32_t ) localPhotoInfo . channel , ( uint32_t ) localPhotoInfo . preset , localPhotoInfo . photoId , m_ethernetFailures ) ;
# endif
TakePhotoCb ( 0 , localPhotoInfo , " " , 0 ) ;
TakePhotoCb ( 0 , localPhotoInfo , " " , 0 ) ;
XYLOG ( XYLOG_SEVERITY_INFO , " After TakePhotoCb %d IMGID=%u " , localPhotoInfo . photoId ) ;
if ( m_ethernetFailures > 3 )
if ( m_ethernetFailures > 3 )
{
{
time_t rebootTime = GetRebootTime ( ) ;
time_t rebootTime = GetRebootTime ( ) ;
if ( ts - rebootTime > 1800 )
if ( ts - rebootTime > 1800 )
{
{
XYLOG ( XYLOG_SEVERITY_INFO , " Before Reboot %d IMGID=%u " , localPhotoInfo . photoId ) ;
Reboot ( REBOOT_TYPE_DEVICE , true , " Ethernet Not Existing " ) ;
Reboot ( REBOOT_TYPE_DEVICE , true , " Ethernet Not Existing " ) ;
XYLOG ( XYLOG_SEVERITY_INFO , " After Reboot %d IMGID=%u " , localPhotoInfo . photoId ) ;
}
}
}
}
@ -1653,11 +1653,14 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
unsigned int netMask = 0 ;
unsigned int netMask = 0 ;
unsigned int gateway = 0 ;
unsigned int gateway = 0 ;
char buf [ 32 ] = { 0 } ;
char buf [ 32 ] = { 0 } ;
XYLOG ( XYLOG_SEVERITY_INFO , " Before GetNetInfo %d IMGID=%u " , localPhotoInfo . photoId ) ;
if ( GetNetInfo ( " eth0 " , ip , netMask , gateway ) )
if ( GetNetInfo ( " eth0 " , ip , netMask , gateway ) )
{
{
XYLOG ( XYLOG_SEVERITY_INFO , " After GetNetInfo %d IMGID=%u " , localPhotoInfo . photoId ) ;
// const
// const
sockaddr_in addrIn = { AF_INET , 0 , ip } ;
sockaddr_in addrIn = { AF_INET , 0 , ip } ;
inet_ntop ( AF_INET , & addrIn . sin_addr , buf , sizeof ( buf ) ) ; //其中recvAddr为SOCKADDR_IN类型
inet_ntop ( AF_INET , & addrIn . sin_addr , buf , sizeof ( buf ) ) ; //其中recvAddr为SOCKADDR_IN类型
XYLOG ( XYLOG_SEVERITY_INFO , " After ntop %d IMGID=%u " , localPhotoInfo . photoId ) ;
}
}
XYLOG ( XYLOG_SEVERITY_INFO , " Ethernet is Available Handle=%llu IP=%s CH=%u PR=%X PHOTOID=%u " , ( uint64_t ) netHandle , buf , ( uint32_t ) localPhotoInfo . channel , ( uint32_t ) localPhotoInfo . preset , localPhotoInfo . photoId ) ;
XYLOG ( XYLOG_SEVERITY_INFO , " Ethernet is Available Handle=%llu IP=%s CH=%u PR=%X PHOTOID=%u " , ( uint64_t ) netHandle , buf , ( uint32_t ) localPhotoInfo . channel , ( uint32_t ) localPhotoInfo . preset , localPhotoInfo . photoId ) ;
@ -1703,7 +1706,7 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
UniviewResolutionSet ( netPhotoInfo , localPhotoInfo . cameraId , localPhotoInfo . resolution ) ;
UniviewResolutionSet ( netPhotoInfo , localPhotoInfo . cameraId , localPhotoInfo . resolution ) ;
}
}
# endif
# endif
:
img . clear ( ) ;
img . clear ( ) ;
netCaptureResult = vendorCtrl - > TakePhoto ( localPhotoInfo . cameraId , img ) ;
netCaptureResult = vendorCtrl - > TakePhoto ( localPhotoInfo . cameraId , img ) ;
@ -1850,7 +1853,6 @@ bool CPhoneDevice::TakeVideoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
vendorCtrl - > SetResolution ( localPhotoInfo . cameraId , 1 , localPhotoInfo . width , localPhotoInfo . height ) ;
vendorCtrl - > SetResolution ( localPhotoInfo . cameraId , 1 , localPhotoInfo . width , localPhotoInfo . height ) ;
}
}
std : : string streamingUrl = vendorCtrl - > GetStreamingUrl ( localPhotoInfo . cameraId ) ;
std : : string streamingUrl = vendorCtrl - > GetStreamingUrl ( localPhotoInfo . cameraId ) ;
if ( streamingUrl . empty ( ) )
if ( streamingUrl . empty ( ) )