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
1eac4633
提交
1eac4633
authored
12月 16, 2018
作者:
autulin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.绑定本地端口
2.视频预览优化
上级
6e09bf98
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
79 行增加
和
33 行删除
+79
-33
DemoActivity.java
...ava/com/example/autulin/gb28181_android/DemoActivity.java
+8
-3
activity_demo.xml
app/src/main/res/layout/activity_demo.xml
+18
-13
GB28181_sender.cpp
gb28181library/src/main/cpp/GB28181_sender.cpp
+17
-5
GB28181_sender.h
gb28181library/src/main/cpp/GB28181_sender.h
+1
-1
gb_native.cpp
gb28181library/src/main/cpp/gb_native.cpp
+3
-2
user_arguments.h
gb28181library/src/main/cpp/user_arguments.h
+2
-1
JNIBridge.java
...y/src/main/java/com/autulin/gb28181library/JNIBridge.java
+2
-1
MediaOutput.java
...src/main/java/com/autulin/gb28181library/MediaOutput.java
+19
-0
MediaRecorderBase.java
...in/java/com/autulin/gb28181library/MediaRecorderBase.java
+2
-2
MediaRecorderNative.java
.../java/com/autulin/gb28181library/MediaRecorderNative.java
+1
-0
gradle.properties
gradle.properties
+6
-5
没有找到文件。
app/src/main/java/com/example/autulin/gb28181_android/DemoActivity.java
浏览文件 @
1eac4633
...
...
@@ -23,6 +23,7 @@ public class DemoActivity extends AppCompatActivity implements
private
Button
mButton
;
private
SurfaceView
mSurfaceView
;
private
RelativeLayout
bottomLayout
;
private
MediaRecorderNative
mMediaRecorder
;
private
MediaOutput
mediaOutput
;
...
...
@@ -92,6 +93,7 @@ public class DemoActivity extends AppCompatActivity implements
private
void
initView
()
{
mButton
=
findViewById
(
R
.
id
.
start_btn
);
mSurfaceView
=
findViewById
(
R
.
id
.
record_preview
);
bottomLayout
=
findViewById
(
R
.
id
.
bottom_lt
);
}
/**
...
...
@@ -102,14 +104,15 @@ public class DemoActivity extends AppCompatActivity implements
mMediaRecorder
.
setOnErrorListener
(
this
);
mMediaRecorder
.
setOnPreparedListener
(
this
);
// mMediaRecorder.setCameraFront();
// mMediaRecorder.setCameraFront();
// 设置前置摄像头
// 设置输出
// String fileName = String.valueOf(System.currentTimeMillis());
// String fileName = "tttttt";
// mediaOutput = mMediaRecorder.setFileOutPut(fileName); //输出到文件,这里demo是/sdcard/pstest/tttttt.ps
int
ssrc
=
1
;
mediaOutput
=
mMediaRecorder
.
setUdpOutPut
(
"10.210.100.76"
,
8888
,
ssrc
);
// mediaOutput = mMediaRecorder.setUdpOutPut("10.210.100.69", 8888, ssrc);
mediaOutput
=
mMediaRecorder
.
setTcpOutPut
(
"10.210.100.69"
,
8888
,
8088
,
ssrc
);
mMediaRecorder
.
setSurfaceHolder
(
mSurfaceView
.
getHolder
());
mMediaRecorder
.
prepare
();
...
...
@@ -120,8 +123,10 @@ public class DemoActivity extends AppCompatActivity implements
*/
private
void
initSurfaceView
()
{
final
int
w
=
DeviceUtils
.
getScreenWidth
(
this
);
// 避免摄像头的转换,只取上面h部分
((
RelativeLayout
.
LayoutParams
)
bottomLayout
.
getLayoutParams
()).
topMargin
=
(
int
)
(
w
/
(
MediaRecorderBase
.
SMALL_VIDEO_HEIGHT
/
(
MediaRecorderBase
.
SMALL_VIDEO_WIDTH
*
1.0f
)));
int
width
=
w
;
int
height
=
(
int
)
(
w
*
(
(
MediaRecorderBase
.
mSupportedPreviewWidth
*
1.0f
)
/
MediaRecorderBase
.
SMALL_VIDEO_HEIGHT
))
;
int
height
=
(
int
)
(
w
*
(
MediaRecorderBase
.
mSupportedPreviewWidth
*
1.0f
))
/
MediaRecorderBase
.
SMALL_VIDEO_HEIGHT
;
Log
.
e
(
"debug"
,
"initSurfaceView: w="
+
width
+
",h="
+
height
);
FrameLayout
.
LayoutParams
lp
=
(
FrameLayout
.
LayoutParams
)
mSurfaceView
.
getLayoutParams
();
...
...
app/src/main/res/layout/activity_demo.xml
浏览文件 @
1eac4633
...
...
@@ -12,17 +12,23 @@
android:layout_height=
"match_parent"
/>
</FrameLayout>
<RelativeLayout
android:id=
"@+id/bottom_lt"
android:background=
"#ffffff"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<Button
android:id=
"@+id/start_btn"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"16dp"
android:layout_marginEnd=
"8dp"
android:layout_marginLeft=
"8dp"
android:layout_marginRight=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_alignParentBottom=
"true"
android:layout_centerInParent=
"true"
android:text=
"开始录制"
/>
</RelativeLayout>
<Button
android:id=
"@+id/start_btn"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"16dp"
android:layout_marginEnd=
"8dp"
android:layout_marginLeft=
"8dp"
android:layout_marginRight=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_alignParentBottom=
"true"
android:layout_centerInParent=
"true"
android:text=
"开始录制"
/>
</RelativeLayout>
\ No newline at end of file
gb28181library/src/main/cpp/GB28181_sender.cpp
浏览文件 @
1eac4633
...
...
@@ -10,12 +10,12 @@ GB28181_sender::GB28181_sender(UserArguments *arg) : args(arg) {}
int
GB28181_sender
::
initSender
()
{
switch
(
args
->
outType
)
{
case
0
:
// udp
LOGE
(
"ip:%s,
port:%d, out_type:%d"
,
args
->
ip_addr
,
args
->
p
ort
,
args
->
outType
);
initSocket
(
args
->
ip_addr
,
args
->
p
ort
);
LOGE
(
"ip:%s,
remotePort:%d, out_type:%d"
,
args
->
ip_addr
,
args
->
remoteP
ort
,
args
->
outType
);
initSocket
(
args
->
ip_addr
,
args
->
remotePort
,
args
->
localP
ort
);
break
;
case
1
:
// tcp
LOGE
(
"ip:%s,
port:%d, out_type:%d"
,
args
->
ip_addr
,
args
->
p
ort
,
args
->
outType
);
initSocket
(
args
->
ip_addr
,
args
->
p
ort
);
LOGE
(
"ip:%s,
remotePort:%d, localPort:%d out_type:%d"
,
args
->
ip_addr
,
args
->
remotePort
,
args
->
localP
ort
,
args
->
outType
);
initSocket
(
args
->
ip_addr
,
args
->
remotePort
,
args
->
localP
ort
);
break
;
case
2
:
// file
//打开ps文件
...
...
@@ -108,7 +108,7 @@ int GB28181_sender::closeSender() {
return
n
;
}
int
GB28181_sender
::
initSocket
(
char
*
hostname
,
int
port
)
{
int
GB28181_sender
::
initSocket
(
char
*
hostname
,
int
port
,
int
localPort
)
{
switch
(
args
->
outType
)
{
case
0
:
// udp
sockfd
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
...
...
@@ -143,6 +143,18 @@ int GB28181_sender::initSocket(char *hostname, int port) {
serverlen
=
sizeof
(
serveraddr
);
if
(
args
->
outType
==
1
)
{
// tcp
if
(
args
->
localPort
!=
0
)
{
struct
sockaddr_in
client_addr
;
bzero
((
char
*
)
&
client_addr
,
sizeof
(
client_addr
));
client_addr
.
sin_family
=
AF_INET
;
client_addr
.
sin_addr
.
s_addr
=
INADDR_ANY
;
client_addr
.
sin_port
=
htons
(
args
->
localPort
);
int
ret
=
bind
(
sockfd
,
(
struct
sockaddr
*
)
&
client_addr
,
sizeof
(
client_addr
));
if
(
ret
<
0
){
LOGE
(
"ERROR local bind.(%d)"
,
ret
);
return
ret
;
}
}
int
ret
=
connect
(
sockfd
,
(
const
sockaddr
*
)
&
serveraddr
,
serverlen
);
if
(
ret
<
0
){
LOGE
(
"ERROR connect.(%d)"
,
ret
);
...
...
gb28181library/src/main/cpp/GB28181_sender.h
浏览文件 @
1eac4633
...
...
@@ -46,7 +46,7 @@ private:
struct
sockaddr_in
serveraddr
;
int
serverlen
;
int
initSocket
(
char
*
hostname
,
int
port
);
int
initSocket
(
char
*
hostname
,
int
port
,
int
localPort
);
ssize_t
sendData
(
uint8_t
*
buf
,
int
len
);
int
closeSocket
();
...
...
gb28181library/src/main/cpp/gb_native.cpp
浏览文件 @
1eac4633
...
...
@@ -28,7 +28,7 @@ Java_com_autulin_gb28181library_JNIBridge_getFFmpegConfig(JNIEnv *env, jclass ty
extern
"C"
JNIEXPORT
jint
JNICALL
Java_com_autulin_gb28181library_JNIBridge_initMuxer
(
JNIEnv
*
env
,
jclass
type
,
jstring
ip_
,
jint
port
,
jint
outType
,
jint
remote_port
,
jint
local_
port
,
jint
outType
,
jstring
mediaBasePath_
,
jstring
mediaName_
,
jint
filter
,
jint
in_width
,
jint
in_height
,
jint
out_width
,
jint
out_height
,
jint
frameRate
,
...
...
@@ -42,7 +42,8 @@ Java_com_autulin_gb28181library_JNIBridge_initMuxer(JNIEnv *env, jclass type, js
arguments
->
ip_addr
=
(
char
*
)
malloc
(
strlen
(
ip
)
+
1
);
strcpy
(
arguments
->
ip_addr
,
ip
);
arguments
->
port
=
port
;
arguments
->
remotePort
=
remote_port
;
arguments
->
localPort
=
local_port
;
arguments
->
outType
=
outType
;
arguments
->
ssrc
=
ssrc
;
arguments
->
queue_max
=
queue_max
;
...
...
gb28181library/src/main/cpp/user_arguments.h
浏览文件 @
1eac4633
...
...
@@ -7,7 +7,8 @@
class
JNIHandler
;
typedef
struct
UserArguments
{
char
*
ip_addr
;
int
port
;
int
remotePort
;
int
localPort
;
int
outType
;
char
*
media_path
;
//合成后的MP4储存地址
int
in_width
;
//输出宽度
...
...
gb28181library/src/main/java/com/autulin/gb28181library/JNIBridge.java
浏览文件 @
1eac4633
...
...
@@ -53,7 +53,8 @@ public class JNIBridge {
*/
public
static
native
int
initMuxer
(
String
ip
,
int
port
,
int
remotePort
,
int
localPort
,
int
outType
,
String
mediaBasePath
,
String
mediaName
,
...
...
gb28181library/src/main/java/com/autulin/gb28181library/MediaOutput.java
浏览文件 @
1eac4633
...
...
@@ -7,6 +7,7 @@ public class MediaOutput {
private
String
outputName
;
private
int
outputType
;
private
int
ssrc
;
private
int
localPort
=
0
;
public
MediaOutput
(
String
ip
,
int
port
,
String
outputDir
,
String
outputName
,
int
outputType
,
int
ssrc
)
{
this
.
ip
=
ip
;
...
...
@@ -17,6 +18,16 @@ public class MediaOutput {
this
.
ssrc
=
ssrc
;
}
public
MediaOutput
(
String
ip
,
int
port
,
int
localPort
,
String
outputDir
,
String
outputName
,
int
outputType
,
int
ssrc
)
{
this
.
ip
=
ip
;
this
.
port
=
port
;
this
.
outputDir
=
outputDir
;
this
.
outputName
=
outputName
;
this
.
outputType
=
outputType
;
this
.
ssrc
=
ssrc
;
this
.
localPort
=
localPort
;
}
public
String
getIp
()
{
return
ip
;
}
...
...
@@ -64,4 +75,12 @@ public class MediaOutput {
public
void
setSsrc
(
int
ssrc
)
{
this
.
ssrc
=
ssrc
;
}
public
int
getLocalPort
()
{
return
localPort
;
}
public
void
setLocalPort
(
int
localPort
)
{
this
.
localPort
=
localPort
;
}
}
gb28181library/src/main/java/com/autulin/gb28181library/MediaRecorderBase.java
浏览文件 @
1eac4633
...
...
@@ -727,8 +727,8 @@ public abstract class MediaRecorderBase implements Callback, PreviewCallback, IM
this
.
mFrameRateCmd
=
String
.
format
(
" -r %d"
,
rate
);
}
public
MediaOutput
setTcpOutPut
(
String
ip
,
int
p
ort
,
int
ssrc
)
{
mediaOutput
=
new
MediaOutput
(
ip
,
p
ort
,
""
,
""
,
JNIBridge
.
TCP
,
ssrc
);
public
MediaOutput
setTcpOutPut
(
String
ip
,
int
remotePort
,
int
localP
ort
,
int
ssrc
)
{
mediaOutput
=
new
MediaOutput
(
ip
,
remotePort
,
localP
ort
,
""
,
""
,
JNIBridge
.
TCP
,
ssrc
);
return
mediaOutput
;
}
...
...
gb28181library/src/main/java/com/autulin/gb28181library/MediaRecorderNative.java
浏览文件 @
1eac4633
...
...
@@ -75,6 +75,7 @@ public class MediaRecorderNative extends MediaRecorderBase implements MediaRecor
JNIBridge
.
initMuxer
(
mediaOutput
.
getIp
(),
mediaOutput
.
getPort
(),
mediaOutput
.
getLocalPort
(),
mediaOutput
.
getOutputType
(),
mediaOutput
.
getOutputDir
(),
mediaOutput
.
getOutputName
(),
...
...
gradle.properties
浏览文件 @
1eac4633
...
...
@@ -13,8 +13,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Wed Sep 12 17:58:18 CST 2018
systemProp.https.proxyPort
=
1080
systemProp.http.proxyHost
=
127.0.0.1
org.gradle.jvmargs
=
-Xmx
1536m
systemProp.https.proxyHost
=
127.0.0.1
systemProp.http.proxyPort
=
1080
#
systemProp.https.proxyPort=1080
#
systemProp.http.proxyHost=127.0.0.1
org.gradle.jvmargs
=
-Xmx
2048m -DsocksProxyHost
\=
127.0.0.1 -DsocksProxyPort
\=
1080
#
systemProp.https.proxyHost=127.0.0.1
#
systemProp.http.proxyPort
=
1080
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论