nodejs中的RTMP实现是可能的? [英] RTMP implementation in nodejs is possible?

查看:775
本文介绍了nodejs中的RTMP实现是可能的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Node.js中实现RTMP,但看到文档和尝试后,我无法,我怀疑这是不可能的,使它看到如何node.js处理的流数据。

我分叉这个代码: https://github.com/timwhitlock/node-amf/tree/master/node-rtmp



根据代码和写得不好的adobe文档,在连接之后,握手过程开始,客户端发送1537个八比特组的流,其中第一个是rtmp版本(应该总是3),以下4个是时间戳,另一个是4应该是0(0000),所有其余的数据都是随机字符。

现在,链接库完成了所有这些工作,但是在检查4个零点的时候就会被破坏。它使用Net模块创建一个服务器,并监听连接事件。使用由事件提供的套接字对象,将编码设置为二进制(这种类型的编码不存在,直到我看到在文档 http://nodejs.org/api/stream.html#stream_stream_setencoding_encoding ),然后尝试检查四个零的

我怀疑套接字是在'utf8'编码,而且有什么地方这个流被搞砸,因为打印第一个字节,是不相同的数据。更改为十六进制编码的套接字,我发现匹配,将表明我要找的四个零:

  V | TIME | 4 ZEROS | RANDOM DATA 
03 | 0091c3ee | 80000702 | 3e904115
03 | 0091ea60 | 80000702 | f6e2d38a
03 | 00921a47 | 80000702 | f2e21db3

03 | 0092eaeb | 80000702 | 15834dbf
03 | 00931e0d | 80000702 | 5f0b7891
03 | 00933c68 | 80000702 | b4980c5d


$甚至当我需要将真实的数据,如视频,音频等等,流到服务器(我知道我可以从中写入)时,即使我可以使它工作 socket二进制数据传递一个Buffer对象并使用它: https://github.com/substack/node-binary ),而套接字无法处理二进制数据,我会损坏数据的权利?

我不是专家,但我试图调查尽我所能,即使这不能解决,我想有人可以告诉我,如果我是对的,或者只是我搞砸了:)

好吧,我的回答是相同的
仍然,收到的数据不是0(字节5,6,7和8有128 0 7 2),所以我需要知道如何正确解析二进制数据,但至少现在看来,这似乎是可能的。



问候,
阴影。


i'm trying to make a implementation of RTMP in Node.js but after seeing the documentation and trying, i'm unable to, and i suspect this is not possible to make it seeing how node.js handle the streams of data.

i'm forking this code: https://github.com/timwhitlock/node-amf/tree/master/node-rtmp

according to the code and the poorly written adobe documentation, after the connection, the handshaking process starts, the clients send a stream of 1537 octets, where the first one is the rtmp version (should be always 3), the following 4 are the timestamp and the other 4 should be 0 (0000), all the rest of the data are random characters.

now, the linked library do all this, but get broken at the point of checking the 4 zero's. it uses the Net module to create a server, and listen on connection event. using the socket object provided by the event, set the encoding to "binary" (this type of encoding doesn't exist as far i see in the documentation http://nodejs.org/api/stream.html#stream_stream_setencoding_encoding ) and then try to check for the four zero's

i suspect that the socket is encoding in 'utf8' anyways, and there is where the stream get screw up, as printing the first bytes, is never the same data. changing to hex the encoding of the socket, i found matches that would indicate the four zero's i'm looking for:

V | TIME   |4 ZEROS |RANDOM DATA
03|0091c3ee|80000702|3e904115
03|0091ea60|80000702|f6e2d38a
03|00921a47|80000702|f2e21db3

03|0092eaeb|80000702|15834dbf
03|00931e0d|80000702|5f0b7891
03|00933c68|80000702|b4980c5d

even i could make it work like that, when i need to stream real data, as video, audio, etc.. , to the server (i know that i can write from the socket binary data passing a Buffer object and using this: https://github.com/substack/node-binary ) and the socket can't handle binary data, i will have corrupted data right?

i'm not an expert, but i tried to investigate this as far i can, even if this can't be solved, i'd like someone could tell me if i'm right or just i'm screwing up :)

解决方案

well, my answer was on the same documentation, if i don't call at all setEncoding() on the socket object returned by the Net module, i can receive a plain binary Buffer, that i can parse at will, so this seems to be possible.

still, the data received are not 0's (on bytes 5,6,7 and 8 there is 128 0 7 2) so i need to know how to correctly parse binary data, but at least for now, this seems to be possible.

Regards, Shadow.

这篇关于nodejs中的RTMP实现是可能的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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