Link to home
Start Free TrialLog in
Avatar of cskiong
cskiongFlag for Malaysia

asked on

WinInet to communicate with Web Server for real time media streams

Hi Experts,

I need some advices on using WinInet to establish HTTP connection with a web server synchornously/ asynchronously to send CGI Command for real time media stream transfer.
Basically the flow is as follow:
1. Client application connects to web server (with HTTP Basic Authentication).
2. Client sends CGI command to the web server using HTTP/1.0.  (If using WebBrowser2 Object, it will be webBrowser.Navigate(_T("http://127.0.0.1:8080/CGI_Commands..."));  how should I do this if I want to use WinInet instead of WebBrowser object)
3. The web server will reply with the media stream info embeded in the HTTP /1.0 200 OK response.
4. End connection.

Some brief step-by-step procedure using the WinInet API (Sequence and API to be used for each step as described above) will be enough for the work.  Appreciate if there are some advices in choosing Synchornous/ Asynchronous connection for the task.

For your information, I'm using Visual C++ 2005 and pure Win32 Programming to create a DLL components for doing this task.

Thank you!
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cskiong

ASKER

Hi DanRollins,

Thanks for the web reference.  The web page gives me something to start from.
I think I would need to use the WinInet to work in asynchornous mode, as I need to send CGI commands to the web server while the web server keeps sending my application some real time multi-media streams.

I have found one website: http://www.codeproject.com/KB/IP/asyncwininet.aspx
However I'm still digging my head and feel a bit lost.  Some advices on how to implementing the work as described will be very much appreciated:
1. Connect to the web server in asynchronous mode.
2. Send CGI command to request for some real time media stream (MPEG-4/ JPEG image).
3. Web server sends the media stream.
4. The application extracts the media data from HTTP or RTP(UDP) and pass to decoder library.
5. Then displays the decoded data on the MFC Windows (how should I display the decoded media stream on it)

Really appreciate for some advices and suggestions.  Thank you!
Alas, I know nothing about processing media streams.
However, if you look in the code at the posted link, in the CWebWorld::GetWebPage() fn, notice that the fn allocates a buffer and then use InternetReadFile to read it all at once.  It would also be possible to read it in blocks.  Read a block, pass it to a decoding / display fn, read another block, etc.
As a first pass, I'd simply use synchronous WinInet functionality.  Once that was working, you could try using the asynch option.   There is some example code here:
   SAMPLE: How to Use AsyncHTTP to Call WinInet APIs Asynchronously
   http://support.microsoft.com/kb/275046
Avatar of cskiong

ASKER

Hi DanRollins,

Thanks for the suggetsion, I'm doing the Asynchronous way.
I'll use some open source libraries to process the media streams.  However, I wonder how should I send the decoded data stream to the MFC applicatication to load it onto the UI, for example JPEG image and MPEG 4 stream?  I'm creating a dll library which will carry out all the WinInet things and also the data extraction and media stream decoding.  Some sample codes are very much appreciated.

Thank you!
Avatar of cskiong

ASKER

Thanks DanRollins,
I found one of your post to a similar question, where you suggest to use different thread to do the synchronous WinInet call, and it is working fine to me.  Thanks for all the help.