File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -635,8 +635,10 @@ OnvifDevice.prototype._mediaGetSnapshotUri = function() {
635635 this . services . media . getSnapshotUri ( params , ( error , result ) => {
636636 if ( ! error ) {
637637 try {
638- profile [ 'snapshot' ] = result [ 'data' ] [ 'GetSnapshotUriResponse' ] [ 'MediaUri' ] [ 'Uri' ] ;
639- } catch ( e ) { }
638+ let snapshotUri = result [ 'data' ] [ 'GetSnapshotUriResponse' ] [ 'MediaUri' ] [ 'Uri' ] ;
639+ snapshotUri = this . _getSnapshotUri ( snapshotUri ) ;
640+ profile [ 'snapshot' ] = snapshotUri ;
641+ } catch ( e ) { console . log ( e ) ; }
640642 }
641643 profile_index ++ ;
642644 getSnapshotUri ( ) ;
@@ -668,4 +670,17 @@ OnvifDevice.prototype._getUri = function(directUri) {
668670 return newUri ;
669671}
670672
673+ OnvifDevice . prototype . _getSnapshotUri = function ( directUri ) {
674+ if ( ! this . keepAddr ) return directUri ;
675+ const base = mUrl . parse ( 'http://' + this . address ) ;
676+ const parts = mUrl . parse ( directUri ) ;
677+ const newParts = {
678+ protocol : parts . protocol ,
679+ host : base . host ,
680+ pathname : base . pathname + parts . pathname
681+ } ;
682+ const newUri = mUrl . format ( newParts ) ;
683+ return newUri ;
684+ }
685+
671686module . exports = OnvifDevice ;
You can’t perform that action at this time.
0 commit comments