如何用C程序流媒体直播视频。应该用什么HTTP应答?如何使用分块编码如果可能的话? [英] How to live stream video using C program. What should be the HTTP reply ? How can I use chunked encoding if possible?

查看:211
本文介绍了如何用C程序流媒体直播视频。应该用什么HTTP应答?如何使用分块编码如果可能的话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(实际问题进行了编辑,因为我成功了做现场直播,但现在我不明白客户端和我的C code之间的通讯。)

(the actual question has been edited because I was successful doing live streaming, BUT NOW I DO NOT UNDERSTAND THE COMMUNICATION between client and my C code.)

好吧,我终于做到了用我的C code直播。但如何HTTP就是在这里工作我无法理解。
我研究的B / W我的浏览器的通信,并在链接 http://www.flumo​​tion.com / demosite / WEBM / 使用Wireshark的。

Okay I finally did live streaming using my C code. BUT I COULD NOT UNDERSTAND HOW "HTTP" IS WORKING HERE. I studied the communication b/w my browser and the server at the link http://www.flumotion.com/demosite/webm/ using wireshark.

我发现,客户端首先发送此GET请求

I found that the client first sends this GET request

GET /ahiasfhsasfsafsgfg.webm HTTP/1.1
Host: localhost
Connection: keep-alive
Referer: file:///home/anirudh/Desktop/anitom.html
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Range: bytes=0-1024

这个GET请求的服务器发送此回复响应

to this get request the server responds by sending this reply

HTTP/1.0 200 OK
Date: Tue, 01 Mar 2011 06:14:58 GMT
Connection: close
Cache-control: private
Content-type: video/webm
Server: FlumotionHTTPServer/0.7.0.1

,然后服务器发送数据,直到客户端断开连接。当它接收一定量的数据的客户端断开。然后,客户端连接到服务器的新端口上,并且在同一GET请求被发送到服务器。服务器再次给出了同样的答复,但此时客户端不会断开,但连续读取数据包,直到服务器断开连接。我写了一个C code这其中我有它复制上述行为的服务器套接字。 (感谢Wireshark的,flumo​​tion和计算器)

and then the server sends the data until the client disconnects. The client disconnects when it receives a certain amount of data. The CLIENT then connects to the server on a new port and the same GET request is sent to the server. The server again gives the same reply but this time the client does not disconnect but continuously reads the packets until the server disconnects. I wrote a C code which in which I have a server socket which replicates the above behavior. (thanks to wireshark, flumotion and stackoverflow)

但却只是,我不明白为什么客户端需要发送两个请求?为什么它重置第一个请求,然后重新发送一个新的端口上相同的请求,这一次它监听数据,如果得到现场直播。
此外,我不知道我怎么可以使用块编码实时流。

BUT BUT BUT, I could not understand why does the client need to send two requests and why does it resets on the first request and again send the same request on a new port and this time it listens to the data as if its getting live streamed. Also I do not know how I can live stream using chunked encoding.

在细节同样的事情可以在这里找到:的http://systemsdaemon.blogspot.com/2011/03/live-streaming-video-tutorial-for.html

The same thing in detail is available here : http://systemsdaemon.blogspot.com/2011/03/live-streaming-video-tutorial-for.html

和这里的http://systemsdaemon.blogspot.com/2011/03/http-streaming-video-using-program-in-c.html

请帮助我。先谢谢了。

推荐答案

第一个请求被限制为1024字节,以测试该流实际上是一个有效的视频源,而不是说一个600MB的Windows可执行文件。

The first request is limited to 1024 bytes in order to test that the stream is actually a valid video source and not say a 600MB Windows executable.

这篇关于如何用C程序流媒体直播视频。应该用什么HTTP应答?如何使用分块编码如果可能的话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆