Skip to content

Commit 4b6cecb

Browse files
author
hide
committed
chore: modify code comment & add LICENSE.
1 parent 85072ac commit 4b6cecb

File tree

8 files changed

+868
-20
lines changed

8 files changed

+868
-20
lines changed

LICENSE

+674
Large diffs are not rendered by default.

LINCENSE_CN

+173
Large diffs are not rendered by default.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
- [x] 1. encode with x264.
66
- [x] 2. push into RTMP server.
7-
- [ ] 3. encode with openh264.
8-
- [ ] 4. echo cancellation in software. Maybe need libspeex, currently has a scheme which is hardware scheme in **VOICE_COMMUNICATION**.
7+
- [x] 3. encode with openh264.
8+
- [ ] 4. echo cancellation in software. Maybe need libspeex.
99

1010

1111
## Building & Testing

openh264-codec/src/main/java/io/github/brucewind/softcodec/RtmpHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.util.concurrent.atomic.AtomicInteger;
1010

1111
/**
12-
* Created by wei on 16-11-27.
12+
* Created by bruce on 16-11-27.
1313
*
1414
* It is used to manager picture to be encode, and transfer encoded data to server in {@link ExecutorService}.
1515
*/

openh264-codec/src/main/java/io/github/brucewind/softcodec/StreamHelper.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.brucewind.softcodec;
22

33
/**
4-
* Created by wei on 16-11-24.
4+
* Created by bruce on 16-11-24.
55
* It is used to connect server and push stream.
66
*/
77
class StreamHelper {
@@ -21,12 +21,12 @@ class StreamHelper {
2121
/**
2222
* x264 function
2323
* @param encoder
24-
* @param NV12
25-
* @param NV12size
26-
* @param H264
24+
* @param I420
25+
* @param I420Size
26+
* @param H264, it is unused.
2727
* @return
2828
*/
29-
public native int compressBuffer(long encoder, byte[] NV12, int NV12size, byte[] H264);
29+
public native int compressBuffer(long encoder, byte[] I420, int I420Size, byte[] H264);
3030

3131
public native long compressBegin(int width, int height, int bitrate, int fps);
3232

openh264-codec/src/main/jni/softcodec/h264Encoder.cc

+11-10
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ int handle_sps_pps(int NAL_type, unsigned char *buffer, int len) {
2424
ALOGE("buffer format is wrong.");
2525
return -1;
2626
}
27-
if (NAL_type == 7) {
27+
if (NAL_type == NAL_SPS) {
2828
sps = buffer;
2929
sps_len = len;
3030
print_hex("SPS", sps, sps_len);
31-
} else if (NAL_type == 8) {
31+
} else if (NAL_type == NAL_PPS) {
3232
pps = buffer;
3333
pps_len = len;
3434
send_video_sps_pps(sps, sps_len, pps, pps_len);
@@ -63,16 +63,16 @@ Java_io_github_brucewind_softcodec_StreamHelper_compressBegin(JNIEnv *env,
6363
encoder->GetDefaultParams(
6464
&param);//call InitializeExt must have a extension parameter with this default.
6565
param.iUsageType = CAMERA_VIDEO_REAL_TIME; //tell openH264 steam type is LIVE.
66-
param.iRCMode = RC_QUALITY_MODE;
66+
param.iRCMode = RC_BITRATE_MODE;
6767
param.fMaxFrameRate = fps; //fps
6868
param.iPicWidth = width;
6969
param.iPicHeight = height;
7070
param.iTargetBitrate = bitrate * 1024; //the input parameter need to * 1024
7171
// param.iInputCsp = videoFormatI420; //it is stable YUV format for openh264
72-
param.bEnableDenoise = 1; //enable eliminating noisy.
72+
// param.bEnableDenoise = 1; //enable eliminating noisy.
7373
param.iSpatialLayerNum = 1;
7474
//if (sliceMode != SM_SINGLE_SLICE && sliceMode != SM_DYN_SLICE) //SM_DYN_SLICE don't support multi-thread now
75-
// param.iMultipleThreadIdc = 2;
75+
param.iMultipleThreadIdc = 2;
7676
for (int i = 0; i < param.iSpatialLayerNum; i++) {
7777
param.sSpatialLayers[i].iVideoWidth = width >> (param.iSpatialLayerNum - 1 - i);
7878
param.sSpatialLayers[i].iVideoHeight = height >> (param.iSpatialLayerNum - 1 - i);
@@ -199,7 +199,7 @@ extern "C" JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_compr
199199
ALOGW("skip this frame");
200200
return 0;
201201
} else {
202-
ALOGD("foreach NAL type : %d., laytype is %d.", info.sLayerInfo[i].eFrameType,
202+
ALOGD("FrameType : %d, layertype: %d.", info.sLayerInfo[i].eFrameType,
203203
info.sLayerInfo[i].uiLayerType);
204204
}
205205

@@ -209,9 +209,8 @@ extern "C" JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_compr
209209
* transmit serveral NALUs to RTMP server.
210210
* Two NAL types : SPS & PPS are very important.
211211
*/
212-
for (i = 0; i < info.iLayerNum; i++) {//iLayerNum is the count of NALUs.
213-
// int type = info.sLayerInfo[i].eFrameType;//it is NON_VIDEO_CODING_LAYER
214-
//
212+
for (i = 0; i < info.iLayerNum; i++) {
213+
// int fType = info.sLayerInfo[i].eFrameType;//it is NON_VIDEO_CODING_LAYER
215214
// if (info.sLayerInfo[i].uiLayerType == NON_VIDEO_CODING_LAYER) {//this NAL type is SPS.
216215
// }
217216
const SLayerBSInfo layerInfo = info.sLayerInfo[i];
@@ -236,7 +235,9 @@ extern "C" JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_compr
236235
ALOGE("start code not found.");
237236
}
238237
}
239-
if (NAL_type == 7 || NAL_type == 8) {
238+
ALOGD("NAL type : %d.",NAL_type);
239+
//begin to handle one of NALs.
240+
if (NAL_type == NAL_SPS || NAL_type == NAL_PPS) {
240241
buffer += start_len;
241242
handle_sps_pps(NAL_type, buffer, buf_len - start_len);
242243
buffer+=(buf_len - start_len);

x264-codec/src/main/java/io/github/brucewind/softcodec/RtmpHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.util.concurrent.atomic.AtomicInteger;
1010

1111
/**
12-
* Created by wei on 16-11-27.
12+
* Created by bruce on 16-11-27.
1313
*
1414
* It is used to manager picture to be encode, and transfer encoded data to server in {@link ExecutorService}.
1515
*/

x264-codec/src/main/java/io/github/brucewind/softcodec/StreamHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.brucewind.softcodec;
22

33
/**
4-
* Created by wei on 16-11-24.
4+
* Created by bruce on 16-11-24.
55
* It is used to connect server and push stream.
66
*/
77
class StreamHelper {

0 commit comments

Comments
 (0)