Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.nio.ByteBuffer;

public class Main {
    public static byte[] addHeader(byte[] data) {
        byte[] h264 = new byte[data.length + 4];
        for (int i = 0; i < data.length; i++) {
            h264[i + 4] = data[i];
        }
        byte[] lens = ByteBuffer.allocate(4).putInt(data.length).array();
        h264[0] = lens[0];
        h264[1] = lens[1];
        h264[2] = lens[2];
        h264[3] = lens[3];
        return h264;
    }
}