Jump to content

Recommended Posts

Posted

hello world!

hopefully someone has a workaround for this... i would like to use ienavigate to browse to a camera feed

 

when I use this address in chrome, it shows me the video feed i want.  when i use IE 7 it prompts me to download video.cgi and I never get the video feed.

i think the ie udf uses ie 7 because i get the same behavior when using ienavigate

any help is greatly appreciated!

Posted (edited)

Hi,

The download prompt shows that IE does not support the stream in the way it's sent.

Try to upgrade your IE version.

Why do you need this for? You can directly display the stream in your GUI with some TCP and GDIPlus functions (take a look at the IP Camera link in my signature).

Edit: @JLogan3o13

Again you?? Get the f**k out of here ! :D

Br, FireFox.

Edited by FireFox
Posted

Yes it will work :)

It's not a UDF, just an example.

If you don't have a HTTP authentication then remove the lines where it authenticates.

Br, FireFox.

Posted

still cant get a feed

using this

TCPSend($iSocket, _
        "GET /-wvhttp-01-/video.cgi?v=jpg:320x240::10000 HTTP/1.1" & @CRLF & _
        "Host: " & $iIPAddress & ":" & $iPort & @CRLF & _
        "Connection: keep-alive" & @CRLF)

 

the camera doesnt use a port and it seems its a required field for tcpconnect

Posted (edited)

The default HTTP port is 80.

Edit: The double CRLF is required at the end of your header request !

Edited by FireFox
Posted (edited)

i am trying to strip out the recording part of it as i only need the viewer.. so many variables to go through - my eyes hurt!

id like just a bare viewer

Edited by gcue
Posted (edited)

Not hard to do, here you go (not tested) :

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <Memory.au3>

#region Global Vars
Global Const $sProgramTitle = "IP Camera stream"

;HERE YOU GO:
Global Const $iIPAddress = "192.168.1.99", $iPort = 80

Global Const $STM_SETIMAGE = 0x0172

Global $blGUIMinimized = False

Global $bRecvtmp = Binary(""), $bStream = $bRecvtmp
Global $iImgLen = 0, $iStreamLen = 0, $iWritten = 0, $iEOH = 0, $iContLenPos = 0, $pBuffer = 0
Global Const $iContLengthLen = StringLen("Content-Length: ")
Global $sStream = "", $sTrim2ContLen = ""

Global $hBMP = 0, $hHBITMAP2 = 0
#endregion Global Vars

TCPStartup()

Global $iSocket = TCPConnect($iIPAddress, $iPort)
If @error Then
    MsgBox(16, $sProgramTitle, "Could not connect !")
    Exit -1
EndIf

TCPSend($iSocket, _
        "GET /videostream.cgi HTTP/1.1" & @CRLF & _
        "Host: " & $iIPAddress & ":" & $iPort & @CRLF & _
        "Connection: keep-alive" & @CRLF & @CRLF)

#region GUI
Global $hGUI = 0, $pPic = 0, $hPic = 0

$hGUI = GUICreate($sProgramTitle, 640, 525)

$pPic = GUICtrlCreatePic("", 0, 0, 640, 480, $SS_BITMAP)
GUICtrlSetState($pPic, $GUI_DISABLE)
$hPic = GUICtrlGetHandle($pPic)

GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")

GUISetState(@SW_SHOW, $hGUI)
#endregion GUI

_GDIPlus_Startup()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch

    $bRecvtmp = TCPRecv($iSocket, 4096, 1) ;4kb
    If @error Then ExitLoop

    If Not BinaryLen($bRecvtmp) Then ContinueLoop
    $bStream &= $bRecvtmp

    If $iImgLen = 0 Then
        $sStream = BinaryToString($bStream)

        $iContLenPos = StringInStr($sStream, "Content-Length: ", 2)
        $iEOH = StringInStr($sStream, @CRLF & @CRLF, 2, 1, $iContLenPos)

        If $iEOH = 0 Or $iContLenPos = 0 Then ContinueLoop

        $sTrim2ContLen = StringTrimLeft($sStream, $iContLenPos + $iContLengthLen - 1)

        $iImgLen = Number(StringLeft($sTrim2ContLen, StringInStr($sTrim2ContLen, @CR, 2) - 1))

        $bStream = BinaryMid($bStream, $iEOH + 4)
    EndIf

    If $iImgLen = 0 Then ContinueLoop

    $iStreamLen = BinaryLen($bStream)
    If $iStreamLen < $iImgLen Then ContinueLoop

    If Not $blGUIMinimized Then
        $hBMP = Load_BMP_From_Mem($bStream)

        $hHBITMAP2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP)

        _WinAPI_DeleteObject(_SendMessage($hPic, $STM_SETIMAGE, 0, $hHBITMAP2))

        _GDIPlus_ImageDispose($hBMP)
        _WinAPI_DeleteObject($hHBITMAP2)
    EndIf

    $iImgLen = 0
WEnd

_GDIPlus_Shutdown()

TCPCloseSocket($iSocket)
TCPShutdown()

Func WM_SYSCOMMAND($hWnd, $iMsg, $wParam, $lParam)
    Local Const $SC_MINIMIZE = 0xF020, $SC_RESTORE = 0xF120

    Switch BitAND($wParam, 0xFFF0)
        Case $SC_MINIMIZE, $SC_RESTORE
            $blGUIMinimized = Not $blGUIMinimized
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SYSCOMMAND

Func Load_BMP_From_Mem($mem_image)
    ;author: UEZ
    ;Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines
    If Not IsBinary($mem_image) Then Return SetError(1, 0, 0)

    Local Const $memBitmap = Binary($mem_image)
    Local Const $len = BinaryLen($memBitmap)
    Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE)
    Local Const $pData = _MemGlobalLock($hData)
    Local $tMem = DllStructCreate("byte[" & $len & "]", $pData)

    DllStructSetData($tMem, 1, $memBitmap)
    _MemGlobalUnlock($hData)

    Local $hStream = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0)
    $hStream = $hStream[3]

    Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0)
    $hBitmap = $hBitmap[2]
    Local Const $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
            "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT))
    $tMem = 0
    Return $hBitmap
EndFunc   ;==>Load_BMP_From_Mem
Br, FireFox. Edited by FireFox
Posted (edited)

if the camera does require authentication.. how do i pass username and password.. i see your example only passes 1 variable  $sauth

"Authorization: Basic " & $shtauth & @CRLF & @CRLF)

i tried

$shtauth = "user:pass"

but that didn't work

Edited by gcue
Posted

i know.  but the one i sent you a link for works - i checked it against another online tool.

i just liked the autoitscript so i can keep it for future use. =)

Posted

If you encode "user:pass" you will have :

$shtauth = "dXNlcjpwYXNz"
In case you have == at the end, don't strip it.

If it does not work, capture the request sent by Chrome under the network tab of the developer tools.

Br, FireFox.

Posted

yes i am sending the credentials correctly.


If it does not work, capture the request sent by Chrome under the network tab of the developer tools.

 

not sure what you mean 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...