默认
发表评论 2
想开发IM:买成品怕坑?租第3方怕贵?找开源自已撸?尽量别走弯路了... 找站长给点建议
javascript ArrayBuffer的问题请教
阅读(36334) | 评论(2 收藏 淘帖
神秘人  发表于 6 年前 倒序浏览 |阅读模式
eMirroring.prototype.connectbyh264 = function(address,callback){

      _tcpSocket = new TcpSocket(address, 60000);
      var ip = loaclip;
      seqh264 = ++seqh264;
      var setupVideoBin = [0x62 ,0x70 ,0x6c ,0x69 ,0x73 ,0x74 ,0x30 ,0x30 ,0xd1 ,0x01 ,0x02 ,0x57 ,0x73 ,0x74 ,0x72 ,0x65 ,
    0x61 ,0x6d ,0x73 ,0xa1 ,0x03 ,0xd6 ,0x04 ,0x06 ,0x08 ,0x09 ,0x0b ,0x0d ,0x05 ,0x07 ,0x07 ,0x0a ,
    0x0c ,0x0e ,0x54 ,0x74 ,0x79 ,0x70 ,0x65 ,0x10 ,0x6e ,0x5c ,0x77 ,0x69 ,0x6e ,0x64 ,0x6f ,0x77 ,
    0x53 ,0x74 ,0x72 ,0x65 ,0x61 ,0x6d ,0x09 ,0x5f ,0x10 ,0x10 ,0x77 ,0x69 ,0x6e ,0x64 ,0x6f ,0x77 ,
    0x38 ,0x75 ,0x70 ,0x56 ,0x65 ,0x72 ,0x73 ,0x69 ,0x6f ,0x6e ,0x5c ,0x6d ,0x61 ,0x63 ,0x68 ,0x69 ,
    0x6e ,0x65 ,0x5f ,0x6e ,0x61 ,0x6d ,0x65 ,0x46 ,0x43 ,0x68 ,0x72 ,0x6f ,0x6d ,0x65 ,0xa0 ,0x5a ,
    0x6d ,0x61 ,0x63 ,0x68 ,0x69 ,0x6e ,0x65 ,0x5f ,0x69 ,0x70 ,0x49 ,0x31 ,0x32 ,0x37 ,0x2e ,0x30 ,
    0x2e ,0x30 ,0x2e ,0x31 ,0xa0 ,0x5f ,0x10 ,0x13 ,0x6d ,0x61 ,0x63 ,0x68 ,0x69 ,0x6e ,0x65 ,0x5f ,
    0x6d ,0x61 ,0x63 ,0x5f ,0x61 ,0x64 ,0x64 ,0x72 ,0x65 ,0x73 ,0x73 ,0x4f ,0x10 ,0x11 ,0x31 ,0x31 ,
    0x3a ,0x31 ,0x31 ,0x3a ,0x31 ,0x31 ,0x3a ,0x31 ,0x31 ,0x3a ,0x31 ,0x31 ,0x3a ,0x31 ,0x31 ,0xa0 ,
    0x08 ,0x0b ,0x13 ,0x15 ,0x22 ,0x27 ,0x29 ,0x36 ,0x37 ,0x4a ,0x57 ,0x5f ,0x6a ,0x75 ,0x8b ,0x00 ,
    0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x01 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x0f ,0x00 ,
    0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0xa0];

      var messageh264 = util.str2ab("SETUP rtsp://"+ip+" RTSP/1.0\r\nCSeq: "+seqh264+"\r\nUser-Agent: EShare (EShare 1.0)\r\nContent-Length: "+setupVideoBin.length+"\r\n\r\n");
      _tcpSocket.init(function() {


      _tcpSocket.send(messageh264,function(sendinfo){
              console.log("打通了51040");
      });这里我可以发送成功


       _tcpSocket.send(util.str2ab(setupVideoBin),function(sendinfo){
              console.log("打通了5040");
      这里我无法发送成功
    请问我要如何处理才能使得 setupVideoBin 数据成为 messageh264 这样的数据 而成功发送呢
      });;



    }.bind(this));

  }




  util.str2ab = function(str){
    var buf = new ArrayBuffer(str.length);
    bufView = new Uint8Array(buf);
    for(var i=0; i<str.length; i++){
        bufView = str.charCodeAt(i);
    }
    return buf;
  };

即时通讯网 - 即时通讯开发者社区! 来源: - 即时通讯开发者社区!

上一篇:请教谁能破解md5下一篇:新来的想问下有关实时视频的问题?
推荐方案
评论 2
这是在做什么功能?
自已逐段调试一下代码吧,网络程序肯定是首先确保数据有没有送达、送达的数据是不是完整的、送数的数据格式是不是合规的,无非就这些思路来排查。
签名: 国庆长假还没有缓过来,请让我静一静,产品狗死远点...
打赏楼主 ×
使用微信打赏! 使用支付宝打赏!

返回顶部