Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
GB28181Android
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
规范查询wiki:
http://gitlab.anweitech.com/root/AW-Project-Manage/wikis/pages
Open sidebar
Administrator
GB28181Android
Commits
6e09bf98
提交
6e09bf98
authored
12月 01, 2018
作者:
autulin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.新增前置摄像头接口
2.新增队列清理机制
上级
494dae45
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
40 行增加
和
7 行删除
+40
-7
DemoActivity.java
...ava/com/example/autulin/gb28181_android/DemoActivity.java
+4
-2
gb28181_muxer.cpp
gb28181library/src/main/cpp/gb28181_muxer.cpp
+14
-2
gb_native.cpp
gb28181library/src/main/cpp/gb_native.cpp
+2
-1
user_arguments.h
gb28181library/src/main/cpp/user_arguments.h
+1
-0
JNIBridge.java
...y/src/main/java/com/autulin/gb28181library/JNIBridge.java
+2
-1
MediaRecorderBase.java
...in/java/com/autulin/gb28181library/MediaRecorderBase.java
+15
-0
MediaRecorderNative.java
.../java/com/autulin/gb28181library/MediaRecorderNative.java
+2
-1
没有找到文件。
app/src/main/java/com/example/autulin/gb28181_android/DemoActivity.java
浏览文件 @
6e09bf98
...
@@ -84,7 +84,8 @@ public class DemoActivity extends AppCompatActivity implements
...
@@ -84,7 +84,8 @@ public class DemoActivity extends AppCompatActivity implements
// 设置视频的宽高,比特率等
// 设置视频的宽高,比特率等
// MediaRecorderBase.SMALL_VIDEO_HEIGHT = mediaRecorderConfig.getSmallVideoHeight();
// MediaRecorderBase.SMALL_VIDEO_HEIGHT = mediaRecorderConfig.getSmallVideoHeight();
// MediaRecorderBase.SMALL_VIDEO_WIDTH = mediaRecorderConfig.getSmallVideoWidth();
// MediaRecorderBase.SMALL_VIDEO_WIDTH = mediaRecorderConfig.getSmallVideoWidth();
// MediaRecorderBase.mVideoBitrate = mediaRecorderConfig.getVideoBitrate();
// MediaRecorderBase. = mediaRecorderConfig.getVideoBitrate();
MediaRecorderBase
.
QUEUE_MAX_SIZE
=
20
;
Log
.
i
(
"debug"
,
"SMALL_VIDEO_HEIGHT: "
+
MediaRecorderBase
.
SMALL_VIDEO_HEIGHT
+
", SMALL_VIDEO_WIDTH:"
+
MediaRecorderBase
.
SMALL_VIDEO_WIDTH
);
Log
.
i
(
"debug"
,
"SMALL_VIDEO_HEIGHT: "
+
MediaRecorderBase
.
SMALL_VIDEO_HEIGHT
+
", SMALL_VIDEO_WIDTH:"
+
MediaRecorderBase
.
SMALL_VIDEO_WIDTH
);
}
}
...
@@ -101,13 +102,14 @@ public class DemoActivity extends AppCompatActivity implements
...
@@ -101,13 +102,14 @@ public class DemoActivity extends AppCompatActivity implements
mMediaRecorder
.
setOnErrorListener
(
this
);
mMediaRecorder
.
setOnErrorListener
(
this
);
mMediaRecorder
.
setOnPreparedListener
(
this
);
mMediaRecorder
.
setOnPreparedListener
(
this
);
// mMediaRecorder.setCameraFront();
// 设置输出
// 设置输出
// String fileName = String.valueOf(System.currentTimeMillis());
// String fileName = String.valueOf(System.currentTimeMillis());
// String fileName = "tttttt";
// String fileName = "tttttt";
// mediaOutput = mMediaRecorder.setFileOutPut(fileName); //输出到文件,这里demo是/sdcard/pstest/tttttt.ps
// mediaOutput = mMediaRecorder.setFileOutPut(fileName); //输出到文件,这里demo是/sdcard/pstest/tttttt.ps
int
ssrc
=
1
;
int
ssrc
=
1
;
mediaOutput
=
mMediaRecorder
.
set
TcpOutPut
(
"10.112.154.194
"
,
8888
,
ssrc
);
mediaOutput
=
mMediaRecorder
.
set
UdpOutPut
(
"10.210.100.76
"
,
8888
,
ssrc
);
mMediaRecorder
.
setSurfaceHolder
(
mSurfaceView
.
getHolder
());
mMediaRecorder
.
setSurfaceHolder
(
mSurfaceView
.
getHolder
());
mMediaRecorder
.
prepare
();
mMediaRecorder
.
prepare
();
...
...
gb28181library/src/main/cpp/gb28181_muxer.cpp
浏览文件 @
6e09bf98
...
@@ -171,9 +171,21 @@ void *GB28181Muxer::startEncode(void *obj) {
...
@@ -171,9 +171,21 @@ void *GB28181Muxer::startEncode(void *obj) {
avpicture_fill
((
AVPicture
*
)
pNewFrame
,
buf
,
gb28181Muxer
->
pCodecCtx
->
pix_fmt
,
gb28181Muxer
->
pCodecCtx
->
width
,
avpicture_fill
((
AVPicture
*
)
pNewFrame
,
buf
,
gb28181Muxer
->
pCodecCtx
->
pix_fmt
,
gb28181Muxer
->
pCodecCtx
->
width
,
gb28181Muxer
->
pCodecCtx
->
height
);
gb28181Muxer
->
pCodecCtx
->
height
);
int
skipNum
=
10
;
while
(
!
gb28181Muxer
->
is_end
)
{
while
(
!
gb28181Muxer
->
is_end
)
{
uint8_t
*
new_buf
;
//队列帧数过多直接跳过skipNum帧
if
(
gb28181Muxer
->
video_queue
.
size
()
>
gb28181Muxer
->
arguments
->
queue_max
)
{
LOGW
(
"[muxer][encode]queue is too big, clearing..."
)
for
(
int
i
=
0
;
i
<
skipNum
;
++
i
)
{
new_buf
=
*
gb28181Muxer
->
video_queue
.
wait_and_pop
();
delete
new_buf
;
}
continue
;
}
int64_t
st
=
getCurrentTime
();
int64_t
st
=
getCurrentTime
();
uint8_t
*
new_buf
=
*
gb28181Muxer
->
video_queue
.
wait_and_pop
();
new_buf
=
*
gb28181Muxer
->
video_queue
.
wait_and_pop
();
gb28181Muxer
->
custom_filter
(
gb28181Muxer
,
new_buf
,
pNewFrame
);
gb28181Muxer
->
custom_filter
(
gb28181Muxer
,
new_buf
,
pNewFrame
);
delete
new_buf
;
delete
new_buf
;
...
@@ -190,7 +202,7 @@ void *GB28181Muxer::startEncode(void *obj) {
...
@@ -190,7 +202,7 @@ void *GB28181Muxer::startEncode(void *obj) {
ret
=
avcodec_send_frame
(
gb28181Muxer
->
pCodecCtx
,
pNewFrame
);
ret
=
avcodec_send_frame
(
gb28181Muxer
->
pCodecCtx
,
pNewFrame
);
}
}
int64_t
et2
=
getCurrentTime
();
int64_t
et2
=
getCurrentTime
();
LOGI
(
"fetch raw frame from queue time:%lld (video frame queue left:%d),in FFmpeg time:%lld."
,
et1
-
st
,
gb28181Muxer
->
video_queue
.
size
(),
et2
-
et1
);
LOGI
(
"
[muxer][encode]
fetch raw frame from queue time:%lld (video frame queue left:%d),in FFmpeg time:%lld."
,
et1
-
st
,
gb28181Muxer
->
video_queue
.
size
(),
et2
-
et1
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
LOGE
(
"send FFmpeg error:%d."
,
ret
);
LOGE
(
"send FFmpeg error:%d."
,
ret
);
}
}
...
...
gb28181library/src/main/cpp/gb_native.cpp
浏览文件 @
6e09bf98
...
@@ -32,7 +32,7 @@ Java_com_autulin_gb28181library_JNIBridge_initMuxer(JNIEnv *env, jclass type, js
...
@@ -32,7 +32,7 @@ Java_com_autulin_gb28181library_JNIBridge_initMuxer(JNIEnv *env, jclass type, js
jstring
mediaBasePath_
,
jstring
mediaName_
,
jstring
mediaBasePath_
,
jstring
mediaName_
,
jint
filter
,
jint
in_width
,
jint
in_height
,
jint
filter
,
jint
in_width
,
jint
in_height
,
jint
out_width
,
jint
out_height
,
jint
frameRate
,
jint
out_width
,
jint
out_height
,
jint
frameRate
,
jlong
bit_rate
,
jint
audioFrameLen
,
jint
ssrc
)
{
jlong
bit_rate
,
jint
audioFrameLen
,
jint
ssrc
,
jint
queue_max
)
{
const
char
*
ip
=
env
->
GetStringUTFChars
(
ip_
,
0
);
const
char
*
ip
=
env
->
GetStringUTFChars
(
ip_
,
0
);
const
char
*
mediaBasePath
=
env
->
GetStringUTFChars
(
mediaBasePath_
,
0
);
const
char
*
mediaBasePath
=
env
->
GetStringUTFChars
(
mediaBasePath_
,
0
);
const
char
*
mediaName
=
env
->
GetStringUTFChars
(
mediaName_
,
0
);
const
char
*
mediaName
=
env
->
GetStringUTFChars
(
mediaName_
,
0
);
...
@@ -45,6 +45,7 @@ Java_com_autulin_gb28181library_JNIBridge_initMuxer(JNIEnv *env, jclass type, js
...
@@ -45,6 +45,7 @@ Java_com_autulin_gb28181library_JNIBridge_initMuxer(JNIEnv *env, jclass type, js
arguments
->
port
=
port
;
arguments
->
port
=
port
;
arguments
->
outType
=
outType
;
arguments
->
outType
=
outType
;
arguments
->
ssrc
=
ssrc
;
arguments
->
ssrc
=
ssrc
;
arguments
->
queue_max
=
queue_max
;
size_t
m_path_size
=
strlen
(
mediaBasePath
)
+
strlen
(
mediaName
)
+
strlen
(
MEDIA_FORMAT
)
+
1
;
size_t
m_path_size
=
strlen
(
mediaBasePath
)
+
strlen
(
mediaName
)
+
strlen
(
MEDIA_FORMAT
)
+
1
;
arguments
->
media_path
=
(
char
*
)
malloc
(
m_path_size
+
1
);
arguments
->
media_path
=
(
char
*
)
malloc
(
m_path_size
+
1
);
...
...
gb28181library/src/main/cpp/user_arguments.h
浏览文件 @
6e09bf98
...
@@ -19,6 +19,7 @@ typedef struct UserArguments {
...
@@ -19,6 +19,7 @@ typedef struct UserArguments {
int
v_custom_format
;
//一些滤镜操作控制
int
v_custom_format
;
//一些滤镜操作控制
int
a_frame_len
;
int
a_frame_len
;
int
ssrc
;
int
ssrc
;
int
queue_max
;
//队列最大长度
JNIEnv
*
env
;
//env全局指针
JNIEnv
*
env
;
//env全局指针
JavaVM
*
javaVM
;
//jvm指针
JavaVM
*
javaVM
;
//jvm指针
jclass
java_class
;
//java接口类的calss对象
jclass
java_class
;
//java接口类的calss对象
...
...
gb28181library/src/main/java/com/autulin/gb28181library/JNIBridge.java
浏览文件 @
6e09bf98
...
@@ -65,7 +65,8 @@ public class JNIBridge {
...
@@ -65,7 +65,8 @@ public class JNIBridge {
int
frameRate
,
int
frameRate
,
long
bit_rate
,
long
bit_rate
,
int
audioFrameLen
,
int
audioFrameLen
,
int
ssrc
int
ssrc
,
int
queue_max
);
);
public
static
native
int
sendOneVideoFrame
(
byte
[]
data
);
public
static
native
int
sendOneVideoFrame
(
byte
[]
data
);
...
...
gb28181library/src/main/java/com/autulin/gb28181library/MediaRecorderBase.java
浏览文件 @
6e09bf98
...
@@ -161,6 +161,8 @@ public abstract class MediaRecorderBase implements Callback, PreviewCallback, IM
...
@@ -161,6 +161,8 @@ public abstract class MediaRecorderBase implements Callback, PreviewCallback, IM
*/
*/
protected
static
int
mVideoBitrate
=
580000
;
protected
static
int
mVideoBitrate
=
580000
;
public
static
int
QUEUE_MAX_SIZE
=
20
;
public
static
int
mSupportedPreviewWidth
=
0
;
public
static
int
mSupportedPreviewWidth
=
0
;
/**
/**
* 状态标记
* 状态标记
...
@@ -183,6 +185,19 @@ public abstract class MediaRecorderBase implements Callback, PreviewCallback, IM
...
@@ -183,6 +185,19 @@ public abstract class MediaRecorderBase implements Callback, PreviewCallback, IM
}
}
/**
* 设置为后置摄像头
*/
public
void
setCameraBack
()
{
mCameraId
=
Camera
.
CameraInfo
.
CAMERA_FACING_BACK
;
}
/**
* 设置为前置摄像头
*/
public
void
setCameraFront
()
{
mCameraId
=
Camera
.
CameraInfo
.
CAMERA_FACING_FRONT
;
}
/**
/**
* 设置预览输出SurfaceHolder
* 设置预览输出SurfaceHolder
*
*
...
...
gb28181library/src/main/java/com/autulin/gb28181library/MediaRecorderNative.java
浏览文件 @
6e09bf98
...
@@ -86,7 +86,8 @@ public class MediaRecorderNative extends MediaRecorderBase implements MediaRecor
...
@@ -86,7 +86,8 @@ public class MediaRecorderNative extends MediaRecorderBase implements MediaRecor
mFrameRate
,
mFrameRate
,
mVideoBitrate
,
mVideoBitrate
,
mAudioCollector
.
getFrameLen
(),
mAudioCollector
.
getFrameLen
(),
mediaOutput
.
getSsrc
()
mediaOutput
.
getSsrc
(),
QUEUE_MAX_SIZE
);
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论