@@ -24,11 +24,11 @@ int handle_sps_pps(int NAL_type, unsigned char *buffer, int len) {
24
24
ALOGE (" buffer format is wrong." );
25
25
return -1 ;
26
26
}
27
- if (NAL_type == 7 ) {
27
+ if (NAL_type == NAL_SPS ) {
28
28
sps = buffer;
29
29
sps_len = len;
30
30
print_hex (" SPS" , sps, sps_len);
31
- } else if (NAL_type == 8 ) {
31
+ } else if (NAL_type == NAL_PPS ) {
32
32
pps = buffer;
33
33
pps_len = len;
34
34
send_video_sps_pps (sps, sps_len, pps, pps_len);
@@ -63,16 +63,16 @@ Java_io_github_brucewind_softcodec_StreamHelper_compressBegin(JNIEnv *env,
63
63
encoder->GetDefaultParams (
64
64
¶m);// call InitializeExt must have a extension parameter with this default.
65
65
param.iUsageType = CAMERA_VIDEO_REAL_TIME; // tell openH264 steam type is LIVE.
66
- param.iRCMode = RC_QUALITY_MODE ;
66
+ param.iRCMode = RC_BITRATE_MODE ;
67
67
param.fMaxFrameRate = fps; // fps
68
68
param.iPicWidth = width;
69
69
param.iPicHeight = height;
70
70
param.iTargetBitrate = bitrate * 1024 ; // the input parameter need to * 1024
71
71
// param.iInputCsp = videoFormatI420; //it is stable YUV format for openh264
72
- param.bEnableDenoise = 1 ; // enable eliminating noisy.
72
+ // param.bEnableDenoise = 1; //enable eliminating noisy.
73
73
param.iSpatialLayerNum = 1 ;
74
74
// 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 ;
76
76
for (int i = 0 ; i < param.iSpatialLayerNum ; i++) {
77
77
param.sSpatialLayers [i].iVideoWidth = width >> (param.iSpatialLayerNum - 1 - i);
78
78
param.sSpatialLayers [i].iVideoHeight = height >> (param.iSpatialLayerNum - 1 - i);
@@ -199,7 +199,7 @@ extern "C" JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_compr
199
199
ALOGW (" skip this frame" );
200
200
return 0 ;
201
201
} else {
202
- ALOGD (" foreach NAL type : %d., laytype is %d." , info.sLayerInfo [i].eFrameType ,
202
+ ALOGD (" FrameType : %d, layertype: %d." , info.sLayerInfo [i].eFrameType ,
203
203
info.sLayerInfo [i].uiLayerType );
204
204
}
205
205
@@ -209,9 +209,8 @@ extern "C" JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_compr
209
209
* transmit serveral NALUs to RTMP server.
210
210
* Two NAL types : SPS & PPS are very important.
211
211
*/
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
215
214
// if (info.sLayerInfo[i].uiLayerType == NON_VIDEO_CODING_LAYER) {//this NAL type is SPS.
216
215
// }
217
216
const SLayerBSInfo layerInfo = info.sLayerInfo [i];
@@ -236,7 +235,9 @@ extern "C" JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_compr
236
235
ALOGE (" start code not found." );
237
236
}
238
237
}
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) {
240
241
buffer += start_len;
241
242
handle_sps_pps (NAL_type, buffer, buf_len - start_len);
242
243
buffer+=(buf_len - start_len);
0 commit comments