1.打印100个字节的数据
2.设置成电脑ip 端口号
| | |
| | | try { |
| | | // 将字节数组包装为ByteBuf |
| | | ByteBuf buffer = Unpooled.wrappedBuffer(packet); |
| | | String str = BytesUtils.bytesToHexString( BytesUtils.subArray(buffer.array(),0,30)); |
| | | byte[] dataBytes = buffer.array(); |
| | | int len = 0; |
| | | if (dataBytes.length<100){ |
| | | len = dataBytes.length; |
| | | }else { |
| | | len = 100; |
| | | } |
| | | String str = BytesUtils.bytesToHexString( BytesUtils.subArray(dataBytes,0,len)); |
| | | Timber.i( "Send TCP packet:"+ str); |
| | | // 异步写入 |
| | | ChannelFuture future = channel.writeAndFlush(buffer); |
| | |
| | | h264Encoder?.setEncoderParams(640, 480, 25, 2000000) |
| | | |
| | | // 设置输出文件(可选) |
| | | val outputFile = File(getExternalFilesDir(null), "test.h264") |
| | | val outputFile = File(getExternalFilesDir(null), "test2.h264") |
| | | h264Encoder?.setOutputFile(outputFile.absolutePath) |
| | | h264Encoder?.setEnableFileOutput(true) // 启用文件输出 |
| | | h264Encoder?.setEnableFileOutput(false) // 启用文件输出 |
| | | |
| | | // 设置UDP服务器地址(可选) |
| | | // h264Encoder?.setServerAddress("58.48.93.67", 11935) |
| | | h264Encoder?.setEnableNetworkTransmission(false) |
| | | h264Encoder?.setServerAddress("192.168.16.12", 11935) |
| | | h264Encoder?.setEnableNetworkTransmission(true) |
| | | h264Encoder?.setServerAddress("192.168.16.138", 1078) |
| | | h264Encoder?.setProtocolParams("013120122580", 1) |
| | | |
| | | // 初始化并启动 |