Streaming 如何编写Lighttpd插件来进行流媒体直播
我想写一个Lighttpd插件来做流媒体 到目前为止,我在函数“mod\u strm\u handle\u physical”中复制了客户端套接字(con->fd)。这样我就可以在子进程中通过它发送流式数据。至于主进程,我为连接结构设置了一些状态,以告诉服务器不要关闭此连接 以下是我在“mod\u strm\u handle\u physical”函数中所做的操作:Streaming 如何编写Lighttpd插件来进行流媒体直播,streaming,lighttpd,live-streaming,Streaming,Lighttpd,Live Streaming,我想写一个Lighttpd插件来做流媒体 到目前为止,我在函数“mod\u strm\u handle\u physical”中复制了客户端套接字(con->fd)。这样我就可以在子进程中通过它发送流式数据。至于主进程,我为连接结构设置了一些状态,以告诉服务器不要关闭此连接 以下是我在“mod\u strm\u handle\u physical”函数中所做的操作: URIHANDLER_FUNC(mod_strm_handle_physical) { if(con->uri.pa
URIHANDLER_FUNC(mod_strm_handle_physical)
{
if(con->uri.path->ptr)
{
if(!strcmp("/abcd", con->uri.path->ptr))
{
// change Content-Type
response_header_overwrite(srv, con
, CONST_STR_LEN("Content-Type")
, CONST_STR_LEN("application/octet-stream"));
con->http_status = 200;
con->file_finished = 0; // not to close the connection
con->response.keep_alive = 1;
int dup_fd = dup(con->fd); // duplicate the client-socket
int child = fork();
if(child>0)
return HANDLER_FINISHED;
else if(child==0)
{
send(dup_fd, STREAMING_DATA, LENGTH, 0);
close(dup_fd);
exit(0);
}
else
perror("fork()");
}
}
return HANDLER_GO_ON;
}
问题是。。
通过这种方式,服务器可以进行流式处理,看起来还可以。但是,服务器不能同时执行多个流。我做错什么了吗?我认为流媒体作业已退出进程为什么不使用现有模块?或或者至少,使用现有的一个例子?谢谢你的评论,但我确实读过mod_flv_streaming,知道它是如何工作的。实际上我正在做一个直播,mod_flv_stream正在直播一个文件。